Skip to content

Commit 2619909

Browse files
npal-cynazar.palamarwoody-applesmides-nest
authored andcommitted
P6: Added support of BLE GATT Notification instead of GATT Indication… (#10336)
* P6: Added support of BLE GATT Notification instead of GATT Indication for C2 GATT Characteristic. It required by Matter spec (section 4.15.3.2. BTP GATT Service): "... the server SHALL exclusively use C2 to respond to BTP handshake requests and send data to the client via GATT ATT_HANDLE_VALUE_NTF PDUs..." * Update src/platform/P6/BLEManagerImpl.cpp Co-authored-by: Matt Smith <smides@google.com> Co-authored-by: nazar.palamar <npal@cypress.com> Co-authored-by: Justin Wood <woody@apple.com> Co-authored-by: Matt Smith <smides@google.com>
1 parent a766482 commit 2619909

File tree

1 file changed

+14
-31
lines changed

1 file changed

+14
-31
lines changed

src/platform/P6/BLEManagerImpl.cpp

+14-31
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event)
254254
PacketBufferHandle::Adopt(event->CHIPoBLEWriteReceived.Data));
255255
break;
256256

257-
case DeviceEventType::kCHIPoBLEIndicateConfirm:
258-
HandleIndicationConfirmation(event->CHIPoBLEIndicateConfirm.ConId, &CHIP_BLE_SVC_ID, &ChipUUID_CHIPoBLEChar_TX);
257+
case DeviceEventType::kCHIPoBLENotifyConfirm:
258+
HandleIndicationConfirmation(event->CHIPoBLENotifyConfirm.ConId, &CHIP_BLE_SVC_ID, &ChipUUID_CHIPoBLEChar_TX);
259259
break;
260260

261261
case DeviceEventType::kCHIPoBLEConnectionError:
@@ -342,18 +342,26 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU
342342
VerifyOrExit(conState != NULL, err = CHIP_ERROR_INVALID_ARGUMENT);
343343

344344
#ifdef BLE_DEBUG
345-
ChipLogDetail(DeviceLayer, "Sending indication for CHIPoBLE TX characteristic (con %u, len %u)", conId, dataLen);
345+
ChipLogDetail(DeviceLayer, "Sending notification for CHIPoBLE TX characteristic (con %u, len %u)", conId, dataLen);
346346
#endif
347347

348-
// Send a indication for the CHIPoBLE TX characteristic to the client containing the supplied data.
349-
gatt_err = wiced_bt_gatt_send_indication((uint16_t) conId, HDLC_CHIP_SERVICE_CHAR_C2_VALUE, dataLen, data->Start());
348+
// Send a notification for the CHIPoBLE TX characteristic to the client containing the supplied data.
349+
gatt_err = wiced_bt_gatt_send_notification((uint16_t) conId, HDLC_CHIP_SERVICE_CHAR_C2_VALUE, dataLen, data->Start());
350350

351351
exit:
352352
if (gatt_err != WICED_BT_GATT_SUCCESS)
353353
{
354-
ChipLogError(DeviceLayer, "BLEManagerImpl::SendIndication() failed: %ld", gatt_err);
354+
ChipLogError(DeviceLayer, "BLEManagerImpl::SendNotification() failed: %ld", gatt_err);
355355
return false;
356356
}
357+
else
358+
{
359+
// Post an event to the CHIP queue.
360+
ChipDeviceEvent event;
361+
event.Type = DeviceEventType::kCHIPoBLENotifyConfirm;
362+
event.CHIPoBLENotifyConfirm.ConId = conId;
363+
err = PlatformMgr().PostEvent(&event);
364+
}
357365
return err == CHIP_NO_ERROR;
358366
}
359367

@@ -615,27 +623,6 @@ wiced_bt_gatt_status_t BLEManagerImpl::HandleGattServiceMtuReq(wiced_bt_gatt_att
615623
return WICED_BT_GATT_SUCCESS;
616624
}
617625

618-
/*
619-
* Process GATT Indication Confirm from the client
620-
*/
621-
wiced_bt_gatt_status_t BLEManagerImpl::HandleGattServiceIndCfm(uint16_t conn_id, uint16_t handle)
622-
{
623-
#ifdef BLE_DEBUG
624-
ChipLogDetail(DeviceLayer, "GATT Ind Cfm received con:%04x handle:%d", conn_id, handle);
625-
#endif
626-
if (handle == HDLC_CHIP_SERVICE_CHAR_C2_VALUE)
627-
{
628-
ChipDeviceEvent event;
629-
event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm;
630-
event.CHIPoBLEIndicateConfirm.ConId = conn_id;
631-
if (PlatformMgr().PostEvent(&event) != CHIP_NO_ERROR)
632-
{
633-
return WICED_BT_GATT_INTERNAL_ERROR;
634-
}
635-
}
636-
return WICED_BT_GATT_SUCCESS;
637-
}
638-
639626
/*
640627
* Process GATT attribute requests
641628
*/
@@ -658,10 +645,6 @@ wiced_bt_gatt_status_t BLEManagerImpl::HandleGattServiceRequestEvent(wiced_bt_ga
658645
result = HandleGattServiceMtuReq(p_request, p_conn);
659646
break;
660647

661-
case GATTS_REQ_TYPE_CONF:
662-
result = HandleGattServiceIndCfm(p_request->conn_id, p_request->data.handle);
663-
break;
664-
665648
default:
666649
break;
667650
}

0 commit comments

Comments
 (0)