Skip to content

Commit

Permalink
P6: Added support of BLE GATT Notification instead of GATT Indication… (
Browse files Browse the repository at this point in the history
#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>
  • Loading branch information
4 people authored and pull[bot] committed Nov 9, 2022
1 parent a766482 commit 2619909
Showing 1 changed file with 14 additions and 31 deletions.
45 changes: 14 additions & 31 deletions src/platform/P6/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event)
PacketBufferHandle::Adopt(event->CHIPoBLEWriteReceived.Data));
break;

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

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

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

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

exit:
if (gatt_err != WICED_BT_GATT_SUCCESS)
{
ChipLogError(DeviceLayer, "BLEManagerImpl::SendIndication() failed: %ld", gatt_err);
ChipLogError(DeviceLayer, "BLEManagerImpl::SendNotification() failed: %ld", 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;
}

Expand Down Expand Up @@ -615,27 +623,6 @@ wiced_bt_gatt_status_t BLEManagerImpl::HandleGattServiceMtuReq(wiced_bt_gatt_att
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
*/
Expand All @@ -658,10 +645,6 @@ wiced_bt_gatt_status_t BLEManagerImpl::HandleGattServiceRequestEvent(wiced_bt_ga
result = HandleGattServiceMtuReq(p_request, p_conn);
break;

case GATTS_REQ_TYPE_CONF:
result = HandleGattServiceIndCfm(p_request->conn_id, p_request->data.handle);
break;

default:
break;
}
Expand Down

0 comments on commit 2619909

Please sign in to comment.