move createHapResponse()
This commit is contained in:
1 parent
83ad264e35
commit
b3f0598b1a
4 files changed
+23
-23
No files matched your search
@@ -182,27 +182,6 @@ uint16_t HAPCharacteristic::writeHapValue(uint32_t num)
|
||||
return writeHapValue(&num, len);
|
||||
}
|
||||
|
||||
HAPResponse_t* HAPCharacteristic::createHapResponse(uint8_t tid, uint8_t status, TLV8_t tlv_para[], uint8_t count)
|
||||
{
|
||||
// Determine body len, does not to include 2 byte length itself
|
||||
uint16_t body_len = tlv8_calculate_encode_len(tlv_para, count);
|
||||
HAPResponse_t* hap_resp = (HAPResponse_t*) rtos_malloc(sizeof(HAPResponseHeader_t) + 2 + body_len);
|
||||
VERIFY( hap_resp != NULL, NULL );
|
||||
|
||||
/*------------- Header -------------*/
|
||||
varclr(&hap_resp->header.control);
|
||||
hap_resp->header.control.fragment = 0;
|
||||
hap_resp->header.control.type = HAP_PDU_RESPONSE;
|
||||
hap_resp->header.tid = tid;
|
||||
hap_resp->header.status = status;
|
||||
hap_resp->body_len = body_len;
|
||||
|
||||
/*------------- Serialize Data -------------*/
|
||||
tlv8_encode_n(hap_resp->body_data, body_len, tlv_para, count);
|
||||
|
||||
return hap_resp;
|
||||
}
|
||||
|
||||
HAPResponse_t* HAPCharacteristic::processChrSignatureRead(HAPRequest_t* hap_req)
|
||||
{
|
||||
uint16_t svc_id = ((HAPService*)_service)->getSvcId();
|
||||
|
||||
@@ -71,8 +71,6 @@ class HAPCharacteristic : public BLECharacteristic
|
||||
// Callbacks
|
||||
void setHapWriteCallback(hap_write_cb_t fp);
|
||||
|
||||
HAPResponse_t* createHapResponse(uint8_t tid, uint8_t status, TLV8_t tlv_para[] = NULL, uint8_t count = 0);
|
||||
|
||||
/*------------- Internal Functions -------------*/
|
||||
virtual void _eventHandler(ble_evt_t* event);
|
||||
|
||||
|
||||
@@ -143,3 +143,24 @@ uint16_t tlv8_encode_n(uint8_t* buf, uint16_t bufsize, TLV8_t tlv[], uint8_t cou
|
||||
|
||||
return len - bufsize;
|
||||
}
|
||||
|
||||
HAPResponse_t* createHapResponse(uint8_t tid, uint8_t status, TLV8_t tlv_para[], uint8_t count)
|
||||
{
|
||||
// Determine body len, does not to include 2 byte length itself
|
||||
uint16_t body_len = tlv8_calculate_encode_len(tlv_para, count);
|
||||
HAPResponse_t* hap_resp = (HAPResponse_t*) rtos_malloc(sizeof(HAPResponseHeader_t) + 2 + body_len);
|
||||
VERIFY( hap_resp != NULL, NULL );
|
||||
|
||||
/*------------- Header -------------*/
|
||||
varclr(&hap_resp->header.control);
|
||||
hap_resp->header.control.fragment = 0;
|
||||
hap_resp->header.control.type = HAP_PDU_RESPONSE;
|
||||
hap_resp->header.tid = tid;
|
||||
hap_resp->header.status = status;
|
||||
hap_resp->body_len = body_len;
|
||||
|
||||
/*------------- Serialize Data -------------*/
|
||||
tlv8_encode_n(hap_resp->body_data, body_len, tlv_para, count);
|
||||
|
||||
return hap_resp;
|
||||
}
|
||||
@@ -154,4 +154,6 @@ bool tlv8_encode_next(uint8_t** pp_buf, uint16_t* p_buflen, TLV8_t tlv);
|
||||
uint16_t tlv8_encode_n(uint8_t* buf, uint16_t bufsize, TLV8_t tlv[], uint8_t count);
|
||||
uint16_t tlv8_calculate_encode_len(TLV8_t tlv_para[], uint8_t count);
|
||||
|
||||
HAPResponse_t* createHapResponse(uint8_t tid, uint8_t status, TLV8_t tlv_para[] = NULL, uint8_t count = 0);
|
||||
|
||||
#endif /* HAPPROCEDURE_H_ */
|
||||
Reference in new issue
Block a user