File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,41 @@ class GattServer {
132
132
(void )params;
133
133
}
134
134
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
+
135
170
/* *
136
171
* Function invoked when the client has subscribed to characteristic updates
137
172
*
Original file line number Diff line number Diff line change @@ -878,6 +878,11 @@ GapAdvertisingData::Appearance GattServer::getAppearance()
878
878
ble_error_t GattServer::reset (ble::GattServer* server)
879
879
{
880
880
/* Notify that the instance is about to shutdown */
881
+ if (eventHandler) {
882
+ eventHandler->onShutdown (server);
883
+ }
884
+
885
+ // Execute callbacks added with deprecated API
881
886
shutdownCallChain.call (server);
882
887
shutdownCallChain.clear ();
883
888
@@ -1480,11 +1485,21 @@ GattServer::EventHandler *GattServer::getEventHandler()
1480
1485
1481
1486
void GattServer::handleDataWrittenEvent (const GattWriteCallbackParams *params)
1482
1487
{
1488
+ if (eventHandler) {
1489
+ eventHandler->onDataWritten (params);
1490
+ }
1491
+
1492
+ // Execute callbacks added with deprecated API
1483
1493
dataWrittenCallChain.call (params);
1484
1494
}
1485
1495
1486
1496
void GattServer::handleDataReadEvent (const GattReadCallbackParams *params)
1487
1497
{
1498
+ if (eventHandler) {
1499
+ eventHandler->onDataRead (params);
1500
+ }
1501
+
1502
+ // Execute callbacks added with deprecated API
1488
1503
dataReadCallChain.call (params);
1489
1504
}
1490
1505
You can’t perform that action at this time.
0 commit comments