19 #ifndef BLE_GAP_TYPES_H 20 #define BLE_GAP_TYPES_H 22 #include "ble/common/Duration.h" 23 #include "ble/common/Bounded.h" 24 #include "ble/common/SafeEnum.h" 44 typedef Duration<uint32_t, 625, Range<0x20, 0xFFFFFF> > adv_interval_t;
53 typedef Duration<uint16_t, 10000, Range<0x00, 0xFFFF>, Value<uint16_t, 0x0000> > adv_duration_t;
62 typedef Duration<uint16_t, 10000, Range<0x00, 0xFFFF>, Value<uint16_t, 0x0000> > scan_duration_t;
70 typedef Duration<uint16_t, 1280000, Range<0x00, 0xFFFF> > scan_period_t;
77 typedef Duration<uint16_t, 625, Range<0x04, 0xFFFF> > scan_interval_t;
84 typedef Duration<uint16_t, 625, Range<0x04, 0xFFFF> > scan_window_t;
91 typedef Duration<uint16_t, 1250, Range<0x06, 0x0C80> > conn_interval_t;
100 typedef Duration<uint16_t, 10000, Range<0x0A, 0x0C80> > supervision_timeout_t;
107 typedef Duration<uint16_t, 625, Range<0, 0xFFFF> > conn_event_length_t;
115 typedef Duration<uint16_t, 10000, Range<0x0A, 0x4000> > sync_timeout_t;
122 typedef Duration<uint16_t, 1250, Range<0x06, 0xFFFF> > periodic_interval_t;
129 typedef Bounded<uint16_t, 0, 0x01F3> slave_latency_t;
136 typedef uint8_t advertising_handle_t;
143 typedef uint16_t periodic_sync_handle_t;
151 struct advertising_type_t : SafeEnum<advertising_type_t, uint8_t> {
162 CONNECTABLE_UNDIRECTED = 0x00,
169 CONNECTABLE_DIRECTED = 0x01,
176 SCANNABLE_UNDIRECTED = 0x02,
183 NON_CONNECTABLE_UNDIRECTED = 0x03,
188 CONNECTABLE_DIRECTED_LOW_DUTY = 0x04,
195 CONNECTABLE_NON_SCANNABLE_UNDIRECTED = 0x05,
197 #if !defined(DOXYGEN_ONLY) 200 ADV_DIRECT_IND = 0x01,
202 ADV_NONCONN_IND = 0x03,
203 ADV_DIRECT_IND_LOW_DUTY_CYCLE = 0x04,
204 ADV_NONSCAN_IND = 0x05
213 advertising_type_t(type value) : SafeEnum(value)
221 struct advertising_data_status_t : SafeEnum<advertising_data_status_t, uint8_t> {
225 INCOMPLETE_MORE_DATA = 0x01,
226 INCOMPLETE_DATA_TRUNCATED = 0x02
234 advertising_data_status_t(type value) : SafeEnum(value)
238 #if !defined(DOXYGEN_ONLY) 243 explicit advertising_data_status_t(uint8_t raw_value) :
254 struct advertising_event_t {
264 SCANNABLE_ADVERTISING_BIT = 1,
265 DIRECTED_ADVERTISING_BIT = 2,
266 SCAN_RESPONSE_BIT = 3,
268 DATA_STATUS_INDEX = 5,
269 DATA_STATUS_MASK = 0x03
274 #if !defined(DOXYGEN_ONLY) 280 explicit advertising_event_t(uint8_t value) : value(value)
290 bool connectable()
const 292 return static_cast<bool>(value & (1 << CONNECTABLE_BIT));
299 bool scannable_advertising()
const 301 return static_cast<bool>(value & (1 << SCANNABLE_ADVERTISING_BIT));
308 bool directed_advertising()
const 310 return static_cast<bool>(value & (1 << DIRECTED_ADVERTISING_BIT));
317 bool scan_response()
const 319 return static_cast<bool>(value & (1 << SCAN_RESPONSE_BIT));
326 bool legacy_advertising()
const 328 return static_cast<bool>(value & (1 << LEGACY_PDU_BIT));
335 advertising_data_status_t data_status()
const 337 return static_cast<advertising_data_status_t::type
>(
338 (value >> DATA_STATUS_INDEX) & DATA_STATUS_MASK
346 bool complete()
const 348 return data_status() == advertising_data_status_t::COMPLETE;
355 bool more_data_to_come()
const 357 return data_status() == advertising_data_status_t::INCOMPLETE_MORE_DATA;
364 bool truncated()
const 366 return data_status() == advertising_data_status_t::INCOMPLETE_DATA_TRUNCATED;
376 typedef uint8_t advertising_sid_t;
380 typedef int8_t rssi_t;
389 typedef int8_t advertising_power_t;
396 struct advertising_filter_policy_t : SafeEnum<advertising_filter_policy_t, uint8_t> {
409 FILTER_SCAN_REQUESTS = 0x01,
415 FILTER_CONNECTION_REQUEST = 0x02,
421 FILTER_SCAN_AND_CONNECTION_REQUESTS = 0x03
428 advertising_filter_policy_t(type value) : SafeEnum(value)
438 struct scanning_filter_policy_t : SafeEnum<scanning_filter_policy_t, uint8_t> {
451 FILTER_ADVERTISING = 0x01,
460 NO_FILTER_INCLUDE_UNRESOLVABLE_DIRECTED = 2,
472 FILTER_ADVERTISING_INCLUDE_UNRESOLVABLE_DIRECTED = 3
480 scanning_filter_policy_t(type value) : SafeEnum(value)
488 struct initiator_filter_policy_t : SafeEnum<initiator_filter_policy_t, uint8_t> {
506 initiator_filter_policy_t(type value) : SafeEnum(value)
516 struct duplicates_filter_t : SafeEnum<duplicates_filter_t, uint8_t> {
539 duplicates_filter_t(type value) : SafeEnum(value)
548 struct own_address_type_t : SafeEnum<own_address_type_t, uint8_t> {
566 RESOLVABLE_PRIVATE_ADDRESS_PUBLIC_FALLBACK = 0x02,
573 RESOLVABLE_PRIVATE_ADDRESS_RANDOM_FALLBACK = 0x03,
580 own_address_type_t(type value) : SafeEnum(value)
587 own_address_type_t() :
588 SafeEnum<own_address_type_t, uint8_t>(PUBLIC) { }
596 struct target_peer_address_type_t : SafeEnum<target_peer_address_type_t, uint8_t> {
607 target_peer_address_type_t(type value) : SafeEnum(value)
615 struct clock_accuracy_t : SafeEnum<clock_accuracy_t, uint8_t> {
691 clock_accuracy_t(type value) : SafeEnum(value)
695 #if !defined(DOXYGEN_ONLY) 701 explicit clock_accuracy_t(uint8_t raw_value) : SafeEnum(raw_value)
715 struct connection_role_t : SafeEnum<connection_role_t, uint8_t> {
744 connection_role_t(type value) : SafeEnum(value)
748 #if !defined(DOXYGEN_ONLY) 754 explicit connection_role_t(uint8_t raw_value) : SafeEnum(raw_value)
764 struct local_disconnection_reason_t : SafeEnum<local_disconnection_reason_t, uint8_t> {
770 AUTHENTICATION_FAILURE = 0x05,
775 USER_TERMINATION = 0x13,
780 LOW_RESOURCES = 0x14,
790 UNSUPPORTED_REMOTE_FEATURE = 0x1A,
795 PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED = 0x29,
800 UNACCEPTABLE_CONNECTION_PARAMETERS = 0x3B
808 local_disconnection_reason_t(type value) : SafeEnum(value)
817 struct disconnection_reason_t : SafeEnum<disconnection_reason_t, uint8_t> {
823 AUTHENTICATION_FAILURE = 0x05,
828 CONNECTION_TIMEOUT = 0x08,
833 REMOTE_USER_TERMINATED_CONNECTION = 0x13,
838 REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES = 0x14,
843 REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF = 0x15,
849 LOCAL_HOST_TERMINATED_CONNECTION = 0x16,
854 UNACCEPTABLE_CONNECTION_PARAMETERS = 0x3B
862 disconnection_reason_t(type value) : SafeEnum(value)
866 #if !defined(DOXYGEN_ONLY) 874 explicit disconnection_reason_t(uint8_t value) : SafeEnum(value)
878 #endif // !defined(DOXYGEN_ONLY) 885 struct peripheral_privacy_configuration_t {
892 bool use_non_resolvable_random_address;
898 enum resolution_strategy_t {
910 REJECT_NON_RESOLVED_ADDRESS,
916 PERFORM_PAIRING_PROCEDURE,
922 PERFORM_AUTHENTICATION_PROCEDURE
929 resolution_strategy_t resolution_strategy;
938 struct central_privacy_configuration_t {
945 bool use_non_resolvable_random_address;
952 enum resolution_strategy_t {
979 resolution_strategy_t resolution_strategy;
990 #endif //BLE_GAP_TYPES_H Entry namespace for all BLE API definitions.