20
20
#ifndef MBED_GATT_SERVER_H__
21
21
#define MBED_GATT_SERVER_H__
22
22
23
+ #include " platform/mbed_toolchain.h"
24
+
23
25
#include " ble/common/CallChainOfFunctionPointersWithContext.h"
24
26
#include " ble/common/blecommon.h"
25
27
@@ -118,6 +120,84 @@ class GattServer {
118
120
(void )connectionHandle;
119
121
(void )attMtuSize;
120
122
}
123
+
124
+ /* *
125
+ * Function invoked when the server has sent data to a client as
126
+ * part of a notification/indication.
127
+ *
128
+ * @note params has a temporary scope and should be copied by the
129
+ * application if needed later
130
+ */
131
+ virtual void onDataSent (const GattDataSentCallbackParams ¶ms) {
132
+ (void )params;
133
+ }
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 ¶ms) {
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 ¶ms) {
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
+
170
+ /* *
171
+ * Function invoked when the client has subscribed to characteristic updates
172
+ *
173
+ * @note params has a temporary scope and should be copied by the
174
+ * application if needed later
175
+ */
176
+ virtual void onUpdatesEnabled (const GattUpdatesEnabledCallbackParams ¶ms) {
177
+ (void )params;
178
+ }
179
+
180
+ /* *
181
+ * Function invoked when the client has unsubscribed to characteristic updates
182
+ *
183
+ * @note params has a temporary scope and should be copied by the
184
+ * application if needed later
185
+ */
186
+ virtual void onUpdatesDisabled (const GattUpdatesDisabledCallbackParams ¶ms) {
187
+ (void )params;
188
+ }
189
+
190
+ /* *
191
+ * Function invoked when an ACK has been received for an
192
+ * indication sent to the client.
193
+ *
194
+ * @note params has a temporary scope and should be copied by the
195
+ * application if needed later
196
+ */
197
+ virtual void onConfirmationReceived (const GattConfirmationReceivedCallbackParams ¶ms) {
198
+ (void )params;
199
+ }
200
+
121
201
protected:
122
202
/* *
123
203
* Prevent polymorphic deletion and avoid unnecessary virtual destructor
@@ -204,6 +284,12 @@ class GattServer {
204
284
* module to signal events back to the application.
205
285
*
206
286
* @param handler Application implementation of an EventHandler.
287
+ *
288
+ * @note Multiple discrete EventHandler instances may be used by adding them
289
+ * to a ChainableGattServerEventHandler and then setting the chain as the primary
290
+ * GattServer EventHandler using this function.
291
+ *
292
+ * @see ChainableGattServerEventHandler
207
293
*/
208
294
void setEventHandler (EventHandler *handler);
209
295
@@ -401,6 +487,8 @@ class GattServer {
401
487
* @note It is possible to chain together multiple onDataSent callbacks
402
488
* (potentially from different modules of an application).
403
489
*/
490
+ MBED_DEPRECATED_SINCE (" mbed-os-6.3.0" , " Individual callback-registering functions have"
491
+ " been replaced by GattServer::setEventHandler. Use that function instead." )
404
492
void onDataSent (const DataSentCallback_t &callback);
405
493
406
494
/* *
@@ -413,6 +501,8 @@ class GattServer {
413
501
* function.
414
502
*/
415
503
template <typename T>
504
+ MBED_DEPRECATED_SINCE (" mbed-os-6.3.0" , " Individual callback-registering functions have"
505
+ " been replaced by GattServer::setEventHandler. Use that function instead." )
416
506
void onDataSent (T *objPtr, void (T::*memberPtr)(unsigned count))
417
507
{
418
508
onDataSent ({objPtr, memberPtr});
@@ -423,6 +513,8 @@ class GattServer {
423
513
*
424
514
* @return A reference to the DATA_SENT event callback chain.
425
515
*/
516
+ MBED_DEPRECATED_SINCE (" mbed-os-6.3.0" , " Individual callback-registering functions have"
517
+ " been replaced by GattServer::setEventHandler. Use that function instead." )
426
518
DataSentCallbackChain_t &onDataSent ();
427
519
428
520
/* *
@@ -434,6 +526,8 @@ class GattServer {
434
526
* @attention It is possible to set multiple event handlers. Registered
435
527
* handlers may be removed with onDataWritten().detach(callback).
436
528
*/
529
+ MBED_DEPRECATED_SINCE (" mbed-os-6.3.0" , " Individual callback-registering functions have"
530
+ " been replaced by GattServer::setEventHandler. Use that function instead." )
437
531
void onDataWritten (const DataWrittenCallback_t &callback);
438
532
439
533
/* *
@@ -446,6 +540,8 @@ class GattServer {
446
540
* function.
447
541
*/
448
542
template <typename T>
543
+ MBED_DEPRECATED_SINCE (" mbed-os-6.3.0" , " Individual callback-registering functions have"
544
+ " been replaced by GattServer::setEventHandler. Use that function instead." )
449
545
void onDataWritten (
450
546
T *objPtr,
451
547
void (T::*memberPtr)(const GattWriteCallbackParams *context)
@@ -465,6 +561,8 @@ class GattServer {
465
561
* @note It is possible to unregister callbacks using
466
562
* onDataWritten().detach(callback).
467
563
*/
564
+ MBED_DEPRECATED_SINCE (" mbed-os-6.3.0" , " Individual callback-registering functions have"
565
+ " been replaced by GattServer::setEventHandler. Use that function instead." )
468
566
DataWrittenCallbackChain_t &onDataWritten();
469
567
470
568
/* *
@@ -485,6 +583,8 @@ class GattServer {
485
583
* @attention It is possible to set multiple event handlers. Registered
486
584
* handlers may be removed with onDataRead().detach(callback).
487
585
*/
586
+ MBED_DEPRECATED_SINCE (" mbed-os-6.3.0" , " Individual callback-registering functions have"
587
+ " been replaced by GattServer::setEventHandler. Use that function instead." )
488
588
ble_error_t onDataRead(const DataReadCallback_t &callback);
489
589
490
590
/* *
@@ -496,6 +596,8 @@ class GattServer {
496
596
* function.
497
597
*/
498
598
template <typename T>
599
+ MBED_DEPRECATED_SINCE (" mbed-os-6.3.0" , " Individual callback-registering functions have"
600
+ " been replaced by GattServer::setEventHandler. Use that function instead." )
499
601
ble_error_t onDataRead(
500
602
T *objPtr,
501
603
void (T::*memberPtr)(const GattReadCallbackParams *context)
@@ -515,6 +617,8 @@ class GattServer {
515
617
* @note It is possible to unregister callbacks using
516
618
* onDataRead().detach(callback).
517
619
*/
620
+ MBED_DEPRECATED_SINCE (" mbed-os-6.3.0" , " Individual callback-registering functions have"
621
+ " been replaced by GattServer::setEventHandler. Use that function instead." )
518
622
DataReadCallbackChain_t &onDataRead();
519
623
520
624
/* *
@@ -530,6 +634,8 @@ class GattServer {
530
634
* @note It is possible to unregister a callback using
531
635
* onShutdown().detach(callback)
532
636
*/
637
+ MBED_DEPRECATED_SINCE (" mbed-os-6.3.0" , " Individual callback-registering functions have"
638
+ " been replaced by GattServer::setEventHandler. Use that function instead." )
533
639
void onShutdown(const GattServerShutdownCallback_t &callback);
534
640
535
641
/* *
@@ -544,6 +650,8 @@ class GattServer {
544
650
* function.
545
651
*/
546
652
template <typename T>
653
+ MBED_DEPRECATED_SINCE (" mbed-os-6.3.0" , " Individual callback-registering functions have"
654
+ " been replaced by GattServer::setEventHandler. Use that function instead." )
547
655
void onShutdown(T *objPtr, void (T::*memberPtr)(const GattServer *))
548
656
{
549
657
onShutdown ({objPtr, memberPtr});
@@ -560,6 +668,8 @@ class GattServer {
560
668
* @note It is possible to unregister callbacks using
561
669
* onShutdown().detach(callback).
562
670
*/
671
+ MBED_DEPRECATED_SINCE (" mbed-os-6.3.0" , " Individual callback-registering functions have"
672
+ " been replaced by GattServer::setEventHandler. Use that function instead." )
563
673
GattServerShutdownCallbackChain_t& onShutdown();
564
674
565
675
/* *
@@ -568,6 +678,8 @@ class GattServer {
568
678
*
569
679
* @param[in] callback Event handler being registered.
570
680
*/
681
+ MBED_DEPRECATED_SINCE (" mbed-os-6.3.0" , " Individual callback-registering functions have"
682
+ " been replaced by GattServer::setEventHandler. Use that function instead." )
571
683
void onUpdatesEnabled(EventCallback_t callback);
572
684
573
685
/* *
@@ -576,6 +688,8 @@ class GattServer {
576
688
*
577
689
* @param[in] callback Event handler being registered.
578
690
*/
691
+ MBED_DEPRECATED_SINCE (" mbed-os-6.3.0" , " Individual callback-registering functions have"
692
+ " been replaced by GattServer::setEventHandler. Use that function instead." )
579
693
void onUpdatesDisabled(EventCallback_t callback);
580
694
581
695
/* *
@@ -586,6 +700,8 @@ class GattServer {
586
700
*
587
701
* @param[in] callback Event handler being registered.
588
702
*/
703
+ MBED_DEPRECATED_SINCE (" mbed-os-6.3.0" , " Individual callback-registering functions have"
704
+ " been replaced by GattServer::setEventHandler. Use that function instead." )
589
705
void onConfirmationReceived(EventCallback_t callback);
590
706
591
707
#if !defined(DOXYGEN_ONLY)
0 commit comments