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 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 &params) {
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 &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 
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  */
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  */
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  */
198  (void)params;
199  }
200 
201  protected:
202  /**
203  * Prevent polymorphic deletion and avoid unnecessary virtual destructor
204  * as the GattServer class will never delete the instance it contains.
205  */
206  ~EventHandler() = default;
207  };
208 
209  /**
210  * Event handler invoked when the server has sent data to a client.
211  *
212  * @see onDataSent().
213  */
215 
216  /**
217  * Callchain of DataSentCallback_t objects.
218  *
219  * @see onDataSent().
220  */
223 
224  /**
225  * Event handler invoked when the client has written an attribute of the
226  * server.
227  *
228  * @see onDataWritten().
229  */
232 
233  /**
234  * Callchain of DataWrittenCallback_t objects.
235  *
236  * @see onDataWritten().
237  */
240 
241  /**
242  * Event handler invoked when the client has read an attribute of the server.
243  *
244  * @see onDataRead().
245  */
248 
249  /**
250  * Callchain of DataReadCallback_t.
251  *
252  * @see onDataRead().
253  */
256 
257  /**
258  * Event handler invoked when the GattServer is reset.
259  *
260  * @see onShutdown() reset()
261  */
264 
265  /**
266  * Callchain of GattServerShutdownCallback_t.
267  *
268  * @see onShutdown() reset()
269  */
272 
273  /**
274  * Event handler that handles subscription to characteristic updates,
275  * unsubscription from characteristic updates and notification confirmation.
276  *
277  * @see onUpdatesEnabled() onUpdateDisabled() onConfirmationReceived()
278  */
280 
281 public:
282  /**
283  * Assign the event handler implementation that will be used by the
284  * module to signal events back to the application.
285  *
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
293  */
294  void setEventHandler(EventHandler *handler);
295 
296  /**
297  * Shut down the GattServer instance.
298  *
299  * This function notifies all event handlers listening for shutdown events
300  * that the GattServer is about to be shut down; then it clears all
301  * GattServer state.
302  *
303  * @note This function is meant to be overridden in the platform-specific
304  * subclass. Overides must call the parent function before any cleanup.
305  *
306  * @return BLE_ERROR_NONE on success.
307  */
308  ble_error_t reset();
309 
310  /**
311  * Add a service declaration to the local attribute server table.
312  *
313  * This functions inserts a service declaration in the attribute table
314  * followed by the characteristic declarations (including characteristic
315  * descriptors) present in @p service.
316  *
317  * The process assigns a unique attribute handle to all the elements added
318  * into the attribute table. This handle is an ID that must be used for
319  * subsequent interractions with the elements.
320  *
321  * @note There is no mirror function that removes a single service.
322  * Application code can remove all the registered services by calling
323  * reset().
324  *
325  * @attention Service, characteristics and descriptors objects registered
326  * within the GattServer must remain reachable until reset() is called.
327  *
328  * @param[in] service The service to be added; attribute handle of services,
329  * characteristic and characteristic descriptors are updated by the
330  * process.
331  *
332  * @return BLE_ERROR_NONE if the service was successfully added.
333  */
334  ble_error_t addService(GattService &service);
335 
336  /**
337  * Read the value of an attribute present in the local GATT server.
338  *
339  * @param[in] attributeHandle Handle of the attribute to read.
340  * @param[out] buffer A buffer to hold the value being read.
341  * @param[in,out] lengthP Length of the buffer being supplied. If the
342  * attribute value is longer than the size of the supplied buffer, this
343  * variable holds upon return the total attribute value length (excluding
344  * offset). The application may use this information to allocate a suitable
345  * buffer size.
346  *
347  * @return BLE_ERROR_NONE if a value was read successfully into the buffer.
348  *
349  * @attention read(ble::connection_handle_t, GattAttribute::Handle_t, uint8_t *, uint16_t *)
350  * must be used to read Client Characteristic Configuration Descriptor (CCCD)
351  * because the value of this type of attribute depends on the connection.
352  */
353  ble_error_t read(
354  GattAttribute::Handle_t attributeHandle,
355  uint8_t buffer[],
356  uint16_t *lengthP
357  );
358 
359  /**
360  * Read the value of an attribute present in the local GATT server.
361  *
362  * The connection handle allows application code to read the value of a
363  * Client Characteristic Configuration Descriptor for a given connection.
364  *
365  * @param[in] connectionHandle Connection handle.
366  * @param[in] attributeHandle Attribute handle for the value attribute of
367  * the characteristic.
368  * @param[out] buffer A buffer to hold the value being read.
369  * @param[in,out] lengthP Length of the buffer being supplied. If the
370  * attribute value is longer than the size of the supplied buffer, this
371  * variable holds upon return the total attribute value length (excluding
372  * offset). The application may use this information to allocate a suitable
373  * buffer size.
374  *
375  * @return BLE_ERROR_NONE if a value was read successfully into the buffer.
376  */
377  ble_error_t read(
378  ble::connection_handle_t connectionHandle,
379  GattAttribute::Handle_t attributeHandle,
380  uint8_t *buffer,
381  uint16_t *lengthP
382  );
383 
384  /**
385  * Update the value of an attribute present in the local GATT server.
386  *
387  * @param[in] attributeHandle Handle of the attribute to write.
388  * @param[in] value A pointer to a buffer holding the new value.
389  * @param[in] size Size in bytes of the new value (in bytes).
390  * @param[in] localOnly If this flag is false and the attribute handle
391  * written is a characteristic value, then the server sends an update
392  * containing the new value to all clients that have subscribed to the
393  * characteristic's notifications or indications. Otherwise, the update does
394  * not generate a single server initiated event.
395  *
396  * @return BLE_ERROR_NONE if the attribute value has been successfully
397  * updated.
398  */
399  ble_error_t write(
400  GattAttribute::Handle_t attributeHandle,
401  const uint8_t *value,
402  uint16_t size,
403  bool localOnly = false
404  );
405 
406  /**
407  * Update the value of an attribute present in the local GATT server.
408  *
409  * The connection handle parameter allows application code to direct
410  * notification or indication resulting from the update to a specific client.
411  *
412  * @param[in] connectionHandle Connection handle.
413  * @param[in] attributeHandle Handle for the value attribute of the
414  * characteristic.
415  * @param[in] value A pointer to a buffer holding the new value.
416  * @param[in] size Size of the new value (in bytes).
417  * @param[in] localOnly If this flag is false and the attribute handle
418  * written is a characteristic value, then the server sends an update
419  * containing the new value to the client identified by the parameter
420  * @p connectionHandle if it is subscribed to the characteristic's
421  * notifications or indications. Otherwise, the update does not generate a
422  * single server initiated event.
423  *
424  * @return BLE_ERROR_NONE if the attribute value has been successfully
425  * updated.
426  */
427  ble_error_t write(
428  ble::connection_handle_t connectionHandle,
429  GattAttribute::Handle_t attributeHandle,
430  const uint8_t *value,
431  uint16_t size,
432  bool localOnly = false
433  );
434 
435  /**
436  * Determine if one of the connected clients has subscribed to notifications
437  * or indications of the characteristic in input.
438  *
439  * @param[in] characteristic The characteristic.
440  * @param[out] enabledP Upon return, *enabledP is true if updates are
441  * enabled for a connected client; otherwise, *enabledP is false.
442  *
443  * @return BLE_ERROR_NONE if the connection and handle are found. False
444  * otherwise.
445  */
446  ble_error_t areUpdatesEnabled(
447  const GattCharacteristic &characteristic,
448  bool *enabledP
449  );
450 
451  /**
452  * Determine if an identified client has subscribed to notifications or
453  * indications of a given characteristic.
454  *
455  * @param[in] connectionHandle The connection handle.
456  * @param[in] characteristic The characteristic.
457  * @param[out] enabledP Upon return, *enabledP is true if the client
458  * identified by @p connectionHandle has subscribed to notifications or
459  * indications of @p characteristic; otherwise, *enabledP is false.
460  *
461  * @return BLE_ERROR_NONE if the connection and handle are found. False
462  * otherwise.
463  */
464  ble_error_t areUpdatesEnabled(
465  ble::connection_handle_t connectionHandle,
466  const GattCharacteristic &characteristic,
467  bool *enabledP
468  );
469 
470  /**
471  * Indicate if the underlying stack emit events when an attribute is read by
472  * a client.
473  *
474  * @attention This function should be overridden to return true if
475  * applicable.
476  *
477  * @return true if onDataRead is supported; false otherwise.
478  */
479  bool isOnDataReadAvailable() const;
480 
481  /**
482  * Add an event handler that monitors emission of characteristic value
483  * updates.
484  *
485  * @param[in] callback Event handler being registered.
486  *
487  * @note It is possible to chain together multiple onDataSent callbacks
488  * (potentially from different modules of an application).
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.")
492  void onDataSent(const DataSentCallback_t &callback);
493 
494  /**
495  * Add an event handler that monitors emission of characteristic value
496  * updates.
497  *
498  * @param[in] objPtr Pointer to the instance that is used to invoke the
499  * event handler.
500  * @param[in] memberPtr Event handler being registered. It is a member
501  * function.
502  */
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.")
506  void onDataSent(T *objPtr, void (T::*memberPtr)(unsigned count))
507  {
508  onDataSent({objPtr, memberPtr});
509  }
510 
511  /**
512  * Access the callchain of data sent event handlers.
513  *
514  * @return A reference to the DATA_SENT event callback chain.
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.")
518  DataSentCallbackChain_t &onDataSent();
519 
520  /**
521  * Set an event handler that is called after
522  * a connected peer has written an attribute.
523  *
524  * @param[in] callback The event handler being registered.
525  *
526  * @attention It is possible to set multiple event handlers. Registered
527  * handlers may be removed with onDataWritten().detach(callback).
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.")
531  void onDataWritten(const DataWrittenCallback_t &callback);
532 
533  /**
534  * Set an event handler that is called after
535  * a connected peer has written an attribute.
536  *
537  * @param[in] objPtr Pointer to the instance that is used to invoke the
538  * event handler (@p memberPtr).
539  * @param[in] memberPtr Event handler being registered. It is a member
540  * function.
541  */
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.")
545  void onDataWritten(
546  T *objPtr,
547  void (T::*memberPtr)(const GattWriteCallbackParams *context)
548  )
549  {
550  onDataWritten({objPtr, memberPtr});
551  }
552 
553  /**
554  * Access the callchain of data written event handlers.
555  *
556  * @return A reference to the data written event callbacks chain.
557  *
558  * @note It is possible to register callbacks using
559  * onDataWritten().add(callback).
560  *
561  * @note It is possible to unregister callbacks using
562  * onDataWritten().detach(callback).
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.")
566  DataWrittenCallbackChain_t &onDataWritten();
567 
568  /**
569  * Set an event handler that monitors attribute reads from connected clients.
570  *
571  * @param[in] callback Event handler being registered.
572  *
573  * @return BLE_ERROR_NOT_IMPLEMENTED if this functionality isn't available;
574  * else BLE_ERROR_NONE.
575  *
576  * @note This functionality may not be available on all underlying stacks.
577  * Application code may work around that limitation by monitoring read
578  * requests instead of read events.
579  *
580  * @see GattCharacteristic::setReadAuthorizationCallback()
581  * @see isOnDataReadAvailable().
582  *
583  * @attention It is possible to set multiple event handlers. Registered
584  * handlers may be removed with onDataRead().detach(callback).
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.")
588  ble_error_t onDataRead(const DataReadCallback_t &callback);
589 
590  /**
591  * Set an event handler that monitors attribute reads from connected clients.
592  *
593  * @param[in] objPtr Pointer to the instance that is used to invoke the
594  * event handler (@p memberPtr).
595  * @param[in] memberPtr Event handler being registered. It is a member
596  * function.
597  */
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.")
601  ble_error_t onDataRead(
602  T *objPtr,
603  void (T::*memberPtr)(const GattReadCallbackParams *context)
604  )
605  {
606  return onDataRead({objPtr, memberPtr});
607  }
608 
609  /**
610  * Access the callchain of data read event handlers.
611  *
612  * @return A reference to the data read event callbacks chain.
613  *
614  * @note It is possible to register callbacks using
615  * onDataRead().add(callback).
616  *
617  * @note It is possible to unregister callbacks using
618  * onDataRead().detach(callback).
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.")
622  DataReadCallbackChain_t &onDataRead();
623 
624  /**
625  * Set an event handler that monitors shutdown or reset of the GattServer.
626  *
627  * The event handler is invoked when the GattServer instance is about
628  * to be shut down. This can result in a call to reset() or BLE::reset().
629  *
630  * @param[in] callback Event handler being registered.
631  *
632  * @note It is possible to set up multiple shutdown event handlers.
633  *
634  * @note It is possible to unregister a callback using
635  * onShutdown().detach(callback)
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.")
639  void onShutdown(const GattServerShutdownCallback_t &callback);
640 
641  /**
642  * Set an event handler that monitors shutdown or reset of the GattServer.
643  *
644  * The event handler is invoked when the GattServer instance is about
645  * to be shut down. This can result of a call to reset() or BLE::reset().
646  *
647  * @param[in] objPtr Pointer to the instance that is used to invoke the
648  * event handler (@p memberPtr).
649  * @param[in] memberPtr Event handler being registered. It is a member
650  * function.
651  */
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.")
655  void onShutdown(T *objPtr, void (T::*memberPtr)(const GattServer *))
656  {
657  onShutdown({objPtr, memberPtr});
658  }
659 
660  /**
661  * Access the callchain of shutdown event handlers.
662  *
663  * @return A reference to the shutdown event callbacks chain.
664  *
665  * @note It is possible to register callbacks using
666  * onShutdown().add(callback).
667  *
668  * @note It is possible to unregister callbacks using
669  * onShutdown().detach(callback).
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.")
673  GattServerShutdownCallbackChain_t& onShutdown();
674 
675  /**
676  * Set up an event handler that monitors subscription to characteristic
677  * updates.
678  *
679  * @param[in] callback Event handler being registered.
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.")
683  void onUpdatesEnabled(EventCallback_t callback);
684 
685  /**
686  * Set up an event handler that monitors unsubscription from characteristic
687  * updates.
688  *
689  * @param[in] callback Event handler being registered.
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.")
693  void onUpdatesDisabled(EventCallback_t callback);
694 
695  /**
696  * Set up an event handler that monitors notification acknowledgment.
697  *
698  * The event handler is called when a client sends a confirmation that it has
699  * correctly received a notification from the server.
700  *
701  * @param[in] callback Event handler being registered.
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.")
705  void onConfirmationReceived(EventCallback_t callback);
706 
707 #if !defined(DOXYGEN_ONLY)
708  GattServer(impl::GattServer* impl) : impl(impl) {}
709  GattServer(const GattServer&) = delete;
710  GattServer& operator=(const GattServer&) = delete;
711 #endif // !defined(DOXYGEN_ONLY)
712 
713 private:
714  impl::GattServer *impl;
715 };
716 
717 /**
718  * @}
719  * @}
720  * @}
721  */
722 
723 } // ble
724 
725 /** @deprecated Use the namespaced ble::GattServer instead of the global GattServer. */
726 using ble::GattServer;
727 
728 #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:214
Function like object adapter over freestanding and member functions.
CallChainOfFunctionPointersWithContext< unsigned > DataSentCallbackChain_t
Callchain of DataSentCallback_t objects.
Definition: GattServer.h:222
Construct and operates a GATT server.
Definition: GattServer.h:102
uintptr_t connection_handle_t
Opaque reference to a connection.
virtual void onConfirmationReceived(const GattConfirmationReceivedCallbackParams &params)
Function invoked when an ACK has been received for an indication sent to the client.
Definition: GattServer.h:197
FunctionPointerWithContext< GattAttribute::Handle_t > EventCallback_t
Event handler that handles subscription to characteristic updates, unsubscription from characteristic...
Definition: GattServer.h:279
virtual void onDataWritten(const GattWriteCallbackParams &params)
Function invoked when a client writes an attribute.
Definition: GattServer.h:141
CallChainOfFunctionPointersWithContext< const GattServer * > GattServerShutdownCallbackChain_t
Callchain of GattServerShutdownCallback_t.
Definition: GattServer.h:271
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:255
virtual void onDataSent(const GattDataSentCallbackParams &params)
Function invoked when the server has sent data to a client as part of a notification/indication.
Definition: GattServer.h:131
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:176
virtual void onDataRead(const GattReadCallbackParams &params)
Function invoked when a client reads an attribute.
Definition: GattServer.h:158
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:247
Representation of a GattServer service.
FunctionPointerWithContext< const GattWriteCallbackParams * > DataWrittenCallback_t
Event handler invoked when the client has written an attribute of the server.
Definition: GattServer.h:231
virtual void onUpdatesDisabled(const GattUpdatesDisabledCallbackParams &params)
Function invoked when the client has unsubscribed to characteristic updates.
Definition: GattServer.h:186
Entry namespace for all BLE API definitions.
Definition: ATHandler.h:46
CallChainOfFunctionPointersWithContext< const GattWriteCallbackParams * > DataWrittenCallbackChain_t
Callchain of DataWrittenCallback_t objects.
Definition: GattServer.h:239
FunctionPointerWithContext< const GattServer * > GattServerShutdownCallback_t
Event handler invoked when the GattServer is reset.
Definition: GattServer.h:263
#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:166
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.