mirror of https://github.com/ARMmbed/mbed-os.git
BLE: merge ble::advertising_type_t and pal::advertising_type_t.
parent
b4c704c807
commit
db55540952
|
@ -73,7 +73,7 @@ public:
|
|||
* @note If value in input are out of range, they will be normalized.
|
||||
*/
|
||||
AdvertisingParameters(
|
||||
ble::advertising_type_t advType = ADV_CONNECTABLE_UNDIRECTED,
|
||||
advertising_type_t advType = advertising_type_t::ADV_CONNECTABLE_UNDIRECTED,
|
||||
adv_interval_t minInterval = adv_interval_t(DEFAULT_ADVERTISING_INTERVAL_MIN),
|
||||
adv_interval_t maxInterval = adv_interval_t(DEFAULT_ADVERTISING_INTERVAL_MAX)
|
||||
) :
|
||||
|
@ -97,7 +97,7 @@ public:
|
|||
_includeHeaderTxPower(false)
|
||||
{
|
||||
/* Min interval is slightly larger than in other modes. */
|
||||
if (_advType == ADV_NON_CONNECTABLE_UNDIRECTED) {
|
||||
if (_advType == advertising_type_t::ADV_NON_CONNECTABLE_UNDIRECTED) {
|
||||
_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));
|
||||
}
|
||||
|
|
|
@ -58,42 +58,56 @@ typedef uint16_t periodic_sync_handle_t;
|
|||
* It determine how the device appears to other scanner and peripheral
|
||||
* devices in the scanning range.
|
||||
*/
|
||||
enum advertising_type_t {
|
||||
struct advertising_type_t : SafeEnum<advertising_type_t, uint8_t> {
|
||||
enum type {
|
||||
/**
|
||||
* Device is connectable, scannable and doesn't expect connection from a
|
||||
* specific peer.
|
||||
*
|
||||
* @see Vol 3, Part C, Section 9.3.4 and Vol 6, Part B, Section 2.3.1.1.
|
||||
*/
|
||||
ADV_CONNECTABLE_UNDIRECTED,
|
||||
ADV_CONNECTABLE_UNDIRECTED = 0x00,
|
||||
ADV_IND = 0x00,
|
||||
|
||||
/**
|
||||
* Device is connectable and expects connection from a specific peer.
|
||||
* (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.
|
||||
*/
|
||||
ADV_CONNECTABLE_DIRECTED,
|
||||
ADV_CONNECTABLE_DIRECTED = 0x01,
|
||||
ADV_DIRECT_IND = 0x01,
|
||||
|
||||
/**
|
||||
* Device is scannable but not connectable.
|
||||
*
|
||||
* @see Vol 6, Part B, Section 2.3.1.4.
|
||||
*/
|
||||
ADV_SCANNABLE_UNDIRECTED,
|
||||
ADV_SCANNABLE_UNDIRECTED = 0x02,
|
||||
ADV_SCAN_IND = 0x02,
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
ADV_NON_CONNECTABLE_UNDIRECTED,
|
||||
ADV_NON_CONNECTABLE_UNDIRECTED = 0x03,
|
||||
ADV_NONCONN_IND = 0x03,
|
||||
|
||||
/**
|
||||
* Device is connectable and expects connection from a specific peer (sent at long user set intervals).
|
||||
*/
|
||||
ADV_CONNECTABLE_DIRECTED_LOW_DUTY
|
||||
ADV_CONNECTABLE_DIRECTED_LOW_DUTY = 0x04,
|
||||
ADV_DIRECT_IND_LOW_DUTY_CYCLE = 0x04
|
||||
};
|
||||
|
||||
/**
|
||||
* Construct a new advertising_type_t value.
|
||||
*/
|
||||
advertising_type_t(type value) :
|
||||
SafeEnum<advertising_type_t, uint8_t>(value) { }
|
||||
};
|
||||
|
||||
|
||||
/** Used to indicate if the packet is complete and if it's truncated.
|
||||
*/
|
||||
struct advertising_data_status_t : SafeEnum<advertising_data_status_t, uint8_t >{
|
||||
|
|
|
@ -24,44 +24,7 @@
|
|||
namespace ble {
|
||||
namespace pal {
|
||||
|
||||
/**
|
||||
* Type of advertising the LE subsystem can use when it advertise.
|
||||
*/
|
||||
struct advertising_type_t : SafeEnum<advertising_type_t, uint8_t> {
|
||||
enum type {
|
||||
/**
|
||||
* Connectable and scannable undirected advertising.
|
||||
*/
|
||||
ADV_IND = 0x00,
|
||||
|
||||
/**
|
||||
* Connectable high duty cycle directed advertising.
|
||||
*/
|
||||
ADV_DIRECT_IND = 0x01,
|
||||
|
||||
/**
|
||||
* Scannable undirected advertising.
|
||||
*/
|
||||
ADV_SCAN_IND = 0x02,
|
||||
|
||||
/**
|
||||
* Non connectable undirected advertising.
|
||||
*/
|
||||
ADV_NONCONN_IND = 0x03,
|
||||
|
||||
/**
|
||||
* Connectable low duty cycle directed advertising.
|
||||
*/
|
||||
ADV_DIRECT_IND_LOW_DUTY_CYCLE = 0x04
|
||||
};
|
||||
|
||||
/**
|
||||
* Construct a new advertising_type_t value.
|
||||
*/
|
||||
advertising_type_t(type value) :
|
||||
SafeEnum<advertising_type_t, uint8_t>(value) { }
|
||||
};
|
||||
|
||||
typedef ble::advertising_type_t advertising_type_t;
|
||||
|
||||
/**
|
||||
* Type used to model the own address used during the following GAP operations:
|
||||
|
@ -602,7 +565,7 @@ struct advertising_event_properties_t {
|
|||
omit_advertiser_address(false),
|
||||
include_tx_power(false)
|
||||
{
|
||||
switch ((advertising_type_t::type) adv_type.value()) {
|
||||
switch (adv_type.value()) {
|
||||
case advertising_type_t::ADV_IND:
|
||||
connectable = true;
|
||||
scannable = true;
|
||||
|
@ -625,34 +588,6 @@ struct advertising_event_properties_t {
|
|||
}
|
||||
}
|
||||
|
||||
explicit advertising_event_properties_t(ble::advertising_type_t adv_type) :
|
||||
connectable(false),
|
||||
scannable(false),
|
||||
directed(false),
|
||||
high_duty_cycle(false),
|
||||
use_legacy_pdu(true),
|
||||
omit_advertiser_address(false),
|
||||
include_tx_power(false)
|
||||
{
|
||||
switch (adv_type) {
|
||||
case ADV_CONNECTABLE_UNDIRECTED:
|
||||
connectable = true;
|
||||
scannable = true;
|
||||
break;
|
||||
case ADV_CONNECTABLE_DIRECTED:
|
||||
case ADV_CONNECTABLE_DIRECTED_LOW_DUTY:
|
||||
connectable = true;
|
||||
directed = true;
|
||||
break;
|
||||
case ADV_SCANNABLE_UNDIRECTED:
|
||||
scannable = true;
|
||||
break;
|
||||
case ADV_NON_CONNECTABLE_UNDIRECTED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If set the advertising event is connectable.
|
||||
*/
|
||||
|
|
|
@ -1761,7 +1761,7 @@ ble_error_t GenericGap::setAdvertisingParams(
|
|||
return _pal_gap.set_advertising_parameters(
|
||||
params.getMinPrimaryInterval().value(),
|
||||
params.getMaxPrimaryInterval().value(),
|
||||
(pal::advertising_type_t::type) params.getType(),
|
||||
params.getType(),
|
||||
(pal::own_address_type_t::type) params.getOwnAddressType().value(),
|
||||
(pal::advertising_peer_address_type_t::type) params.getPeerAddressType().value(),
|
||||
params.getPeerAddress(),
|
||||
|
@ -1782,8 +1782,7 @@ ble_error_t GenericGap::setExtendedAdvertisingParameters(
|
|||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
pal::advertising_event_properties_t event_properties(
|
||||
(pal::advertising_type_t::type)params.getType());
|
||||
pal::advertising_event_properties_t event_properties(params.getType());
|
||||
event_properties.include_tx_power = params.getTxPowerInHeader();
|
||||
event_properties.omit_advertiser_address = params.getAnonymousAdvertising();
|
||||
event_properties.use_legacy_pdu = params.getUseLegacyPDU();
|
||||
|
|
Loading…
Reference in New Issue