BLE: Cleanup enum duplicates in gap/Types.h

pull/8738/head
Vincent Coubard 2018-11-25 11:22:55 +00:00
parent 884d870b68
commit 78d4a9b6c8
5 changed files with 40 additions and 56 deletions

View File

@ -127,7 +127,7 @@ public:
* @note If value in input are out of range, they will be normalized. * @note If value in input are out of range, they will be normalized.
*/ */
AdvertisingParameters( AdvertisingParameters(
advertising_type_t advType = advertising_type_t::ADV_CONNECTABLE_UNDIRECTED, advertising_type_t advType = advertising_type_t::CONNECTABLE_UNDIRECTED,
adv_interval_t minInterval = adv_interval_t(DEFAULT_ADVERTISING_INTERVAL_MIN), adv_interval_t minInterval = adv_interval_t(DEFAULT_ADVERTISING_INTERVAL_MIN),
adv_interval_t maxInterval = adv_interval_t(DEFAULT_ADVERTISING_INTERVAL_MAX) adv_interval_t maxInterval = adv_interval_t(DEFAULT_ADVERTISING_INTERVAL_MAX)
) : ) :
@ -151,7 +151,7 @@ public:
_includeHeaderTxPower(false) _includeHeaderTxPower(false)
{ {
/* Min interval is slightly larger than in other modes. */ /* Min interval is slightly larger than in other modes. */
if (_advType == advertising_type_t::ADV_NON_CONNECTABLE_UNDIRECTED) { if (_advType == advertising_type_t::NON_CONNECTABLE_UNDIRECTED) {
_minInterval = adv_interval_t(std::max(_minInterval.value(), GAP_ADV_PARAMS_INTERVAL_MIN_NONCON)); _minInterval = adv_interval_t(std::max(_minInterval.value(), GAP_ADV_PARAMS_INTERVAL_MIN_NONCON));
_maxInterval = adv_interval_t(std::max(_maxInterval.value(), GAP_ADV_PARAMS_INTERVAL_MIN_NONCON)); _maxInterval = adv_interval_t(std::max(_maxInterval.value(), GAP_ADV_PARAMS_INTERVAL_MIN_NONCON));
} }

View File

@ -95,14 +95,14 @@ typedef Duration<uint16_t, 1250, Range<0x06, 0x0C80> > conn_interval_t;
* *
* @note this time should be no larger than (1 + ConnLatency) * ConnIntervalMax * 2 * @note this time should be no larger than (1 + ConnLatency) * ConnIntervalMax * 2
*/ */
typedef Duration<uint16_t, 10000, Range<0x0A, 0x0C80> > supervision_timeout_t; typedef Duration<uint16_t, 10000, Range<0x0A, 0x0C80> > supervision_timeout_t;
/** /**
* Duration of a connection event. * Duration of a connection event.
* *
* The duration is in unit of 625µs and ranges from 0x0 to 0xFFFF . * The duration is in unit of 625µs and ranges from 0x0 to 0xFFFF .
*/ */
typedef Duration<uint16_t, 625, Range< 0, 0xFFFF> > conn_event_length_t; typedef Duration<uint16_t, 625, Range<0, 0xFFFF> > conn_event_length_t;
/** /**
* Time after which a periodic sync link is considered loss if the receiver hasn't * Time after which a periodic sync link is considered loss if the receiver hasn't
@ -110,14 +110,14 @@ typedef Duration<uint16_t, 625, Range< 0, 0xFFFF> > conn_event_length_t
* *
* The duration is in unit of 10 milliseconds and ranges from 0x0A to 0x4000. * The duration is in unit of 10 milliseconds and ranges from 0x0A to 0x4000.
*/ */
typedef Duration<uint16_t, 10000, Range<0x0A, 0x4000> > sync_timeout_t; typedef Duration<uint16_t, 10000, Range<0x0A, 0x4000> > sync_timeout_t;
/** /**
* Interval between two periodic advertsising events. * Interval between two periodic advertsising events.
* *
* The duration is in unit of 1.250ms and ranges from 0x06 to 0xFFFF. * The duration is in unit of 1.250ms and ranges from 0x06 to 0xFFFF.
*/ */
typedef Duration<uint16_t, 1250, Range<0x06, 0xFFFF> > periodic_interval_t; typedef Duration<uint16_t, 1250, Range<0x06, 0xFFFF> > periodic_interval_t;
/** /**
* Number of connection events that can be skipped by the slave. * Number of connection events that can be skipped by the slave.
@ -155,38 +155,42 @@ struct advertising_type_t : SafeEnum<advertising_type_t, uint8_t> {
* *
* @see Vol 3, Part C, Section 9.3.4 and Vol 6, Part B, Section 2.3.1.1. * @see Vol 3, Part C, Section 9.3.4 and Vol 6, Part B, Section 2.3.1.1.
*/ */
ADV_CONNECTABLE_UNDIRECTED = 0x00, CONNECTABLE_UNDIRECTED = 0x00,
ADV_IND = 0x00,
/** /**
* Device is connectable and expects connection from a specific peer. * Device is connectable and expects connection from a specific peer.
* (3.75 ms or smaller Advertising Interval) * (3.75 ms or smaller Advertising Interval)
* @see Vol 3, Part C, Section 9.3.3 and Vol 6, Part B, Section 2.3.1.2. * @see Vol 3, Part C, Section 9.3.3 and Vol 6, Part B, Section 2.3.1.2.
*/ */
ADV_CONNECTABLE_DIRECTED = 0x01, CONNECTABLE_DIRECTED = 0x01,
ADV_DIRECT_IND = 0x01,
/** /**
* Device is scannable but not connectable. * Device is scannable but not connectable.
* *
* @see Vol 6, Part B, Section 2.3.1.4. * @see Vol 6, Part B, Section 2.3.1.4.
*/ */
ADV_SCANNABLE_UNDIRECTED = 0x02, SCANNABLE_UNDIRECTED = 0x02,
ADV_SCAN_IND = 0x02,
/** /**
* Device is not connectable and not scannable. * Device is not connectable and not scannable.
* *
* @see Vol 3, Part C, Section 9.3.2 and Vol 6, Part B, Section 2.3.1.3. * @see Vol 3, Part C, Section 9.3.2 and Vol 6, Part B, Section 2.3.1.3.
*/ */
ADV_NON_CONNECTABLE_UNDIRECTED = 0x03, NON_CONNECTABLE_UNDIRECTED = 0x03,
ADV_NONCONN_IND = 0x03,
/** /**
* Device is connectable and expects connection from a specific peer (sent at long user set intervals). * Device is connectable and expects connection from a specific peer (sent at long user set intervals).
*/ */
ADV_CONNECTABLE_DIRECTED_LOW_DUTY = 0x04, CONNECTABLE_DIRECTED_LOW_DUTY = 0x04,
#if !defined(DOXYGEN_ONLY)
// used by the PAL; naming in line with the the spec.
ADV_IND = 0x00,
ADV_DIRECT_IND = 0x01,
ADV_SCAN_IND = 0x02,
ADV_NONCONN_IND = 0x03,
ADV_DIRECT_IND_LOW_DUTY_CYCLE = 0x04 ADV_DIRECT_IND_LOW_DUTY_CYCLE = 0x04
#endif
}; };
/** /**
@ -329,7 +333,7 @@ public:
*/ */
bool complete() const bool complete() const
{ {
return data_status().value() == advertising_data_status_t::COMPLETE; return data_status() == advertising_data_status_t::COMPLETE;
} }
/** Is there more data coming. /** Is there more data coming.
@ -338,7 +342,7 @@ public:
*/ */
bool more_data_to_come() const bool more_data_to_come() const
{ {
return data_status().value() == advertising_data_status_t::INCOMPLETE_MORE_DATA; return data_status() == advertising_data_status_t::INCOMPLETE_MORE_DATA;
} }
/** Is the payload truncated. /** Is the payload truncated.
@ -347,7 +351,7 @@ public:
*/ */
bool truncated() const bool truncated() const
{ {
return data_status().value() == advertising_data_status_t::INCOMPLETE_DATA_TRUNCATED; return data_status() == advertising_data_status_t::INCOMPLETE_DATA_TRUNCATED;
} }
private: private:
@ -535,13 +539,11 @@ struct own_address_type_t : SafeEnum<own_address_type_t, uint8_t> {
/** /**
* Use the public device address. * Use the public device address.
*/ */
PUBLIC_ADDRESS = 0x00,
PUBLIC = 0x00, PUBLIC = 0x00,
/** /**
* Use the random device address. * Use the random device address.
*/ */
RANDOM_ADDRESS = 0x01,
RANDOM = 0x01, RANDOM = 0x01,
/** /**
@ -577,10 +579,7 @@ struct target_peer_address_type_t : SafeEnum<target_peer_address_type_t, uint8_t
/// enumeration of target_peer_address_type_t values. /// enumeration of target_peer_address_type_t values.
enum type { enum type {
PUBLIC = 0x00, /**< Public Device Address or Public Identity Address. */ PUBLIC = 0x00, /**< Public Device Address or Public Identity Address. */
PUBLIC_ADDRESS = 0x00,
RANDOM = 0x01, /**< Random Device Address or Random (static) Identity Address. */ RANDOM = 0x01, /**< Random Device Address or Random (static) Identity Address. */
RANDOM_ADDRESS = 0x01
}; };
/** /**
@ -708,11 +707,6 @@ struct connection_role_t : SafeEnum<connection_role_t, uint8_t> {
*/ */
CENTRAL = 0x00, CENTRAL = 0x00,
/**
* @see CENTRAL
*/
MASTER = 0x00,
/** /**
* Peripheral Role. * Peripheral Role.
* *
@ -721,12 +715,7 @@ struct connection_role_t : SafeEnum<connection_role_t, uint8_t> {
* *
* @note A peripheral is a broadcaster. * @note A peripheral is a broadcaster.
*/ */
PERIPHERAL = 0x01, PERIPHERAL = 0x01
/**
* @see PERIPHERAL
*/
SLAVE = 0x01
}; };
/** /**
@ -761,25 +750,21 @@ struct local_disconnection_reason_t : SafeEnum<local_disconnection_reason_t, uin
* GAP or GATT failed to authenticate the peer. * GAP or GATT failed to authenticate the peer.
*/ */
AUTHENTICATION_FAILURE = 0x05, AUTHENTICATION_FAILURE = 0x05,
AUTHENTICATION_FAILLURE = 0x05,
/** /**
* Connection terminated by the user. * Connection terminated by the user.
*/ */
USER_TERMINATION = 0x13, USER_TERMINATION = 0x13,
REMOTE_USER_TERMINATED_CONNECTION = 0x13,
/** /**
* Connection termination due to low resources. * Connection termination due to low resources.
*/ */
LOW_RESOURCES = 0x14, LOW_RESOURCES = 0x14,
REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES = 0x14,
/** /**
* Connection termination due to power off. * Connection termination due to power off.
*/ */
POWER_OFF = 0x15, POWER_OFF = 0x15,
REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_POWER_OFF = 0x15,
/** /**
* Remote feature not supported * Remote feature not supported
@ -794,7 +779,6 @@ struct local_disconnection_reason_t : SafeEnum<local_disconnection_reason_t, uin
/** /**
* Connection parameters were unacceptable. * Connection parameters were unacceptable.
*/ */
CONN_INTERVAL_UNACCEPTABLE = 0x3B,
UNACCEPTABLE_CONNECTION_PARAMETERS = 0x3B UNACCEPTABLE_CONNECTION_PARAMETERS = 0x3B
}; };
@ -849,7 +833,7 @@ struct disconnection_reason_t : SafeEnum<disconnection_reason_t, uint8_t> {
/** /**
* Connection parameters were unacceptable. * Connection parameters were unacceptable.
*/ */
CONN_INTERVAL_UNACCEPTABLE = 0x3B UNACCEPTABLE_CONNECTION_PARAMETERS = 0x3B
}; };
/** /**

View File

@ -158,7 +158,7 @@ struct GapConnectionCompleteEvent : public GapEvent {
connection_handle(connection_handle), connection_handle(connection_handle),
role(role), role(role),
peer_address_type( peer_address_type(
peer_address_type == advertising_peer_address_type_t::PUBLIC_ADDRESS ? peer_address_type == advertising_peer_address_type_t::PUBLIC ?
peer_address_type_t::PUBLIC : peer_address_type_t::PUBLIC :
peer_address_type_t::RANDOM peer_address_type_t::RANDOM
), ),

View File

@ -1097,7 +1097,7 @@ ble_error_t GenericGap::startRadioScan(const GapScanningParams &scanningParams)
pal::own_address_type_t own_address_type = get_own_address_type(CENTRAL_SCAN /* central, can use non resolvable address for scan requests */); pal::own_address_type_t own_address_type = get_own_address_type(CENTRAL_SCAN /* central, can use non resolvable address for scan requests */);
if (_privacy_enabled && (own_address_type == pal::own_address_type_t::RANDOM_ADDRESS)) { if (_privacy_enabled && (own_address_type == pal::own_address_type_t::RANDOM)) {
// Use non-resolvable static random address // Use non-resolvable static random address
set_random_address_rotation(true); set_random_address_rotation(true);
} }
@ -1227,7 +1227,7 @@ ble_error_t GenericGap::startAdvertising(const GapAdvertisingParams &params)
pal::own_address_type_t own_address_type = get_own_address_type(address_use_type); pal::own_address_type_t own_address_type = get_own_address_type(address_use_type);
if (_privacy_enabled && (own_address_type == pal::own_address_type_t::RANDOM_ADDRESS)) { if (_privacy_enabled && (own_address_type == pal::own_address_type_t::RANDOM)) {
// Use non-resolvable static random address // Use non-resolvable static random address
set_random_address_rotation(true); set_random_address_rotation(true);
} }
@ -1243,7 +1243,7 @@ ble_error_t GenericGap::startAdvertising(const GapAdvertisingParams &params)
/* advertising_interval_max */ params.getIntervalInADVUnits(), /* advertising_interval_max */ params.getIntervalInADVUnits(),
(pal::advertising_type_t::type) params.getAdvertisingType(), (pal::advertising_type_t::type) params.getAdvertisingType(),
own_address_type, own_address_type,
pal::advertising_peer_address_type_t::PUBLIC_ADDRESS, pal::advertising_peer_address_type_t::PUBLIC,
ble::address_t(), ble::address_t(),
pal::advertising_channel_map_t::ALL_ADVERTISING_CHANNELS, pal::advertising_channel_map_t::ALL_ADVERTISING_CHANNELS,
_advertising_filter_policy _advertising_filter_policy
@ -1473,7 +1473,7 @@ BLE_DEPRECATED_API_USE_END()
bool needs_authentication = false; bool needs_authentication = false;
if (_privacy_enabled && if (_privacy_enabled &&
e.role.value() == e.role.SLAVE && e.role.value() == e.role.PERIPHERAL &&
e.peer_address_type == peer_address_type_t::RANDOM e.peer_address_type == peer_address_type_t::RANDOM
) { ) {
// Apply privacy policy if in peripheral mode for non-resolved addresses // Apply privacy policy if in peripheral mode for non-resolved addresses
@ -1490,7 +1490,7 @@ BLE_DEPRECATED_API_USE_END()
// Reject connection request - the user will get notified through a callback // Reject connection request - the user will get notified through a callback
_pal_gap.disconnect( _pal_gap.disconnect(
e.connection_handle, e.connection_handle,
pal::disconnection_reason_t::AUTHENTICATION_FAILLURE pal::disconnection_reason_t::AUTHENTICATION_FAILURE
); );
return; return;
@ -1508,7 +1508,7 @@ BLE_DEPRECATED_API_USE_END()
} }
} }
if (e.role.value() == e.role.SLAVE) { if (e.role.value() == e.role.PERIPHERAL) {
_advertising_timeout.detach(); _advertising_timeout.detach();
_pal_gap.advertising_enable(false); _pal_gap.advertising_enable(false);
@ -1534,7 +1534,7 @@ BLE_DEPRECATED_API_USE_END()
processConnectionEvent( processConnectionEvent(
e.connection_handle, e.connection_handle,
e.role.value() == e.role.MASTER ? ::Gap::CENTRAL : ::Gap::PERIPHERAL, e.role.value() == e.role.CENTRAL ? ::Gap::CENTRAL : ::Gap::PERIPHERAL,
e.peer_address_type, e.peer_address_type,
e.peer_address.data(), e.peer_address.data(),
_address_type, _address_type,
@ -1606,7 +1606,7 @@ pal::own_address_type_t GenericGap::get_own_address_type(AddressUseType_t addres
// An non resolvable private address should be generated // An non resolvable private address should be generated
if (use_non_resolvable_address) { if (use_non_resolvable_address) {
return pal::own_address_type_t::RANDOM_ADDRESS; return pal::own_address_type_t::RANDOM;
} }
switch (_address_type) { switch (_address_type) {
@ -1619,9 +1619,9 @@ pal::own_address_type_t GenericGap::get_own_address_type(AddressUseType_t addres
switch (_address_type) { switch (_address_type) {
case BLEProtocol::AddressType::PUBLIC: case BLEProtocol::AddressType::PUBLIC:
return pal::own_address_type_t::PUBLIC_ADDRESS; return pal::own_address_type_t::PUBLIC;
default: default:
return pal::own_address_type_t::RANDOM_ADDRESS; return pal::own_address_type_t::RANDOM;
} }
} }

View File

@ -1100,8 +1100,8 @@ void GenericSecurityManager::on_security_entry_retrieved(
_pal.add_device_to_resolving_list( _pal.add_device_to_resolving_list(
identity->identity_address_is_public ? identity->identity_address_is_public ?
address_type_t::PUBLIC_ADDRESS : address_type_t::PUBLIC :
address_type_t::RANDOM_ADDRESS, address_type_t::RANDOM,
identity->identity_address, identity->identity_address,
identity->irk identity->irk
); );
@ -1117,8 +1117,8 @@ void GenericSecurityManager::on_identity_list_retrieved(
for (size_t i = 0; i < count; ++i) { for (size_t i = 0; i < count; ++i) {
_pal.add_device_to_resolving_list( _pal.add_device_to_resolving_list(
identity_list[i].identity_address_is_public ? identity_list[i].identity_address_is_public ?
address_type_t::PUBLIC_ADDRESS : address_type_t::PUBLIC :
address_type_t::RANDOM_ADDRESS, address_type_t::RANDOM,
identity_list[i].identity_address, identity_list[i].identity_address,
identity_list[i].irk identity_list[i].irk
); );
@ -1564,7 +1564,7 @@ void GenericSecurityManager::on_keys_distributed_bdaddr(
_db->set_entry_peer_bdaddr( _db->set_entry_peer_bdaddr(
cb->db_entry, cb->db_entry,
(peer_address_type == advertising_peer_address_type_t::PUBLIC_ADDRESS), (peer_address_type == advertising_peer_address_type_t::PUBLIC),
peer_identity_address peer_identity_address
); );
} }