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