Mistake on this page?
Report an issue in GitHub or email us
GattServer.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2006-2020 ARM Limited
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 
20 #ifndef MBED_GATT_SERVER_H__
21 #define MBED_GATT_SERVER_H__
22 
23 #include "platform/mbed_toolchain.h"
24 
25 #include "ble/common/CallChainOfFunctionPointersWithContext.h"
26 #include "ble/common/blecommon.h"
27 
28 #include "ble/gatt/GattService.h"
29 #include "ble/gatt/GattAttribute.h"
30 #include "ble/gatt/GattCallbackParamTypes.h"
31 
32 namespace ble {
33 
34 #if !defined(DOXYGEN_ONLY)
35 namespace impl {
36 class GattServer;
37 }
38 #endif // !defined(DOXYGEN_ONLY)
39 
40 
41 /**
42  * @addtogroup ble
43  * @{
44  * @addtogroup gatt
45  * @{
46  * @addtogroup server
47  * @{
48  */
49 
50 /**
51  * Construct and operates a GATT server.
52  *
53  * A Gatt server is a collection of GattService; these services contain
54  * characteristics that a peer connected to the device may read or write.
55  * These characteristics may also emit updates to subscribed clients when their
56  * values change.
57  *
58  * @p Server Layout
59  *
60  * Application code can add a GattService object to the server with the help of
61  * the function addService(). That function registers all the GattCharacteristic
62  * enclosed in the service, as well as all the characteristics descriptors (see
63  * GattAttribute) these characteristics contain. Service registration assigns
64  * a unique handle to the various attributes being part of the service; this
65  * handle should be used for subsequent read or write of these components.
66  *
67  * There are no primitives defined to remove a single service; however, a call to
68  * the function reset() removes all services previously registered in the
69  * GattServer.
70  *
71  * @p Characteristic and attributes access
72  *
73  * Values of the characteristic and the characteristic descriptor present in the
74  * GattServer must be accessed through the handle assigned to them when the service
75  * has been registered; the GattServer class offers several flavors of read()
76  * and write() functions that retrieve or mutate an attribute value.
77  *
78  * Application code can query if a client has subscribed to a given
79  * characteristic's value update by invoking the function areUpdatesEnabled().
80  *
81  * @p Events
82  *
83  * The GattServer allows application code to register several event handlers that
84  * can be used to monitor client and server activities:
85  * - onDataSent(): Register an event handler that is called when a
86  * characteristic value update has been sent to a client.
87  * - onDataWriten(): Register an event handler that is called when a
88  * client has written an attribute of the server.
89  * - onDataRead(): Register an event handler that is called when a
90  * client has read an attribute of the server.
91  * - onUpdatesEnabled: Register an event handler that is called when a
92  * client subscribes to updates of a characteristic.
93  * - onUpdatesDisabled: Register an event handler that is called when a
94  * client unsubscribes from updates of a characteristic.
95  * - onConfimationReceived: Register an event handler that is called
96  * when a client acknowledges a characteristic value notification.
97  *
98  * @note The term characteristic value update is used to represent
99  * Characteristic Value Notification and Characteristic Value Indication when
100  * the nature of the server initiated is not relevant.
101  */
102 class GattServer {
103 public:
104  /**
105  * Definition of the general handler of GattServer related events.
106  */
107  struct EventHandler {
108  /**
109  * Function invoked when the connections changes the ATT_MTU which controls
110  * the maximum size of an attribute that can be read in a single L2CAP packet
111  * which might be fragmented across multiple packets.
112  *
113  * @param connectionHandle The handle of the connection that changed the size.
114  * @param attMtuSize
115  */
116  virtual void onAttMtuChange(
117  ble::connection_handle_t connectionHandle,
118  uint16_t attMtuSize
119  ) {
120  (void)connectionHandle;
121  (void)attMtuSize;
122  }
123 
124  /**
125  * Function invoked when the server has sent data to a client. For
126  * notifications this is triggered when data is sent, for indications
127  * it's only triggered when the confirmation has been received.
128  *
129  * @note params has a temporary scope and should be copied by the
130  * application if needed later
131  */
132  virtual void onDataSent(const GattDataSentCallbackParams &params) {
133  (void)params;
134  }
135 
136  /**
137  * Function invoked when a client writes an attribute
138  *
139  * @note params has a temporary scope and should be copied by the
140  * application if needed later
141  */
142  virtual void onDataWritten(const GattWriteCallbackParams &params) {
143  (void)params;
144  }
145 
146  /**
147  * Function invoked when a client reads an attribute
148  *
149  * @note This functionality may not be available on all underlying stacks.
150  * Application code may work around that limitation by monitoring read
151  * requests instead of read events.
152  *
153  * @note params has a temporary scope and should be copied by the
154  * application if needed later
155  *
156  * @see GattCharacteristic::setReadAuthorizationCallback()
157  * @see isOnDataReadAvailable().
158  */
159  virtual void onDataRead(const GattReadCallbackParams &params) {
160  (void)params;
161  }
162 
163  /**
164  * Function invoked when the GattServer instance is about
165  * to be shut down. This can result in a call to reset() or BLE::reset().
166  */
167  virtual void onShutdown(const GattServer &server) {
168  (void)server;
169  }
170 
171  /**
172  * Function invoked when the client has subscribed to characteristic updates
173  *
174  * @note params has a temporary scope and should be copied by the
175  * application if needed later
176  */
178  (void)params;
179  }
180 
181  /**
182  * Function invoked when the client has unsubscribed to characteristic updates
183  *
184  * @note params has a temporary scope and should be copied by the
185  * application if needed later
186  */
188  (void)params;
189  }
190 
191  /**
192  * Event not used.
193  *
194  * @note params has a temporary scope and should be copied by the
195  * application if needed later
196  */
197  MBED_DEPRECATED_SINCE("mbed-os-6.11.0", "This event is never triggered. Indication triggers onDataSent"
198  "when confirmation is received.")
199  virtual void onConfirmationReceived(const GattConfirmationReceivedCallbackParams &params) {
200  (void)params;
201  }
202 
203  protected:
204  /**
205  * Prevent polymorphic deletion and avoid unnecessary virtual destructor
206  * as the GattServer class will never delete the instance it contains.
207  */
208  ~EventHandler() = default;
209  };
210 
211  /**
212  * Event handler invoked when the server has sent data to a client.
213  *
214  * @see onDataSent().
215  */
217 
218  /**
219  * Callchain of DataSentCallback_t objects.
220  *
221  * @see onDataSent().
222  */
225 
226  /**
227  * Event handler invoked when the client has written an attribute of the
228  * server.
229  *
230  * @see onDataWritten().
231  */
234 
235  /**
236  * Callchain of DataWrittenCallback_t objects.
237  *
238  * @see onDataWritten().
239  */
242 
243  /**
244  * Event handler invoked when the client has read an attribute of the server.
245  *
246  * @see onDataRead().
247  */
250 
251  /**
252  * Callchain of DataReadCallback_t.
253  *
254  * @see onDataRead().
255  */
258 
259  /**
260  * Event handler invoked when the GattServer is reset.
261  *
262  * @see onShutdown() reset()
263  */
266 
267  /**
268  * Callchain of GattServerShutdownCallback_t.
269  *
270  * @see onShutdown() reset()
271  */
274 
275  /**
276  * Event handler that handles subscription to characteristic updates,
277  * unsubscription from characteristic updates and notification confirmation.
278  *
279  * @see onUpdatesEnabled() onUpdateDisabled()
280  */
282 
283 public:
284  /**
285  * Assign the event handler implementation that will be used by the
286  * module to signal events back to the application.
287  *
288  * @param handler Application implementation of an EventHandler.
289  *
290  * @note Multiple discrete EventHandler instances may be used by adding them
291  * to a ChainableGattServerEventHandler and then setting the chain as the primary
292  * GattServer EventHandler using this function.
293  *
294  * @see ChainableGattServerEventHandler
295  */
296  void setEventHandler(EventHandler *handler);
297 
298  /**
299  * Shut down the GattServer instance.
300  *
301  * This function notifies all event handlers listening for shutdown events
302  * that the GattServer is about to be shut down; then it clears all
303  * GattServer state.
304  *
305  * @note This function is meant to be overridden in the platform-specific
306  * subclass. Overides must call the parent function before any cleanup.
307  *
308  * @return BLE_ERROR_NONE on success.
309  */
310  ble_error_t reset();
311 
312  /**
313  * Add a service declaration to the local attribute server table.
314  *
315  * This functions inserts a service declaration in the attribute table
316  * followed by the characteristic declarations (including characteristic
317  * descriptors) present in @p service.
318  *
319  * The process assigns a unique attribute handle to all the elements added
320  * into the attribute table. This handle is an ID that must be used for
321  * subsequent interactions with the elements.
322  *
323  * @note There is no mirror function that removes a single service.
324  * Application code can remove all the registered services by calling
325  * reset().
326  *
327  * @attention GattServer allocates its own memory for all the attributes.
328  * The GattServer will set the handles on the service passed in and the
329  * characteristics it contains. You may record the handles you want to
330  * interact with in the future. After that the service and characteristics
331  * you passed in as the parameter may be freed. To write to the GattServer
332  * instances of the characteristics you have to use the saved handles.
333  *
334  * @param[in] service The service to be added; attribute handle of services,
335  * characteristic and characteristic descriptors are updated by the
336  * process.
337  *
338  * @return BLE_ERROR_NONE if the service was successfully added.
339  */
340  ble_error_t addService(GattService &service);
341 
342  /**
343  * Read the value of an attribute present in the local GATT server.
344  *
345  * @param[in] attributeHandle Handle of the attribute to read.
346  * @param[out] buffer A buffer to hold the value being read.
347  * @param[in,out] lengthP Length of the buffer being supplied. If the
348  * attribute value is longer than the size of the supplied buffer, this
349  * variable holds upon return the total attribute value length (excluding
350  * offset). The application may use this information to allocate a suitable
351  * buffer size.
352  *
353  * @return BLE_ERROR_NONE if a value was read successfully into the buffer.
354  *
355  * @attention read(ble::connection_handle_t, GattAttribute::Handle_t, uint8_t *, uint16_t *)
356  * must be used to read Client Characteristic Configuration Descriptor (CCCD)
357  * because the value of this type of attribute depends on the connection.
358  */
359  ble_error_t read(
360  GattAttribute::Handle_t attributeHandle,
361  uint8_t buffer[],
362  uint16_t *lengthP
363  );
364 
365  /**
366  * Read the value of an attribute present in the local GATT server.
367  *
368  * The connection handle allows application code to read the value of a
369  * Client Characteristic Configuration Descriptor for a given connection.
370  *
371  * @param[in] connectionHandle Connection handle.
372  * @param[in] attributeHandle Attribute handle for the value attribute of
373  * the characteristic.
374  * @param[out] buffer A buffer to hold the value being read.
375  * @param[in,out] lengthP Length of the buffer being supplied. If the
376  * attribute value is longer than the size of the supplied buffer, this
377  * variable holds upon return the total attribute value length (excluding
378  * offset). The application may use this information to allocate a suitable
379  * buffer size.
380  *
381  * @return BLE_ERROR_NONE if a value was read successfully into the buffer.
382  */
383  ble_error_t read(
384  ble::connection_handle_t connectionHandle,
385  GattAttribute::Handle_t attributeHandle,
386  uint8_t *buffer,
387  uint16_t *lengthP
388  );
389 
390  /**
391  * Update the value of an attribute present in the local GATT server.
392  *
393  * @param[in] attributeHandle Handle of the attribute to write.
394  * @param[in] value A pointer to a buffer holding the new value.
395  * @param[in] size Size in bytes of the new value (in bytes).
396  * @param[in] localOnly If this flag is false and the attribute handle
397  * written is a characteristic value, then the server sends an update
398  * containing the new value to all clients that have subscribed to the
399  * characteristic's notifications or indications. Otherwise, the update does
400  * not generate a single server initiated event.
401  *
402  * @return BLE_ERROR_NONE if the attribute value has been successfully
403  * updated.
404  */
405  ble_error_t write(
406  GattAttribute::Handle_t attributeHandle,
407  const uint8_t *value,
408  uint16_t size,
409  bool localOnly = false
410  );
411 
412  /**
413  * Update the value of an attribute present in the local GATT server.
414  *
415  * The connection handle parameter allows application code to direct
416  * notification or indication resulting from the update to a specific client.
417  *
418  * @param[in] connectionHandle Connection handle.
419  * @param[in] attributeHandle Handle for the value attribute of the
420  * characteristic.
421  * @param[in] value A pointer to a buffer holding the new value.
422  * @param[in] size Size of the new value (in bytes).
423  * @param[in] localOnly If this flag is false and the attribute handle
424  * written is a characteristic value, then the server sends an update
425  * containing the new value to the client identified by the parameter
426  * @p connectionHandle if it is subscribed to the characteristic's
427  * notifications or indications. Otherwise, the update does not generate a
428  * single server initiated event.
429  *
430  * @return BLE_ERROR_NONE if the attribute value has been successfully
431  * updated.
432  */
433  ble_error_t write(
434  ble::connection_handle_t connectionHandle,
435  GattAttribute::Handle_t attributeHandle,
436  const uint8_t *value,
437  uint16_t size,
438  bool localOnly = false
439  );
440 
441  /**
442  * Determine if one of the connected clients has subscribed to notifications
443  * or indications of the characteristic in input.
444  *
445  * @param[in] characteristic The characteristic.
446  * @param[out] enabledP Upon return, *enabledP is true if updates are
447  * enabled for a connected client; otherwise, *enabledP is false.
448  *
449  * @return BLE_ERROR_NONE if the connection and handle are found. False
450  * otherwise.
451  */
452  ble_error_t areUpdatesEnabled(
453  const GattCharacteristic &characteristic,
454  bool *enabledP
455  );
456 
457  /**
458  * Determine if an identified client has subscribed to notifications or
459  * indications of a given characteristic.
460  *
461  * @param[in] connectionHandle The connection handle.
462  * @param[in] characteristic The characteristic.
463  * @param[out] enabledP Upon return, *enabledP is true if the client
464  * identified by @p connectionHandle has subscribed to notifications or
465  * indications of @p characteristic; otherwise, *enabledP is false.
466  *
467  * @return BLE_ERROR_NONE if the connection and handle are found. False
468  * otherwise.
469  */
470  ble_error_t areUpdatesEnabled(
471  ble::connection_handle_t connectionHandle,
472  const GattCharacteristic &characteristic,
473  bool *enabledP
474  );
475 
476  /**
477  * Indicate if the underlying stack emit events when an attribute is read by
478  * a client.
479  *
480  * @attention This function should be overridden to return true if
481  * applicable.
482  *
483  * @return true if onDataRead is supported; false otherwise.
484  */
485  bool isOnDataReadAvailable() const;
486 
487  /**
488  * Add an event handler that monitors emission of characteristic value
489  * updates.
490  *
491  * @param[in] callback Event handler being registered.
492  *
493  * @note It is possible to chain together multiple onDataSent callbacks
494  * (potentially from different modules of an application).
495  */
496  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
497  "been replaced by GattServer::setEventHandler. Use that function instead.")
498  void onDataSent(const DataSentCallback_t &callback);
499 
500  /**
501  * Add an event handler that monitors emission of characteristic value
502  * updates.
503  *
504  * @param[in] objPtr Pointer to the instance that is used to invoke the
505  * event handler.
506  * @param[in] memberPtr Event handler being registered. It is a member
507  * function.
508  */
509  template <typename T>
510  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
511  "been replaced by GattServer::setEventHandler. Use that function instead.")
512  void onDataSent(T *objPtr, void (T::*memberPtr)(unsigned count))
513  {
514  onDataSent({objPtr, memberPtr});
515  }
516 
517  /**
518  * Access the callchain of data sent event handlers.
519  *
520  * @return A reference to the DATA_SENT event callback chain.
521  */
522  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
523  "been replaced by GattServer::setEventHandler. Use that function instead.")
524  DataSentCallbackChain_t &onDataSent();
525 
526  /**
527  * Set an event handler that is called after
528  * a connected peer has written an attribute.
529  *
530  * @param[in] callback The event handler being registered.
531  *
532  * @attention It is possible to set multiple event handlers. Registered
533  * handlers may be removed with onDataWritten().detach(callback).
534  */
535  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
536  "been replaced by GattServer::setEventHandler. Use that function instead.")
537  void onDataWritten(const DataWrittenCallback_t &callback);
538 
539  /**
540  * Set an event handler that is called after
541  * a connected peer has written an attribute.
542  *
543  * @param[in] objPtr Pointer to the instance that is used to invoke the
544  * event handler (@p memberPtr).
545  * @param[in] memberPtr Event handler being registered. It is a member
546  * function.
547  */
548  template <typename T>
549  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
550  "been replaced by GattServer::setEventHandler. Use that function instead.")
551  void onDataWritten(
552  T *objPtr,
553  void (T::*memberPtr)(const GattWriteCallbackParams *context)
554  )
555  {
556  onDataWritten({objPtr, memberPtr});
557  }
558 
559  /**
560  * Access the callchain of data written event handlers.
561  *
562  * @return A reference to the data written event callbacks chain.
563  *
564  * @note It is possible to register callbacks using
565  * onDataWritten().add(callback).
566  *
567  * @note It is possible to unregister callbacks using
568  * onDataWritten().detach(callback).
569  */
570  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
571  "been replaced by GattServer::setEventHandler. Use that function instead.")
572  DataWrittenCallbackChain_t &onDataWritten();
573 
574  /**
575  * Set an event handler that monitors attribute reads from connected clients.
576  *
577  * @param[in] callback Event handler being registered.
578  *
579  * @return BLE_ERROR_NOT_IMPLEMENTED if this functionality isn't available;
580  * else BLE_ERROR_NONE.
581  *
582  * @note This functionality may not be available on all underlying stacks.
583  * Application code may work around that limitation by monitoring read
584  * requests instead of read events.
585  *
586  * @see GattCharacteristic::setReadAuthorizationCallback()
587  * @see isOnDataReadAvailable().
588  *
589  * @attention It is possible to set multiple event handlers. Registered
590  * handlers may be removed with onDataRead().detach(callback).
591  */
592  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
593  "been replaced by GattServer::setEventHandler. Use that function instead.")
594  ble_error_t onDataRead(const DataReadCallback_t &callback);
595 
596  /**
597  * Set an event handler that monitors attribute reads from connected clients.
598  *
599  * @param[in] objPtr Pointer to the instance that is used to invoke the
600  * event handler (@p memberPtr).
601  * @param[in] memberPtr Event handler being registered. It is a member
602  * function.
603  */
604  template <typename T>
605  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
606  "been replaced by GattServer::setEventHandler. Use that function instead.")
607  ble_error_t onDataRead(
608  T *objPtr,
609  void (T::*memberPtr)(const GattReadCallbackParams *context)
610  )
611  {
612  return onDataRead({objPtr, memberPtr});
613  }
614 
615  /**
616  * Access the callchain of data read event handlers.
617  *
618  * @return A reference to the data read event callbacks chain.
619  *
620  * @note It is possible to register callbacks using
621  * onDataRead().add(callback).
622  *
623  * @note It is possible to unregister callbacks using
624  * onDataRead().detach(callback).
625  */
626  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
627  "been replaced by GattServer::setEventHandler. Use that function instead.")
628  DataReadCallbackChain_t &onDataRead();
629 
630  /**
631  * Set an event handler that monitors shutdown or reset of the GattServer.
632  *
633  * The event handler is invoked when the GattServer instance is about
634  * to be shut down. This can result in a call to reset() or BLE::reset().
635  *
636  * @param[in] callback Event handler being registered.
637  *
638  * @note It is possible to set up multiple shutdown event handlers.
639  *
640  * @note It is possible to unregister a callback using
641  * onShutdown().detach(callback)
642  */
643  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
644  "been replaced by GattServer::setEventHandler. Use that function instead.")
645  void onShutdown(const GattServerShutdownCallback_t &callback);
646 
647  /**
648  * Set an event handler that monitors shutdown or reset of the GattServer.
649  *
650  * The event handler is invoked when the GattServer instance is about
651  * to be shut down. This can result of a call to reset() or BLE::reset().
652  *
653  * @param[in] objPtr Pointer to the instance that is used to invoke the
654  * event handler (@p memberPtr).
655  * @param[in] memberPtr Event handler being registered. It is a member
656  * function.
657  */
658  template <typename T>
659  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
660  "been replaced by GattServer::setEventHandler. Use that function instead.")
661  void onShutdown(T *objPtr, void (T::*memberPtr)(const GattServer *))
662  {
663  onShutdown({objPtr, memberPtr});
664  }
665 
666  /**
667  * Access the callchain of shutdown event handlers.
668  *
669  * @return A reference to the shutdown event callbacks chain.
670  *
671  * @note It is possible to register callbacks using
672  * onShutdown().add(callback).
673  *
674  * @note It is possible to unregister callbacks using
675  * onShutdown().detach(callback).
676  */
677  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
678  "been replaced by GattServer::setEventHandler. Use that function instead.")
679  GattServerShutdownCallbackChain_t& onShutdown();
680 
681  /**
682  * Set up an event handler that monitors subscription to characteristic
683  * updates.
684  *
685  * @param[in] callback Event handler being registered.
686  */
687  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
688  "been replaced by GattServer::setEventHandler. Use that function instead.")
689  void onUpdatesEnabled(EventCallback_t callback);
690 
691  /**
692  * Set up an event handler that monitors unsubscription from characteristic
693  * updates.
694  *
695  * @param[in] callback Event handler being registered.
696  */
697  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
698  "been replaced by GattServer::setEventHandler. Use that function instead.")
699  void onUpdatesDisabled(EventCallback_t callback);
700 
701  /**
702  * Set up an event handler that monitors notification acknowledgment.
703  *
704  * The event handler is called when a client sends a confirmation that it has
705  * correctly received a notification from the server.
706  *
707  * @param[in] callback Event handler being registered.
708  */
709  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
710  "been replaced by an event handler. Indication confirmation triggers"
711  "GattServer::onDataSent event instead.")
712  void onConfirmationReceived(EventCallback_t callback);
713 
714 #if !defined(DOXYGEN_ONLY)
715  GattServer(impl::GattServer* impl) : impl(impl) {}
716  GattServer(const GattServer&) = delete;
717  GattServer& operator=(const GattServer&) = delete;
718 #endif // !defined(DOXYGEN_ONLY)
719 
720 private:
721  impl::GattServer *impl;
722 };
723 
724 /**
725  * @}
726  * @}
727  * @}
728  */
729 
730 } // ble
731 
732 /** @deprecated Use the namespaced ble::GattServer instead of the global GattServer. */
733 using ble::GattServer;
734 
735 #endif /* ifndef MBED_GATT_SERVER_H__ */
FunctionPointerWithContext< unsigned > DataSentCallback_t
Event handler invoked when the server has sent data to a client.
Definition: GattServer.h:216
Function like object adapter over freestanding and member functions.
CallChainOfFunctionPointersWithContext< unsigned > DataSentCallbackChain_t
Callchain of DataSentCallback_t objects.
Definition: GattServer.h:224
Construct and operates a GATT server.
Definition: GattServer.h:102
uintptr_t connection_handle_t
Opaque reference to a connection.
FunctionPointerWithContext< GattAttribute::Handle_t > EventCallback_t
Event handler that handles subscription to characteristic updates, unsubscription from characteristic...
Definition: GattServer.h:281
virtual void onDataWritten(const GattWriteCallbackParams &params)
Function invoked when a client writes an attribute.
Definition: GattServer.h:142
CallChainOfFunctionPointersWithContext< const GattServer * > GattServerShutdownCallbackChain_t
Callchain of GattServerShutdownCallback_t.
Definition: GattServer.h:273
Callback< R(ArgTs...)> callback(R(*func)(ArgTs...)=nullptr) noexcept
Create a callback class with type inferred from the arguments.
Definition: Callback.h:678
CallChainOfFunctionPointersWithContext< const GattReadCallbackParams * > DataReadCallbackChain_t
Callchain of DataReadCallback_t.
Definition: GattServer.h:257
virtual void onDataSent(const GattDataSentCallbackParams &params)
Function invoked when the server has sent data to a client.
Definition: GattServer.h:132
ble::attribute_handle_t Handle_t
Representation of an attribute handle.
Gatt Data Sent Attribute related events.
virtual void onUpdatesEnabled(const GattUpdatesEnabledCallbackParams &params)
Function invoked when the client has subscribed to characteristic updates.
Definition: GattServer.h:177
virtual void onDataRead(const GattReadCallbackParams &params)
Function invoked when a client reads an attribute.
Definition: GattServer.h:159
Definition of the general handler of GattServer related events.
Definition: GattServer.h:107
GATT Write event definition.
GATT Read event definition.
Representation of a GattServer characteristic.
virtual void onAttMtuChange(ble::connection_handle_t connectionHandle, uint16_t attMtuSize)
Function invoked when the connections changes the ATT_MTU which controls the maximum size of an attri...
Definition: GattServer.h:116
Function like object hosting a list of FunctionPointerWithContext.
FunctionPointerWithContext< const GattReadCallbackParams * > DataReadCallback_t
Event handler invoked when the client has read an attribute of the server.
Definition: GattServer.h:249
Representation of a GattServer service.
Gatt Updates Changed Attribute related events.
FunctionPointerWithContext< const GattWriteCallbackParams * > DataWrittenCallback_t
Event handler invoked when the client has written an attribute of the server.
Definition: GattServer.h:233
virtual void onUpdatesDisabled(const GattUpdatesDisabledCallbackParams &params)
Function invoked when the client has unsubscribed to characteristic updates.
Definition: GattServer.h:187
Entry namespace for all BLE API definitions.
Definition: ATHandler.h:46
CallChainOfFunctionPointersWithContext< const GattWriteCallbackParams * > DataWrittenCallbackChain_t
Callchain of DataWrittenCallback_t objects.
Definition: GattServer.h:241
FunctionPointerWithContext< const GattServer * > GattServerShutdownCallback_t
Event handler invoked when the GattServer is reset.
Definition: GattServer.h:265
#define MBED_DEPRECATED_SINCE(D, M)
MBED_DEPRECATED("message string") Mark a function declaration as deprecated, if it used then a warnin...
virtual void onShutdown(const GattServer &server)
Function invoked when the GattServer instance is about to be shut down.
Definition: GattServer.h:167
ble_error_t
Error codes for the BLE API.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.