19 #ifndef MBED_ADVERTISING_PARAMETERS_H__ 20 #define MBED_ADVERTISING_PARAMETERS_H__ 24 #include "ble/common/BLETypes.h" 25 #include "ble/common/blecommon.h" 26 #include "ble/common/SafeEnum.h" 104 static const uint32_t DEFAULT_ADVERTISING_INTERVAL_MIN = 0x400;
109 static const uint32_t DEFAULT_ADVERTISING_INTERVAL_MAX = 0x800;
117 static const uint32_t GAP_ADV_PARAMS_INTERVAL_MIN_NONCON = 0x00A0;
137 advertising_type_t advType = advertising_type_t::CONNECTABLE_UNDIRECTED,
138 adv_interval_t minInterval = adv_interval_t(DEFAULT_ADVERTISING_INTERVAL_MIN),
139 adv_interval_t maxInterval = adv_interval_t(DEFAULT_ADVERTISING_INTERVAL_MAX),
140 bool useLegacyPDU =
true 143 _minInterval(minInterval),
144 _maxInterval(maxInterval),
145 _peerAddressType(target_peer_address_type_t::PUBLIC),
146 _ownAddressType(own_address_type_t::RANDOM),
147 _policy(advertising_filter_policy_t::NO_FILTER),
148 _primaryPhy(
phy_t::LE_1M),
149 _secondaryPhy(
phy_t::LE_1M),
157 _notifyOnScan(false),
158 _legacyPDU(useLegacyPDU),
159 _includeHeaderTxPower(false)
176 advertising_type_t advType,
180 _minInterval(adv_interval_t(DEFAULT_ADVERTISING_INTERVAL_MIN)),
181 _maxInterval(adv_interval_t(DEFAULT_ADVERTISING_INTERVAL_MAX)),
182 _peerAddressType(target_peer_address_type_t::PUBLIC),
183 _ownAddressType(own_address_type_t::RANDOM),
184 _policy(advertising_filter_policy_t::NO_FILTER),
185 _primaryPhy(
phy_t::LE_1M),
186 _secondaryPhy(
phy_t::LE_1M),
194 _notifyOnScan(false),
195 _legacyPDU(useLegacyPDU),
196 _includeHeaderTxPower(false)
216 if (newAdvType == advertising_type_t::CONNECTABLE_UNDIRECTED ||
217 newAdvType == advertising_type_t::CONNECTABLE_DIRECTED) {
221 _advType = newAdvType;
238 if (newAdvType == advertising_type_t::CONNECTABLE_UNDIRECTED ||
239 newAdvType == advertising_type_t::CONNECTABLE_DIRECTED) {
243 _advType = newAdvType;
266 adv_interval_t min, adv_interval_t max
302 bool channel37,
bool channel38,
bool channel39
305 if (!channel37 && !channel38 && !channel39) {
306 channel37 = channel38 = channel39 =
true;
308 _channel37 = channel37;
309 _channel38 = channel38;
310 _channel39 = channel39;
347 _ownAddressType = addressType;
357 return _ownAddressType;
369 target_peer_address_type_t addressType
372 _peerAddress = address;
373 _peerAddressType = addressType;
393 return _peerAddressType;
414 #if BLE_FEATURE_WHITELIST 417 return advertising_filter_policy_t::NO_FILTER;
418 #endif // BLE_FEATURE_WHITELIST 432 _primaryPhy = primaryPhy;
433 _secondaryPhy = secondaryPhy;
452 return _secondaryPhy;
484 _maxSkip = eventNumber;
507 _notifyOnScan = enable;
517 return _notifyOnScan;
533 MBED_ASSERT((_advType != advertising_type_t::CONNECTABLE_UNDIRECTED) &&
534 (_advType != advertising_type_t::CONNECTABLE_DIRECTED));
558 _includeHeaderTxPower = enable;
568 return _includeHeaderTxPower;
601 if (_advType == advertising_type_t::NON_CONNECTABLE_UNDIRECTED) {
602 _minInterval = adv_interval_t(std::max(_minInterval.value(), GAP_ADV_PARAMS_INTERVAL_MIN_NONCON));
603 _maxInterval = adv_interval_t(std::max(_maxInterval.value(), GAP_ADV_PARAMS_INTERVAL_MIN_NONCON));
605 if (_advType == advertising_type_t::CONNECTABLE_DIRECTED ||
606 _advType == advertising_type_t::CONNECTABLE_UNDIRECTED) {
612 advertising_type_t _advType;
614 adv_interval_t _minInterval;
616 adv_interval_t _maxInterval;
618 target_peer_address_type_t _peerAddressType;
619 own_address_type_t _ownAddressType;
620 advertising_filter_policy_t _policy;
624 advertising_power_t _txPower;
630 bool _notifyOnScan:1;
632 bool _includeHeaderTxPower:1;
bool getChannel37() const
Check if channel 37 is used for primary advertising.
AdvertisingParameters & setType(advertising_type_t newAdvType)
Update the advertising type.
AdvertisingParameters & setType(advertising_type_t newAdvType, bool legacy)
Update the advertising type and whether to use legacy PDU.
advertising_filter_policy_t getFilter() const
Get the filter policy of whitelist use during advertising;.
AdvertisingParameters & setScanRequestNotification(bool enable=true)
Enabled or disable the callback that notifies the user about a scan request.
AdvertisingParameters & setPeer(const address_t &address, target_peer_address_type_t addressType)
Set peer address and type used during directed advertising.
own_address_type_t getOwnAddressType() const
Get what type of address is to be used as your own address during advertising.
advertising_power_t getTxPower() const
Get the advertising TX power.
phy_t getSecondaryPhy() const
Get PHY used for secondary advertising.
AdvertisingParameters & setTxPower(advertising_power_t txPower)
Set the advertising TX power.
AdvertisingParameters(advertising_type_t advType, bool useLegacyPDU)
Construct an instance of GapAdvertisingParams.
const address_t & getPeerAddress() const
Get the peer address used during directed advertising.
bool getChannel38() const
Check if channel 38 is used for primary advertising.
target_peer_address_type_t getPeerAddressType() const
Get the peer address type used during directed advertising.
AdvertisingParameters & setOwnAddressType(own_address_type_t addressType)
Get what type of address is to be used as your own address during advertising.
AdvertisingParameters & setPhy(phy_t primaryPhy, phy_t secondaryPhy)
Get PHYs used on primary and secondary advertising channels.
Type that describes a bluetooth PHY(sical) transport.
AdvertisingParameters & setPrimaryChannels(bool channel37, bool channel38, bool channel39)
Set which channels are to be used for primary advertising.
adv_interval_t getMaxPrimaryInterval() const
Get the maximum advertising intervals on the primary channels.
AdvertisingParameters(advertising_type_t advType=advertising_type_t::CONNECTABLE_UNDIRECTED, adv_interval_t minInterval=adv_interval_t(DEFAULT_ADVERTISING_INTERVAL_MIN), adv_interval_t maxInterval=adv_interval_t(DEFAULT_ADVERTISING_INTERVAL_MAX), bool useLegacyPDU=true)
Construct an instance of GapAdvertisingParams.
AdvertisingParameters & setPrimaryInterval(adv_interval_t min, adv_interval_t max)
Set the advertising intervals on the primary channels.
advertising_type_t getType() const
Return the advertising type.
uint8_t getSecondaryMaxSkip() const
Return how many events can be skipped on the secondary channel.
phy_t getPrimaryPhy() const
Get PHY used for primary advertising.
bool getUseLegacyPDU() const
Check if legacy PDU is used during advertising.
adv_interval_t getMinPrimaryInterval() const
Get the minimum advertising intervals on the primary channels.
Parameters defining the advertising process.
AdvertisingParameters & includeTxPowerInHeader(bool enable=true)
Set if TX power should be included in the header.
AdvertisingParameters & setSecondaryMaxSkip(uint8_t eventNumber)
Set how many events can be skipped on the secondary channel.
AdvertisingParameters & setFilter(advertising_filter_policy_t mode)
Set the filter policy of whitelist use during advertising;.
AdvertisingParameters & setUseLegacyPDU(bool enable=true)
Use legacy PDU during advertising.
bool getTxPowerInHeader() const
Check if TX power should be included in the header.
Entry namespace for all BLE API definitions.
AdvertisingParameters & setAnonymousAdvertising(bool enable)
Advertise without your own address.
bool getAnonymousAdvertising() const
Check if advertising is anonymous.
bool getScanRequestNotification() const
Return of the callback for scan request is enabled.
bool getChannel39() const
Check if channel 39 is used for primary advertising.