Mistake on this page?
Report an issue in GitHub or email us
GattClient.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_CLIENT_H__
21 
22 #define MBED_GATT_CLIENT_H__
23 
24 #include "ble/common/CallChainOfFunctionPointersWithContext.h"
25 #include "ble/common/blecommon.h"
26 
27 #include "ble/gatt/GattAttribute.h"
28 #include "ble/gatt/ServiceDiscovery.h"
29 #include "ble/gatt/CharacteristicDescriptorDiscovery.h"
30 #include "ble/gatt/GattCallbackParamTypes.h"
31 #include "ble/gatt/DiscoveredService.h"
32 #include "ble/gatt/DiscoveredCharacteristic.h"
33 
34 namespace ble {
35 
36 #if !defined(DOXYGEN_ONLY)
37 namespace impl {
38 class GattClient;
39 }
40 #endif // !defined(DOXYGEN_ONLY)
41 
42 /**
43  * @addtogroup ble
44  * @{
45  * @addtogroup gatt
46  * @{
47  * @addtogroup client
48  * @{
49  */
50 
51 /**
52  * Define procedures required for interacting with a distant GATT server.
53  *
54  * @par Discovery procedures
55  *
56  * A GATT server hosts a fixed set of services. These services are a logical
57  * composition of characteristics that may be discovered, read, written or also
58  * broadcast their state to a connected client. These characteristics may also
59  * contain metainformation named characteristic descriptors. A characteristic
60  * descriptor may be used to indicate the unit used for a characteristic value,
61  * describe in a textual form the characterisic purpose or allow a client to
62  * register for notification of updates of the characteristic value.
63  *
64  * Prior to any interaction with server characteristic, a GATT client
65  * discovers the layout of the services and characteristics present on the
66  * server.
67  *
68  * The layout of the descriptors of a characteristic may also be issued to
69  * as an extra discovery step.
70  *
71  * @par Attribute manipulation
72  *
73  * As a result of the discovery process, the client can start interacting with
74  * the characteristic discovered. Depending on the characteristic properties
75  * (acquired during discovery), a client can read or write the value of a given
76  * characteristic.
77  *
78  * Mbed BLE abstracts most read and write operations to offer a single API that
79  * can be used to read or write characteristics values. Application code does not
80  * have to handle the fragmentation/reassembly process necessary if the attribute
81  * value to transported cannot fit in a single data packet.
82  *
83  * @par Server Initiated events
84  *
85  * If a characteristic has to notify or indicate a property set; then, a client may
86  * register to a notification or indication from the characteristic. When the
87  * server updates the characteristic value, the server can forward the
88  * new value to the registered clients. The notification/indication mechanism
89  * prevents polling from the client and therefore minimize the transactions
90  * involved between a client and a server.
91  *
92  * Registration is made by writing the Client Characteristic Configuration
93  * Descriptor, which is present in the characteristic if the notify or
94  * indicate properties are set. The client discovers that descriptor
95  * if it intends to register to server initiated events.
96  */
97 class GattClient {
98 public:
99  /**
100  * Definition of the general handler of GattClient related events.
101  */
102  struct EventHandler {
103  /**
104  * Function invoked when the connections changes the ATT_MTU which controls
105  * the maximum size of an attribute that can be read in a single L2CAP packet
106  * which might be fragmented across multiple packets.
107  *
108  * @param connectionHandle The handle of the connection that changed the size.
109  * @param attMtuSize
110  */
111  virtual void onAttMtuChange(
112  ble::connection_handle_t connectionHandle,
113  uint16_t attMtuSize
114  ) {
115  (void)connectionHandle;
116  (void)attMtuSize;
117  }
118  protected:
119  /**
120  * Prevent polymorphic deletion and avoid unnecessary virtual destructor
121  * as the GattClient class will never delete the instance it contains.
122  */
123  ~EventHandler() = default;
124  };
125 
126  /**
127  * Assign the event handler implementation that will be used by the
128  * module to signal events back to the application.
129  *
130  * @param handler Application implementation of an EventHandler.
131  */
132  void setEventHandler(EventHandler *handler);
133 
134  /**
135  * Attribute read event handler.
136  *
137  * @see GattClient::onDataRead().
138  * @deprecated Use the version in global ble namespace.
139  */
142 
143  /**
144  * Callchain of attribute read event handlers.
145  * @deprecated Use the version in global ble namespace.
146  */
149 
150  /**
151  * GATT write operations.
152  */
153  enum WriteOp_t {
154  /**
155  * Write request.
156  *
157  * It is used to request the server to write the value of an attribute
158  * and acknowledge that this has been achieved in a Write Response.
159  */
160  GATT_OP_WRITE_REQ = 0x01,
161 
162  /**
163  * Write command.
164  *
165  * It is used to request the server to write the value of an attribute.
166  * The server does not acknowledge the status of the operation.
167  */
168  GATT_OP_WRITE_CMD = 0x02,
169 
170  /**
171  * Signed Write command.
172  *
173  * It is used to request the server to write the value of an attribute
174  * using a signed packet. The server does not acknowledge the status
175  * of the operation.
176  */
177  GATT_OP_SIGNED_WRITE_CMD = 0x03
178  };
179 
180  /**
181  * Attribute write event handler.ble::WriteCallback_t
182  *
183  * @see GattClient::onDataWrite().
184  * @deprecated Use the version in global ble namespace.
185  */
188 
189  /**
190  * Callchain of attribute write event handlers.
191  *
192  * @see GattClient::onDataWrite().
193  * @deprecated Use the version in global ble namespace.
194  */
197 
198  /**
199  * Handle value notification/indication event handler.
200  *
201  * @see to GattClient::onHVX().
202  */
205 
206  /**
207  * Callchain of handle value notification/indication event handlers.
208  *
209  * @see GattClient::onHVX().
210  */
213 
214  /**
215  * Shutdown event handler.
216  *
217  * @see GattClient::onShutdown().
218  */
221 
222 
223  /**
224  * Callchain of shutdown event handlers.
225  *
226  * @see to GattClient::onShutown().
227  */
230 
231  /*
232  * The following functions are meant to be overridden in the platform
233  * specific subclass.
234  */
235 
236  ~GattClient() = default;
237 
238  /**
239  * Launch the service and characteristic discovery procedure of a GATT server
240  * peer.
241  *
242  * The procedure invokes application callbacks for matching services or
243  * characteristics. The process ends after all the services and
244  * characteristics present on the distant GATT server have been discovered.
245  * Termination callbacks registered with onServiceDiscoveryTermination() are
246  * invoked to notify the application of the termination of the procedure.
247  *
248  * Application code can track the status of the procedure by invoking the
249  * function isServiceDiscoveryActive(), which returns true if the
250  * procedure is ongoing.
251  *
252  * At any point, application code can prematurely terminate the discovery
253  * procedure by calling terminateServiceDiscovery().
254  *
255  * @param[in] connectionHandle Handle of the connection with the peer GATT
256  * server.
257  * @param[in] sc Service discovered event handler invoked when a matching
258  * service has been discovered. This parameter may be NULL.
259  * @param[in] cc Characteristic discovered event handler invoked when a
260  * matching characteristic has been found. This parameter may be NULL.
261  * @param[in] matchingServiceUUID UUID of the service the caller is
262  * interested in. If a service discovered matches this filter, then @p sc is
263  * invoked with it. The special value BLE_UUID_UNKNOWN acts as a wildcard,
264  * which can be used to discover all services present on the peer GATT
265  * server.
266  * @param[in] matchingCharacteristicUUIDIn UUID of the characteristic the
267  * caller is interested in. If a characteristic discovered matches this
268  * filter, then @p cc is invoked with it. The special value BLE_UUID_UNKNOWN
269  * acts as a wildcard, which can be used to discover all services present on
270  * the peer GATT server.
271  *
272  * @par Discovery procedure implementation detail
273  *
274  * It is recommended to implement several strategies based on the
275  * combination of callbacks and filters passed in input to efficiently
276  * realize the discovery procedure:
277  * - If @p sc and @p cc are NULL, then it is not necessay to initiate any
278  * discovery, and the termination handlers can be invoked immediately.
279  * - If @p matchingServiceUUID is set, then the GATT discover services by
280  * service UUID procedure should be used; otherwise, the GATT discover primary
281  * services procedure should be used.
282  * - If @p cc is NULL, then the discovery process should end after the discovery
283  * of the services.
284  *
285  * @return BLE_ERROR_NONE if the discovery procedure has been successfully
286  * started and an appropriate error otherwise.
287  */
288  ble_error_t launchServiceDiscovery(
289  ble::connection_handle_t connectionHandle,
292  const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN),
293  const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)
294  );
295 
296  /**
297  * Launch the service discovery procedure of a GATT server peer.
298  *
299  * The procedure invokes the application callback for matching services.
300  * The process ends after all the services present on the distant GATT
301  * server have been discovered.
302  * Termination callbacks registered with onServiceDiscoveryTermination() are
303  * invoked to notify the application of the termination of the procedure.
304  *
305  * Application code can track the status of the procedure by invoking the
306  * function isServiceDiscoveryActive(), which returns true if the
307  * procedure is ongoing.
308  *
309  * At any point, application code can prematurely terminate the discovery
310  * procedure by calling terminateServiceDiscovery().
311  *
312  * @param[in] connectionHandle Handle of the connection with the peer GATT
313  * server.
314  * @param[in] callback Service discovered event handler invoked when a
315  * matching service has been discovered. This parameter may be NULL.
316  * @param[in] matchingServiceUUID UUID of the service the caller is
317  * interested in. If a service discovered matches this filter, then @p sc is
318  * invoked with it. The special value BLE_UUID_UNKNOWN act is a wildcard,
319  * which can be used to discover all services present on the peer GATT
320  * server.
321  *
322  * @return BLE_ERROR_NONE if the discovery procedure has been successfully
323  * started and an appropriate error otherwise.
324  */
325  ble_error_t discoverServices(
326  ble::connection_handle_t connectionHandle,
328  const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)
329  );
330 
331  /**
332  * Launch the service discovery procedure of a GATT server peer.
333  *
334  * The process ends after all the services present in the attribute range @p
335  * startHandle to @p endHandle have been discovered.
336  *
337  * Termination callbacks registered with onServiceDiscoveryTermination() are
338  * invoked to notify the application of the termination of the procedure.
339  *
340  * Application code can track the status of the procedure by invoking the
341  * function isServiceDiscoveryActive(), which returns true if the
342  * procedure is ongoing.
343  *
344  * At any point, application code can prematurely terminate the discovery
345  * procedure by calling terminateServiceDiscovery().
346  *
347  * @param[in] connectionHandle Handle of the connection with the peer GATT
348  * server.
349  * @param[in] callback Service discovered event handler invoked when a
350  * matching service has been discovered. This parameter may be NULL.
351  * @param[in] startHandle First attribute handle of the discovery range.
352  * @param[in] endHandle end Lasr attribute handle of the discovery range.
353  *
354  * @return BLE_ERROR_NONE if the discovery procedure has been successfully
355  * started and an appropriate error otherwise.
356  */
357  ble_error_t discoverServices(
358  ble::connection_handle_t connectionHandle,
360  GattAttribute::Handle_t startHandle,
361  GattAttribute::Handle_t endHandle
362  );
363 
364  /**
365  * Check if the service discovery procedure is currently active.
366  *
367  * @return true if service discovery procedure is active and false otherwise.
368  */
369  bool isServiceDiscoveryActive() const;
370 
371  /**
372  * Terminate all ongoing service discovery procedures.
373  *
374  * It results in an invocation of the service discovery termination handler
375  * registered with onServiceDiscoveryTermination().
376  */
377  void terminateServiceDiscovery();
378 
379  /**
380  * Initiate the read procedure of an attribute handle.
381  *
382  * Once the attribute value has been read in its entirety, the process issues
383  * an attribute read event and passes it to all events handlers registered
384  * by onDataRead.
385  *
386  * @param[in] connHandle Handle of the connection used to send the read
387  * request.
388  * @param[in] attributeHandle Handle of the attribute to read data from.
389  * @param[in] offset The offset from the start of the attribute value to be
390  * read.
391  *
392  * @return BLE_ERROR_NONE if read procedure successfully started.
393  *
394  * @par Implementation notes:
395  *
396  * Reading the attribute value in its entirety may involve sending several
397  * GATT requests to the peer. The following algorithm may be used to
398  * implement the process:
399  *
400  * If the offset is equal to 0, then send a read request; otherwise, send a
401  * read blob request at the specified offset.
402  *
403  * While the attribute data in the response are MTU - 1 long:
404  * - Concat the response to the value containing the previous responses.
405  * - Increment the value of the offset by MTU - 1.
406  * - Send a read blob request with the updated offset.
407  *
408  * Finally, concat the last response with the value containing all the
409  * previous responses and forward that value to the event handlers.
410  */
411  ble_error_t read(
412  ble::connection_handle_t connHandle,
413  GattAttribute::Handle_t attributeHandle,
414  uint16_t offset
415  ) const;
416 
417  /**
418  * Initiate a write procedure on an attribute value.
419  *
420  * If @p cmd is equal to GATT_OP_WRITE_REQ, then the status of the operation
421  * is reported to the event handlers registered through onDataWritten().
422  *
423  * @param[in] cmd Type of the write procedure used. If GATT_OP_WRITE_CMD
424  * is set, then value length is not greater than the size of the mtu
425  * of connHandle minus three.
426  * @param[in] connHandle Handle of the connection used to send the write
427  * request or command.
428  * @param[in] attributeHandle Handle of the attribute value to write.
429  * @param[in] length Number of bytes present in @p value.
430  * @param[in] value Data buffer to write to attributeHandle.
431  *
432  * @return BLE_ERROR_NONE if the write procedure successfully started.
433  *
434  * @par Implementation notes:
435  *
436  * If the operation is a write command, then an implementation uses the
437  * GATT write without response procedure and an error is returned if
438  * the data buffer to write is larger than the size of the MTU - 3.
439  *
440  * If the operation is a write command and the size of the data buffer to
441  * write is less than than the size of the MTU - 3, then the ATT write request
442  * procedure is used, and the response is reported to the handlers
443  * listening for write response.
444  *
445  * Otherwise, the data buffer to write is divided in chunks with a
446  * maximum size of MTU - 5. Those chunks are sent sequentially to the
447  * peer in ATT prepare write requests. If an error response is received
448  * during the process, the procedure ends immediately, the prepared
449  * write is discarded and an error is reported to the application handlers.
450  * Once all the chunks have been sent, the transaction is completed
451  * by sending an execute write request to the peer. The peer response is
452  * forwarded to the application handlers.
453  */
454  ble_error_t write(
456  ble::connection_handle_t connHandle,
457  GattAttribute::Handle_t attributeHandle,
458  size_t length,
459  const uint8_t *value
460  ) const;
461 
462  /* Event callback handlers. */
463 
464  /**
465  * Register an attribute read event handler.
466  *
467  * @note It is possible to unregister a callback using
468  * onDataRead().detach(callbackToRemove).
469  *
470  * @param[in] callback Event handler being registered.
471  */
472  void onDataRead(ble::ReadCallback_t callback);
473 
474  /**
475  * Get the callchain of attribute read event handlers.
476  *
477  * @return A reference to the read event callback chain.
478  *
479  * @note It is possible to register new handlers using
480  * onDataRead().add(callback).
481  *
482  * @note It is possible to unregister an handler by using
483  * onDataRead().detach(callback).
484  */
485  ble::ReadCallbackChain_t& onDataRead();
486 
487  /**
488  * Register an attribute write event handler.
489  *
490  * @param[in] callback Event handler being registered.
491  *
492  * @note It is possible to remove registered handlers using
493  * onDataWritten().detach(callbackToRemove).
494  *
495  * @note Write commands (issued using writeWoResponse) don't generate a
496  * response.
497  */
498  void onDataWritten(ble::WriteCallback_t callback);
499 
500  /**
501  * Get the callchain of attribute write event handlers.
502  *
503  * @return A reference to the data written callbacks chain.
504  *
505  * @note It is possible to register new handlers by using
506  * onDataWritten().add(callback).
507  *
508  * @note It is possible to unregister an handler by using
509  * onDataWritten().detach(callback).
510  */
511  ble::WriteCallbackChain_t& onDataWritten();
512 
513  /**
514  * Register a service discovery termination event handler.
515  *
516  * @param[in] callback Event handler being registered.
517  */
518  void onServiceDiscoveryTermination(
520  );
521 
522  /**
523  * Initiate the descriptor discovery procedure for a given characteristic.
524  *
525  * When a descriptor is discovered the discovered descriptor is forwarded
526  * to @p discoveryCallback. After the discovery of all the descriptors, the
527  * procedure ends and send a descriptor discovery termination event to @p
528  * termination callback.
529  *
530  * Application code may monitor the discovery process by querying its status
531  * with isCharacteristicDescriptorDiscoveryActive(). It can also end the
532  * discovery process by calling terminateCharacteristicDescriptorDiscovery().
533  *
534  * @param[in] characteristic The characteristic owning the descriptors to
535  * discover.
536  * @param[in] discoveryCallback Handle descriptor discovered events for the
537  * duration of the procedure.
538  * @param[in] terminationCallback Handle descriptor discovery termination
539  * event of the procedure.
540  *
541  * @return BLE_ERROR_NONE if the characteristic descriptor discovery
542  * procedure has been launched successfully otherwise an appropriate error.
543  */
544  ble_error_t discoverCharacteristicDescriptors(
545  const DiscoveredCharacteristic& characteristic,
548  );
549 
550  /**
551  * Query status of the descriptor discovery procedure for a given
552  * characteristic.
553  *
554  * @param[in] characteristic The characteristic concerned by the descriptors
555  * discovery.
556  *
557  * @return true if a descriptors discovery is active for the characteristic
558  * in input otherwise false.
559  */
560  bool isCharacteristicDescriptorDiscoveryActive(
561  const DiscoveredCharacteristic& characteristic
562  ) const;
563 
564  /**
565  * @brief Terminate an ongoing characteristic descriptor discovery procedure.
566  *
567  * If the procedure is active, then it ends, and the termination handler
568  * associated with the procedure is called.
569  *
570  * @param[in] characteristic The characteristic containing the descriptors
571  * being discovered.
572  */
573  void terminateCharacteristicDescriptorDiscovery(
574  const DiscoveredCharacteristic& characteristic
575  );
576 
577  /**
578  * Trigger MTU negotiation. This might result in a Gap event onAttMtuChange
579  * being called if MTU changes.
580  *
581  * @note This does not guarantee a change in MTU size. If size remains
582  * unchanged no event will be generated.
583  *
584  * @param connection Connection on which the MTU is to be negotiated.
585  *
586  * @return BLE_ERROR_NONE if the procedure has been launched successfully
587  * otherwise an appropriate error.
588  */
589  ble_error_t negotiateAttMtu(ble::connection_handle_t connection);
590 
591  /**
592  * Register an handler for Handle Value Notification/Indication events.
593  *
594  * @param callback Event handler to register.
595  *
596  * @note It is possible to unregister a callback by using
597  * onHVX().detach(callbackToRemove).
598  */
599  void onHVX(HVXCallback_t callback);
600 
601  /**
602  * Register a shutdown event handler.
603  *
604  * The registered handler is invoked when the GattClient instance is
605  * about to be shut down.
606  *
607  * @param[in] callback Event handler to invoke when a shutdown event is
608  * available.
609  *
610  * @note onShutdown().detach(callback) may be used to unregister a given
611  * callback.
612  *
613  * @see BLE::shutdown()
614  */
615  void onShutdown(const GattClientShutdownCallback_t& callback);
616 
617  /**
618  * Register a shutdown event handler.
619  *
620  * The registered handler is invoked when the GattClient instance is
621  * about to be shut down.
622  *
623  * @param[in] objPtr Instance that will be used to invoke @p memberPtr.
624  * @param[in] memberPtr Event handler to invoke when a shutdown event is
625  * available.
626  */
627  template <typename T>
628  void onShutdown(T *objPtr, void (T::*memberPtr)(const GattClient *))
629  {
630  onShutdown({objPtr, memberPtr});
631  }
632 
633  /**
634  * Get the callchain of shutdown event handlers.
635  *
636  * @return A reference to the shutdown event callbacks chain.
637  *
638  * @note onShutdown().add(callback) may be used to register new handlers.
639  *
640  * @note onShutdown().detach(callback) may be used to unregister an handler.
641  */
642  GattClientShutdownCallbackChain_t& onShutdown();
643 
644  /**
645  * @brief provide access to the callchain of HVX callbacks.
646  *
647  * @return A reference to the HVX callbacks chain.
648  *
649  * @note It is possible to register callbacks using onHVX().add(callback).
650  *
651  * @note It is possible to unregister callbacks using onHVX().detach(callback).
652  */
653  HVXCallbackChain_t& onHVX();
654 
655  /**
656  * Reset the state of the GattClient instance.
657  *
658  * Prior to any state modification, shutdown event handlers are notified
659  * that the GattClient instance is about to be shut down. Then, running
660  * procedures end. Finally, the state of the instance is reset.
661  *
662  * @par implementation note
663  *
664  * This function is meant to be overridden in the platform-specific
665  * subclass. Nevertheless, the subclass only resets its
666  * state and not the data held in GattClient members. This is achieved
667  * by a call to GattClient::reset() from the subclass' reset()
668  * implementation.
669  *
670  * @return BLE_ERROR_NONE on success.
671  */
672  ble_error_t reset();
673 
674  /* Entry points for the underlying stack to report events back to the user. */
675 
676  /**
677  * Forward an attribute read event to all registered handlers.
678  *
679  * @attention This function is meant to be called from the vendor
680  * implementation when an attribute read event occurs.
681  *
682  * @param[in] params Attribute read event to pass to the registered handlers.
683  */
684  void processReadResponse(const GattReadCallbackParams *params);
685 
686  /**
687  * Forward an attribute written event to all registered handlers.
688  *
689  * @attention This function is meant to be called from the vendor
690  * implementation when an attribute written event occurs.
691  *
692  * @param[in] params Attribute written event to pass to the registered
693  * handlers.
694  */
695  void processWriteResponse(const GattWriteCallbackParams *params);
696 
697  /**
698  * Forward a handle value notification or indication event to all registered
699  * handlers.
700  *
701  * @attention This function is meant to be called from the vendor
702  * implementation when a notification or indication event is available.
703  *
704  * @param[in] params Notification or Indication event to pass to the
705  * registered handlers.
706  */
707  void processHVXEvent(const GattHVXCallbackParams *params);
708 
709 #if !defined(DOXYGEN_ONLY)
710  GattClient(impl::GattClient* impl) : impl(impl) { }
711  GattClient(const GattClient&) = delete;
712  GattClient& operator=(const GattClient&) = delete;
713 #endif // !defined(DOXYGEN_ONLY)
714 
715 private:
716  impl::GattClient *impl;
717 };
718 
719 /**
720  * @}
721  * @}
722  * @}
723  */
724 
725 } // namespace ble
726 
727 /** @deprecated Use the namespaced ble::GattClient instead of the global GattClient. */
728 using ble::GattClient;
729 
730 #endif /* ifndef MBED_GATT_CLIENT_H__ */
Function like object adapter over freestanding and member functions.
Definition of the general handler of GattClient related events.
Definition: GattClient.h:102
FunctionPointerWithContext< const GattClient * > GattClientShutdownCallback_t
Shutdown event handler.
Definition: GattClient.h:220
uintptr_t connection_handle_t
Opaque reference to a connection.
Representation of a characteristic discovered.
Handle Value Notification/Indication event.
CallChainOfFunctionPointersWithContext< const GattReadCallbackParams * > ReadCallbackChain_t
Callchain of attribute read event handlers.
Definition: GattClient.h:148
CallChainOfFunctionPointersWithContext< const GattWriteCallbackParams * > WriteCallbackChain_t
Callchain of attribute write event handlers.
Definition: GattClient.h:196
Callback< R(ArgTs...)> callback(R(*func)(ArgTs...)=nullptr) noexcept
Create a callback class with type inferred from the arguments.
Definition: Callback.h:678
Representation of a Universally Unique Identifier (UUID).
Definition: common/UUID.h:76
FunctionPointerWithContext< const GattHVXCallbackParams * > HVXCallback_t
Handle value notification/indication event handler.
Definition: GattClient.h:204
ble::attribute_handle_t Handle_t
Representation of an attribute handle.
FunctionPointerWithContext< const GattWriteCallbackParams * > WriteCallback_t
Attribute write event handler.ble::WriteCallback_t.
Definition: GattClient.h:187
GATT Write event definition.
Reserved UUID.
void onShutdown(T *objPtr, void(T::*memberPtr)(const GattClient *))
Register a shutdown event handler.
Definition: GattClient.h:628
uint16_t ShortUUIDBytes_t
Type for a 16-bit UUID.
Definition: common/UUID.h:114
GATT Read event definition.
WriteOp_t
GATT write operations.
Definition: GattClient.h:153
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: GattClient.h:111
Define procedures required for interacting with a distant GATT server.
Definition: GattClient.h:97
CallChainOfFunctionPointersWithContext< const GattClient * > GattClientShutdownCallbackChain_t
Callchain of shutdown event handlers.
Definition: GattClient.h:229
Function like object hosting a list of FunctionPointerWithContext.
FunctionPointerWithContext< const GattReadCallbackParams * > ReadCallback_t
Attribute read event handler.
Definition: GattClient.h:141
Entry namespace for all BLE API definitions.
CallChainOfFunctionPointersWithContext< const GattHVXCallbackParams * > HVXCallbackChain_t
Callchain of handle value notification/indication event handlers.
Definition: GattClient.h:212
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.