implement BLECharacteristic long write #91,#220

This commit is contained in:
hathach committed 2019-02-13 14:57:36 +07:00
1 parent 457456a54b
commit e05bdc9030
6 files changed
+113 -11

No files matched your search

+16 -1
View File
@@ -124,11 +124,25 @@ void BLEGatt::_eventHandler(ble_evt_t* evt)
BLECharacteristic* chr = _server.chr_list[i];
uint16_t req_handle = BLE_GATT_HANDLE_INVALID;
// BLE_GATTS_OP_EXEC_WRITE_REQ_NOW has no handle, uuid only command op
bool exec_write_now = false;
switch (evt_id)
{
case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
{
// Handle has the same offset for read & write request
req_handle = evt->evt.gatts_evt.params.authorize_request.request.read.handle;
if ( evt->evt.gatts_evt.params.authorize_request.type == BLE_GATTS_AUTHORIZE_TYPE_WRITE )
{
ble_gatts_evt_write_t * wr_req = &evt->evt.gatts_evt.params.authorize_request.request.write;
if ( wr_req->op == BLE_GATTS_OP_EXEC_WRITE_REQ_NOW )
{
exec_write_now = true;
}
}
}
break;
case BLE_GATTS_EVT_WRITE:
@@ -139,7 +153,8 @@ void BLEGatt::_eventHandler(ble_evt_t* evt)
}
// invoke characteristic handler if matched
if ((req_handle != BLE_GATT_HANDLE_INVALID) && (req_handle == chr->handles().value_handle || req_handle == chr->handles().cccd_handle ))
if ( exec_write_now ||
((req_handle != BLE_GATT_HANDLE_INVALID) && (req_handle == chr->handles().value_handle || req_handle == chr->handles().cccd_handle)) )
{
chr->_eventHandler(evt);