Skip to content

Commit 2457934

Browse files
committed
Add remaining deprecated onXXX handlers to GattServer::EventHandler
1 parent f1625f8 commit 2457934

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

connectivity/FEATURE_BLE/include/ble/GattServer.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,41 @@ class GattServer {
132132
(void)params;
133133
}
134134

135+
/**
136+
* Function invoked when a client writes an attribute
137+
*
138+
* @note params has a temporary scope and should be copied by the
139+
* application if needed later
140+
*/
141+
virtual void onDataWritten(const GattWriteCallbackParams *params) {
142+
(void)params;
143+
}
144+
145+
/**
146+
* Function invoked when a client reads an attribute
147+
*
148+
* @note This functionality may not be available on all underlying stacks.
149+
* Application code may work around that limitation by monitoring read
150+
* requests instead of read events.
151+
*
152+
* @note params has a temporary scope and should be copied by the
153+
* application if needed later
154+
*
155+
* @see GattCharacteristic::setReadAuthorizationCallback()
156+
* @see isOnDataReadAvailable().
157+
*/
158+
virtual void onDataRead(const GattReadCallbackParams *params) {
159+
(void)params;
160+
}
161+
162+
/**
163+
* Function invoked when the GattServer instance is about
164+
* to be shut down. This can result in a call to reset() or BLE::reset().
165+
*/
166+
virtual void onShutdown(const GattServer *server) {
167+
(void)server;
168+
}
169+
135170
/**
136171
* Function invoked when the client has subscribed to characteristic updates
137172
*

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,11 @@ GapAdvertisingData::Appearance GattServer::getAppearance()
878878
ble_error_t GattServer::reset(ble::GattServer* server)
879879
{
880880
/* Notify that the instance is about to shutdown */
881+
if(eventHandler) {
882+
eventHandler->onShutdown(server);
883+
}
884+
885+
// Execute callbacks added with deprecated API
881886
shutdownCallChain.call(server);
882887
shutdownCallChain.clear();
883888

@@ -1480,11 +1485,21 @@ GattServer::EventHandler *GattServer::getEventHandler()
14801485

14811486
void GattServer::handleDataWrittenEvent(const GattWriteCallbackParams *params)
14821487
{
1488+
if(eventHandler) {
1489+
eventHandler->onDataWritten(params);
1490+
}
1491+
1492+
// Execute callbacks added with deprecated API
14831493
dataWrittenCallChain.call(params);
14841494
}
14851495

14861496
void GattServer::handleDataReadEvent(const GattReadCallbackParams *params)
14871497
{
1498+
if(eventHandler) {
1499+
eventHandler->onDataRead(params);
1500+
}
1501+
1502+
// Execute callbacks added with deprecated API
14881503
dataReadCallChain.call(params);
14891504
}
14901505

0 commit comments

Comments
 (0)