update
This commit is contained in:
1 parent
98072c1622
commit
76a366f94c
2 files changed
+41
-23
No files matched your search
@@ -125,25 +125,19 @@ void HAPCharacteristic::_eventHandler(ble_evt_t* event)
|
||||
{
|
||||
ble_gatts_evt_rw_authorize_request_t * request = &event->evt.gatts_evt.params.authorize_request;
|
||||
|
||||
ble_gatts_rw_authorize_reply_params_t reply =
|
||||
{
|
||||
.type = request->type,
|
||||
// BLE_GATT_STATUS_SUCCESS
|
||||
};
|
||||
|
||||
// Handle HAP Request
|
||||
if (request->type == BLE_GATTS_AUTHORIZE_TYPE_WRITE)
|
||||
{
|
||||
HAPRequest_t* hap_req = (HAPRequest_t*) request->request.write.data;
|
||||
VERIFY(hap_req->control.type == HAP_PDU_REQUEST, );
|
||||
VERIFY(hap_req->header.control.type == HAP_PDU_REQUEST, );
|
||||
|
||||
// ble_gatts_rw_authorize_reply_params_t reply =
|
||||
// {
|
||||
// .type = request->type,
|
||||
// .params.write =
|
||||
// {
|
||||
// .gatt_status = BLE_GATT_STATUS_SUCCESS,
|
||||
// .
|
||||
// };
|
||||
// };
|
||||
|
||||
// sd_ble_gatts_rw_authorize_reply(Bluefruit.connHandle(), &reply);
|
||||
|
||||
switch(hap_req->opcode)
|
||||
switch(hap_req->header.opcode)
|
||||
{
|
||||
/* Return <Chr Type, Svc Type, Svc ID, Meta Descriptors>
|
||||
* Where descriptors are:
|
||||
@@ -156,8 +150,12 @@ void HAPCharacteristic::_eventHandler(ble_evt_t* event)
|
||||
}
|
||||
break;
|
||||
|
||||
default: break;
|
||||
default:
|
||||
reply.params.write.gatt_status = BLE_GATT_STATUS_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
sd_ble_gatts_rw_authorize_reply(Bluefruit.connHandle(), &reply);
|
||||
}
|
||||
|
||||
// Handle HAP Response
|
||||
|
||||
@@ -115,6 +115,12 @@ enum TLVType_t
|
||||
TLV_TYPE_SEPARATOR
|
||||
};
|
||||
|
||||
typedef struct ATTR_PACKED
|
||||
{
|
||||
uint8_t type; // TLVType_t
|
||||
uint8_t length;
|
||||
uint8_t value[];
|
||||
}TLV8_t;
|
||||
|
||||
typedef struct ATTR_PACKED
|
||||
{
|
||||
@@ -132,24 +138,38 @@ typedef struct ATTR_PACKED
|
||||
uint8_t opcode ;
|
||||
uint8_t tid ; // Transaction ID
|
||||
uint16_t instance_id ; // Service or Characteristic Instance ID
|
||||
} HAPRequest_t;
|
||||
} HAPRequestHeader_t;
|
||||
|
||||
VERIFY_STATIC(sizeof (HAPRequest_t) == 5);
|
||||
VERIFY_STATIC(sizeof (HAPRequestHeader_t) == 5);
|
||||
|
||||
typedef struct ATTR_PACKED
|
||||
{
|
||||
HAPRequestHeader_t header;
|
||||
|
||||
// Optional
|
||||
uint16_t len;
|
||||
uint8_t tlvdata[1];
|
||||
} HAPRequest_t;
|
||||
|
||||
typedef struct ATTR_PACKED
|
||||
{
|
||||
HAPControl_t control;
|
||||
uint8_t tid;
|
||||
uint8_t status;
|
||||
}HAPResponse_t;
|
||||
}HAPResponseHeader_t;
|
||||
|
||||
VERIFY_STATIC(sizeof (HAPResponseHeader_t) == 3);
|
||||
|
||||
VERIFY_STATIC(sizeof (HAPResponse_t) == 3);
|
||||
|
||||
typedef struct ATTR_PACKED
|
||||
{
|
||||
uint8_t type; // TLVType_t
|
||||
uint8_t length;
|
||||
uint8_t value[];
|
||||
}TLV8_t;
|
||||
HAPResponseHeader_t header;
|
||||
|
||||
// Optional
|
||||
uint16_t len;
|
||||
uint8_t tlvdata[1];
|
||||
} HAPResponse_t;
|
||||
|
||||
|
||||
|
||||
#endif /* HAPPROCEDURE_H_ */
|
||||
Reference in new issue
Block a user