Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate indications event onConfirmationReceived #14602

Merged
merged 1 commit into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions connectivity/FEATURE_BLE/include/ble/GattServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ class GattServer {
}

/**
* Function invoked when the server has sent data to a client as
* part of a notification/indication.
* Function invoked when the server has sent data to a client. For
* notifications this is triggered when data is sent, for indications
* it's only triggered when the confirmation has been received.
Copy link

@noonfom noonfom Apr 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, Cordio executes the "application callback function with confirmation event" whether the client is subscribed to notifications or indications, which triggers the call stack that leads to onDataSent. The difference is it is triggered in the sending function for notifications but in the confirming function for indications. In other words, attsExecCallback is called in both cases, which calls attExecCallback with ATTS_HANDLE_VALUE_CNF as the event, so the Gatt Server cannot differentiate between notifications and indications.

Perhaps, we could define a separate ATT server callback event for notifications? This way we can call attExecCallback directly during the sending function, enabling the Gatt Server to differentiate between notifications and indications using the new event type. Of course, this requires modifications to Cordio which might be undesirable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I guess you weren't at the standup but that's pretty much my conclusion as well - we could keep the event but then we have to make changes to Cordio and try to upstream them - it's up to Vincent.

*
* @note params has a temporary scope and should be copied by the
* application if needed later
Expand Down Expand Up @@ -188,12 +189,13 @@ class GattServer {
}

/**
* Function invoked when an ACK has been received for an
* indication sent to the client.
* Event not used.
*
* @note params has a temporary scope and should be copied by the
* application if needed later
*/
MBED_DEPRECATED_SINCE("mbed-os-6.11.0", "This event is never triggered. Indication triggers onDataSent"
"when confirmation is received.")
virtual void onConfirmationReceived(const GattConfirmationReceivedCallbackParams &params) {
(void)params;
}
Expand Down Expand Up @@ -274,7 +276,7 @@ class GattServer {
* Event handler that handles subscription to characteristic updates,
* unsubscription from characteristic updates and notification confirmation.
*
* @see onUpdatesEnabled() onUpdateDisabled() onConfirmationReceived()
* @see onUpdatesEnabled() onUpdateDisabled()
*/
typedef FunctionPointerWithContext<GattAttribute::Handle_t> EventCallback_t;

Expand Down Expand Up @@ -705,7 +707,8 @@ class GattServer {
* @param[in] callback Event handler being registered.
*/
MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
"been replaced by GattServer::setEventHandler. Use that function instead.")
"been replaced by an event handler. Indication confirmation triggers"
"GattServer::onDataSent event instead.")
void onConfirmationReceived(EventCallback_t callback);

#if !defined(DOXYGEN_ONLY)
Expand Down
15 changes: 0 additions & 15 deletions connectivity/FEATURE_BLE/source/cordio/source/GattServerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1767,21 +1767,6 @@ void GattServer::handleEvent(
updatesDisabledCallback(attributeHandle);
}
break;
case GattServerEvents::GATT_EVENT_CONFIRMATION_RECEIVED:
tr_debug("Confirmation received for attribute %d on connection %d", attributeHandle, connHandle);
if(eventHandler) {
GattConfirmationReceivedCallbackParams params({
.connHandle = connHandle,
.attHandle = attributeHandle
});
eventHandler->onConfirmationReceived(params);
}

// Execute deprecated callback
if (confirmationReceivedCallback) {
confirmationReceivedCallback(attributeHandle);
}
break;

case GattServerEvents::GATT_EVENT_DATA_SENT:
tr_debug("Data sent for attribute %d on connection %d", attributeHandle, connHandle);
Expand Down
2 changes: 2 additions & 0 deletions connectivity/FEATURE_BLE/source/generic/GattServerEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class GattServerEvents

/**
* Response received from Characteristic Value Indication message.
* @deprecated This event is never used. Indications use GATT_EVENT_DATA_SENT
* only after confirmation is received.
*/
GATT_EVENT_CONFIRMATION_RECEIVED = 5,

Expand Down