Mistake on this page?
Report an issue in GitHub or email us
Gap.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2006-2013 ARM Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MBED_BLE_GAP_H__
18 #define MBED_BLE_GAP_H__
19 
20 #include "BLERoles.h"
21 #include "ble/common/StaticInterface.h"
22 #include "BLETypes.h"
23 #include "BLEProtocol.h"
24 #include "ble/GapAdvertisingData.h"
25 #include "ble/GapAdvertisingParams.h"
26 #include "ble/GapScanningParams.h"
27 #include "ble/GapEvents.h"
28 
29 #include "CallChainOfFunctionPointersWithContext.h"
31 #include "platform/mbed_toolchain.h"
32 
33 #include "ble/gap/Gap.h"
34 #include "BleImplementationForward.h"
35 
36 /**
37  * @addtogroup ble
38  * @{
39  * @addtogroup gap
40  * @{
41  */
42 
43 #if !defined(DOXYGEN_ONLY)
44 namespace ble {
45 namespace interface {
46 #endif
47 
48 /**
49  * @copydoc ble::Gap
50  */
51 #if defined(DOXYGEN_ONLY)
52 class Gap : public ble::Gap {
53 #else
54 template<class Impl>
55 class LegacyGap :
56  public ble::StaticInterface<Impl, LegacyGap>,
57  public ble::interface::Gap<Impl>
58 {
59 #endif
61 
62 public:
63 #if BLE_ROLE_BROADCASTER
64  using ble::interface::Gap<Impl>::setAdvertisingParameters;
65  using ble::interface::Gap<Impl>::setAdvertisingPayload;
66  using ble::interface::Gap<Impl>::setAdvertisingScanResponse;
67  using ble::interface::Gap<Impl>::startAdvertising;
68  using ble::interface::Gap<Impl>::stopAdvertising;
69 #endif // BLE_ROLE_BROADCASTER
70 #if BLE_ROLE_CENTRAL
71  using ble::interface::Gap<Impl>::connect;
72 #endif
73 #if BLE_FEATURE_CONNECTABLE
74  using ble::interface::Gap<Impl>::disconnect;
75 #endif
76 #if BLE_ROLE_OBSERVER
77  using ble::interface::Gap<Impl>::startScan;
78 #endif
79 
80  /**
81  * Address-type for BLEProtocol addresses.
82  *
83  * @deprecated Use BLEProtocol::AddressType_t instead.
84  */
86 
87  /**
88  * Address-type for BLEProtocol addresses.
89  *
90  * @deprecated Use BLEProtocol::AddressType_t instead.
91  */
93 
94  /**
95  * Address-type for BLEProtocol addresses.
96  *
97  * @deprecated Use BLEProtocol::AddressType_t instead. The following
98  * constants have been left in their deprecated state to transparently
99  * support existing applications that may have used Gap::ADDR_TYPE_*.
100  */
102  ADDR_TYPE_PUBLIC = BLEProtocol::AddressType::PUBLIC,
103  ADDR_TYPE_RANDOM_STATIC = BLEProtocol::AddressType::RANDOM_STATIC,
104  ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE = BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE,
105  ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE = BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE
106  };
107 
108  /**
109  * Length (in octets) of the BLE MAC address.
110  */
111  static const unsigned ADDR_LEN = BLEProtocol::ADDR_LEN;
112 
113  /**
114  * 48-bit address, LSB format.
115  *
116  * @deprecated Use BLEProtocol::AddressBytes_t instead.
117  */
119 
120  /**
121  * 48-bit address, LSB format.
122  *
123  * @deprecated Use BLEProtocol::AddressBytes_t instead.
124  */
126 
127 public:
128  /**
129  * Enumeration of possible timeout sources.
130  */
132  /**
133  * Advertising timeout.
134  */
135  TIMEOUT_SRC_ADVERTISING = 0x00,
136 
137  /**
138  * Security request timeout.
139  */
140  TIMEOUT_SRC_SECURITY_REQUEST = 0x01,
141 
142  /**
143  * Scanning timeout.
144  */
145  TIMEOUT_SRC_SCAN = 0x02,
146 
147  /**
148  * Connection timeout.
149  */
150  TIMEOUT_SRC_CONN = 0x03,
151  };
152 
153  /**
154  * Enumeration of disconnection reasons.
155  *
156  * @attention There might be a mismatch between the disconnection reason
157  * passed to disconnect() and the disconnection event generated locally
158  * because the disconnection reason passed to disconnect() is the
159  * disconnection reason to be transmitted to the peer.
160  */
162 
163  /**
164  * GAP or GATT failed to authenticate the peer.
165  */
166  AUTHENTICATION_FAILURE = 0x05,
167 
168  /**
169  * The connection timed out.
170  *
171  * @attention shall not be used as a reason in disconnect().
172  */
173  CONNECTION_TIMEOUT = 0x08,
174 
175  /**
176  * Connection terminated by the user.
177  */
178  REMOTE_USER_TERMINATED_CONNECTION = 0x13,
179 
180  /**
181  * Remote device terminated connection due to low resources.
182  */
183  REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES = 0x14,
184 
185  /**
186  * Remote device terminated connection due to power off.
187  */
188  REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF = 0x15,
189 
190  /**
191  * Indicate that the local user or the internal
192  * Bluetooth subsystem terminated the connection.
193  *
194  * @attention shall not be used as a reason in disconnect().
195  */
196  LOCAL_HOST_TERMINATED_CONNECTION = 0x16,
197 
198  /**
199  * Connection parameters were unacceptable.
200  */
201  CONN_INTERVAL_UNACCEPTABLE = 0x3B,
202  };
203 
204  /**
205  * Advertising policy filter modes.
206  *
207  * @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.2.
208  */
210  /**
211  * The whitelist is not used to filter peer request during advertising.
212  */
213  ADV_POLICY_IGNORE_WHITELIST = 0,
214 
215  /**
216  * The whitelist is used to filter peer scan requests.
217  */
218  ADV_POLICY_FILTER_SCAN_REQS = 1,
219 
220  /**
221  * The whitelist is used to filter peer connection requests.
222  */
223  ADV_POLICY_FILTER_CONN_REQS = 2,
224 
225  /**
226  * The whitelist is used to filter peer scan and connection requests.
227  */
228  ADV_POLICY_FILTER_ALL_REQS = 3,
229  };
230 
231  /**
232  * Scanning policy filter mode.
233  *
234  * @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.3.
235  */
237  /**
238  * The whitelist is not used for scanning operations.
239  */
240  SCAN_POLICY_IGNORE_WHITELIST = 0,
241 
242  /**
243  * The whitelist is used to filter incoming advertising.
244  */
245  SCAN_POLICY_FILTER_ALL_ADV = 1,
246  };
247 
248  /**
249  * Connection initiation policy filter mode.
250  *
251  * @see Bluetooth Core Specification 4.2 (vol. 6), Part B, Section 4.4.4.
252  */
254  /**
255  * Connection can be initiated to any device.
256  */
257  INIT_POLICY_IGNORE_WHITELIST = 0,
258 
259  /**
260  * Connection initiation is restricted to the devices present in the
261  * whitelist.
262  */
263  INIT_POLICY_FILTER_ALL_ADV = 1,
264  };
265 
266  /**
267  * Representation of a whitelist of addresses.
268  */
269  struct Whitelist_t {
270  /**
271  * Pointer to the array of the addresses composing the whitelist.
272  */
274 
275  /**
276  * Number addresses in this whitelist.
277  */
278  uint8_t size;
279 
280  /**
281  * Capacity of the array holding the addresses.
282  */
283  uint8_t capacity;
284  };
285 
286  /**
287  * Description of the states of the device.
288  */
289  struct GapState_t {
290  /**
291  * If set, the device is currently advertising.
292  */
293  unsigned advertising : 1;
294 
295  /**
296  * If set, the device is connected to at least one other peer.
297  */
298  unsigned connected : 1;
299  };
300 
301  /**
302  * Opaque value type representing a connection handle.
303  *
304  * It is used to identify to refer to a specific connection across Gap,
305  * GattClient and GattEvent API.
306  *
307  * @note instances are generated by in the connection callback.
308  */
310 
311  /**
312  * Enumeration of random address types.
313  */
315 
316  /**
317  * Enumeration of peer address types
318  */
320 
321  /**
322  * Enumeration of BLE PHY
323  */
324  typedef ble::phy_t Phy_t;
325 
326  /**
327  * Set of BLE PHYs
328  */
330 
331  /**
332  * Enumeration of type of symbols that can be used with LE coded PHY.
333  */
335 
336  /**
337  * Parameters of a BLE connection.
338  */
339  typedef struct {
340  /**
341  * Minimum interval between two connection events allowed for a
342  * connection.
343  *
344  * It shall be less than or equal to maxConnectionInterval. This value,
345  * in units of 1.25ms, is included in the range [0x0006 : 0x0C80].
346  */
348 
349  /**
350  * Maximum interval between two connection events allowed for a
351  * connection.
352  *
353  * It shall be greater than or equal to minConnectionInterval. This
354  * value is in unit of 1.25ms and is in the range [0x0006 : 0x0C80].
355  */
357 
358  /**
359  * Number of connection events the slave can drop if it has nothing to
360  * communicate to the master.
361  *
362  * This value shall be in the range [0x0000 : 0x01F3].
363  */
364  uint16_t slaveLatency;
365 
366  /**
367  * Link supervision timeout for the connection.
368  *
369  * Time after which the connection is considered lost if the device
370  * didn't receive a packet from its peer.
371  *
372  * It is larger than:
373  * (1 + slaveLatency) * maxConnectionInterval * 2
374  *
375  * This value is in the range [0x000A : 0x0C80] and is in unit of
376  * 10 ms.
377  *
378  * @note maxConnectionInterval is in ms in the formulae above.
379  */
382 
383  /**
384  * Enumeration of GAP roles.
385  *
386  * @note The BLE API does not express the broadcaster and scanner roles.
387  *
388  * @attention A device can fulfill different roles concurrently.
389  */
390  enum Role_t {
391  /**
392  * Peripheral Role.
393  *
394  * The device can advertise and it can be connected by a central. It
395  * acts as a slave when connected.
396  *
397  * @note A peripheral is a broadcaster.
398  */
399  PERIPHERAL = 0x1,
400 
401  /**
402  * Central Role.
403  *
404  * The device can scan and initiate connection to peripherals. It
405  * acts as the master when a connection is established.
406  *
407  * @note A central is a scanner.
408  */
409  CENTRAL = 0x2,
410  };
411 
412  /**
413  * Representation of a scanned advertising packet.
414  *
415  * Instances of this type are passed to the callback registered in
416  * startScan().
417  */
419  /**
420  * Default constructor.
421  */
423 
424  /**
425  * BLE address of the device that has advertised the packet.
426  */
428 
429  /**
430  * RSSI value of the packet.
431  */
432  int8_t rssi;
433 
434  /**
435  * Flag indicating if the packet is a response to a scan request.
436  */
438 
439  /**
440  * Type of advertisement.
441  */
443 
444  /**
445  * Length of the advertisement data.
446  */
448 
449  /**
450  * Pointer to the advertisement packet's data.
451  */
452  const uint8_t *advertisingData;
453 
454  /**
455  * Type of the address received.
456  *
457  * @deprecated AddressType_t do not carry enough information to be used
458  * when privacy is enabled. Use peerAddressType instead.
459  *
460  * @note This value should be used in the connect function to establish
461  * a connection with the peer that has sent this advertisement packet.
462  */
464  "mbed-os-5.9.0",
465  "addressType won't work in connect when privacy is enabled; please"
466  "use peerAddrType"
467  )
468  AddressType_t addressType;
469 
470  /**
471  * Type of the address received.
472  *
473  * @note This value should be used in the connect function to establish
474  * a connection with the peer that has sent this advertisement packet.
475  */
476  PeerAddressType_t peerAddrType;
477  };
478 
479  /**
480  * Type of the callback handling scanned advertisement packets.
481  *
482  * @see Gap::startScan().
483  */
486 
487  /**
488  * Connection events.
489  *
490  * It contains all the information related to a newly established connection.
491  *
492  * Instances of this structure are passed to handlers that
493  * Gap::onConnection() registers when a connection is established.
494  */
496  /**
497  * Connection handle.
498  */
499  Handle_t handle;
500 
501  /**
502  * Connection Role of the local device.
503  */
505 
506  /**
507  * Type of the address the peer uses.
508  *
509  * @deprecated The type BLEProtocol::AddressType_t is not suitable when
510  * privacy is enabled. Use peerAddressType instead.
511  */
513  "mbed-os-5.9",
514  "The type BLEProtocol::AddressType_t is not suitable when privacy is "
515  "enabled. Use peerAddressType instead."
516  )
517  BLEProtocol::AddressType_t peerAddrType;
518 
519  /**
520  * Address of the peer.
521  */
522  BLEProtocol::AddressBytes_t peerAddr;
523 
524  /**
525  * Address type of the local device.
526  */
527  BLEProtocol::AddressType_t ownAddrType;
528 
529  /**
530  * Address of the local device.
531  *
532  * @deprecated The local address used for the connection may not be known,
533  * Therefore this field is not reliable.
534  *
535  * @note All bytes of the address are set to 0 if not applicable
536  */
538  "mbed-os-5.9",
539  "A Bluetooth controller is not supposed to return the address it used"
540  "to connect. With privacy enabled the controller address may be unknown"
541  "to the host. There is no replacement for this deprecation."
542  )
543  BLEProtocol::AddressBytes_t ownAddr;
544 
545  /**
546  * Connection parameters.
547  */
548  const ConnectionParams_t *connectionParams;
549 
550  /**
551  * Resolvable address used by the peer.
552  *
553  * @note All bytes of the address are set to 0 if not applicable
554  */
555  BLEProtocol::AddressBytes_t peerResolvableAddr;
556 
557  /**
558  * resolvable address of the local device.
559  *
560  * @note All bytes of the address are set to 0 if not applicable
561  */
562  BLEProtocol::AddressBytes_t localResolvableAddr;
563 
564  /**
565  * Type of the address the peer uses.
566  */
567  PeerAddressType_t peerAddressType;
568 
569  /**
570  * Construct an instance of ConnectionCallbackParams_t.
571  *
572  * @param[in] handleIn Value to assign to handle.
573  * @param[in] roleIn Value to assign to role.
574  * @param[in] peerAddrTypeIn Value to assign to peerAddrType.
575  * @param[in] peerAddrIn Value to assign to peerAddr.
576  * @param[in] ownAddrTypeIn Value to assign to ownAddrType.
577  * @param[in] ownAddrIn Value to assign to ownAddr. This may be NULL.
578  * @param[in] connectionParamsIn Value to assign to connectionParams.
579  * @param[in] peerResolvableAddrIn Value to assign to peerResolvableAddr.
580  * @param[in] localResolvableAddrIn Value to assign to localResolvableAddr.
581  *
582  * @note Constructor is not meant to be called by user code.
583  * The BLE API vendor code generates ConnectionCallbackParams_t.
584  */
585  ConnectionCallbackParams_t(
586  Handle_t handleIn,
587  Role_t roleIn,
588  PeerAddressType_t peerAddrTypeIn,
589  const uint8_t *peerAddrIn,
590  BLEProtocol::AddressType_t ownAddrTypeIn,
591  const uint8_t *ownAddrIn,
592  const ConnectionParams_t *connectionParamsIn,
593  const uint8_t *peerResolvableAddrIn = NULL,
594  const uint8_t *localResolvableAddrIn = NULL
595  );
596 
597  /**
598  * Construct an instance of ConnectionCallbackParams_t.
599  *
600  * @param[in] handleIn Value to assign to handle.
601  * @param[in] roleIn Value to assign to role.
602  * @param[in] peerAddrTypeIn Value to assign to peerAddrType.
603  * @param[in] peerAddrIn Value to assign to peerAddr.
604  * @param[in] ownAddrTypeIn Value to assign to ownAddrType.
605  * @param[in] ownAddrIn Value to assign to ownAddr.
606  * @param[in] connectionParamsIn Value to assign to connectionParams.
607  * @param[in] peerResolvableAddrIn Value to assign to peerResolvableAddr.
608  * @param[in] localResolvableAddrIn Value to assign to localResolvableAddr.
609  *
610  * @note Constructor is not meant to be called by user code.
611  * The BLE API vendor code generates ConnectionCallbackParams_t.
612  *
613  * @deprecated The type BLEProtocol::AddressType_t is not suitable when
614  * privacy is enabled. Use the constructor that accepts a
615  * PeerAddressType_t instead.
616  */
618  "mbed-os-5.9.0",
619  "The type BLEProtocol::AddressType_t is not suitable when privacy is "
620  "enabled. Use the constructor that accepts a PeerAddressType_t instead."
621  )
622  ConnectionCallbackParams_t(
623  Handle_t handleIn,
624  Role_t roleIn,
625  BLEProtocol::AddressType_t peerAddrTypeIn,
626  const uint8_t *peerAddrIn,
627  BLEProtocol::AddressType_t ownAddrTypeIn,
628  const uint8_t *ownAddrIn,
629  const ConnectionParams_t *connectionParamsIn,
630  const uint8_t *peerResolvableAddrIn = NULL,
631  const uint8_t *localResolvableAddrIn = NULL
632  );
633 
634  private:
635  void constructor_helper(
636  const uint8_t *peerAddrIn,
637  const uint8_t *ownAddrIn,
638  const uint8_t *peerResolvableAddrIn,
639  const uint8_t *localResolvableAddrIn
640  );
641  };
642 
643  /**
644  * Disconnection event.
645  *
646  * Instances of this event are passed to callbacks registered with
647  * Gap::onDisconnection() when a connection ends.
648  *
649  * @note Constructor is not meant to be called by user code.
650  * The BLE API vendor code generates ConnectionCallbackParams_t.
651  */
653  /**
654  * ID of the connection that has ended.
655  */
656  Handle_t handle;
657 
658  /**
659  * Reason of the disconnection.
660  */
662 
663  /**
664  * Construct a DisconnectionCallbackParams_t.
665  *
666  * @param[in] handleIn Value assigned to handle.
667  * @param[in] reasonIn Value assigned to reason.
668  */
670  Handle_t handleIn,
671  DisconnectionReason_t reasonIn
672  ) : handle(handleIn),
673  reason(reasonIn)
674  {
675  }
676  };
677 
678  /**
679  * @copydoc ble::peripheral_privacy_configuration_t
680  */
682 
683  /**
684  * @copydoc ble::central_privay_configuration_t
685  */
687 
688  /**
689  * Number of microseconds in 1.25 milliseconds.
690  */
691  static const uint16_t UNIT_1_25_MS = 1250;
692 
693  /**
694  * Convert milliseconds into 1.25ms units.
695  *
696  * This function may be used to convert ms time of connection intervals into
697  * the format expected for connection parameters.
698  *
699  * @param[in] durationInMillis The duration in milliseconds.
700  *
701  * @return The duration in unit of 1.25ms.
702  */
703  static uint16_t MSEC_TO_GAP_DURATION_UNITS(uint32_t durationInMillis)
704  {
705  return (durationInMillis * 1000) / UNIT_1_25_MS;
706  }
707 
708  /**
709  * Timeout event handler.
710  *
711  * @see Gap::onTimeout().
712  */
714 
715  /**
716  * Callchain of timeout event handlers.
717  *
718  * @see Gap::onTimeout().
719  */
722 
723  /**
724  * Connection event handler.
725  *
726  * @see Gap::onConnection().
727  */
730 
731  /**
732  * Callchain of connection event handlers.
733  *
734  * @see Gap::onConnection().
735  */
738 
739  /**
740  * Disconnection event handler.
741  *
742  * @see Gap::onDisconnection().
743  */
746 
747  /**
748  * Callchain of disconnection event handlers.
749  *
750  * @see Gap::onDisconnection().
751  */
754 
755  /**
756  * Radio notification event handler.
757  *
758  * @see Gap::onRadioNotification().
759  */
761 
762  /**
763  * Gap shutdown event handler.
764  *
765  * @see Gap::onShutdown().
766  */
768 
769  /**
770  * Callchain of gap shutdown event handler.
771  *
772  * @see Gap::onShutdown().
773  */
776 
777  /*
778  * The following functions are meant to be overridden in the platform-specific subclass.
779  */
780 public:
781  /**
782  * Set the device MAC address and type.
783  *
784  * The address set is used in subsequent GAP operations: scanning,
785  * advertising and connection initiation.
786  *
787  * @param[in] type Type of the address to set.
788  * @param[in] address Value of the address to set. It is ordered in
789  * little endian. This parameter is not considered if the address type
790  * is RANDOM_PRIVATE_RESOLVABLE or RANDOM_PRIVATE_NON_RESOLVABLE. For those
791  * types of address, the BLE API itself generates the address.
792  *
793  * @note Some implementation may refuse to set a new PUBLIC address.
794  * @note Random static address set does not change.
795  *
796  * @deprecated Starting with mbed-os-5.9.0 this function is deprecated and
797  * address management is delegated to implementation. Implementations may or
798  * may not continue to support this function. Compliance with the Bluetooth
799  * specification and unification of behaviour between implementations are
800  * the key reasons behind this change:
801  * - Many implementations do not allow changing of the public address.
802  * Therefore programs relying on this function are not portable across BLE
803  * implementations.
804  * - The Bluetooth specification forbid replacement of the random static
805  * address; this address can be set once and only once: at startup.
806  * Depending on the underlying implementation the random address may or
807  * may not have been set automatically at startup; therefore update of the
808  * Random Static address after ble initialisation may be a fault. As a
809  * result calls to this function were not portable.
810  * Furthermore replacement of the random static address silently
811  * invalidates the bond stored in the secure database.
812 
813  * @return BLE_ERROR_NONE on success.
814  */
816  "mbed-os-5.9.0",
817  "Non portable API, use enablePrivacy to enable use of private addresses"
818  )
819  ble_error_t setAddress(
820  BLEProtocol::AddressType_t type,
821  const BLEProtocol::AddressBytes_t address
822  );
823 
824  /**
825  * Fetch the current address and its type.
826  *
827  * @param[out] typeP Type of the current address set.
828  * @param[out] address Value of the current address.
829  *
830  * @note If privacy is enabled the device address may be unavailable to
831  * application code.
832  *
833  * @return BLE_ERROR_NONE on success.
834  */
835  ble_error_t getAddress(
836  BLEProtocol::AddressType_t *typeP,
837  BLEProtocol::AddressBytes_t address
838  );
839 
840  /**
841  * Return the type of a random address.
842  *
843  * @param[in] address The random address to retrieve the type from. The
844  * address must be ordered in little endian.
845  *
846  * @param[out] addressType Type of the address to fill.
847  *
848  * @return BLE_ERROR_NONE in case of success or BLE_ERROR_INVALID_PARAM if
849  * the address in input was not identifiable as a random address.
850  */
851  static ble_error_t getRandomAddressType(
852  const BLEProtocol::AddressBytes_t address,
853  RandomAddressType_t *addressType
854  );
855 
856 #if BLE_ROLE_BROADCASTER
857  /**
858  * Get the minimum advertising interval in milliseconds, which can be used
859  * for connectable advertising types.
860  *
861  * @return Minimum Advertising interval in milliseconds for connectable
862  * undirected and connectable directed advertising types.
863  */
864  uint16_t getMinAdvertisingInterval(void) const;
865 
866  /**
867  * Get the minimum advertising interval in milliseconds, which can be
868  * used for nonconnectable advertising type.
869  *
870  * @return Minimum Advertising interval in milliseconds for scannable
871  * undirected and nonconnectable undirected event types.
872  */
873  uint16_t getMinNonConnectableAdvertisingInterval(void) const;
874 
875  /**
876  * Get the maximum advertising interval in milliseconds.
877  *
878  * @return Maximum Advertising interval in milliseconds.
879  */
880  uint16_t getMaxAdvertisingInterval(void) const;
881 
882  /**
883  * Stop the ongoing advertising procedure.
884  *
885  * @note The current advertising parameters remain in effect.
886  *
887  * @retval BLE_ERROR_NONE if the advertising procedure has been successfully
888  * stopped.
889  *
890  * @deprecated Deprecated since addition of extended advertising support.
891  * Use stopAdvertising(advertising_handle_t).
892  */
894  "mbed-os-5.11.0",
895  "Deprecated since addition of extended advertising support."
896  "Use stopAdvertising(advertising_handle_t) instead."
897  )
898  ble_error_t stopAdvertising(void);
899 #endif //BLE_ROLE_BROADCASTER
900 #if BLE_ROLE_CENTRAL
901  /**
902  * Initiate a connection to a peer.
903  *
904  * Once the connection is established, a ConnectionCallbackParams_t event is
905  * emitted to handlers that have been registered with onConnection().
906  *
907  * @param[in] peerAddr MAC address of the peer. It must be in LSB format.
908  * @param[in] peerAddrType Address type of the peer. It is usually obtained
909  * from advertising frames.
910  * @param[in] connectionParams Connection parameters to use.
911  * @param[in] scanParams Scan parameters used to find the peer.
912  *
913  * @return BLE_ERROR_NONE if connection establishment procedure is started
914  * successfully. The connectionCallChain (if set) is invoked upon
915  * a connection event.
916  *
917  * @deprecated Deprecated since addition of extended advertising support.
918  * Use connect(target_peer_address_type_t, address_t, ConnectionParameters).
919  */
921  "mbed-os-5.11.0",
922  "Deprecated since addition of extended advertising support."
923  "Use connect(target_peer_address_type_t, address_t, ConnectionParameters) instead."
924  )
925  ble_error_t connect(
926  const BLEProtocol::AddressBytes_t peerAddr,
927  PeerAddressType_t peerAddrType,
928  const ConnectionParams_t *connectionParams,
929  const GapScanningParams *scanParams
930  );
931 
932  /**
933  * Initiate a connection to a peer.
934  *
935  * Once the connection is established, a ConnectionCallbackParams_t event is
936  * emitted to handlers that have been registered with onConnection().
937  *
938  * @param[in] peerAddr MAC address of the peer. It must be in LSB format.
939  * @param[in] peerAddrType Address type of the peer.
940  * @param[in] connectionParams Connection parameters to use.
941  * @param[in] scanParams Scan parameters used to find the peer.
942  *
943  * @deprecated BLEProtocol::AddressType_t is not able to to carry accurate
944  * meaning when privacy is in use. Please Uses the connect overload that
945  * accept a PeerAddressType_t as the peer address type.
946  *
947  * @return BLE_ERROR_NONE if connection establishment procedure is started
948  * successfully. The connectionCallChain (if set) is invoked upon
949  * a connection event.
950  */
952  "mbed-os-5.9.0",
953  "This function won't work if privacy is enabled; You must use the overload "
954  "accepting PeerAddressType_t."
955  )
956  ble_error_t connect(
957  const BLEProtocol::AddressBytes_t peerAddr,
958  BLEProtocol::AddressType_t peerAddrType,
959  const ConnectionParams_t *connectionParams,
960  const GapScanningParams *scanParams
961  );
962 
963  /**
964  * Initiate a connection to a peer.
965  *
966  * @see connect()
967  *
968  * @deprecated This funtion overloads Gap::connect(
969  * const BLEProtocol::Address_t peerAddr,
970  * BLEProtocol::AddressType_t peerAddrType,
971  * const ConnectionParams_t *connectionParams,
972  * const GapScanningParams *scanParams
973  * )
974  * to maintain backward compatibility for changes from Gap::AddressType_t to
975  * BLEProtocol::AddressType_t.
976  */
977  MBED_DEPRECATED("Gap::DeprecatedAddressType_t is deprecated, use BLEProtocol::AddressType_t instead")
978  ble_error_t connect(
979  const BLEProtocol::AddressBytes_t peerAddr,
980  DeprecatedAddressType_t peerAddrType,
981  const ConnectionParams_t *connectionParams,
982  const GapScanningParams *scanParams
983  );
984 #endif // BLE_ROLE_CENTRAL
985 
986 #if BLE_FEATURE_CONNECTABLE
987  /**
988  * Initiate a disconnection procedure.
989  *
990  * Once the disconnection procedure has completed a
991  * DisconnectionCallbackParams_t, the event is emitted to handlers that
992  * have been registered with onDisconnection().
993  *
994  * @param[in] reason Reason of the disconnection transmitted to the peer.
995  * @param[in] connectionHandle Handle of the connection to end.
996  *
997  * @return BLE_ERROR_NONE if the disconnection procedure successfully
998  * started.
999  *
1000  * @deprecated Deprecated since addition of extended advertising support.
1001  * Use disconnect(connection_handle_t, local_disconnection_reason_t) instead.
1002  */
1004  "mbed-os-5.11.0",
1005  "Deprecated since addition of extended advertising support."
1006  "Use disconnect(connection_handle_t, local_disconnection_reason_t) instead."
1007  )
1008  ble_error_t disconnect(
1009  Handle_t connectionHandle, DisconnectionReason_t reason
1010  );
1011 
1012  /**
1013  * Initiate a disconnection procedure.
1014  *
1015  * @deprecated This version of disconnect() doesn't take a connection handle.
1016  * It works reliably only for stacks that are limited to a single connection.
1017  * Use Gap::disconnect(Handle_t connectionHandle, DisconnectionReason_t reason)
1018  * instead.
1019  *
1020  * @param[in] reason The reason for disconnection; to be sent back to the peer.
1021  *
1022  * @return BLE_ERROR_NONE if disconnection was successful.
1023  */
1024  MBED_DEPRECATED("Use disconnect(Handle_t, DisconnectionReason_t) instead.")
1025  ble_error_t disconnect(DisconnectionReason_t reason);
1026 
1027 public:
1028 
1029  /**
1030  * Returned the preferred connection parameters exposed in the GATT Generic
1031  * Access Service.
1032  *
1033  * @param[out] params Structure where the parameters are stored.
1034  *
1035  * @return BLE_ERROR_NONE if the parameters were successfully filled into
1036  * @p params.
1037  */
1038  ble_error_t getPreferredConnectionParams(ConnectionParams_t *params);
1039 
1040  /**
1041  * Set the value of the preferred connection parameters exposed in the GATT
1042  * Generic Access Service.
1043  *
1044  * A connected peer may read the characteristic exposing these parameters
1045  * and request an update of the connection parameters to accommodate the
1046  * local device.
1047  *
1048  * @param[in] params Value of the preferred connection parameters.
1049  *
1050  * @return BLE_ERROR_NONE if the preferred connection params were set
1051  * correctly.
1052  */
1053  ble_error_t setPreferredConnectionParams(
1054  const ConnectionParams_t *params
1055  );
1056 
1057  /**
1058  * Update connection parameters of an existing connection.
1059  *
1060  * In the central role, this initiates a Link Layer connection parameter
1061  * update procedure. In the peripheral role, this sends the corresponding
1062  * L2CAP request and waits for the central to perform the procedure.
1063  *
1064  * @param[in] handle Connection Handle.
1065  * @param[in] params Pointer to desired connection parameters.
1066  *
1067  * @return BLE_ERROR_NONE if the connection parameters were updated correctly.
1068  *
1069  * @deprecated Deprecated since addition of extended advertising support.
1070  * Use updateConnectionParameters(connection_handle_t, conn_interval_t,
1071  * conn_interval_t, slave_latency_t, supervision_timeout_t,
1072  * conn_event_length_t, conn_event_length_t) instead.
1073  */
1075  "mbed-os-5.11.0",
1076  "Deprecated since addition of extended advertising support."
1077  "Use updateConnectionParameters(connection_handle_t, conn_interval_t, "
1078  "conn_interval_t, slave_latency_t, supervision_timeout_t, "
1079  "conn_event_length_t, conn_event_length_t) instead."
1080  )
1081  ble_error_t updateConnectionParams(
1082  Handle_t handle,
1083  const ConnectionParams_t *params
1084  );
1085 #endif // BLE_FEATURE_CONNECTABLE
1086 #if BLE_FEATURE_GATT_SERVER
1087  /**
1088  * Set the value of the device name characteristic in the Generic Access
1089  * Service.
1090  *
1091  * @param[in] deviceName The new value for the device-name. This is a
1092  * UTF-8 encoded, <b>NULL-terminated</b> string.
1093  *
1094  * @return BLE_ERROR_NONE if the device name was set correctly.
1095  */
1096  ble_error_t setDeviceName(const uint8_t *deviceName);
1097 
1098  /**
1099  * Get the value of the device name characteristic in the Generic Access
1100  * Service.
1101  *
1102  * To obtain the length of the deviceName value, this function is
1103  * invoked with the @p deviceName parameter set to NULL.
1104  *
1105  * @param[out] deviceName Pointer to an empty buffer where the UTF-8
1106  * <b>non NULL-terminated</b> string is placed.
1107  *
1108  * @param[in,out] lengthP Length of the @p deviceName buffer. If the device
1109  * name is successfully copied, then the length of the device name
1110  * string (excluding the null terminator) replaces this value.
1111  *
1112  * @return BLE_ERROR_NONE if the device name was fetched correctly from the
1113  * underlying BLE stack.
1114  *
1115  * @note If the device name is longer than the size of the supplied buffer,
1116  * length returns the complete device name length and not the number of
1117  * bytes actually returned in deviceName. The application may use this
1118  * information to retry with a suitable buffer size.
1119  */
1120  ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP);
1121 
1122  /**
1123  * Set the value of the appearance characteristic in the GAP service.
1124  *
1125  * @param[in] appearance The new value for the device-appearance.
1126  *
1127  * @return BLE_ERROR_NONE if the new appearance was set correctly.
1128  */
1129  ble_error_t setAppearance(GapAdvertisingData::Appearance appearance);
1130 
1131  /**
1132  * Get the value of the appearance characteristic in the GAP service.
1133  *
1134  * @param[out] appearanceP The current device-appearance value.
1135  *
1136  * @return BLE_ERROR_NONE if the device-appearance was fetched correctly
1137  * from the underlying BLE stack.
1138  */
1139  ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP);
1140 #endif // BLE_FEATURE_GATT_SERVER
1141 
1142  /**
1143  * Set the radio's transmit power.
1144  *
1145  * @param[in] txPower Radio's transmit power in dBm.
1146  *
1147  * @return BLE_ERROR_NONE if the new radio's transmit power was set
1148  * correctly.
1149  *
1150  * @deprecated Deprecated since addition of extended advertising support.
1151  * See ble::AdvertisingParameters and setAdvertisingParameters.
1152  */
1154  "mbed-os-5.11.0",
1155  "Deprecated since addition of extended advertising support."
1156  "See ble::AdvertisingParameters and setAdvertisingParameters."
1157  )
1158  ble_error_t setTxPower(int8_t txPower);
1159 
1160  /**
1161  * Query the underlying stack for allowed Tx power values.
1162  *
1163  * @param[out] valueArrayPP Receive the immutable array of Tx values.
1164  * @param[out] countP Receive the array's size.
1165  *
1166  * @deprecated Deprecated since addition of extended advertising support.
1167  */
1169  "mbed-os-5.11.0",
1170  "Deprecated since addition of extended advertising support."
1171  )
1172  void getPermittedTxPowerValues(
1173  const int8_t **valueArrayPP, size_t *countP
1174  );
1175 
1176 #if BLE_FEATURE_WHITELIST
1177  /**
1178  * Get the maximum size of the whitelist.
1179  *
1180  * @return Maximum size of the whitelist.
1181  *
1182  * @note If using Mbed OS, you can configure the size of the whitelist by
1183  * setting the YOTTA_CFG_WHITELIST_MAX_SIZE macro in your yotta config file.
1184  */
1185  uint8_t getMaxWhitelistSize(void) const;
1186 
1187  /**
1188  * Get the Link Layer to use the internal whitelist when scanning,
1189  * advertising or initiating a connection depending on the filter policies.
1190  *
1191  * @param[in,out] whitelist Define the whitelist instance which is used
1192  * to store the whitelist requested. In input, the caller provisions memory.
1193  *
1194  * @return BLE_ERROR_NONE if the implementation's whitelist was successfully
1195  * copied into the supplied reference.
1196  */
1197  ble_error_t getWhitelist(Whitelist_t &whitelist) const;
1198 
1199  /**
1200  * Set the value of the whitelist to be used during GAP procedures.
1201  *
1202  * @param[in] whitelist A reference to a whitelist containing the addresses
1203  * to be copied to the internal whitelist.
1204  *
1205  * @return BLE_ERROR_NONE if the implementation's whitelist was successfully
1206  * populated with the addresses in the given whitelist.
1207  *
1208  * @note The whitelist must not contain addresses of type @ref
1209  * BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE. This
1210  * results in a @ref BLE_ERROR_INVALID_PARAM because the remote peer might
1211  * change its private address at any time, and it is not possible to resolve
1212  * it.
1213  *
1214  * @note If the input whitelist is larger than @ref getMaxWhitelistSize(),
1215  * then @ref BLE_ERROR_PARAM_OUT_OF_RANGE is returned.
1216  */
1217  ble_error_t setWhitelist(const Whitelist_t &whitelist);
1218 
1219  /**
1220  * Set the advertising policy filter mode to be used during the next
1221  * advertising procedure.
1222  *
1223  * @param[in] mode New advertising policy filter mode.
1224  *
1225  * @return BLE_ERROR_NONE if the specified policy filter mode was set
1226  * successfully.
1227  *
1228  * @deprecated Deprecated since addition of extended advertising support.
1229  * This setting is now part of ble::AdvertisingParameters.
1230  */
1232  "mbed-os-5.11.0",
1233  "Deprecated since addition of extended advertising support."
1234  "This setting is now part of ble::AdvertisingParameters."
1235  )
1236  ble_error_t setAdvertisingPolicyMode(AdvertisingPolicyMode_t mode);
1237 
1238  /**
1239  * Set the scan policy filter mode to be used during the next scan procedure.
1240  *
1241  * @param[in] mode New scan policy filter mode.
1242  *
1243  * @return BLE_ERROR_NONE if the specified policy filter mode was set
1244  * successfully.
1245  *
1246  * @deprecated Deprecated since addition of extended advertising support.
1247  * This setting is now part of ble::ScanParameters.
1248  */
1250  "mbed-os-5.11.0",
1251  "Deprecated since addition of extended advertising support."
1252  "This setting is now part of ble::ScanParameters."
1253  )
1254  ble_error_t setScanningPolicyMode(ScanningPolicyMode_t mode);
1255 
1256  /**
1257  * Set the initiator policy filter mode to be used during the next connection
1258  * initiation.
1259  *
1260  * @param[in] mode New initiator policy filter mode.
1261  *
1262  * @return BLE_ERROR_NONE if the specified policy filter mode was set
1263  * successfully.
1264  *
1265  * @deprecated Deprecated since addition of extended advertising support.
1266  * This setting is now part of ble::ConnectionParameters.
1267  */
1269  "mbed-os-5.11.0",
1270  "Deprecated since addition of extended advertising support."
1271  "This setting is now part of ble::ConnectionParameters."
1272  )
1273  ble_error_t setInitiatorPolicyMode(InitiatorPolicyMode_t mode);
1274 
1275  /**
1276  * Get the current advertising policy filter mode.
1277  *
1278  * @return The current advertising policy filter mode.
1279  *
1280  * @deprecated Deprecated since addition of extended advertising support.
1281  */
1283  "mbed-os-5.11.0",
1284  "Deprecated since addition of extended advertising support."
1285  )
1286  AdvertisingPolicyMode_t getAdvertisingPolicyMode(void) const;
1287 
1288  /**
1289  * Get the current scan policy filter mode.
1290  *
1291  * @return The current scan policy filter mode.
1292  *
1293  * @deprecated Deprecated since addition of extended advertising support.
1294  */
1296  "mbed-os-5.11.0",
1297  "Deprecated since addition of extended advertising support."
1298  )
1299  ScanningPolicyMode_t getScanningPolicyMode(void) const;
1300 
1301  /**
1302  * Get the current initiator policy filter mode.
1303  *
1304  * @return The current scan policy filter mode.
1305  *
1306  * @deprecated Deprecated since addition of extended advertising support.
1307  */
1309  "mbed-os-5.11.0",
1310  "Deprecated since addition of extended advertising support."
1311  )
1312  InitiatorPolicyMode_t getInitiatorPolicyMode(void) const;
1313 #endif // BLE_FEATURE_WHITELIST
1314 
1315 protected:
1316 #if BLE_ROLE_OBSERVER
1317  /* Override the following in the underlying adaptation layer to provide the
1318  functionality of scanning. */
1319 
1320  /**
1321  * Start scanning procedure in the underlying BLE stack.
1322  *
1323  * @param[in] scanningParams Parameters of the scan procedure.
1324  *
1325  * @return BLE_ERROR_NONE if the scan procedure was successfully started.
1326  *
1327  * @deprecated Deprecated since addition of extended advertising support.
1328  * Vendors should use the Cordio HCI interface or the ble::pal or implement
1329  * startScan(duplicates_filter_t, scan_duration_t, period)
1330  */
1332  "mbed-os-5.11.0",
1333  "Deprecated since addition of extended advertising support. "
1334  "Vendors should use the cordio hci interface or the ble::pal or "
1335  "implement startScan(duplicates_filter_t, scan_duration_t, period)"
1336  )
1337  ble_error_t startRadioScan(const GapScanningParams &scanningParams);
1338 #endif // BLE_ROLE_OBSERVER
1339 
1340  /*
1341  * APIs with nonvirtual implementations.
1342  */
1343 public:
1344  /**
1345  * Get the current advertising and connection states of the device.
1346  *
1347  * @return The current GAP state of the device.
1348  *
1349  * @deprecated Deprecated since addition of extended advertising support.
1350  * This is not meaningful when you use extended advertising; Please replace
1351  * getState().advertising with isAdvertisingActive(), and replace
1352  * getState().connected with your own record and update during callbacks.
1353  */
1355  "mbed-os-5.11.0",
1356  "Deprecated since addition of extended advertising support. "
1357  "Replace getState().advertising with isAdvertisingActive()."
1358  "Replace getState().connected with your own record and update during callbacks."
1359  )
1360  GapState_t getState(void) const;
1361 
1362 #if BLE_ROLE_BROADCASTER
1363  /**
1364  * Set the advertising type to use during the advertising procedure.
1365  *
1366  * @param[in] advType New type of advertising to use.
1367  *
1368  * @deprecated Deprecated since addition of extended advertising support.
1369  * This option is now part of ble::AdvertisingParameters.
1370  */
1372  "mbed-os-5.11.0",
1373  "Deprecated since addition of extended advertising support. "
1374  "This option is now part of ble::AdvertisingParameters"
1375  )
1376  void setAdvertisingType(GapAdvertisingParams::AdvertisingType_t advType);
1377 
1378  /**
1379  * Set the advertising interval.
1380  *
1381  * @param[in] interval Advertising interval in units of milliseconds.
1382  * Advertising is disabled if interval is 0. If interval is smaller than
1383  * the minimum supported value, then the minimum supported value is used
1384  * instead. This minimum value can be discovered using
1385  * getMinAdvertisingInterval().
1386  *
1387  * This field must be set to 0 if connectionMode is equal
1388  * to ADV_CONNECTABLE_DIRECTED.
1389  *
1390  * @note Decreasing this value allows central devices to detect a
1391  * peripheral faster, at the expense of the radio using more power
1392  * due to the higher data transmit rate.
1393  *
1394  * @deprecated Deprecated since addition of extended advertising support.
1395  * This option is now part of ble::AdvertisingParameters.
1396  */
1398  "mbed-os-5.11.0",
1399  "Deprecated since addition of extended advertising support. "
1400  "This option is now part of ble::AdvertisingParameters"
1401  )
1402  void setAdvertisingInterval(uint16_t interval);
1403 
1404  /**
1405  * Set the advertising duration.
1406  *
1407  * A timeout event is genenerated once the advertising period expired.
1408  *
1409  * @param[in] timeout Advertising timeout (in seconds) between 0x1 and 0x3FFF.
1410  * The special value 0 may be used to disable the advertising timeout.
1411  *
1412  * @deprecated Deprecated since addition of extended advertising support.
1413  * This option is now part of ble::AdvertisingParameters.
1414  */
1416  "mbed-os-5.11.0",
1417  "Deprecated since addition of extended advertising support. "
1418  "This option is now part of ble::AdvertisingParameters"
1419  )
1420  void setAdvertisingTimeout(uint16_t timeout);
1421 
1422  /**
1423  * Start the advertising procedure.
1424  *
1425  * @return BLE_ERROR_NONE if the device started advertising successfully.
1426  *
1427  * @deprecated Deprecated since addition of extended advertising support.
1428  * Use startAdvertising(advertising_handle_t, adv_duration_t, uint8_t) instead.
1429  */
1431  "mbed-os-5.11.0",
1432  "Deprecated since addition of extended advertising support. "
1433  "Use startAdvertising(advertising_handle_t, adv_duration_t, uint8_t) instead."
1434  )
1435  ble_error_t startAdvertising(void);
1436 
1437  /**
1438  * Reset the value of the advertising payload advertised.
1439  *
1440  * @deprecated Deprecated since addition of extended advertising support.
1441  * Use setAdvertisingPayload(ble::advertising_handle_t, Span<uint8_t>,
1442  * bool).
1443  */
1445  "mbed-os-5.11.0",
1446  "Deprecated since addition of extended advertising support. "
1447  "Use setAdvertisingPayload(ble::advertising_handle_t, Span<uint8_t>,"
1448  "bool)."
1449  )
1450  void clearAdvertisingPayload(void);
1451 
1452  /**
1453  * Set gap flags in the advertising payload.
1454  *
1455  * A call to this function is equivalent to:
1456  *
1457  * @code
1458  * Gap &gap;
1459  *
1460  * GapAdvertisingData payload = gap.getAdvertisingPayload();
1461  * payload.addFlags(flags);
1462  * gap.setAdvertisingPayload(payload);
1463  * @endcode
1464  *
1465  * @param[in] flags The flags to be added.
1466  *
1467  * @return BLE_ERROR_NONE if the data was successfully added to the
1468  * advertising payload.
1469  *
1470  * @deprecated Deprecated since addition of extended advertising support.
1471  * Use ble::AdvertisingDataBuilder.
1472  */
1474  "mbed-os-5.11.0",
1475  "Deprecated since addition of extended advertising support."
1476  "Use ble::AdvertisingDataBuilder instead."
1477  )
1478  ble_error_t accumulateAdvertisingPayload(uint8_t flags);
1479 
1480  /**
1481  * Set the appearance field in the advertising payload.
1482  *
1483  * A call to this function is equivalent to:
1484  *
1485  * @code
1486  * Gap &gap;
1487  *
1488  * GapAdvertisingData payload = gap.getAdvertisingPayload();
1489  * payload.addAppearance(app);
1490  * gap.setAdvertisingPayload(payload);
1491  * @endcode
1492  *
1493  * @param[in] app The appearance to advertise.
1494  *
1495  * @return BLE_ERROR_NONE if the data was successfully added to the
1496  * advertising payload.
1497  *
1498  * @deprecated Deprecated since addition of extended advertising support.
1499  * Use ble::AdvertisingDataBuilder instead.
1500  */
1502  "mbed-os-5.11.0",
1503  "Deprecated since addition of extended advertising support. "
1504  "Use ble::AdvertisingDataBuilder instead."
1505  )
1506  ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::Appearance app);
1507 
1508  /**
1509  * Set the Tx Power field in the advertising payload.
1510  *
1511  * A call to this function is equivalent to:
1512  *
1513  * @code
1514  * Gap &gap;
1515  *
1516  * GapAdvertisingData payload = gap.getAdvertisingPayload();
1517  * payload.addTxPower(power);
1518  * gap.setAdvertisingPayload(payload);
1519  * @endcode
1520  *
1521  * @param[in] power Transmit power in dBm used by the controller to advertise.
1522  *
1523  * @return BLE_ERROR_NONE if the data was successfully added to the
1524  * advertising payload.
1525  *
1526  * @deprecated Deprecated since addition of extended advertising support.
1527  * Use ble::AdvertisingDataBuilder instead.
1528  */
1530  "mbed-os-5.11.0",
1531  "Deprecated since addition of extended advertising support. "
1532  "Use ble::AdvertisingDataBuilder instead."
1533  )
1534  ble_error_t accumulateAdvertisingPayloadTxPower(int8_t power);
1535 
1536  /**
1537  * Add a new field in the advertising payload.
1538  *
1539  * A call to this function is equivalent to:
1540  *
1541  * @code
1542  * Gap &gap;
1543  *
1544  * GapAdvertisingData payload = gap.getAdvertisingPayload();
1545  * payload.addData(type, data, len);
1546  * gap.setAdvertisingPayload(payload);
1547  * @endcode
1548  *
1549  * @param[in] type Identity of the field being added.
1550  * @param[in] data Buffer containing the value of the field.
1551  * @param[in] len Length of the data buffer.
1552  *
1553  * @return BLE_ERROR_NONE if the advertisement payload was updated based on
1554  * matching AD type; otherwise, an appropriate error.
1555  *
1556  * @note When the specified AD type is INCOMPLETE_LIST_16BIT_SERVICE_IDS,
1557  * COMPLETE_LIST_16BIT_SERVICE_IDS, INCOMPLETE_LIST_32BIT_SERVICE_IDS,
1558  * COMPLETE_LIST_32BIT_SERVICE_IDS, INCOMPLETE_LIST_128BIT_SERVICE_IDS,
1559  * COMPLETE_LIST_128BIT_SERVICE_IDS or LIST_128BIT_SOLICITATION_IDS the
1560  * supplied value is appended to the values previously added to the payload.
1561  *
1562  * @deprecated Deprecated since addition of extended advertising support.
1563  * Use ble::AdvertisingDataBuilder instead.
1564  */
1566  "mbed-os-5.11.0",
1567  "Deprecated since addition of extended advertising support. "
1568  "Use ble::AdvertisingDataBuilder instead."
1569  )
1570  ble_error_t accumulateAdvertisingPayload(
1571  GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len
1572  );
1573 
1574  /**
1575  * Update a particular field in the advertising payload.
1576  *
1577  * A call to this function is equivalent to:
1578  *
1579  * @code
1580  * Gap &gap;
1581  *
1582  * GapAdvertisingData payload = gap.getAdvertisingPayload();
1583  * payload.updateData(type, data, len);
1584  * gap.setAdvertisingPayload(payload);
1585  * @endcode
1586  *
1587  *
1588  * @param[in] type Id of the field to update.
1589  * @param[in] data data buffer containing the new value of the field.
1590  * @param[in] len Length of the data buffer.
1591  *
1592  * @note If advertisements are enabled, then the update takes effect
1593  * immediately.
1594  *
1595  * @return BLE_ERROR_NONE if the advertisement payload was updated based on
1596  * matching AD type; otherwise, an appropriate error.
1597  *
1598  * @deprecated Deprecated since addition of extended advertising support.
1599  * Use ble::AdvertisingDataBuilder instead.
1600  */
1602  "mbed-os-5.11.0",
1603  "Deprecated since addition of extended advertising support. "
1604  " Use ble::AdvertisingDataBuilder instead."
1605  )
1606  ble_error_t updateAdvertisingPayload(
1607  GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len
1608  );
1609 
1610  /**
1611  * Set the value of the payload advertised.
1612  *
1613  * @param[in] payload A reference to a user constructed advertisement
1614  * payload to set.
1615  *
1616  * @return BLE_ERROR_NONE if the advertisement payload was successfully
1617  * set.
1618  *
1619  * @deprecated Deprecated since addition of extended advertising support.
1620  * Use ble::AdvertisingDataBuilder instead.
1621  */
1623  "mbed-os-5.11.0",
1624  "Deprecated since addition of extended advertising support. "
1625  "Use ble::AdvertisingDataBuilder instead."
1626  )
1627  ble_error_t setAdvertisingPayload(const GapAdvertisingData &payload);
1628 
1629  /**
1630  * Get a reference to the current advertising payload.
1631  *
1632  * @return A reference to the current advertising payload.
1633  *
1634  * @deprecated Deprecated since addition of extended advertising support.
1635  */
1637  "mbed-os-5.11.0",
1638  "Deprecated since addition of extended advertising support."
1639  )
1640  const GapAdvertisingData &getAdvertisingPayload(void) const;
1641 
1642  /**
1643  * Add a new field in the advertising payload.
1644  *
1645  * @param[in] type AD type identifier.
1646  * @param[in] data buffer containing AD data.
1647  * @param[in] len Length of the data buffer.
1648  *
1649  * @return BLE_ERROR_NONE if the data was successfully added to the scan
1650  * response payload.
1651  *
1652  * @deprecated Deprecated since addition of extended advertising support.
1653  * Use createAdvertisingSet().
1654  */
1656  "mbed-os-5.11.0",
1657  "Deprecated since addition of extended advertising support."
1658  "Use ble::AdvertisingDataBuilder instead."
1659  )
1660  ble_error_t accumulateScanResponse(
1661  GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len
1662  );
1663 
1664  /**
1665  * Reset the content of the scan response.
1666  *
1667  * @note This should be followed by a call to Gap::setAdvertisingPayload()
1668  * or Gap::startAdvertising() before the update takes effect.
1669  *
1670  * @deprecated Deprecated since addition of extended advertising support.
1671  * Use setAdvertisingScanResponse().
1672  */
1674  "mbed-os-5.11.0",
1675  "Deprecated since addition of extended advertising support. "
1676  "Use setAdvertisingScanResponse() instead."
1677  )
1678  void clearScanResponse(void);
1679 #endif // BLE_ROLE_BROADCASTER
1680 #if BLE_ROLE_OBSERVER
1681  /**
1682  * Set the parameters used during a scan procedure.
1683  *
1684  * @param[in] interval in ms between the start of two consecutive scan windows.
1685  * That value is greater or equal to the scan window value. The
1686  * maximum allowed value is 10.24ms.
1687  *
1688  * @param[in] window Period in ms during which the scanner listens to
1689  * advertising channels. That value is in the range 2.5ms to 10.24s.
1690  *
1691  * @param[in] timeout Duration in seconds of the scan procedure if any. The
1692  * special value 0 disable specific duration of the scan procedure.
1693  *
1694  * @param[in] activeScanning If set to true, then the scanner sends scan
1695  * requests to a scannable or connectable advertiser. If set to false, then the
1696  * scanner does not send any request during the scan procedure.
1697  *
1698  * @return BLE_ERROR_NONE if the scan parameters were correctly set.
1699  *
1700  * @note The scanning window divided by the interval determines the duty
1701  * cycle for scanning. For example, if the interval is 100ms and the window
1702  * is 10ms, then the controller scans for 10 percent of the time.
1703  *
1704  * @note If the interval and the window are set to the same value, then the
1705  * device scans continuously during the scan procedure. The scanning
1706  * frequency changes at every interval.
1707  *
1708  * @note Once the scanning parameters have been configured, scanning can be
1709  * enabled by using startScan().
1710  *
1711  * @note The scan interval and window are recommendations to the BLE stack.
1712  *
1713  * @deprecated Deprecated since addition of extended advertising support.
1714  * Use setScanParameters(const ScanParameters &) instead.
1715  */
1717  "mbed-os-5.11.0",
1718  "Deprecated since addition of extended advertising support. "
1719  "Use setScanParameters(const ScanParameters &) instead."
1720  )
1721  ble_error_t setScanParams(
1722  uint16_t interval = GapScanningParams::SCAN_INTERVAL_MAX,
1723  uint16_t window = GapScanningParams::SCAN_WINDOW_MAX,
1724  uint16_t timeout = 0,
1725  bool activeScanning = false
1726  );
1727 
1728  /**
1729  * Set the parameters used during a scan procedure.
1730  *
1731  * @param[in] scanningParams Parameter struct containing the interval, period,
1732  * timeout and active scanning toggle.
1733  *
1734  * @return BLE_ERROR_NONE if the scan parameters were correctly set.
1735  *
1736  * @note All restrictions from setScanParams(uint16_t, uint16_t, uint16_t, bool) apply.
1737  *
1738  * @deprecated Deprecated since addition of extended advertising support.
1739  * Use setScanParameters(const ScanParameters &) instead.
1740  */
1742  "mbed-os-5.11.0",
1743  "Deprecated since addition of extended advertising support. "
1744  "Use setScanParameters(const ScanParameters &) instead."
1745  )
1746  ble_error_t setScanParams(const GapScanningParams &scanningParams);
1747 
1748  /**
1749  * Set the interval parameter used during scanning procedures.
1750  *
1751  * @param[in] interval Interval in ms between the start of two consecutive
1752  * scan windows. That value is greater or equal to the scan window value.
1753  * The maximum allowed value is 10.24ms.
1754  *
1755  * @return BLE_ERROR_NONE if the scan interval was correctly set.
1756  *
1757  * @deprecated Deprecated since addition of extended advertising support.
1758  * Use setScanParameters(const ScanParameters &) instead.
1759  */
1761  "mbed-os-5.11.0",
1762  "Deprecated since addition of extended advertising support. "
1763  "Use setScanParameters(const ScanParameters &) instead."
1764  )
1765  ble_error_t setScanInterval(uint16_t interval);
1766 
1767  /**
1768  * Set the window parameter used during scanning procedures.
1769  *
1770  * @param[in] window Period in ms during which the scanner listens to
1771  * advertising channels. That value is in the range 2.5ms to 10.24s.
1772  *
1773  * @return BLE_ERROR_NONE if the scan window was correctly set.
1774  *
1775  * @note If scanning is already active, the updated value of scanWindow
1776  * is propagated to the underlying BLE stack.
1777  *
1778  * @deprecated Deprecated since addition of extended advertising support.
1779  * Use setScanParameters(const ScanParameters &) instead.
1780  */
1782  "mbed-os-5.11.0",
1783  "Deprecated since addition of extended advertising support. "
1784  "Use setScanParameters(const ScanParameters &) instead."
1785  )
1786  ble_error_t setScanWindow(uint16_t window);
1787 
1788  /**
1789  * Set the timeout parameter used during scanning procedures.
1790  *
1791  * @param[in] timeout Duration in seconds of the scan procedure if any. The
1792  * special value 0 disables specific duration of the scan procedure.
1793  *
1794  * @return BLE_ERROR_NONE if the scan timeout was correctly set.
1795  *
1796  * @note If scanning is already active, the updated value of scanTimeout
1797  * is propagated to the underlying BLE stack.
1798  *
1799  * @deprecated Deprecated since addition of extended advertising support.
1800  * Use setScanParameters(const ScanParameters &) instead.
1801  */
1803  "mbed-os-5.11.0",
1804  "Deprecated since addition of extended advertising support. "
1805  "Use setScanParameters(const ScanParameters &) instead."
1806  )
1807  ble_error_t setScanTimeout(uint16_t timeout);
1808 
1809  /**
1810  * Enable or disable active scanning.
1811  *
1812  * @param[in] activeScanning If set to true, then the scanner sends scan
1813  * requests to a scannable or connectable advertiser. If set to false then the
1814  * scanner does not send any request during the scan procedure.
1815  *
1816  * @return BLE_ERROR_NONE if active scanning was successfully set.
1817  *
1818  * @note If scanning is already in progress, then active scanning is
1819  * enabled for the underlying BLE stack.
1820  *
1821  * @deprecated Deprecated since addition of extended advertising support.
1822  * Use setScanParameters(const ScanParameters &) instead.
1823  */
1825  "mbed-os-5.11.0",
1826  "Deprecated since addition of extended advertising support. "
1827  "Use setScanParameters(const ScanParameters &) instead."
1828  )
1829  ble_error_t setActiveScanning(bool activeScanning);
1830 
1831  /**
1832  * Start the scanning procedure.
1833  *
1834  * Packets received during the scan procedure are forwarded to the
1835  * scan packet handler passed as argument to this function.
1836  *
1837  * @param[in] callback Advertisement packet event handler. Upon reception
1838  * of an advertising packet, the packet is forwarded to @p callback.
1839  *
1840  * @return BLE_ERROR_NONE if the device successfully started the scan
1841  * procedure.
1842  *
1843  * @note The parameters used by the procedure are defined by setScanParams().
1844  *
1845  * @deprecated Deprecated since addition of extended advertising support.
1846  * Use startScan(duplicates_filter_t, scan_duration_t, scan_period_t) instead.
1847  */
1849  "mbed-os-5.11.0",
1850  "Deprecated since addition of extended advertising support. "
1851  "Use startScan(duplicates_filter_t, scan_duration_t, scan_period_t) instead."
1852  )
1853  ble_error_t startScan(
1854  void (*callback)(const AdvertisementCallbackParams_t *params)
1855  );
1856 
1857  /**
1858  * Start the scanning procedure.
1859  *
1860  * Packets received during the scan procedure are forwarded to the
1861  * scan packet handler passed as argument to this function.
1862  *
1863  * @param[in] object Instance used to invoke @p callbackMember.
1864  *
1865  * @param[in] callbackMember Advertisement packet event handler. Upon
1866  * reception of an advertising packet, the packet is forwarded to @p
1867  * callback invoked from @p object.
1868  *
1869  * @return BLE_ERROR_NONE if the device successfully started the scan
1870  * procedure.
1871  *
1872  * @note The parameters used by the procedure are defined by setScanParams().
1873  *
1874  * @deprecated Deprecated since addition of extended advertising support.
1875  * Use createAdvertisingSet().
1876  *
1877  * @deprecated Deprecated since addition of extended advertising support.
1878  * Use startScan(duplicates_filter_t, scan_duration_t, scan_period_t) instead.
1879  */
1880  template<typename T>
1882  "mbed-os-5.11.0",
1883  "Deprecated since addition of extended advertising support. "
1884  "Use startScan(duplicates_filter_t, scan_duration_t, scan_period_t) instead."
1885  )
1886  ble_error_t startScan(
1887  T *object,
1888  void (T::*callbackMember)(const AdvertisementCallbackParams_t *params)
1889  );
1890 #endif // BLE_ROLE_OBSERVER
1891 
1892  /**
1893  * Enable radio-notification events.
1894  *
1895  * Radio Notification is a feature that notifies the application when the
1896  * radio is in use.
1897  *
1898  * The ACTIVE signal is sent before the radio event starts. The nACTIVE
1899  * signal is sent at the end of the radio event. The application programmer can
1900  * use these signals to synchronize application logic with radio
1901  * activity. For example, the ACTIVE signal can be used to shut off external
1902  * devices, to manage peak current drawn during periods when the radio is on
1903  * or to trigger sensor data collection for transmission in the Radio Event.
1904  *
1905  * @return BLE_ERROR_NONE on successful initialization, otherwise an error code.
1906  *
1907  * @deprecated Deprecated since addition of extended advertising support.
1908  */
1910  "mbed-os-5.11.0",
1911  "Deprecated since addition of extended advertising support. "
1912  )
1913  ble_error_t initRadioNotification(void);
1914 
1915 private:
1916 #if BLE_ROLE_BROADCASTER
1917  /**
1918  * Set the advertising data and scan response in the vendor subsytem.
1919  *
1920  * @param[in] advData Advertising data to set.
1921  * @param[in] scanResponse Scan response to set.
1922  *
1923  * @return BLE_ERROR_NONE if the advertising data was set successfully.
1924  *
1925  * @note Must be implemented in vendor port.
1926  *
1927  * @deprecated Deprecated since addition of extended advertising support.
1928  * Implement setAdvertisingPayload() and setAdvertisingScanResponse() instead.
1929  */
1931  "mbed-os-5.11.0",
1932  "Deprecated since addition of extended advertising support. "
1933  "Implement setAdvertisingPayload() and setAdvertisingScanResponse() instead."
1934  )
1935  ble_error_t setAdvertisingData(
1936  const GapAdvertisingData &advData,
1937  const GapAdvertisingData &scanResponse
1938  );
1939 
1940  /**
1941  * Start the advertising procedure.
1942  *
1943  * @param[in] params Advertising parameters to use.
1944  *
1945  * @return BLE_ERROR_NONE if the advertising procedure successfully
1946  * started.
1947  *
1948  * @note Must be implemented in vendor port.
1949  *
1950  * @deprecated Deprecated since addition of extended advertising support.
1951  * Implement startAdvertising(advertising_handle_t, adv_duration_t, uint8_t)
1952  * instead.
1953  */
1955  "mbed-os-5.11.0",
1956  "Deprecated since addition of extended advertising support. "
1957  "Implement startAdvertising(advertising_handle_t, adv_duration_t, uint8_t)"
1958  "instead."
1959  )
1960  ble_error_t startAdvertising(const GapAdvertisingParams &params);
1961 
1962 public:
1963  /**
1964  * Get the current advertising parameters.
1965  *
1966  * @return A reference to the current advertising parameters.
1967  *
1968  * @deprecated Deprecated since addition of extended advertising support.
1969  */
1971  "mbed-os-5.11.0",
1972  "Deprecated since addition of extended advertising support."
1973  )
1974  GapAdvertisingParams &getAdvertisingParams(void);
1975 
1976  /**
1977  * Const alternative to Gap::getAdvertisingParams().
1978  *
1979  * @return A const reference to the current advertising parameters.
1980  *
1981  * @deprecated Deprecated since addition of extended advertising support.
1982  */
1984  "mbed-os-5.11.0",
1985  "Deprecated since addition of extended advertising support."
1986  )
1987  const GapAdvertisingParams &getAdvertisingParams(void) const;
1988 
1989  /**
1990  * Set the advertising parameters.
1991  *
1992  * @param[in] newParams The new advertising parameters.
1993  *
1994  * @deprecated Deprecated since addition of extended advertising support.
1995  * Use setAdvertisingParameters() instead.
1996  */
1998  "mbed-os-5.11.0",
1999  "Deprecated since addition of extended advertising support."
2000  "Use setAdvertisingParameters() instead."
2001  )
2002  void setAdvertisingParams(const GapAdvertisingParams &newParams);
2003 #endif // BLE_ROLE_BROADCASTER
2004  /* Event handlers. */
2005 public:
2006 
2007  /**
2008  * Register a callback handling timeout events.
2009  *
2010  * @param[in] callback Event handler being registered.
2011  *
2012  * @note A callback may be unregistered using onTimeout().detach(callback).
2013  *
2014  * @see TimeoutSource_t
2015  *
2016  * @deprecated Deprecated since addition of extended advertising support.
2017  * Use setEventHandler() instead.
2018  */
2020  "mbed-os-5.11.0",
2021  "Deprecated since addition of extended advertising support. "
2022  "Use setEventHandler() instead."
2023  )
2024  void onTimeout(TimeoutEventCallback_t callback);
2025 
2026  /**
2027  * Get the callchain of registered timeout event handlers.
2028  *
2029  * @note To register callbacks, use onTimeout().add(callback).
2030  *
2031  * @note To unregister callbacks, use onTimeout().detach(callback).
2032  *
2033  * @return A reference to the timeout event callbacks chain.
2034  *
2035  * @deprecated Deprecated since addition of extended advertising support.
2036  * Use setEventHandler() instead.
2037  */
2039  "mbed-os-5.11.0",
2040  "Deprecated since addition of extended advertising support. "
2041  "Use setEventHandler() instead."
2042  )
2043  TimeoutEventCallbackChain_t &onTimeout();
2044 #if BLE_FEATURE_CONNECTABLE
2045  /**
2046  * Register a callback handling connection events.
2047  *
2048  * @param[in] callback Event handler being registered.
2049  *
2050  * @note A callback may be unregistered using onConnection().detach(callback).
2051  *
2052  * @deprecated Deprecated since addition of extended advertising support.
2053  * Use setEventHandler() instead.
2054  */
2056  "mbed-os-5.11.0",
2057  "Deprecated since addition of extended advertising support. "
2058  "Use setEventHandler() instead."
2059  )
2060  void onConnection(ConnectionEventCallback_t callback);
2061 
2062  /**
2063  * Register a callback handling connection events.
2064  *
2065  * @param[in] tptr Instance used to invoke @p mptr.
2066  * @param[in] mptr Event handler being registered.
2067  *
2068  * @note A callback may be unregistered using onConnection().detach(callback).
2069  *
2070  * @deprecated Deprecated since addition of extended advertising support.
2071  * Use setEventHandler() instead.
2072  */
2073  template<typename T>
2075  "mbed-os-5.11.0",
2076  "Deprecated since addition of extended advertising support. "
2077  "Use setEventHandler() instead."
2078  )
2079  void onConnection(T *tptr, void (T::*mptr)(const ConnectionCallbackParams_t *));
2080 
2081  /**
2082  * Get the callchain of registered connection event handlers.
2083  *
2084  * @note To register callbacks, use onConnection().add(callback).
2085  *
2086  * @note To unregister callbacks, use onConnection().detach(callback).
2087  *
2088  * @return A reference to the connection event callbacks chain.
2089  *
2090  * @deprecated Deprecated since addition of extended advertising support.
2091  * Use setEventHandler() instead.
2092  */
2094  "mbed-os-5.11.0",
2095  "Deprecated since addition of extended advertising support. "
2096  "Use setEventHandler() instead."
2097  )
2098  ConnectionEventCallbackChain_t &onConnection();
2099 
2100  /**
2101  * Register a callback handling disconnection events.
2102  *
2103  * @param[in] callback Event handler being registered.
2104  *
2105  * @note A callback may be unregistered using onDisconnection().detach(callback).
2106  *
2107  * @deprecated Deprecated since addition of extended advertising support.
2108  * Use setEventHandler() instead.
2109  */
2111  "mbed-os-5.11.0",
2112  "Deprecated since addition of extended advertising support. "
2113  "Use setEventHandler() instead."
2114  )
2115  void onDisconnection(DisconnectionEventCallback_t callback);
2116 
2117  /**
2118  * Register a callback handling disconnection events.
2119  *
2120  * @param[in] tptr Instance used to invoke mptr.
2121  * @param[in] mptr Event handler being registered.
2122  *
2123  * @note A callback may be unregistered using onDisconnection().detach(callback).
2124  *
2125  * @deprecated Deprecated since addition of extended advertising support.
2126  * Use setEventHandler() instead.
2127  */
2128  template<typename T>
2130  "mbed-os-5.11.0",
2131  "Deprecated since addition of extended advertising support. "
2132  "Use setEventHandler() instead."
2133  )
2134  void onDisconnection(T *tptr, void (T::*mptr)(const DisconnectionCallbackParams_t *));
2135 
2136  /**
2137  * Get the callchain of registered disconnection event handlers.
2138  *
2139  * @note To register callbacks use onDisconnection().add(callback).
2140  *
2141  * @note To unregister callbacks use onDisconnection().detach(callback).
2142  *
2143  * @return A reference to the disconnection event callbacks chain.
2144  *
2145  * @deprecated Deprecated since addition of extended advertising support.
2146  * Use setEventHandler() instead.
2147  */
2149  "mbed-os-5.11.0",
2150  "Deprecated since addition of extended advertising support. "
2151  "Use setEventHandler() instead."
2152  )
2153  DisconnectionEventCallbackChain_t &onDisconnection();
2154 #endif //BLE_FEATURE_CONNECTABLE
2155  /**
2156  * Set the radio-notification events handler.
2157  *
2158  * Radio Notification is a feature that enables ACTIVE and INACTIVE
2159  * (nACTIVE) signals from the stack that notify the application when the
2160  * radio is in use.
2161  *
2162  * The ACTIVE signal is sent before the radio event starts. The nACTIVE
2163  * signal is sent at the end of the radio event. The application programmer can
2164  * use these signals to synchronize application logic with radio
2165  * activity. For example, the ACTIVE signal can be used to shut off external
2166  * devices, to manage peak current drawn during periods when the radio is on
2167  * or to trigger sensor data collection for transmission in the Radio Event.
2168  *
2169  * @param[in] callback Application handler to be invoked in response to a
2170  * radio ACTIVE/INACTIVE event.
2171  *
2172  * @deprecated Deprecated since addition of extended advertising support.
2173  */
2175  "mbed-os-5.11.0",
2176  "Deprecated since addition of extended advertising support. "
2177  )
2178  void onRadioNotification(void (*callback)(bool param));
2179 
2180  /**
2181  * Set the radio-notification events handler.
2182  *
2183  * @param[in] tptr Instance to be used to invoke mptr.
2184  * @param[in] mptr Application handler to be invoked in response to a
2185  * radio ACTIVE/INACTIVE event.
2186  *
2187  * @deprecated Deprecated since addition of extended advertising support.
2188  * Use setEventHandler() instead.
2189  */
2190  template<typename T>
2192  "mbed-os-5.11.0",
2193  "Deprecated since addition of extended advertising support. "
2194  "Use setEventHandler() instead."
2195  )
2196  void onRadioNotification(T *tptr, void (T::*mptr)(bool));
2197 
2198  /**
2199  * Register a Gap shutdown event handler.
2200  *
2201  * The handler is called when the Gap instance is about to shut down.
2202  * It is usually issued after a call to BLE::shutdown().
2203  *
2204  * @param[in] callback Shutdown event handler to register.
2205  *
2206  * @note To unregister a shutdown event handler, use
2207  * onShutdown().detach(callback).
2208  */
2209  void onShutdown(const GapShutdownCallback_t &callback);
2210 
2211  /**
2212  * Register a Gap shutdown event handler.
2213  *
2214  * @param[in] objPtr Instance used to invoke @p memberPtr.
2215  * @param[in] memberPtr Shutdown event handler to register.
2216  */
2217  template<typename T>
2218  void onShutdown(T *objPtr, void (T::*memberPtr)(const LegacyGap *))
2219  {
2220  shutdownCallChain.add(objPtr, memberPtr);
2221  }
2222 
2223  /**
2224  * Access the callchain of shutdown event handler.
2225  *
2226  * @note To register callbacks, use onShutdown().add(callback).
2227  *
2228  * @note To unregister callbacks, use onShutdown().detach(callback).
2229  *
2230  * @return A reference to the shutdown event callback chain.
2231  */
2232  GapShutdownCallbackChain_t &onShutdown();
2233 
2234 public:
2235  /**
2236  * Reset the Gap instance.
2237  *
2238  * Reset process starts by notifying all registered shutdown event handlers
2239  * that the Gap instance is about to be shut down. Then, it clears all Gap state
2240  * of the associated object and then cleans the state present in the vendor
2241  * implementation.
2242  *
2243  * This function is meant to be overridden in the platform-specific
2244  * subclass. Nevertheless, the subclass only resets its
2245  * state and not the data held in Gap members. This is achieved by a
2246  * call to Gap::reset() from the subclass' reset() implementation.
2247  *
2248  * @return BLE_ERROR_NONE on success.
2249  *
2250  * @note Currently, a call to reset() does not reset the advertising and
2251  * scan parameters to default values.
2252  */
2253  ble_error_t reset(void);
2254 
2255 protected:
2256  /**
2257  * Construct a Gap instance.
2258  */
2259  LegacyGap();
2260 
2261  /* Entry points for the underlying stack to report events back to the user. */
2262 public:
2263  /**
2264  * Notify all registered connection event handlers of a connection event.
2265  *
2266  * @attention This function is meant to be called from the BLE stack specific
2267  * implementation when a connection event occurs.
2268  *
2269  * @param[in] handle Handle of the new connection.
2270  * @param[in] role Role of this BLE device in the connection.
2271  * @param[in] peerAddrType Address type of the connected peer.
2272  * @param[in] peerAddr Address of the connected peer.
2273  * @param[in] ownAddrType Address type this device uses for this
2274  * connection.
2275  * @param[in] ownAddr Address this device uses for this connection. This
2276  * parameter may be NULL if the local address is not available.
2277  * @param[in] connectionParams Parameters of the connection.
2278  * @param[in] peerResolvableAddr Resolvable address used by the peer.
2279  * @param[in] localResolvableAddr resolvable address used by the local device.
2280  *
2281  * @deprecated Deprecated since addition of extended advertising support.
2282  * Use EventHandler::onConnectionComplete() instead.
2283  */
2285  "mbed-os-5.11.0",
2286  "Deprecated since addition of extended advertising support. "
2287  "Use EventHandler::onConnectionComplete() instead"
2288  )
2289  void processConnectionEvent(
2290  Handle_t handle,
2291  Role_t role,
2292  PeerAddressType_t peerAddrType,
2293  const BLEProtocol::AddressBytes_t peerAddr,
2294  BLEProtocol::AddressType_t ownAddrType,
2295  const BLEProtocol::AddressBytes_t ownAddr,
2296  const ConnectionParams_t *connectionParams,
2297  const uint8_t *peerResolvableAddr = NULL,
2298  const uint8_t *localResolvableAddr = NULL
2299  );
2300 
2301  /**
2302  * Notify all registered connection event handlers of a connection event.
2303  *
2304  * @attention This function is meant to be called from the BLE stack specific
2305  * implementation when a connection event occurs.
2306  *
2307  * @param[in] handle Handle of the new connection.
2308  * @param[in] role Role of this BLE device in the connection.
2309  * @param[in] peerAddrType Address type of the connected peer.
2310  * @param[in] peerAddr Address of the connected peer.
2311  * @param[in] ownAddrType Address type this device uses for this
2312  * connection.
2313  * @param[in] ownAddr Address this device uses for this connection.
2314  * @param[in] connectionParams Parameters of the connection.
2315  * @param[in] peerResolvableAddr Resolvable address used by the peer.
2316  * @param[in] localResolvableAddr resolvable address used by the local device.
2317  *
2318  * @deprecated The type BLEProtocol::AddressType_t is not suitable when
2319  * privacy is enabled. Use the overload that accepts a PeerAddressType_t
2320  * instead.
2321  */
2323  "mbed-os-5.9.0",
2324  "The type BLEProtocol::AddressType_t is not suitable when privacy is "
2325  "enabled. Use the overload that accepts a PeerAddressType_t instead."
2326  )
2327  void processConnectionEvent(
2328  Handle_t handle,
2329  Role_t role,
2330  BLEProtocol::AddressType_t peerAddrType,
2331  const BLEProtocol::AddressBytes_t peerAddr,
2332  BLEProtocol::AddressType_t ownAddrType,
2333  const BLEProtocol::AddressBytes_t ownAddr,
2334  const ConnectionParams_t *connectionParams,
2335  const uint8_t *peerResolvableAddr = NULL,
2336  const uint8_t *localResolvableAddr = NULL
2337  );
2338 
2339  /**
2340  * Notify all registered disconnection event handlers of a disconnection event.
2341  *
2342  * @attention This function is meant to be called from the BLE stack specific
2343  * implementation when a disconnection event occurs.
2344  *
2345  * @param[in] handle Handle of the terminated connection.
2346  * @param[in] reason Reason of the disconnection.
2347  *
2348  * @deprecated Deprecated since addition of extended advertising support.
2349  * Use EventHandler::onDisconnection() instead.
2350  */
2352  "mbed-os-5.11.0",
2353  "Deprecated since addition of extended advertising support. "
2354  "Use EventHandler::onDisconnectionComplete() instead"
2355  )
2356  void processDisconnectionEvent(Handle_t handle, DisconnectionReason_t reason);
2357 
2358  /**
2359  * Forward a received advertising packet to all registered event handlers
2360  * listening for scanned packet events.
2361  *
2362  * @attention This function is meant to be called from the BLE stack specific
2363  * implementation when a disconnection event occurs.
2364  *
2365  * @param[in] peerAddr Address of the peer that has emitted the packet.
2366  * @param[in] rssi Value of the RSSI measured for the received packet.
2367  * @param[in] isScanResponse If true, then the packet is a response to a scan
2368  * request.
2369  * @param[in] type Advertising type of the packet.
2370  * @param[in] advertisingDataLen Length of the advertisement data received.
2371  * @param[in] advertisingData Pointer to the advertisement packet's data.
2372  * @param[in] addressType Type of the address of the peer that has emitted
2373  * the packet.
2374  *
2375  * @deprecated Deprecated since addition of extended advertising support.
2376  * Use EventHandler::onAdvertisingReport() instead.
2377  */
2379  "mbed-os-5.11.0",
2380  "Deprecated since addition of extended advertising support. "
2381  "Use EventHandler::onAdvertisingReport() instead"
2382  )
2383  void processAdvertisementReport(
2384  const BLEProtocol::AddressBytes_t peerAddr,
2385  int8_t rssi,
2386  bool isScanResponse,
2388  uint8_t advertisingDataLen,
2389  const uint8_t *advertisingData,
2390  PeerAddressType_t addressType
2391  );
2392 
2393  /**
2394  * Forward a received advertising packet to all registered event handlers
2395  * listening for scanned packet events.
2396  *
2397  * @attention This function is meant to be called from the BLE stack specific
2398  * implementation when a disconnection event occurs.
2399  *
2400  * @param[in] peerAddr Address of the peer that has emitted the packet.
2401  * @param[in] rssi Value of the RSSI measured for the received packet.
2402  * @param[in] isScanResponse If true, then the packet is a response to a scan
2403  * request.
2404  * @param[in] type Advertising type of the packet.
2405  * @param[in] advertisingDataLen Length of the advertisement data received.
2406  * @param[in] advertisingData Pointer to the advertisement packet's data.
2407  * @param[in] addressType Type of the address of the peer that has emitted the packet.
2408  *
2409  * @deprecated The type BLEProtocol::AddressType_t is not suitable when
2410  * privacy is enabled. Use the overload that accepts a PeerAddressType_t
2411  * instead.
2412  */
2414  "mbed-os-5.9.0",
2415  "The type BLEProtocol::AddressType_t is not suitable when privacy is "
2416  "enabled. Use the overload that accepts a PeerAddressType_t instead."
2417  )
2418  void processAdvertisementReport(
2419  const BLEProtocol::AddressBytes_t peerAddr,
2420  int8_t rssi,
2421  bool isScanResponse,
2423  uint8_t advertisingDataLen,
2424  const uint8_t *advertisingData,
2426  );
2427 
2428  /**
2429  * Notify the occurrence of a timeout event to all registered timeout events
2430  * handler.
2431  *
2432  * @attention This function is meant to be called from the BLE stack specific
2433  * implementation when a disconnection event occurs.
2434  *
2435  * @param[in] source Source of the timout event.
2436  *
2437  * @deprecated Deprecated since addition of extended advertising support.
2438  * Use EventHandler instead.
2439  */
2441  "mbed-os-5.11.0",
2442  "Deprecated since addition of extended advertising support. "
2443  "Use EventHandler instead"
2444  )
2445  void processTimeoutEvent(TimeoutSource_t source);
2446 
2447 protected:
2448  /**
2449  * Current advertising parameters.
2450  */
2452 
2453  /**
2454  * Current advertising data.
2455  */
2457 
2458  /**
2459  * Current scanning parameters.
2460  */
2462 
2463  /**
2464  * Current scan response.
2465  */
2467 
2468  /**
2469  * Number of open connections.
2470  */
2472 
2473  /**
2474  * Current GAP state.
2475  */
2477 
2478  /**
2479  * Active scanning flag.
2480  */
2482 
2483 protected:
2484  /**
2485  * Callchain containing all registered callback handlers for timeout
2486  * events.
2487  */
2489 
2490  /**
2491  * The registered callback handler for radio notification events.
2492  */
2493  RadioNotificationEventCallback_t radioNotificationCallback;
2494 
2495  /**
2496  * The registered callback handler for scanned advertisement packet
2497  * notifications.
2498  */
2500 
2501  /**
2502  * Callchain containing all registered callback handlers for connection
2503  * events.
2504  */
2506 
2507  /**
2508  * Callchain containing all registered callback handlers for disconnection
2509  * events.
2510  */
2512 
2513 private:
2514  /**
2515  * Callchain containing all registered callback handlers for shutdown
2516  * events.
2517  */
2518  GapShutdownCallbackChain_t shutdownCallChain;
2519 
2520 private:
2521  /* Disallow copy and assignment. */
2522  LegacyGap(const LegacyGap &);
2523 
2524  LegacyGap &operator=(const LegacyGap &);
2525 
2526 
2527 protected:
2528  using ble::interface::Gap<Impl>::startAdvertising_;
2529  using ble::interface::Gap<Impl>::stopAdvertising_;
2530  using ble::interface::Gap<Impl>::connect_;
2531  using ble::interface::Gap<Impl>::disconnect_;
2532 
2533  /* --- Abstract calls with default implementation --- */
2534  uint16_t getMinAdvertisingInterval_(void) const;
2535 
2536  uint16_t getMinNonConnectableAdvertisingInterval_(void) const;
2537 
2538  uint16_t getMaxAdvertisingInterval_(void) const;
2539 
2540  /* Note: Implementation must call the base class reset_ */
2541  ble_error_t reset_(void);
2542 
2543  /* --- Abstract calls to override --- */
2544 
2545  uint8_t getMaxWhitelistSize_(void) const;
2546 
2547  ble_error_t getWhitelist_(Whitelist_t &whitelist) const;
2548 
2549  ble_error_t setWhitelist_(const Whitelist_t &whitelist);
2550 
2551  ble_error_t setAddress_(
2553  const BLEProtocol::AddressBytes_t address
2554  );
2555 
2556  ble_error_t getAddress_(
2559  );
2560 
2561  ble_error_t stopAdvertising_(void);
2562 
2563  ble_error_t connect_(
2564  const BLEProtocol::AddressBytes_t peerAddr,
2565  PeerAddressType_t peerAddrType,
2566  const ConnectionParams_t *connectionParams,
2567  const GapScanningParams *scanParams
2568  );
2569 
2570  ble_error_t connect_(
2571  const BLEProtocol::AddressBytes_t peerAddr,
2572  BLEProtocol::AddressType_t peerAddrType,
2573  const ConnectionParams_t *connectionParams,
2574  const GapScanningParams *scanParams
2575  );
2576 
2577  ble_error_t disconnect_(
2578  Handle_t connectionHandle, DisconnectionReason_t reason
2579  );
2580 
2581  ble_error_t disconnect_(DisconnectionReason_t reason);
2582 
2583  ble_error_t updateConnectionParams_(
2584  Handle_t handle,
2585  const ConnectionParams_t *params
2586  );
2587 
2588  ble_error_t setTxPower_(int8_t txPower);
2589 
2590  void getPermittedTxPowerValues_(
2591  const int8_t **valueArrayPP, size_t *countP
2592  );
2593 
2594  ble_error_t setAdvertisingPolicyMode_(AdvertisingPolicyMode_t mode);
2595 
2596  ble_error_t setScanningPolicyMode_(ScanningPolicyMode_t mode);
2597 
2598  ble_error_t setInitiatorPolicyMode_(InitiatorPolicyMode_t mode);
2599 
2600  AdvertisingPolicyMode_t getAdvertisingPolicyMode_(void) const;
2601 
2602  ScanningPolicyMode_t getScanningPolicyMode_(void) const;
2603 
2604  InitiatorPolicyMode_t getInitiatorPolicyMode_(void) const;
2605 
2606  ble_error_t startRadioScan_(const GapScanningParams &scanningParams);
2607 
2608  ble_error_t initRadioNotification_(void);
2609 
2610  ble_error_t getPreferredConnectionParams_(ConnectionParams_t *params);
2611 
2612  ble_error_t setPreferredConnectionParams_(
2613  const ConnectionParams_t *params
2614  );
2615 
2616  ble_error_t setDeviceName_(const uint8_t *deviceName);
2617 
2618  ble_error_t getDeviceName_(uint8_t *deviceName, unsigned *lengthP);
2619 
2620  ble_error_t setAppearance_(GapAdvertisingData::Appearance appearance);
2621 
2622  ble_error_t getAppearance_(GapAdvertisingData::Appearance *appearanceP);
2623 
2624  ble_error_t setAdvertisingData_(
2625  const GapAdvertisingData &advData,
2626  const GapAdvertisingData &scanResponse
2627  );
2628 
2629  ble_error_t startAdvertising_(const GapAdvertisingParams &params);
2630 };
2631 
2632 /**
2633  * @}
2634  * @}
2635  */
2636 
2637 /* -------- deprecated template implementation -------- */
2638 
2639 #if defined(__GNUC__) && !defined(__CC_ARM)
2640 #pragma GCC diagnostic push
2641 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
2642 #elif defined(__CC_ARM)
2643 #pragma push
2644 #pragma diag_suppress 1361
2645 #endif
2646 
2647 #if BLE_ROLE_OBSERVER
2648 template<class Impl>
2649 template<typename T>
2650 ble_error_t LegacyGap<Impl>::startScan(
2651  T *object,
2652  void (T::*callbackMember)(const AdvertisementCallbackParams_t *params)
2653 )
2654 {
2656  if (object && callbackMember) {
2657  if ((err = startRadioScan(_scanningParams)) == BLE_ERROR_NONE) {
2658  scanningActive = true;
2659  onAdvertisementReport.attach(object, callbackMember);
2660  }
2661  }
2662 
2663  return err;
2664 }
2665 #endif // BLE_ROLE_OBSERVER
2666 
2667 #if BLE_FEATURE_CONNECTABLE
2668 template<class Impl>
2669 template<typename T>
2670 void LegacyGap<Impl>::onConnection(T *tptr, void (T::*mptr)(const ConnectionCallbackParams_t *))
2671 {
2672  connectionCallChain.add(tptr, mptr);
2673 }
2674 
2675 template<class Impl>
2676 template<typename T>
2677 void LegacyGap<Impl>::onDisconnection(T *tptr, void (T::*mptr)(const DisconnectionCallbackParams_t *))
2678 {
2679  disconnectionCallChain.add(tptr, mptr);
2680 }
2681 #endif //BLE_FEATURE_CONNECTABLE
2682 
2683 template<class Impl>
2684 template<typename T>
2685 void LegacyGap<Impl>::onRadioNotification(T *tptr, void (T::*mptr)(bool))
2686 {
2687  radioNotificationCallback.attach(tptr, mptr);
2688 }
2689 
2690 #if defined(__GNUC__) && !defined(__CC_ARM)
2691 #pragma GCC diagnostic pop
2692 #elif defined(__CC_ARM)
2693 #pragma pop
2694 #endif
2695 
2696 } // interface
2697 } // ble
2698 
2699 // import LegacyGap implementation into global namespace
2700 typedef ble::impl::LegacyGap Gap;
2701 
2702 // import Gap implementation into ble namespace
2703 namespace ble {
2704 typedef impl::Gap Gap;
2705 }
2706 
2707 
2708 #endif // ifndef MBED_BLE_GAP_H__
BLEProtocol::Address_t * addresses
Pointer to the array of the addresses composing the whitelist.
Definition: Gap.h:273
ble::coded_symbol_per_bit_t CodedSymbolPerBit_t
Enumeration of type of symbols that can be used with LE coded PHY.
Definition: Gap.h:334
BLE address representation.
Definition: BLEProtocol.h:115
BLEProtocol::AddressType_t AddressType_t
Address-type for BLEProtocol addresses.
Definition: Gap.h:85
InitiatorPolicyMode_t
Connection initiation policy filter mode.
Definition: Gap.h:253
ble::central_privay_configuration_t CentralPrivacyConfiguration_t
Privacy configuration of the central role.
Definition: Gap.h:686
Function like object adapter over freestanding and member functions.
Common namespace for types and constants used everywhere in BLE API.
Definition: BLEProtocol.h:34
ScanningPolicyMode_t
Scanning policy filter mode.
Definition: Gap.h:236
Define device discovery, connection and link management procedures.
Definition: gap/Gap.h:275
Duration< uint16_t, 10000, Range< 0x00, 0xFFFF >, Value< uint16_t, 0x0000 > > scan_duration_t
Scan process duration.
Definition: Types.h:60
BLEProtocol::AddressBytes_t address_t
48-bit address, LSB format.
Definition: Gap.h:125
GapAdvertisingData _advPayload
Current advertising data.
Definition: Gap.h:2456
uintptr_t connection_handle_t
Opaque reference to a connection.
Definition: BLETypes.h:86
Static Interface helper class.
uint16_t connectionSupervisionTimeout
Link supervision timeout for the connection.
Definition: Gap.h:380
uint8_t advertisingDataLen
Length of the advertisement data.
Definition: Gap.h:447
ble::peer_address_type_t PeerAddressType_t
Enumeration of peer address types.
Definition: Gap.h:319
uint16_t slaveLatency
Number of connection events the slave can drop if it has nothing to communicate to the master...
Definition: Gap.h:364
Duration< uint16_t, 10000, Range< 0x0A, 0x0C80 > > supervision_timeout_t
Time after which a connection is loss of devices have not exchanged data.
Definition: Types.h:98
Type that describes a random device address type.
Definition: BLETypes.h:494
ble::connection_handle_t Handle_t
Opaque value type representing a connection handle.
Definition: Gap.h:309
uint16_t maxConnectionInterval
Maximum interval between two connection events allowed for a connection.
Definition: Gap.h:356
Parameters defining the advertising process.
Type describing the number of symbols per bit in le coded PHY.
Definition: BLETypes.h:808
Random static device address.
Definition: BLEProtocol.h:70
DisconnectionCallbackParams_t(Handle_t handleIn, DisconnectionReason_t reasonIn)
Construct a DisconnectionCallbackParams_t.
Definition: Gap.h:669
TimeoutEventCallbackChain_t timeoutCallbackChain
Callchain containing all registered callback handlers for timeout events.
Definition: Gap.h:2488
CallChainOfFunctionPointersWithContext< const DisconnectionCallbackParams_t * > DisconnectionEventCallbackChain_t
Callchain of disconnection event handlers.
Definition: Gap.h:753
Parameters defining the scan process.
FunctionPointerWithContext< const LegacyGap * > GapShutdownCallback_t
Gap shutdown event handler.
Definition: Gap.h:767
Duration< uint16_t, 1250, Range< 0x06, 0x0C80 > > conn_interval_t
Time interval between two connection events.
Definition: Types.h:89
Connection events.
Definition: Gap.h:495
BLEProtocol::AddressType_t addr_type_t
Address-type for BLEProtocol addresses.
Definition: Gap.h:92
Private resolvable device address.
Definition: BLEProtocol.h:80
Duration< uint16_t, 625, Range< 0, 0xFFFF > > conn_event_length_t
Duration of a connection event.
Definition: Types.h:105
Handle_t handle
Connection handle.
Definition: Gap.h:499
Role_t role
Connection Role of the local device.
Definition: Gap.h:504
static const size_t ADDR_LEN
Length (in octets) of the BLE MAC address.
Definition: BLEProtocol.h:102
No error.
Definition: blecommon.h:151
GAP advertising data builder.
FunctionPointerWithContext< const DisconnectionCallbackParams_t * > DisconnectionEventCallback_t
Disconnection event handler.
Definition: Gap.h:745
Define device discovery, connection and link management procedures.
Definition: Gap.h:52
Callback< R()> callback(R(*func)()=0)
Create a callback class with type inferred from the arguments.
Definition: Callback.h:3848
ConnectionEventCallbackChain_t connectionCallChain
Callchain containing all registered callback handlers for connection events.
Definition: Gap.h:2505
bool scanningActive
Active scanning flag.
Definition: Gap.h:2481
static uint16_t MSEC_TO_GAP_DURATION_UNITS(uint32_t durationInMillis)
Convert milliseconds into 1.25ms units.
Definition: Gap.h:703
Description of the states of the device.
Definition: Gap.h:289
GapState_t state
Current GAP state.
Definition: Gap.h:2476
GapAdvertisingParams _advParams
Current advertising parameters.
Definition: Gap.h:2451
Type that describes a bluetooth PHY(sical) transport.
Definition: BLETypes.h:628
Duration< uint16_t, 1280000, Range< 0x00, 0xFFFF > > scan_period_t
Time interval between two scan processes.
Definition: Types.h:68
DeprecatedAddressType_t
Address-type for BLEProtocol addresses.
Definition: Gap.h:101
BLEProtocol::AddressBytes_t Address_t
48-bit address, LSB format.
Definition: Gap.h:118
ble::phy_t Phy_t
Enumeration of BLE PHY.
Definition: Gap.h:324
bool isScanResponse
Flag indicating if the packet is a response to a scan request.
Definition: Gap.h:437
CallChainOfFunctionPointersWithContext< const LegacyGap * > GapShutdownCallbackChain_t
Callchain of gap shutdown event handler.
Definition: Gap.h:775
Representation of a scanned advertising packet.
Definition: Gap.h:418
uint8_t advertising_handle_t
Handle of an advertising set.
Definition: Types.h:134
int8_t rssi
RSSI value of the packet.
Definition: Gap.h:432
FunctionPointerWithContext< bool > RadioNotificationEventCallback_t
Radio notification event handler.
Definition: Gap.h:760
Parameters of a BLE connection.
Definition: Gap.h:339
CallChainOfFunctionPointersWithContext< const ConnectionCallbackParams_t * > ConnectionEventCallbackChain_t
Callchain of connection event handlers.
Definition: Gap.h:737
GapAdvertisingParams::AdvertisingType_t type
Type of advertisement.
Definition: Gap.h:442
ble::phy_set_t PhySet_t
Set of BLE PHYs.
Definition: Gap.h:329
ble::random_address_type_t RandomAddressType_t
Enumeration of random address types.
Definition: Gap.h:314
GapScanningParams _scanningParams
Current scanning parameters.
Definition: Gap.h:2461
DisconnectionReason_t
Enumeration of disconnection reasons.
Definition: Gap.h:161
uint8_t connectionCount
Number of open connections.
Definition: Gap.h:2471
AdvertisingType_t
Encapsulates the peripheral advertising modes.
Type that describes a peer device address type.
Definition: BLETypes.h:580
enum Appearance_t Appearance
Alias for GapAdvertisingData::Appearance_t.
const uint8_t * advertisingData
Pointer to the advertisement packet&#39;s data.
Definition: Gap.h:452
Representation of a whitelist of addresses.
Definition: Gap.h:269
Type that describe a set of PHY(sical) transports.
Definition: BLETypes.h:693
uint16_t minConnectionInterval
Minimum interval between two connection events allowed for a connection.
Definition: Gap.h:347
RadioNotificationEventCallback_t radioNotificationCallback
The registered callback handler for radio notification events.
Definition: Gap.h:2493
DisconnectionEventCallbackChain_t disconnectionCallChain
Callchain containing all registered callback handlers for disconnection events.
Definition: Gap.h:2511
FunctionPointerWithContext< const ConnectionCallbackParams_t * > ConnectionEventCallback_t
Connection event handler.
Definition: Gap.h:729
GapAdvertisingData _scanResponse
Current scan response.
Definition: Gap.h:2466
Bounded< uint16_t, 0, 0x01F3 > slave_latency_t
Number of connection events that can be skipped by the slave.
Definition: Types.h:127
Private non-resolvable device address.
Definition: BLEProtocol.h:90
FunctionPointerWithContext< TimeoutSource_t > TimeoutEventCallback_t
Timeout event handler.
Definition: Gap.h:713
ble::peripheral_privacy_configuration_t PeripheralPrivacyConfiguration_t
Privacy Configuration of the peripheral role.
Definition: Gap.h:681
Privacy configuration of the central role.
Definition: Types.h:910
Handle_t handle
ID of the connection that has ended.
Definition: Gap.h:656
AdvertisementReportCallback_t onAdvertisementReport
The registered callback handler for scanned advertisement packet notifications.
Definition: Gap.h:2499
Disconnection event.
Definition: Gap.h:652
TimeoutSource_t
Enumeration of possible timeout sources.
Definition: Gap.h:131
AdvertisingPolicyMode_t
Advertising policy filter modes.
Definition: Gap.h:209
Privacy Configuration of the peripheral role.
Definition: Types.h:854
Public device address.
Definition: BLEProtocol.h:60
BLEProtocol::AddressBytes_t peerAddr
BLE address of the device that has advertised the packet.
Definition: Gap.h:427
uint8_t AddressBytes_t[ADDR_LEN]
48-bit address, in LSB format.
Definition: BLEProtocol.h:107
uint8_t size
Number addresses in this whitelist.
Definition: Gap.h:278
Entry namespace for all BLE API definitions.
uint8_t capacity
Capacity of the array holding the addresses.
Definition: Gap.h:283
Type
Address-types for Protocol addresses.
Definition: BLEProtocol.h:56
DisconnectionReason_t reason
Reason of the disconnection.
Definition: Gap.h:661
Role_t
Enumeration of GAP roles.
Definition: Gap.h:390
CallChainOfFunctionPointersWithContext< TimeoutSource_t > TimeoutEventCallbackChain_t
Callchain of timeout event handlers.
Definition: Gap.h:721
#define MBED_DEPRECATED_SINCE(D, M)
MBED_DEPRECATED("message string") Mark a function declaration as deprecated, if it used then a warnin...
Duration< uint16_t, 10000, Range< 0x00, 0xFFFF >, Value< uint16_t, 0x0000 > > adv_duration_t
Advertising process duration.
Definition: Types.h:51
ble_error_t
Error codes for the BLE API.
Definition: blecommon.h:147
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.