Skip to content

Commit d42c0a7

Browse files
author
Abbas Bracken Ziad
committed
Add value handle field to callback params
1 parent 8b07e97 commit d42c0a7

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

connectivity/FEATURE_BLE/include/ble/gatt/GattCallbackParamTypes.h

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,31 @@ struct GattDataSentCallbackParams {
443443

444444
};
445445

446-
using GattUpdatesEnabledCallbackParams = GattDataSentCallbackParams;
447-
using GattUpdatesDisabledCallbackParams = GattDataSentCallbackParams;
446+
/**
447+
* Gatt Updates Enabled Attribute related events
448+
*
449+
* Used by `onUpdatesEnabled`
450+
*/
451+
struct GattUpdatesEnabledCallbackParams {
452+
453+
/**
454+
* The handle of the connection that triggered the event.
455+
*/
456+
ble::connection_handle_t connHandle;
457+
458+
/**
459+
* The handle of the CCCD producing the event
460+
*/
461+
GattAttribute::Handle_t attHandle;
462+
463+
/**
464+
* The handle of the characteristic containing the CCCD
465+
*/
466+
GattAttribute::Handle_t charHandle;
467+
468+
};
469+
470+
using GattUpdatesDisabledCallbackParams = GattUpdatesEnabledCallbackParams;
448471
using GattConfirmationReceivedCallbackParams = GattDataSentCallbackParams;
449472

450473
namespace ble {

connectivity/FEATURE_BLE/source/cordio/source/GattServerImpl.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,13 +1729,18 @@ void GattServer::handleEvent(
17291729
GattAttribute::Handle_t attributeHandle
17301730
)
17311731
{
1732+
// To be used in cases where the characteristic value handle differs from the attribute handle
1733+
GattAttribute::Handle_t charHandle;
1734+
17321735
switch (type) {
17331736
case GattServerEvents::GATT_EVENT_UPDATES_ENABLED:
17341737
tr_info("Updates enabled for attribute %d on connection %d", attributeHandle, connHandle);
1738+
get_value_handle_by_cccd_handle(attributeHandle, charHandle);
17351739
if(eventHandler) {
17361740
GattUpdatesEnabledCallbackParams params({
17371741
.connHandle = connHandle,
1738-
.attHandle = attributeHandle
1742+
.attHandle = attributeHandle,
1743+
.charHandle = charHandle
17391744
});
17401745
eventHandler->onUpdatesEnabled(params);
17411746
}
@@ -1747,10 +1752,12 @@ void GattServer::handleEvent(
17471752
break;
17481753
case GattServerEvents::GATT_EVENT_UPDATES_DISABLED:
17491754
tr_info("Updates disabled for attribute %d on connection %d", attributeHandle, connHandle);
1755+
get_value_handle_by_cccd_handle(attributeHandle, charHandle);
17501756
if(eventHandler) {
17511757
GattUpdatesDisabledCallbackParams params({
17521758
.connHandle = connHandle,
1753-
.attHandle = attributeHandle
1759+
.attHandle = attributeHandle,
1760+
.charHandle = charHandle
17541761
});
17551762
eventHandler->onUpdatesDisabled(params);
17561763
}

0 commit comments

Comments
 (0)