From 7913189de71552ab884c154449d7b6318111df31 Mon Sep 17 00:00:00 2001 From: Praveen Chandran Date: Tue, 9 Aug 2022 17:56:44 -0700 Subject: [PATCH] [Infineon] Update BLE Char C2 to Indicate instead of Notify (#21652) --- src/platform/P6/BLEManagerImpl.cpp | 45 ++++++++++++++++++++---------- src/platform/P6/cycfg_gatt_db.c | 2 +- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/platform/P6/BLEManagerImpl.cpp b/src/platform/P6/BLEManagerImpl.cpp index 01e27cb49f9c40..f786895eb052d2 100644 --- a/src/platform/P6/BLEManagerImpl.cpp +++ b/src/platform/P6/BLEManagerImpl.cpp @@ -257,8 +257,8 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) PacketBufferHandle::Adopt(event->CHIPoBLEWriteReceived.Data)); break; - case DeviceEventType::kCHIPoBLENotifyConfirm: - HandleIndicationConfirmation(event->CHIPoBLENotifyConfirm.ConId, &CHIP_BLE_SVC_ID, &ChipUUID_CHIPoBLEChar_TX); + case DeviceEventType::kCHIPoBLEIndicateConfirm: + HandleIndicationConfirmation(event->CHIPoBLEIndicateConfirm.ConId, &CHIP_BLE_SVC_ID, &ChipUUID_CHIPoBLEChar_TX); break; case DeviceEventType::kCHIPoBLEConnectionError: @@ -331,27 +331,19 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUU VerifyOrExit(conState != NULL, err = CHIP_ERROR_INVALID_ARGUMENT); #ifdef BLE_DEBUG - ChipLogDetail(DeviceLayer, "Sending notification for CHIPoBLE TX characteristic (con %u, len %u)", conId, dataLen); + ChipLogDetail(DeviceLayer, "Sending indication for CHIPoBLE TX characteristic (con %u, len %u)", conId, dataLen); #endif - // Send a notification for the CHIPoBLE TX characteristic to the client containing the supplied data. + // Send a indication for the CHIPoBLE TX characteristic to the client containing the supplied data. gatt_err = - wiced_bt_gatt_server_send_notification((uint16_t) conId, HDLC_CHIP_SERVICE_CHAR_C2_VALUE, dataLen, data->Start(), NULL); + wiced_bt_gatt_server_send_indication((uint16_t) conId, HDLC_CHIP_SERVICE_CHAR_C2_VALUE, dataLen, data->Start(), NULL); exit: if (gatt_err != WICED_BT_GATT_SUCCESS) { - ChipLogError(DeviceLayer, "BLEManagerImpl::SendNotification() failed: %d", gatt_err); + ChipLogError(DeviceLayer, "BLEManagerImpl::SendIndication() failed: %d", gatt_err); return false; } - else - { - // Post an event to the CHIP queue. - ChipDeviceEvent event; - event.Type = DeviceEventType::kCHIPoBLENotifyConfirm; - event.CHIPoBLENotifyConfirm.ConId = conId; - err = PlatformMgr().PostEvent(&event); - } return err == CHIP_NO_ERROR; } @@ -661,6 +653,27 @@ wiced_bt_gatt_status_t BLEManagerImpl::HandleGattServiceMtuReq(uint16_t conn_id, return WICED_BT_GATT_SUCCESS; } +/* + * Process GATT Indication Confirm from the client + */ +wiced_bt_gatt_status_t BLEManagerImpl::HandleGattServiceIndCfm(uint16_t conn_id, uint16_t handle) +{ +#ifdef BLE_DEBUG + ChipLogDetail(DeviceLayer, "GATT Ind Cfm received con:%04x handle:%d", conn_id, handle); +#endif + if (handle == HDLC_CHIP_SERVICE_CHAR_C2_VALUE) + { + ChipDeviceEvent event; + event.Type = DeviceEventType::kCHIPoBLEIndicateConfirm; + event.CHIPoBLEIndicateConfirm.ConId = conn_id; + if (PlatformMgr().PostEvent(&event) != CHIP_NO_ERROR) + { + return WICED_BT_GATT_INTERNAL_ERROR; + } + } + return WICED_BT_GATT_SUCCESS; +} + /* * Process GATT attribute requests */ @@ -693,6 +706,10 @@ wiced_bt_gatt_status_t BLEManagerImpl::HandleGattServiceRequestEvent(wiced_bt_ga result = HandleGattServiceMtuReq(p_request->conn_id, p_request->data.remote_mtu); break; + case GATT_HANDLE_VALUE_CONF: + result = HandleGattServiceIndCfm(p_request->conn_id, p_request->data.confirm.handle); + break; + default: break; } diff --git a/src/platform/P6/cycfg_gatt_db.c b/src/platform/P6/cycfg_gatt_db.c index 5ed8dddce91f1e..75d0814673ae04 100644 --- a/src/platform/P6/cycfg_gatt_db.c +++ b/src/platform/P6/cycfg_gatt_db.c @@ -70,7 +70,7 @@ const uint8_t gatt_database[] = { GATTDB_CHAR_PROP_WRITE, GATTDB_PERM_READABLE | GATTDB_PERM_WRITE_REQ), /* Characteristic: C2 */ CHARACTERISTIC_UUID128_WRITABLE(HDLC_CHIP_SERVICE_CHAR_C2, HDLC_CHIP_SERVICE_CHAR_C2_VALUE, __UUID128_CHIPoBLEChar_C2, - GATTDB_CHAR_PROP_READ | GATTDB_CHAR_PROP_NOTIFY, + GATTDB_CHAR_PROP_READ | GATTDB_CHAR_PROP_INDICATE, GATTDB_PERM_RELIABLE_WRITE | GATTDB_PERM_READABLE | GATTDB_CHAR_PROP_WRITE), /* Descriptor: Client Characteristic Configuration */