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  * @see negotiateAttMtu()
117  */
118  virtual void onAttMtuChange(
119  ble::connection_handle_t connectionHandle,
120  uint16_t attMtuSize
121  ) {
122  (void)connectionHandle;
123  (void)attMtuSize;
124  }
125 
126  /**
127  * Function invoked when the server has sent data to a client. For
128  * notifications this is triggered when data is sent, for indications
129  * it's only triggered when the confirmation has been received.
130  *
131  * @note params has a temporary scope and should be copied by the
132  * application if needed later
133  */
134  virtual void onDataSent(const GattDataSentCallbackParams &params) {
135  (void)params;
136  }
137 
138  /**
139  * Function invoked when a client writes an attribute
140  *
141  * @note params has a temporary scope and should be copied by the
142  * application if needed later
143  */
144  virtual void onDataWritten(const GattWriteCallbackParams &params) {
145  (void)params;
146  }
147 
148  /**
149  * Function invoked when a client reads an attribute
150  *
151  * @note This functionality may not be available on all underlying stacks.
152  * Application code may work around that limitation by monitoring read
153  * requests instead of read events.
154  *
155  * @note params has a temporary scope and should be copied by the
156  * application if needed later
157  *
158  * @see GattCharacteristic::setReadAuthorizationCallback()
159  * @see isOnDataReadAvailable().
160  */
161  virtual void onDataRead(const GattReadCallbackParams &params) {
162  (void)params;
163  }
164 
165  /**
166  * Function invoked when the GattServer instance is about
167  * to be shut down. This can be the result of a call to reset() or BLE::reset().
168  */
169  virtual void onShutdown(const GattServer &server) {
170  (void)server;
171  }
172 
173  /**
174  * Function invoked when the client has subscribed to characteristic updates.
175  *
176  * @note params has a temporary scope and should be copied by the
177  * application if needed later
178  */
180  (void)params;
181  }
182 
183  /**
184  * Function invoked when the client has unsubscribed from characteristic updates.
185  *
186  * @note params has a temporary scope and should be copied by the
187  * application if needed later
188  */
190  (void)params;
191  }
192 
193  /**
194  * Event not used.
195  *
196  * @note params has a temporary scope and should be copied by the
197  * application if needed later
198  */
199  MBED_DEPRECATED_SINCE("mbed-os-6.11.0", "This event is never triggered. Indication triggers onDataSent"
200  "when confirmation is received.")
201  virtual void onConfirmationReceived(const GattConfirmationReceivedCallbackParams &params) {
202  (void)params;
203  }
204 
205  protected:
206  /**
207  * Prevent polymorphic deletion and avoid unnecessary virtual destructor
208  * as the GattServer class will never delete the instance it contains.
209  */
210  ~EventHandler() = default;
211  };
212 
213  /**
214  * Event handler invoked when the server has sent data to a client.
215  *
216  * @see onDataSent().
217  */
219 
220  /**
221  * Callchain of DataSentCallback_t objects.
222  *
223  * @see onDataSent().
224  */
227 
228  /**
229  * Event handler invoked when the client has written an attribute of the
230  * server.
231  *
232  * @see onDataWritten().
233  */
236 
237  /**
238  * Callchain of DataWrittenCallback_t objects.
239  *
240  * @see onDataWritten().
241  */
244 
245  /**
246  * Event handler invoked when the client has read an attribute of the server.
247  *
248  * @see onDataRead().
249  */
252 
253  /**
254  * Callchain of DataReadCallback_t.
255  *
256  * @see onDataRead().
257  */
260 
261  /**
262  * Event handler invoked when the GattServer is reset.
263  *
264  * @see onShutdown() reset()
265  */
268 
269  /**
270  * Callchain of GattServerShutdownCallback_t.
271  *
272  * @see onShutdown() reset()
273  */
276 
277  /**
278  * Event handler that handles subscription to characteristic updates,
279  * unsubscription from characteristic updates and notification confirmation.
280  *
281  * @see onUpdatesEnabled() onUpdateDisabled()
282  */
284 
285 public:
286  /**
287  * Assign the event handler implementation that will be used by the
288  * module to signal events back to the application.
289  *
290  * @param handler Application implementation of an EventHandler.
291  *
292  * @note Multiple discrete EventHandler instances may be used by adding them
293  * to a ChainableGattServerEventHandler and then setting the chain as the primary
294  * GattServer EventHandler using this function.
295  *
296  * @see ChainableGattServerEventHandler
297  */
298  void setEventHandler(EventHandler *handler);
299 
300  /**
301  * Shut down the GattServer instance.
302  *
303  * This function notifies all event handlers listening for shutdown events
304  * that the GattServer is about to be shut down; then it clears all
305  * GattServer state.
306  *
307  * @note This function is meant to be overridden in the platform-specific
308  * subclass. Overrides must call the parent function before any cleanup.
309  *
310  * @return BLE_ERROR_NONE on success.
311  *
312  * @see EventHandler::onShutdown()
313  */
314  ble_error_t reset();
315 
316  /**
317  * Add a service declaration to the local attribute server table.
318  *
319  * This functions inserts a service declaration in the attribute table
320  * followed by the characteristic declarations (including characteristic
321  * descriptors) present in @p service.
322  *
323  * The process assigns a unique attribute handle to all the elements added
324  * into the attribute table. This handle is an ID that must be used for
325  * subsequent interactions with the elements.
326  *
327  * @note There is no mirror function that removes a single service.
328  * Application code can remove all the registered services by calling
329  * reset().
330  *
331  * @attention GattServer allocates its own memory for all the attributes.
332  * The GattServer will set the handles on the service passed in and the
333  * characteristics it contains. You may record the handles you want to
334  * interact with in the future. After that the service and characteristics
335  * you passed in as the parameter may be freed. To write to the GattServer
336  * instances of the characteristics you have to use the saved handles.
337  *
338  * @param[in] service The service to be added; attribute handle of services,
339  * characteristic and characteristic descriptors are updated by the
340  * process.
341  *
342  * @return BLE_ERROR_NONE if the service was successfully added.
343  */
344  ble_error_t addService(GattService &service);
345 
346  /**
347  * Read the value of an attribute present in the local GATT server.
348  *
349  * @param[in] attributeHandle Handle of the attribute to read.
350  * @param[out] buffer A buffer to hold the value being read.
351  * @param[in,out] lengthP Length of the buffer being supplied. If the
352  * attribute value is longer than the size of the supplied buffer, this
353  * variable holds upon return the total attribute value length (excluding
354  * offset). The application may use this information to allocate a suitable
355  * buffer size.
356  *
357  * @return BLE_ERROR_NONE if a value was read successfully into the buffer.
358  *
359  * @attention read(ble::connection_handle_t, GattAttribute::Handle_t, uint8_t *, uint16_t *)
360  * must be used to read Client Characteristic Configuration Descriptor (CCCD)
361  * because the value of this type of attribute depends on the connection.
362  */
363  ble_error_t read(
364  GattAttribute::Handle_t attributeHandle,
365  uint8_t buffer[],
366  uint16_t *lengthP
367  );
368 
369  /**
370  * Read the value of an attribute present in the local GATT server.
371  *
372  * The connection handle allows application code to read the value of a
373  * Client Characteristic Configuration Descriptor for a given connection.
374  *
375  * @param[in] connectionHandle Connection handle.
376  * @param[in] attributeHandle Attribute handle for the value attribute of
377  * the characteristic.
378  * @param[out] buffer A buffer to hold the value being read.
379  * @param[in,out] lengthP Length of the buffer being supplied. If the
380  * attribute value is longer than the size of the supplied buffer, this
381  * variable holds upon return the total attribute value length (excluding
382  * offset). The application may use this information to allocate a suitable
383  * buffer size.
384  *
385  * @return BLE_ERROR_NONE if a value was read successfully into the buffer.
386  */
387  ble_error_t read(
388  ble::connection_handle_t connectionHandle,
389  GattAttribute::Handle_t attributeHandle,
390  uint8_t *buffer,
391  uint16_t *lengthP
392  );
393 
394  /**
395  * Update the value of an attribute present in the local GATT server.
396  *
397  * @param[in] attributeHandle Handle of the attribute to write.
398  * @param[in] value A pointer to a buffer holding the new value.
399  * @param[in] size Size in bytes of the new value (in bytes).
400  * @param[in] localOnly If this flag is false and the attribute handle
401  * written is a characteristic value, then the server sends an update
402  * containing the new value to all clients that have subscribed to the
403  * characteristic's notifications or indications. Otherwise, the update does
404  * not generate a single server initiated event.
405  *
406  * @return BLE_ERROR_NONE if the attribute value has been successfully
407  * updated.
408  *
409  * @see EventHandler::onDataSent(), this will only be triggered if there are
410  * client subscribed and the localOnly parameter is set to false.
411  */
412  ble_error_t write(
413  GattAttribute::Handle_t attributeHandle,
414  const uint8_t *value,
415  uint16_t size,
416  bool localOnly = false
417  );
418 
419  /**
420  * Update the value of an attribute present in the local GATT server.
421  *
422  * The connection handle parameter allows application code to direct
423  * notification or indication resulting from the update to a specific client.
424  *
425  * @param[in] connectionHandle Connection handle.
426  * @param[in] attributeHandle Handle for the value attribute of the
427  * characteristic.
428  * @param[in] value A pointer to a buffer holding the new value.
429  * @param[in] size Size of the new value (in bytes).
430  * @param[in] localOnly If this flag is false and the attribute handle
431  * written is a characteristic value, then the server sends an update
432  * containing the new value to the client identified by the parameter
433  * @p connectionHandle if it is subscribed to the characteristic's
434  * notifications or indications. Otherwise, the update does not generate a
435  * single server initiated event.
436  *
437  * @return BLE_ERROR_NONE if the attribute value has been successfully
438  * updated.
439  *
440  * @see EventHandler::onDataSent(), this will only be triggered if there are
441  * client subscribed and the localOnly parameter is set to false.
442  */
443  ble_error_t write(
444  ble::connection_handle_t connectionHandle,
445  GattAttribute::Handle_t attributeHandle,
446  const uint8_t *value,
447  uint16_t size,
448  bool localOnly = false
449  );
450 
451  /**
452  * Determine if one of the connected clients has subscribed to notifications
453  * or indications of the characteristic in input.
454  *
455  * @param[in] characteristic The characteristic.
456  * @param[out] enabledP Upon return, *enabledP is true if updates are
457  * enabled for a connected client; otherwise, *enabledP is false.
458  *
459  * @return BLE_ERROR_NONE if the connection and handle are found. False
460  * otherwise.
461  *
462  * @see EventHandler::onDataSent()
463  */
464  ble_error_t areUpdatesEnabled(
465  const GattCharacteristic &characteristic,
466  bool *enabledP
467  );
468 
469  /**
470  * Determine if an identified client has subscribed to notifications or
471  * indications of a given characteristic.
472  *
473  * @param[in] connectionHandle The connection handle.
474  * @param[in] characteristic The characteristic.
475  * @param[out] enabledP Upon return, *enabledP is true if the client
476  * identified by @p connectionHandle has subscribed to notifications or
477  * indications of @p characteristic; otherwise, *enabledP is false.
478  *
479  * @return BLE_ERROR_NONE if the connection and handle are found. False
480  * otherwise.
481  *
482  * @see EventHandler::onDataSent()
483  */
484  ble_error_t areUpdatesEnabled(
485  ble::connection_handle_t connectionHandle,
486  const GattCharacteristic &characteristic,
487  bool *enabledP
488  );
489 
490  /**
491  * Indicate if the underlying stack emit events when an attribute is read by
492  * a client.
493  *
494  * @attention This function should be overridden to return true if
495  * applicable.
496  *
497  * @return true if onDataRead is supported; false otherwise.
498  */
499  bool isOnDataReadAvailable() const;
500 
501  /**
502  * Add an event handler that monitors emission of characteristic value
503  * updates.
504  *
505  * @param[in] callback Event handler being registered.
506  *
507  * @note It is possible to chain together multiple onDataSent callbacks
508  * (potentially from different modules of an application).
509  */
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(const DataSentCallback_t &callback);
513 
514  /**
515  * Add an event handler that monitors emission of characteristic value
516  * updates.
517  *
518  * @param[in] objPtr Pointer to the instance that is used to invoke the
519  * event handler.
520  * @param[in] memberPtr Event handler being registered. It is a member
521  * function.
522  */
523  template <typename T>
524  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
525  "been replaced by GattServer::setEventHandler. Use that function instead.")
526  void onDataSent(T *objPtr, void (T::*memberPtr)(unsigned count))
527  {
528  onDataSent({objPtr, memberPtr});
529  }
530 
531  /**
532  * Access the callchain of data sent event handlers.
533  *
534  * @return A reference to the DATA_SENT event callback chain.
535  */
536  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
537  "been replaced by GattServer::setEventHandler. Use that function instead.")
538  DataSentCallbackChain_t &onDataSent();
539 
540  /**
541  * Set an event handler that is called after
542  * a connected peer has written an attribute.
543  *
544  * @param[in] callback The event handler being registered.
545  *
546  * @attention It is possible to set multiple event handlers. Registered
547  * handlers may be removed with onDataWritten().detach(callback).
548  */
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(const DataWrittenCallback_t &callback);
552 
553  /**
554  * Set an event handler that is called after
555  * a connected peer has written an attribute.
556  *
557  * @param[in] objPtr Pointer to the instance that is used to invoke the
558  * event handler (@p memberPtr).
559  * @param[in] memberPtr Event handler being registered. It is a member
560  * function.
561  */
562  template <typename T>
563  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
564  "been replaced by GattServer::setEventHandler. Use that function instead.")
565  void onDataWritten(
566  T *objPtr,
567  void (T::*memberPtr)(const GattWriteCallbackParams *context)
568  )
569  {
570  onDataWritten({objPtr, memberPtr});
571  }
572 
573  /**
574  * Access the callchain of data written event handlers.
575  *
576  * @return A reference to the data written event callbacks chain.
577  *
578  * @note It is possible to register callbacks using
579  * onDataWritten().add(callback).
580  *
581  * @note It is possible to unregister callbacks using
582  * onDataWritten().detach(callback).
583  */
584  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
585  "been replaced by GattServer::setEventHandler. Use that function instead.")
586  DataWrittenCallbackChain_t &onDataWritten();
587 
588  /**
589  * Set an event handler that monitors attribute reads from connected clients.
590  *
591  * @param[in] callback Event handler being registered.
592  *
593  * @return BLE_ERROR_NOT_IMPLEMENTED if this functionality isn't available;
594  * else BLE_ERROR_NONE.
595  *
596  * @note This functionality may not be available on all underlying stacks.
597  * Application code may work around that limitation by monitoring read
598  * requests instead of read events.
599  *
600  * @see GattCharacteristic::setReadAuthorizationCallback()
601  * @see isOnDataReadAvailable().
602  *
603  * @attention It is possible to set multiple event handlers. Registered
604  * handlers may be removed with onDataRead().detach(callback).
605  */
606  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
607  "been replaced by GattServer::setEventHandler. Use that function instead.")
608  ble_error_t onDataRead(const DataReadCallback_t &callback);
609 
610  /**
611  * Set an event handler that monitors attribute reads from connected clients.
612  *
613  * @param[in] objPtr Pointer to the instance that is used to invoke the
614  * event handler (@p memberPtr).
615  * @param[in] memberPtr Event handler being registered. It is a member
616  * function.
617  */
618  template <typename T>
619  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
620  "been replaced by GattServer::setEventHandler. Use that function instead.")
621  ble_error_t onDataRead(
622  T *objPtr,
623  void (T::*memberPtr)(const GattReadCallbackParams *context)
624  )
625  {
626  return onDataRead({objPtr, memberPtr});
627  }
628 
629  /**
630  * Access the callchain of data read event handlers.
631  *
632  * @return A reference to the data read event callbacks chain.
633  *
634  * @note It is possible to register callbacks using
635  * onDataRead().add(callback).
636  *
637  * @note It is possible to unregister callbacks using
638  * onDataRead().detach(callback).
639  */
640  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
641  "been replaced by GattServer::setEventHandler. Use that function instead.")
642  DataReadCallbackChain_t &onDataRead();
643 
644  /**
645  * Set an event handler that monitors shutdown or reset of the GattServer.
646  *
647  * The event handler is invoked when the GattServer instance is about
648  * to be shut down. This can result in a call to reset() or BLE::reset().
649  *
650  * @param[in] callback Event handler being registered.
651  *
652  * @note It is possible to set up multiple shutdown event handlers.
653  *
654  * @note It is possible to unregister a callback using
655  * onShutdown().detach(callback)
656  */
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(const GattServerShutdownCallback_t &callback);
660 
661  /**
662  * Set an event handler that monitors shutdown or reset of the GattServer.
663  *
664  * The event handler is invoked when the GattServer instance is about
665  * to be shut down. This can result of a call to reset() or BLE::reset().
666  *
667  * @param[in] objPtr Pointer to the instance that is used to invoke the
668  * event handler (@p memberPtr).
669  * @param[in] memberPtr Event handler being registered. It is a member
670  * function.
671  */
672  template <typename T>
673  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
674  "been replaced by GattServer::setEventHandler. Use that function instead.")
675  void onShutdown(T *objPtr, void (T::*memberPtr)(const GattServer *))
676  {
677  onShutdown({objPtr, memberPtr});
678  }
679 
680  /**
681  * Access the callchain of shutdown event handlers.
682  *
683  * @return A reference to the shutdown event callbacks chain.
684  *
685  * @note It is possible to register callbacks using
686  * onShutdown().add(callback).
687  *
688  * @note It is possible to unregister callbacks using
689  * onShutdown().detach(callback).
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  GattServerShutdownCallbackChain_t& onShutdown();
694 
695  /**
696  * Set up an event handler that monitors subscription to characteristic
697  * updates.
698  *
699  * @param[in] callback Event handler being registered.
700  */
701  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
702  "been replaced by GattServer::setEventHandler. Use that function instead.")
703  void onUpdatesEnabled(EventCallback_t callback);
704 
705  /**
706  * Set up an event handler that monitors unsubscription from characteristic
707  * updates.
708  *
709  * @param[in] callback Event handler being registered.
710  */
711  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
712  "been replaced by GattServer::setEventHandler. Use that function instead.")
713  void onUpdatesDisabled(EventCallback_t callback);
714 
715  /**
716  * Set up an event handler that monitors notification acknowledgment.
717  *
718  * The event handler is called when a client sends a confirmation that it has
719  * correctly received a notification from the server.
720  *
721  * @param[in] callback Event handler being registered.
722  */
723  MBED_DEPRECATED_SINCE("mbed-os-6.3.0", "Individual callback-registering functions have"
724  "been replaced by an event handler. Indication confirmation triggers"
725  "GattServer::onDataSent event instead.")
726  void onConfirmationReceived(EventCallback_t callback);
727 
728 #if !defined(DOXYGEN_ONLY)
729  GattServer(impl::GattServer* impl) : impl(impl) {}
730  GattServer(const GattServer&) = delete;
731  GattServer& operator=(const GattServer&) = delete;
732 #endif // !defined(DOXYGEN_ONLY)
733 
734 private:
735  impl::GattServer *impl;
736 };
737 
738 /**
739  * @}
740  * @}
741  * @}
742  */
743 
744 } // ble
745 
746 /** @deprecated Use the namespaced ble::GattServer instead of the global GattServer. */
747 using ble::GattServer;
748 
749 #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:218
Function like object adapter over freestanding and member functions.
CallChainOfFunctionPointersWithContext< unsigned > DataSentCallbackChain_t
Callchain of DataSentCallback_t objects.
Definition: GattServer.h:226
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:283
virtual void onDataWritten(const GattWriteCallbackParams &params)
Function invoked when a client writes an attribute.
Definition: GattServer.h:144
CallChainOfFunctionPointersWithContext< const GattServer * > GattServerShutdownCallbackChain_t
Callchain of GattServerShutdownCallback_t.
Definition: GattServer.h:275
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:259
virtual void onDataSent(const GattDataSentCallbackParams &params)
Function invoked when the server has sent data to a client.
Definition: GattServer.h:134
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:179
virtual void onDataRead(const GattReadCallbackParams &params)
Function invoked when a client reads an attribute.
Definition: GattServer.h:161
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:118
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:251
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:235
virtual void onUpdatesDisabled(const GattUpdatesDisabledCallbackParams &params)
Function invoked when the client has unsubscribed from characteristic updates.
Definition: GattServer.h:189
Entry namespace for all BLE API definitions.
Definition: ATHandler.h:46
CallChainOfFunctionPointersWithContext< const GattWriteCallbackParams * > DataWrittenCallbackChain_t
Callchain of DataWrittenCallback_t objects.
Definition: GattServer.h:243
FunctionPointerWithContext< const GattServer * > GattServerShutdownCallback_t
Event handler invoked when the GattServer is reset.
Definition: GattServer.h:267
#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:169
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.