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 interactions 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 GattServer allocates its own memory for all the attributes.
326  * The GattServer will set the handles on the service passed in and the
327  * characteristics it contains. You may record the handles you want to
328  * interact with in the future. After that the service and characteristics
329  * you passed in as the parameter may be freed. To write to the GattServer
330  * instances of the characteristics you have to use the saved handles.
331  *
332  * @param[in] service The service to be added; attribute handle of services,
333  * characteristic and characteristic descriptors are updated by the
334  * process.
335  *
336  * @return BLE_ERROR_NONE if the service was successfully added.
337  */
338  ble_error_t addService(GattService &service);
339 
340  /**
341  * Read the value of an attribute present in the local GATT server.
342  *
343  * @param[in] attributeHandle Handle of the attribute to read.
344  * @param[out] buffer A buffer to hold the value being read.
345  * @param[in,out] lengthP Length of the buffer being supplied. If the
346  * attribute value is longer than the size of the supplied buffer, this
347  * variable holds upon return the total attribute value length (excluding
348  * offset). The application may use this information to allocate a suitable
349  * buffer size.
350  *
351  * @return BLE_ERROR_NONE if a value was read successfully into the buffer.
352  *
353  * @attention read(ble::connection_handle_t, GattAttribute::Handle_t, uint8_t *, uint16_t *)
354  * must be used to read Client Characteristic Configuration Descriptor (CCCD)
355  * because the value of this type of attribute depends on the connection.
356  */
357  ble_error_t read(
358  GattAttribute::Handle_t attributeHandle,
359  uint8_t buffer[],
360  uint16_t *lengthP
361  );
362 
363  /**
364  * Read the value of an attribute present in the local GATT server.
365  *
366  * The connection handle allows application code to read the value of a
367  * Client Characteristic Configuration Descriptor for a given connection.
368  *
369  * @param[in] connectionHandle Connection handle.
370  * @param[in] attributeHandle Attribute handle for the value attribute of
371  * the characteristic.
372  * @param[out] buffer A buffer to hold the value being read.
373  * @param[in,out] lengthP Length of the buffer being supplied. If the
374  * attribute value is longer than the size of the supplied buffer, this
375  * variable holds upon return the total attribute value length (excluding
376  * offset). The application may use this information to allocate a suitable
377  * buffer size.
378  *
379  * @return BLE_ERROR_NONE if a value was read successfully into the buffer.
380  */
381  ble_error_t read(
382  ble::connection_handle_t connectionHandle,
383  GattAttribute::Handle_t attributeHandle,
384  uint8_t *buffer,
385  uint16_t *lengthP
386  );
387 
388  /**
389  * Update the value of an attribute present in the local GATT server.
390  *
391  * @param[in] attributeHandle Handle of the attribute to write.
392  * @param[in] value A pointer to a buffer holding the new value.
393  * @param[in] size Size in bytes of the new value (in bytes).
394  * @param[in] localOnly If this flag is false and the attribute handle
395  * written is a characteristic value, then the server sends an update
396  * containing the new value to all clients that have subscribed to the
397  * characteristic's notifications or indications. Otherwise, the update does
398  * not generate a single server initiated event.
399  *
400  * @return BLE_ERROR_NONE if the attribute value has been successfully
401  * updated.
402  */
403  ble_error_t write(
404  GattAttribute::Handle_t attributeHandle,
405  const uint8_t *value,
406  uint16_t size,
407  bool localOnly = false
408  );
409 
410  /**
411  * Update the value of an attribute present in the local GATT server.
412  *
413  * The connection handle parameter allows application code to direct
414  * notification or indication resulting from the update to a specific client.
415  *
416  * @param[in] connectionHandle Connection handle.
417  * @param[in] attributeHandle Handle for the value attribute of the
418  * characteristic.
419  * @param[in] value A pointer to a buffer holding the new value.
420  * @param[in] size Size of the new value (in bytes).
421  * @param[in] localOnly If this flag is false and the attribute handle
422  * written is a characteristic value, then the server sends an update
423  * containing the new value to the client identified by the parameter
424  * @p connectionHandle if it is subscribed to the characteristic's
425  * notifications or indications. Otherwise, the update does not generate a
426  * single server initiated event.
427  *
428  * @return BLE_ERROR_NONE if the attribute value has been successfully
429  * updated.
430  */
431  ble_error_t write(
432  ble::connection_handle_t connectionHandle,
433  GattAttribute::Handle_t attributeHandle,
434  const uint8_t *value,
435  uint16_t size,
436  bool localOnly = false
437  );
438 
439  /**
440  * Determine if one of the connected clients has subscribed to notifications
441  * or indications of the characteristic in input.
442  *
443  * @param[in] characteristic The characteristic.
444  * @param[out] enabledP Upon return, *enabledP is true if updates are
445  * enabled for a connected client; otherwise, *enabledP is false.
446  *
447  * @return BLE_ERROR_NONE if the connection and handle are found. False
448  * otherwise.
449  */
450  ble_error_t areUpdatesEnabled(
451  const GattCharacteristic &characteristic,
452  bool *enabledP
453  );
454 
455  /**
456  * Determine if an identified client has subscribed to notifications or
457  * indications of a given characteristic.
458  *
459  * @param[in] connectionHandle The connection handle.
460  * @param[in] characteristic The characteristic.
461  * @param[out] enabledP Upon return, *enabledP is true if the client
462  * identified by @p connectionHandle has subscribed to notifications or
463  * indications of @p characteristic; otherwise, *enabledP is false.
464  *
465  * @return BLE_ERROR_NONE if the connection and handle are found. False
466  * otherwise.
467  */
468  ble_error_t areUpdatesEnabled(
469  ble::connection_handle_t connectionHandle,
470  const GattCharacteristic &characteristic,
471  bool *enabledP
472  );
473 
474  /**
475  * Indicate if the underlying stack emit events when an attribute is read by
476  * a client.
477  *
478  * @attention This function should be overridden to return true if
479  * applicable.
480  *
481  * @return true if onDataRead is supported; false otherwise.
482  */
483  bool isOnDataReadAvailable() const;
484 
485  /**
486  * Add an event handler that monitors emission of characteristic value
487  * updates.
488  *
489  * @param[in] callback Event handler being registered.
490  *
491  * @note It is possible to chain together multiple onDataSent callbacks
492  * (potentially from different modules of an application).
493  */
494  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
495  "been replaced by GattServer::setEventHandler. Use that function instead.")
496  void onDataSent(const DataSentCallback_t &callback);
497 
498  /**
499  * Add an event handler that monitors emission of characteristic value
500  * updates.
501  *
502  * @param[in] objPtr Pointer to the instance that is used to invoke the
503  * event handler.
504  * @param[in] memberPtr Event handler being registered. It is a member
505  * function.
506  */
507  template <typename T>
508  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
509  "been replaced by GattServer::setEventHandler. Use that function instead.")
510  void onDataSent(T *objPtr, void (T::*memberPtr)(unsigned count))
511  {
512  onDataSent({objPtr, memberPtr});
513  }
514 
515  /**
516  * Access the callchain of data sent event handlers.
517  *
518  * @return A reference to the DATA_SENT event callback chain.
519  */
520  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
521  "been replaced by GattServer::setEventHandler. Use that function instead.")
522  DataSentCallbackChain_t &onDataSent();
523 
524  /**
525  * Set an event handler that is called after
526  * a connected peer has written an attribute.
527  *
528  * @param[in] callback The event handler being registered.
529  *
530  * @attention It is possible to set multiple event handlers. Registered
531  * handlers may be removed with onDataWritten().detach(callback).
532  */
533  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
534  "been replaced by GattServer::setEventHandler. Use that function instead.")
535  void onDataWritten(const DataWrittenCallback_t &callback);
536 
537  /**
538  * Set an event handler that is called after
539  * a connected peer has written an attribute.
540  *
541  * @param[in] objPtr Pointer to the instance that is used to invoke the
542  * event handler (@p memberPtr).
543  * @param[in] memberPtr Event handler being registered. It is a member
544  * function.
545  */
546  template <typename T>
547  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
548  "been replaced by GattServer::setEventHandler. Use that function instead.")
549  void onDataWritten(
550  T *objPtr,
551  void (T::*memberPtr)(const GattWriteCallbackParams *context)
552  )
553  {
554  onDataWritten({objPtr, memberPtr});
555  }
556 
557  /**
558  * Access the callchain of data written event handlers.
559  *
560  * @return A reference to the data written event callbacks chain.
561  *
562  * @note It is possible to register callbacks using
563  * onDataWritten().add(callback).
564  *
565  * @note It is possible to unregister callbacks using
566  * onDataWritten().detach(callback).
567  */
568  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
569  "been replaced by GattServer::setEventHandler. Use that function instead.")
570  DataWrittenCallbackChain_t &onDataWritten();
571 
572  /**
573  * Set an event handler that monitors attribute reads from connected clients.
574  *
575  * @param[in] callback Event handler being registered.
576  *
577  * @return BLE_ERROR_NOT_IMPLEMENTED if this functionality isn't available;
578  * else BLE_ERROR_NONE.
579  *
580  * @note This functionality may not be available on all underlying stacks.
581  * Application code may work around that limitation by monitoring read
582  * requests instead of read events.
583  *
584  * @see GattCharacteristic::setReadAuthorizationCallback()
585  * @see isOnDataReadAvailable().
586  *
587  * @attention It is possible to set multiple event handlers. Registered
588  * handlers may be removed with onDataRead().detach(callback).
589  */
590  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
591  "been replaced by GattServer::setEventHandler. Use that function instead.")
592  ble_error_t onDataRead(const DataReadCallback_t &callback);
593 
594  /**
595  * Set an event handler that monitors attribute reads from connected clients.
596  *
597  * @param[in] objPtr Pointer to the instance that is used to invoke the
598  * event handler (@p memberPtr).
599  * @param[in] memberPtr Event handler being registered. It is a member
600  * function.
601  */
602  template <typename T>
603  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
604  "been replaced by GattServer::setEventHandler. Use that function instead.")
605  ble_error_t onDataRead(
606  T *objPtr,
607  void (T::*memberPtr)(const GattReadCallbackParams *context)
608  )
609  {
610  return onDataRead({objPtr, memberPtr});
611  }
612 
613  /**
614  * Access the callchain of data read event handlers.
615  *
616  * @return A reference to the data read event callbacks chain.
617  *
618  * @note It is possible to register callbacks using
619  * onDataRead().add(callback).
620  *
621  * @note It is possible to unregister callbacks using
622  * onDataRead().detach(callback).
623  */
624  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
625  "been replaced by GattServer::setEventHandler. Use that function instead.")
626  DataReadCallbackChain_t &onDataRead();
627 
628  /**
629  * Set an event handler that monitors shutdown or reset of the GattServer.
630  *
631  * The event handler is invoked when the GattServer instance is about
632  * to be shut down. This can result in a call to reset() or BLE::reset().
633  *
634  * @param[in] callback Event handler being registered.
635  *
636  * @note It is possible to set up multiple shutdown event handlers.
637  *
638  * @note It is possible to unregister a callback using
639  * onShutdown().detach(callback)
640  */
641  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
642  "been replaced by GattServer::setEventHandler. Use that function instead.")
643  void onShutdown(const GattServerShutdownCallback_t &callback);
644 
645  /**
646  * Set an event handler that monitors shutdown or reset of the GattServer.
647  *
648  * The event handler is invoked when the GattServer instance is about
649  * to be shut down. This can result of a call to reset() or BLE::reset().
650  *
651  * @param[in] objPtr Pointer to the instance that is used to invoke the
652  * event handler (@p memberPtr).
653  * @param[in] memberPtr Event handler being registered. It is a member
654  * function.
655  */
656  template <typename T>
657  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
658  "been replaced by GattServer::setEventHandler. Use that function instead.")
659  void onShutdown(T *objPtr, void (T::*memberPtr)(const GattServer *))
660  {
661  onShutdown({objPtr, memberPtr});
662  }
663 
664  /**
665  * Access the callchain of shutdown event handlers.
666  *
667  * @return A reference to the shutdown event callbacks chain.
668  *
669  * @note It is possible to register callbacks using
670  * onShutdown().add(callback).
671  *
672  * @note It is possible to unregister callbacks using
673  * onShutdown().detach(callback).
674  */
675  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
676  "been replaced by GattServer::setEventHandler. Use that function instead.")
677  GattServerShutdownCallbackChain_t& onShutdown();
678 
679  /**
680  * Set up an event handler that monitors subscription to characteristic
681  * updates.
682  *
683  * @param[in] callback Event handler being registered.
684  */
685  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
686  "been replaced by GattServer::setEventHandler. Use that function instead.")
687  void onUpdatesEnabled(EventCallback_t callback);
688 
689  /**
690  * Set up an event handler that monitors unsubscription from characteristic
691  * updates.
692  *
693  * @param[in] callback Event handler being registered.
694  */
695  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
696  "been replaced by GattServer::setEventHandler. Use that function instead.")
697  void onUpdatesDisabled(EventCallback_t callback);
698 
699  /**
700  * Set up an event handler that monitors notification acknowledgment.
701  *
702  * The event handler is called when a client sends a confirmation that it has
703  * correctly received a notification from the server.
704  *
705  * @param[in] callback Event handler being registered.
706  */
707  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
708  "been replaced by GattServer::setEventHandler. Use that function instead.")
709  void onConfirmationReceived(EventCallback_t callback);
710 
711 #if !defined(DOXYGEN_ONLY)
712  GattServer(impl::GattServer* impl) : impl(impl) {}
713  GattServer(const GattServer&) = delete;
714  GattServer& operator=(const GattServer&) = delete;
715 #endif // !defined(DOXYGEN_ONLY)
716 
717 private:
718  impl::GattServer *impl;
719 };
720 
721 /**
722  * @}
723  * @}
724  * @}
725  */
726 
727 } // ble
728 
729 /** @deprecated Use the namespaced ble::GattServer instead of the global GattServer. */
730 using ble::GattServer;
731 
732 #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.
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: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.