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 {
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 *
Original file line number Diff line number Diff line change @@ -878,6 +878,11 @@ GapAdvertisingData::Appearance GattServer::getAppearance()
878878ble_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
@@ -1481,11 +1486,21 @@ GattServer::EventHandler *GattServer::getEventHandler()
14811486
14821487void GattServer::handleDataWrittenEvent (const GattWriteCallbackParams *params)
14831488{
1489+ if (eventHandler) {
1490+ eventHandler->onDataWritten (params);
1491+ }
1492+
1493+ // Execute callbacks added with deprecated API
14841494 dataWrittenCallChain.call (params);
14851495}
14861496
14871497void GattServer::handleDataReadEvent (const GattReadCallbackParams *params)
14881498{
1499+ if (eventHandler) {
1500+ eventHandler->onDataRead (params);
1501+ }
1502+
1503+ // Execute callbacks added with deprecated API
14891504 dataReadCallChain.call (params);
14901505}
14911506
You can’t perform that action at this time.
0 commit comments