Mistake on this page?
Report an issue in GitHub or email us
Types.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2006-2020 ARM Limited
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef BLE_GAP_TYPES_H
20 #define BLE_GAP_TYPES_H
21 
22 #include "ble/common/Duration.h"
23 #include "ble/common/Bounded.h"
24 #include "ble/common/SafeEnum.h"
25 
26 namespace ble {
27 
28 /**
29  * @addtogroup ble
30  * @{
31  * @addtogroup gap
32  * @{
33  */
34 
35 /* BLE units, using microseconds as the common denominator */
36 
37 /**
38  * Time interval between two advertisements.
39  *
40  * The duration is in unit of 625µs and ranges from 0x20 to 0xFFFFFF .
41  *
42  * @note before Bluetooth 5 range was 0x20 to 0xFFFF.
43  */
44 typedef Duration<uint32_t, 625, Range<0x20, 0xFFFFFF> > adv_interval_t;
45 
46 /**
47  * Advertising process duration.
48  *
49  * The duration is in unit of 10ms and ranges from 0x0001 to 0xFFFF. The special
50  * value 0x0000 means the advertising process never ends; it is accessible with
51  * adv_duration_t::forever().
52  */
53 typedef Duration<uint16_t, 10000, Range<0x00, 0xFFFF>, /* forever */ Value<uint16_t, 0x0000> > adv_duration_t;
54 
55 /**
56  * Scan process duration.
57  *
58  * The duration is in unit of 10ms and ranges from 0x0001 to 0xFFFF. The special
59  * value 0x0000 means the scan process never ends; it is accessible with
60  * scan_duration_t::forever().
61  */
62 typedef Duration<uint16_t, 10000, Range<0x00, 0xFFFF>, /* forever */ Value<uint16_t, 0x0000> > scan_duration_t;
63 
64 /**
65  * Time interval between two scan processes.
66  *
67  * The duration is in unit of 1.28s and ranges from 0x0001 to 0xFFFF. The special
68  * value 0x0000 is used to indicate that scan_period_t is not used.
69  */
70 typedef Duration<uint16_t, 1280000, Range<0x00, 0xFFFF> > scan_period_t;
71 
72 /**
73  * Time interval between two scans.
74  *
75  * The duration is in unit of 625µs and ranges from 0x04 to 0xFFFF.
76  */
77 typedef Duration<uint16_t, 625, Range<0x04, 0xFFFF> > scan_interval_t;
78 
79 /**
80  * Duration of a scan.
81  *
82  * The duration is in unit of 625µs and ranges from 0x04 to 0xFFFF.
83  */
84 typedef Duration<uint16_t, 625, Range<0x04, 0xFFFF> > scan_window_t;
85 
86 /**
87  * Time interval between two connection events.
88  *
89  * The interval is in unit of 1.250 milliseconds and ranges from 0x06 to 0xC80.
90  */
91 typedef Duration<uint16_t, 1250, Range<0x06, 0x0C80> > conn_interval_t;
92 
93 /**
94  * Time after which a connection is loss of devices have not exchanged data.
95  *
96  * The duration is in unit of 10 milliseconds and ranges from 0x0A to 0xC80.
97  *
98  * @note this time should be no larger than (1 + ConnLatency) * ConnIntervalMax * 2
99  */
100 typedef Duration<uint16_t, 10000, Range<0x0A, 0x0C80> > supervision_timeout_t;
101 
102 /**
103  * Duration of a connection event.
104  *
105  * The duration is in unit of 625µs and ranges from 0x0 to 0xFFFF .
106  */
107 typedef Duration<uint16_t, 625, Range<0, 0xFFFF> > conn_event_length_t;
108 
109 /**
110  * Time after which a periodic sync link is considered lost if the receiver hasn't
111  * received anything from the advertiser.
112  *
113  * The duration is in unit of 10 milliseconds and ranges from 0x0A to 0x4000.
114  */
115 typedef Duration<uint16_t, 10000, Range<0x0A, 0x4000> > sync_timeout_t;
116 
117 /**
118  * Interval between two periodic advertising events.
119  *
120  * The duration is in unit of 1.250ms and ranges from 0x06 to 0xFFFF.
121  */
122 typedef Duration<uint16_t, 1250, Range<0x06, 0xFFFF> > periodic_interval_t;
123 
124 /**
125  * Number of connection events that can be skipped by the slave.
126  *
127  * It ranges from 0 to 0x1F3.
128  */
129 typedef Bounded<uint16_t, 0, 0x01F3> slave_latency_t;
130 
131 /**
132  * Handle of an advertising set.
133  *
134  * @note Range of valid handle is comprised between 0x00 and 0xEF.
135  */
136 typedef uint8_t advertising_handle_t;
137 
138 /**
139  * Handle of a sync representing a periodic advertiser.
140  *
141  * @note Range of valid handle is comprised between 0x0000 and 0xFFFF.
142  */
143 typedef uint16_t periodic_sync_handle_t;
144 
145 /**
146  * Encapsulates the peripheral advertising modes.
147  *
148  * It determines how the device appears to other scanner and peripheral
149  * devices in the scanning range.
150  */
151 struct advertising_type_t : SafeEnum<advertising_type_t, uint8_t> {
152  /// enumeration of advertising_type_t values
153  enum type {
154  /**
155  * Device is connectable, scannable and doesn't expect connection from a
156  * specific peer.
157  * @note Cannot carry extended advertising payload, only legacy PDUs.
158  * Use CONNECTABLE_NON_SCANNABLE_UNDIRECTED for non-legacy payload.
159  *
160  * @see Vol 3, Part C, Section 9.3.4 and Vol 6, Part B, Section 2.3.1.1.
161  */
162  CONNECTABLE_UNDIRECTED = 0x00,
163 
164  /**
165  * Device is connectable and expects connection from a specific peer.
166  * (3.75 ms or smaller Advertising Interval)
167  * @see Vol 3, Part C, Section 9.3.3 and Vol 6, Part B, Section 2.3.1.2.
168  */
169  CONNECTABLE_DIRECTED = 0x01,
170 
171  /**
172  * Device is scannable but not connectable.
173  *
174  * @see Vol 6, Part B, Section 2.3.1.4.
175  */
176  SCANNABLE_UNDIRECTED = 0x02,
177 
178  /**
179  * Device is not connectable and not scannable.
180  *
181  * @see Vol 3, Part C, Section 9.3.2 and Vol 6, Part B, Section 2.3.1.3.
182  */
183  NON_CONNECTABLE_UNDIRECTED = 0x03,
184 
185  /**
186  * Device is connectable and expects connection from a specific peer (sent at long user set intervals).
187  */
188  CONNECTABLE_DIRECTED_LOW_DUTY = 0x04,
189 
190  /**
191  * Device is connectable, but not scannable and doesn't expect connection from a specific peer.
192  * @note Only for use with extended advertising payload, will not allow legacy PDUs
193  * (use CONNECTABLE_UNDIRECTED for legacy PDU).
194  */
195  CONNECTABLE_NON_SCANNABLE_UNDIRECTED = 0x05,
196 
197 #if !defined(DOXYGEN_ONLY)
198  // used by the PAL; naming in line with the the spec.
199  ADV_IND = 0x00,
200  ADV_DIRECT_IND = 0x01,
201  ADV_SCAN_IND = 0x02,
202  ADV_NONCONN_IND = 0x03,
203  ADV_DIRECT_IND_LOW_DUTY_CYCLE = 0x04,
204  ADV_NONSCAN_IND = 0x05
205 #endif
206  };
207 
208  /**
209  * Construct a new advertising_type_t value.
210  *
211  * @param value The value of the advertising_type_t created.
212  */
213  advertising_type_t(type value) : SafeEnum(value)
214  {
215  }
216 };
217 
218 
219 /** Used to indicate if the packet is complete and if it's truncated.
220  */
221 struct advertising_data_status_t : SafeEnum<advertising_data_status_t, uint8_t> {
222  /// enumeration of advertising_data_status_t values
223  enum type {
224  COMPLETE = 0x00, /// Advertising payload complete.
225  INCOMPLETE_MORE_DATA = 0x01, /// Partial advertising payload, more to come.
226  INCOMPLETE_DATA_TRUNCATED = 0x02 /// Advertising payload incomplete, and no more is coming.
227  };
228 
229  /**
230  * Construct a new advertising_data_status_t value.
231  *
232  * @param value The value of the advertising_data_status_t created.
233  */
234  advertising_data_status_t(type value) : SafeEnum(value)
235  {
236  }
237 
238 #if !defined(DOXYGEN_ONLY)
239 
240  /**
241  * Explicit constructor from a raw value.
242  */
243  explicit advertising_data_status_t(uint8_t raw_value) :
244  SafeEnum(raw_value)
245  {
246  }
247 
248 #endif
249 
250 };
251 
252 /** Properties of an advertising event.
253  */
254 struct advertising_event_t {
255 
256 private:
257  // Implementation note: The object is constructed from the field Event_Type
258  // of an LE Extended Advertising.
259  // Indexes and functions of bits are defined in BLUETOOTH SPECIFICATION
260  // Version 5.0 | Vol 2, Part E -
261  // Section 7.7.65.13 LE Extended Advertising report Event
262  enum {
263  CONNECTABLE_BIT = 0,
264  SCANNABLE_ADVERTISING_BIT = 1,
265  DIRECTED_ADVERTISING_BIT = 2,
266  SCAN_RESPONSE_BIT = 3,
267  LEGACY_PDU_BIT = 4,
268  DATA_STATUS_INDEX = 5,
269  DATA_STATUS_MASK = 0x03
270  };
271 
272 public:
273 
274 #if !defined(DOXYGEN_ONLY)
275 
276  /** Create based on a raw value.
277  *
278  * @param value
279  */
280  explicit advertising_event_t(uint8_t value) : value(value)
281  {
282  }
283 
284 #endif
285 
286  /** Is advertising connectable.
287  *
288  * @return True if connectable.
289  */
290  bool connectable() const
291  {
292  return static_cast<bool>(value & (1 << CONNECTABLE_BIT));
293  }
294 
295  /** Is advertising scannable.
296  *
297  * @return True if scannable
298  */
299  bool scannable_advertising() const
300  {
301  return static_cast<bool>(value & (1 << SCANNABLE_ADVERTISING_BIT));
302  }
303 
304  /** Is advertising directed.
305  *
306  * @return True if directed.
307  */
308  bool directed_advertising() const
309  {
310  return static_cast<bool>(value & (1 << DIRECTED_ADVERTISING_BIT));
311  }
312 
313  /** Is this a scan response.
314  *
315  * @return True if scan response.
316  */
317  bool scan_response() const
318  {
319  return static_cast<bool>(value & (1 << SCAN_RESPONSE_BIT));
320  }
321 
322  /** Is this legacy advertising.
323  *
324  * @return True if legacy.
325  */
326  bool legacy_advertising() const
327  {
328  return static_cast<bool>(value & (1 << LEGACY_PDU_BIT));
329  }
330 
331  /** Payload completeness status.
332  *
333  * @return @see advertising_data_status_t for details.
334  */
335  advertising_data_status_t data_status() const
336  {
337  return static_cast<advertising_data_status_t::type>(
338  (value >> DATA_STATUS_INDEX) & DATA_STATUS_MASK
339  );
340  }
341 
342  /** Is payload complete.
343  *
344  * @return True if payload is coplete.
345  */
346  bool complete() const
347  {
348  return data_status() == advertising_data_status_t::COMPLETE;
349  }
350 
351  /** Is there more data coming.
352  *
353  * @return True if more data coming.
354  */
355  bool more_data_to_come() const
356  {
357  return data_status() == advertising_data_status_t::INCOMPLETE_MORE_DATA;
358  }
359 
360  /** Is the payload truncated.
361  *
362  * @return True if no more data coming.
363  */
364  bool truncated() const
365  {
366  return data_status() == advertising_data_status_t::INCOMPLETE_DATA_TRUNCATED;
367  }
368 
369 private:
370  uint8_t value;
371 };
372 
373 /**
374  * Identify an advertising SID. Range: [0x00, 0x0F]
375  */
376 typedef uint8_t advertising_sid_t;
377 
378 /** Received signal strength. Range <-127, 20>.
379  * @note Special value 127 means RSSI is not available. */
380 typedef int8_t rssi_t;
381 
382 /**
383  * Describe the advertising power.
384  *
385  * Values between -127 and +126 are considered power values in dBm while
386  * the special value 127 can be used as a wildcard to indicate that the host
387  * has no preference or if the power information is not available.
388  */
389 typedef int8_t advertising_power_t;
390 
391 /**
392  * Advertising policy filter modes.
393  *
394  * @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.2.
395  */
396 struct advertising_filter_policy_t : SafeEnum<advertising_filter_policy_t, uint8_t> {
397  /// enumeration of advertising_filter_policy_t values
398  enum type {
399  /**
400  * Process connection and scan requests from all devices. The whitelist is
401  * not used.
402  */
403  NO_FILTER = 0x00,
404 
405  /**
406  * Process connection requests from all devices but filter out scan requests
407  * of devices that are not in the whitelist.
408  */
409  FILTER_SCAN_REQUESTS = 0x01,
410 
411  /**
412  * Process scan requests from all devices but filter out connection requests
413  * of devices that are not in the whitelist.
414  */
415  FILTER_CONNECTION_REQUEST = 0x02,
416 
417  /**
418  * Filter out scan or connection requests of devices that are not in the
419  * whitelist.
420  */
421  FILTER_SCAN_AND_CONNECTION_REQUESTS = 0x03
422  };
423 
424  /**
425  * Construct a advertising_filter_policy_t.
426  * @param value The value of the advertising_filter_policy_t created.
427  */
428  advertising_filter_policy_t(type value) : SafeEnum(value)
429  {
430  }
431 };
432 
433 /**
434  * Scanning policy filter mode.
435  *
436  * @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.3.
437  */
438 struct scanning_filter_policy_t : SafeEnum<scanning_filter_policy_t, uint8_t> {
439  /// enumeration of scanning_filter_policy_t values
440  enum type {
441  /**
442  * Accept all advertising packets except directed advertising packets not
443  * addressed to this device.
444  */
445  NO_FILTER = 0x00,
446 
447  /**
448  * Accept only advertising packets from devices in the whitelist except
449  * directed advertising packets not addressed to this device.
450  */
451  FILTER_ADVERTISING = 0x01,
452 
453  /**
454  * Accept all advertising packets except directed advertising packets
455  * where the initiator's identity address does not address this device.
456  *
457  * @note Directed advertising packets where the initiator's address is a
458  * resolvable private address that cannot be resolved are also accepted.
459  */
460  NO_FILTER_INCLUDE_UNRESOLVABLE_DIRECTED = 2,
461 
462  /**
463  * Accept all advertising packets except:
464  * - Advertising packets where the advertiser's
465  * identity address is not in the whitelist.
466  * - Directed advertising packets where the initiator's identity address
467  * does not address this device.
468  *
469  * @note Directed advertising packets where the initiator's address is a
470  * resolvable private address that cannot be resolved are also accepted.
471  */
472  FILTER_ADVERTISING_INCLUDE_UNRESOLVABLE_DIRECTED = 3
473  };
474 
475  /**
476  * Construct a new instance of scanning_filter_policy_t.
477  *
478  * @param value The value of the scanning_filter_policy_t created.
479  */
480  scanning_filter_policy_t(type value) : SafeEnum(value)
481  {
482  }
483 };
484 
485 /**
486  * Filter policy that you can use during connection initiation.
487  */
488 struct initiator_filter_policy_t : SafeEnum<initiator_filter_policy_t, uint8_t> {
489  /// enumeration of initiator_filter_policy_t values.
490  enum type {
491  /**
492  * The whitelist is not used to determine which advertiser to connect to.
493  */
494  NO_FILTER,
495 
496  /**
497  * The whitelist is used to determine which advertiser to connect to.
498  */
499  USE_WHITE_LIST
500  };
501 
502  /**
503  * Construct a initiator_filter_policy_t.
504  * @param value The value of the initiator_filter_policy_t.
505  */
506  initiator_filter_policy_t(type value) : SafeEnum(value)
507  {
508  }
509 };
510 
511 /**
512  * Scanning policy filter mode.
513  *
514  * @see Bluetooth Core Specification 4.2 (Vol. 6), Part B, Section 4.3.3.
515  */
516 struct duplicates_filter_t : SafeEnum<duplicates_filter_t, uint8_t> {
517  /// enumeration of duplicates_filter_t values
518  enum type {
519  /**
520  * Disable duplicate filtering.
521  */
522  DISABLE,
523 
524  /**
525  * Enable duplicate filtering.
526  */
527  ENABLE,
528 
529  /**
530  * Enable duplicate filtering, and reset the cache periodically.
531  */
532  PERIODIC_RESET
533  };
534 
535  /**
536  * Construct a new duplicates_filter_t value.
537  * @param value The value of the duplicates_filter_t created.
538  */
539  duplicates_filter_t(type value) : SafeEnum(value)
540  {
541  }
542 };
543 
544 /**
545  * Type used to model the own address used during the following GAP operations:
546  * advertising, scanning and initiating
547  */
548 struct own_address_type_t : SafeEnum<own_address_type_t, uint8_t> {
549  /// enumeration of own_address_type_t values.
550  enum type {
551  /**
552  * Use the public device address.
553  */
554  PUBLIC = 0x00,
555 
556  /**
557  * Use the random device address.
558  */
559  RANDOM = 0x01,
560 
561  /**
562  * Generated resolvable private address based on the local IRK from the
563  * resolving list. Use the public address if no entry match in the resolving
564  * list.
565  */
566  RESOLVABLE_PRIVATE_ADDRESS_PUBLIC_FALLBACK = 0x02,
567 
568  /**
569  * Generated resolvable private address based on the local IRK from the
570  * resolving list. Use the random address if no entry match in the resolving
571  * list.
572  */
573  RESOLVABLE_PRIVATE_ADDRESS_RANDOM_FALLBACK = 0x03,
574  };
575 
576  /**
577  * Construct a new instance of own_address_type_t.
578  * @param value The value of the own_address_type_t created.
579  */
580  own_address_type_t(type value) : SafeEnum(value)
581  {
582  }
583 
584  /**
585  * Default initialization of own_address_type_t.
586  */
587  own_address_type_t() :
588  SafeEnum<own_address_type_t, uint8_t>(PUBLIC) { }
589 };
590 
591 /**
592  * Type of an address to connect to.
593  *
594  * It is used to connect to a device directly with directed advertising.
595  */
596 struct target_peer_address_type_t : SafeEnum<target_peer_address_type_t, uint8_t> {
597  /// enumeration of target_peer_address_type_t values.
598  enum type {
599  PUBLIC = 0x00, /**< Public Device Address or Public Identity Address. */
600  RANDOM = 0x01, /**< Random Device Address or Random (static) Identity Address. */
601  };
602 
603  /**
604  * Create a new target_peer_address_type_t.
605  * @param value The value of the target_peer_address_type_t created.
606  */
607  target_peer_address_type_t(type value) : SafeEnum(value)
608  {
609  }
610 };
611 
612 /**
613  * Accuracy of the master clock.
614  */
615 struct clock_accuracy_t : SafeEnum<clock_accuracy_t, uint8_t> {
616  /// enumeration of clock_accuracy_t values.
617  enum type {
618  /**
619  * 500 PPM
620  */
621  PPM_500 = 0x00,
622 
623  /**
624  * 250 PPM
625  */
626  PPM_250 = 0x01,
627 
628  /**
629  * 150 PPM
630  */
631  PPM_150 = 0x02,
632 
633  /**
634  * 100 PPM
635  */
636  PPM_100 = 0x03,
637 
638  /**
639  * 75 PPM
640  */
641  PPM_75 = 0x04,
642 
643  /**
644  * 50 PPM
645  */
646  PPM_50 = 0x05,
647 
648  /**
649  * 30 PPM
650  */
651  PPM_30 = 0x06,
652 
653  /**
654  * 20 PPM
655  */
656  PPM_20 = 0x07
657  };
658 
659  /** Get clock accuracy.
660  *
661  * @return Parts per million as a number.
662  */
663  uint16_t get_ppm()
664  {
665  switch (value()) {
666  case PPM_500:
667  return 500;
668  case PPM_250:
669  return 250;
670  case PPM_150:
671  return 150;
672  case PPM_100:
673  return 100;
674  case PPM_75:
675  return 75;
676  case PPM_50:
677  return 50;
678  case PPM_30:
679  return 30;
680  case PPM_20:
681  return 20;
682  default:
683  return 0;
684  }
685  }
686 
687  /**
688  * Construct a new clock_accuracy_t value.
689  * @param value The value of the clock_accuracy_t created.
690  */
691  clock_accuracy_t(type value) : SafeEnum(value)
692  {
693  }
694 
695 #if !defined(DOXYGEN_ONLY)
696 
697  /**
698  * Construct a new clock_accuracy_t value from a raw value.
699  * @param raw_value The value of the clock accuracy.
700  */
701  explicit clock_accuracy_t(uint8_t raw_value) : SafeEnum(raw_value)
702  {
703  }
704 
705 #endif
706 };
707 
708 /**
709  * Enumeration of GAP roles.
710  *
711  * @note The BLE API does not express the broadcaster and scanner roles.
712  *
713  * @attention A device can fulfill different roles concurrently.
714  */
715 struct connection_role_t : SafeEnum<connection_role_t, uint8_t> {
716  /** struct scoped enum wrapped by the class */
717  enum type {
718  /**
719  * Central Role.
720  *
721  * The device can scan and initiate connection to peripherals. It
722  * acts as the master when a connection is established.
723  *
724  * @note A central is a scanner.
725  */
726  CENTRAL = 0x00,
727 
728  /**
729  * Peripheral Role.
730  *
731  * The device can advertise, and you can connect it by a central. It
732  * acts as a slave when connected.
733  *
734  * @note A peripheral is a broadcaster.
735  */
736  PERIPHERAL = 0x01
737  };
738 
739  /**
740  * Construct a new instance of role_t.
741  *
742  * @param value The value of the role_t created.
743  */
744  connection_role_t(type value) : SafeEnum(value)
745  {
746  }
747 
748 #if !defined(DOXYGEN_ONLY)
749 
750  /**
751  * Explicit constructor from a raw value.
752  * @param raw_value The role.
753  */
754  explicit connection_role_t(uint8_t raw_value) : SafeEnum(raw_value)
755  {
756  }
757 
758 #endif
759 };
760 
761 /**
762  * Enumeration of disconnection reasons that should be transmited to the peer.
763  */
764 struct local_disconnection_reason_t : SafeEnum<local_disconnection_reason_t, uint8_t> {
765  /// enumeration of local_disconnection_reason_t values.
766  enum type {
767  /**
768  * GAP or GATT failed to authenticate the peer.
769  */
770  AUTHENTICATION_FAILURE = 0x05,
771 
772  /**
773  * Connection terminated by the user.
774  */
775  USER_TERMINATION = 0x13,
776 
777  /**
778  * Connection termination due to low resources.
779  */
780  LOW_RESOURCES = 0x14,
781 
782  /**
783  * Connection termination due to power off.
784  */
785  POWER_OFF = 0x15,
786 
787  /**
788  * Remote feature not supported.
789  */
790  UNSUPPORTED_REMOTE_FEATURE = 0x1A,
791 
792  /**
793  * Not possible to pai with a unit key.
794  */
795  PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED = 0x29,
796 
797  /**
798  * Connection parameters were unacceptable.
799  */
800  UNACCEPTABLE_CONNECTION_PARAMETERS = 0x3B
801  };
802 
803  /**
804  * Construct a new instance of disconnection_reason_t.
805  *
806  * @param value The value of the local_disconnection_reason_t created.
807  */
808  local_disconnection_reason_t(type value) : SafeEnum(value)
809  {
810  }
811 };
812 
813 
814 /**
815  * Enumeration of disconnection reasons received in a disconnection event.
816  */
817 struct disconnection_reason_t : SafeEnum<disconnection_reason_t, uint8_t> {
818  /// enumeration of disconnection_reason_t values.
819  enum type {
820  /**
821  * GAP or GATT failed to authenticate the peer.
822  */
823  AUTHENTICATION_FAILURE = 0x05,
824 
825  /**
826  * The connection timed out.
827  */
828  CONNECTION_TIMEOUT = 0x08,
829 
830  /**
831  * Connection terminated by the user.
832  */
833  REMOTE_USER_TERMINATED_CONNECTION = 0x13,
834 
835  /**
836  * Remote device terminated connection due to low resources.
837  */
838  REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES = 0x14,
839 
840  /**
841  * Remote device terminated connection due to power off.
842  */
843  REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF = 0x15,
844 
845  /**
846  * Indicate that the local user or the internal
847  * Bluetooth subsystem terminated the connection.
848  */
849  LOCAL_HOST_TERMINATED_CONNECTION = 0x16,
850 
851  /**
852  * Connection parameters were unacceptable.
853  */
854  UNACCEPTABLE_CONNECTION_PARAMETERS = 0x3B
855  };
856 
857  /**
858  * Construct a new instance of disconnection_reason_t.
859  *
860  * @param value The value of the disconnection_reason_t created.
861  */
862  disconnection_reason_t(type value) : SafeEnum(value)
863  {
864  }
865 
866 #if !defined(DOXYGEN_ONLY)
867  /**
868  * Construct a new instance of disconnection_reason_t.
869  *
870  * @param value The value of the local_disconnection_reason_t created.
871  *
872  * @note This should only be used for casting raw values from HCI.
873  */
874  explicit disconnection_reason_t(uint8_t value) : SafeEnum(value)
875  {
876  }
877 };
878 #endif // !defined(DOXYGEN_ONLY)
879 
880 /**
881  * Privacy Configuration of the peripheral role.
882  *
883  * @note This configuration also applies to the broadcaster role configuration.
884  */
885 struct peripheral_privacy_configuration_t {
886  /**
887  * Indicates if nonresolvable random address should be used when the
888  * peripheral advertises nonconnectable packets.
889  *
890  * Resolvable random address continues to be used for connectable packets.
891  */
892  bool use_non_resolvable_random_address;
893 
894  /**
895  * Resolution strategy for initiator resolvable addresses when a
896  * connection request is received.
897  */
898  enum resolution_strategy_t {
899  /**
900  * Do not resolve the address of the initiator and accept the
901  * connection request.
902  */
903  DO_NOT_RESOLVE,
904 
905  /**
906  * If a bond is present in the secure database and the address
907  * resolution fails, then reject the connection request with the error
908  * code AUTHENTICATION_FAILLURE.
909  */
910  REJECT_NON_RESOLVED_ADDRESS,
911 
912  /**
913  * Perform the pairing procedure if the initiator resolvable
914  * address failed the resolution process.
915  */
916  PERFORM_PAIRING_PROCEDURE,
917 
918  /**
919  * Perform the authentication procedure if the initiator resolvable
920  * address failed the resolution process.
921  */
922  PERFORM_AUTHENTICATION_PROCEDURE
923  };
924 
925  /**
926  * Connection strategy to use when a connection request contains a
927  * private resolvable address.
928  */
929  resolution_strategy_t resolution_strategy;
930 };
931 
932 /**
933  * Privacy configuration of the central role.
934  *
935  * @note This configuration is also used when the local device operates as
936  * an observer.
937  */
938 struct central_privacy_configuration_t {
939  /**
940  * Indicates if nonresolvable random address should be used when the
941  * central or observer sends scan request packets.
942  *
943  * Resolvable random address continues to be used for connection requests.
944  */
945  bool use_non_resolvable_random_address;
946 
947 
948  /**
949  * Resolution strategy of resolvable addresses received in advertising
950  * packets.
951  */
952  enum resolution_strategy_t {
953  /**
954  * Do not resolve the address received in advertising packets.
955  */
956  DO_NOT_RESOLVE,
957 
958  /**
959  * Resolve the resolvable addresses in the advertising packet and
960  * forward advertising packet to the application independently of
961  * the address resolution procedure result.
962  */
963  RESOLVE_AND_FORWARD,
964 
965  /**
966  * Filter out packets containing a resolvable address that cannot be resolved
967  * by this device.
968  *
969  * @note Filtering is applied if the local device contains at least
970  * one bond.
971  */
972  RESOLVE_AND_FILTER
973  };
974 
975  /**
976  * Resolution strategy applied to advertising packets received by the
977  * local device.
978  */
979  resolution_strategy_t resolution_strategy;
980 };
981 
982 
983 /**
984  * @}
985  * @}
986  */
987 
988 } // namespace ble
989 
990 #endif //BLE_GAP_TYPES_H
Entry namespace for all BLE API definitions.
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.