mirror of https://github.com/ARMmbed/mbed-os.git
fix adv and scan types
parent
5d077e6dbc
commit
60fb78795b
|
@ -143,7 +143,7 @@ enum advertising_type_t {
|
|||
|
||||
/**
|
||||
* 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,
|
||||
|
@ -160,7 +160,12 @@ enum advertising_type_t {
|
|||
*
|
||||
* @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,
|
||||
|
||||
/**
|
||||
* Device is connectable and expects connection from a specific peer (sent at long user set intervals).
|
||||
*/
|
||||
ADV_CONNECTABLE_DIRECTED_LOW_DUTY
|
||||
};
|
||||
|
||||
struct advertising_data_status_t : SafeEnum<advertising_data_status_t, uint8_t >{
|
||||
|
@ -204,6 +209,9 @@ struct advertising_event_t {
|
|||
case ADV_NON_CONNECTABLE_UNDIRECTED:
|
||||
value = 0x20;
|
||||
break;
|
||||
case ADV_CONNECTABLE_DIRECTED_LOW_DUTY:
|
||||
value = 0x2D;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1284,15 +1284,14 @@ public:
|
|||
/* scanning */
|
||||
|
||||
ble_error_t setScanParameters(
|
||||
const GapScanningParams* params = NULL,
|
||||
const GapScanningParams* params = NULL,
|
||||
const GapScanningParams* params = NULL
|
||||
const GapScanningParams* params
|
||||
) {
|
||||
return startRadioScan(params);
|
||||
/* Requesting action from porter(s): override this API if this capability is supported. */
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
};
|
||||
|
||||
ble_error_t startScan(
|
||||
ble::scanning_filter_duplicates_t filtering = SCAN_FILTER_DUPLICATES_DISABLED,
|
||||
ble::scanning_filter_duplicates_t filtering = ble::SCAN_FILTER_DUPLICATES_DISABLED,
|
||||
uint32_t duration = 0,
|
||||
uint32_t period = 0
|
||||
) {
|
||||
|
|
|
@ -722,7 +722,7 @@ public:
|
|||
uint16_t appearance = GENERIC_TAG;
|
||||
const uint8_t *field = findField(AdvertisingData::APPEARANCE);
|
||||
if (field) {
|
||||
memcpy((uint8_t*)appearance, field, 2);
|
||||
memcpy((uint8_t*)&appearance, field, 2);
|
||||
}
|
||||
return appearance;
|
||||
}
|
||||
|
|
|
@ -271,21 +271,24 @@ public:
|
|||
the local IRK from the resolving list. If the resolving list
|
||||
contains no matching entry, use previously set random address. */
|
||||
};
|
||||
own_address_type_t(type value) : ble::SafeEnum<own_address_type_t, uint8_t>(value) { }
|
||||
};
|
||||
|
||||
struct peer_address_type_t : ble::SafeEnum<peer_address_type_t, uint8_t> {
|
||||
enum type {
|
||||
PUBLIC = 0, /**< Public Device Address or Public Identity Address. */
|
||||
RANDOM /**< Random Device Address or Random (static) Identity Address. */
|
||||
};
|
||||
peer_address_type_t(type value) : ble::SafeEnum<peer_address_type_t, uint8_t>(value) { }
|
||||
};
|
||||
|
||||
public:
|
||||
GapExtendedAdvertisingParams() :
|
||||
_advType(ble::advertising_event_t().connectable(true).scannable_advertising(true)),
|
||||
_advType(ble::ADV_CONNECTABLE_UNDIRECTED),
|
||||
_minInterval(0),
|
||||
_maxInterval(0),
|
||||
_peerAddressType(),
|
||||
_ownAddressType(),
|
||||
_peerAddressType(peer_address_type_t::PUBLIC),
|
||||
_ownAddressType(own_address_type_t::PUBLIC),
|
||||
_policy(ble::ADV_POLICY_IGNORE_WHITELIST),
|
||||
_primaryPhy(ble::phy_t::LE_1M),
|
||||
_secondaryPhy(ble::phy_t::LE_1M),
|
||||
|
@ -296,7 +299,9 @@ public:
|
|||
_channel38(1),
|
||||
_channel39(1),
|
||||
_anonymous(0),
|
||||
_notifyOnScan(1) { }
|
||||
_notifyOnScan(1),
|
||||
_legacyPDU(0),
|
||||
_includeHeaderTxPower(0) { }
|
||||
|
||||
/**
|
||||
* Update the advertising type.
|
||||
|
@ -314,7 +319,7 @@ public:
|
|||
*
|
||||
* @return Advertising type.
|
||||
*/
|
||||
ble::advertising_event_t getType() const {
|
||||
ble::advertising_type_t getType() const {
|
||||
return _advType;
|
||||
}
|
||||
|
||||
|
@ -372,7 +377,6 @@ public:
|
|||
_channel39 = channel39;
|
||||
}
|
||||
|
||||
//TODO new type in params
|
||||
own_address_type_t getOwnAddressType() const {
|
||||
return _ownAddressType;
|
||||
}
|
||||
|
@ -463,6 +467,26 @@ public:
|
|||
return _notifyOnScan;
|
||||
}
|
||||
|
||||
void setUseLegacyPDU(
|
||||
bool enable = true
|
||||
) {
|
||||
_legacyPDU = enable;
|
||||
}
|
||||
|
||||
bool getUseLegacyPDU() const {
|
||||
return _legacyPDU;
|
||||
}
|
||||
|
||||
void includeTxPowerInHeader(
|
||||
bool enable = true
|
||||
) {
|
||||
_includeHeaderTxPower = enable;
|
||||
}
|
||||
|
||||
bool getTxPowerInHeader() const {
|
||||
return _includeHeaderTxPower;
|
||||
}
|
||||
|
||||
/* helper get functions */
|
||||
|
||||
uint32_t getMinPrimaryInterval() const {
|
||||
|
@ -502,11 +526,11 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
ble::advertising_event_t _advType;
|
||||
ble::advertising_type_t _advType;
|
||||
uint32_t _minInterval;
|
||||
uint32_t _maxInterval;
|
||||
peer_address_type_t _peerAddressType;
|
||||
BLEProtocol::AddressType_t _ownAddressType;
|
||||
own_address_type_t _ownAddressType;
|
||||
ble::advertising_policy_mode_t _policy;
|
||||
ble::phy_t _primaryPhy;
|
||||
ble::phy_t _secondaryPhy;
|
||||
|
@ -518,6 +542,8 @@ private:
|
|||
uint8_t _channel39:1;
|
||||
uint8_t _anonymous:1;
|
||||
uint8_t _notifyOnScan:1;
|
||||
uint8_t _legacyPDU:1;
|
||||
uint8_t _includeHeaderTxPower:1;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -206,26 +206,6 @@ public:
|
|||
return _activeScanning;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param phy LE_2m is illegal
|
||||
*/
|
||||
void setScanningPhy(ble::phy_t phy) {
|
||||
_phy = phy;
|
||||
}
|
||||
|
||||
ble::phy_t getScanningPhy() {
|
||||
return _phy;
|
||||
}
|
||||
|
||||
ble::scanning_policy_mode_t getScanningPolicy() {
|
||||
return _mode;
|
||||
}
|
||||
|
||||
void setScanningPolicy(ble::scanning_policy_mode_t mode) {
|
||||
_mode = mode;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Scan interval in units of 625us (between 2.5ms and 10.24s).
|
||||
|
|
|
@ -651,6 +651,7 @@ struct advertising_event_properties_t {
|
|||
scannable = true;
|
||||
break;
|
||||
case ADV_CONNECTABLE_DIRECTED:
|
||||
case ADV_CONNECTABLE_DIRECTED_LOW_DUTY:
|
||||
connectable = true;
|
||||
directed = true;
|
||||
break;
|
||||
|
|
|
@ -21,9 +21,7 @@ GapScanningParams::GapScanningParams(uint16_t interval, uint16_t window, uint16_
|
|||
_interval(MSEC_TO_SCAN_DURATION_UNITS(interval)),
|
||||
_window(MSEC_TO_SCAN_DURATION_UNITS(window)),
|
||||
_timeout(timeout),
|
||||
_activeScanning(activeScanning),
|
||||
_phy(ble::phy_t::LE_1M),
|
||||
_mode(ble::SCAN_POLICY_IGNORE_WHITELIST) {
|
||||
_activeScanning(activeScanning) {
|
||||
/* stay within limits */
|
||||
if (_interval < SCAN_INTERVAL_MIN) {
|
||||
_interval = SCAN_INTERVAL_MIN;
|
||||
|
|
|
@ -1633,7 +1633,7 @@ ble_error_t GenericGap::setAdvertisingParams(AdvHandle_t handle, const GapAdvert
|
|||
|
||||
address_t dummy_peer_address;
|
||||
|
||||
pal::advertising_event_properties_t event_properties(adv_type);
|
||||
pal::advertising_event_properties_t event_properties((pal::advertising_type_t::type)adv_type);
|
||||
|
||||
return _pal_gap.set_extended_advertising_parameters(
|
||||
Gap::LEGACY_ADVERTISING_HANDLE,
|
||||
|
@ -1660,8 +1660,7 @@ ble_error_t GenericGap::setAdvertisingParams(AdvHandle_t handle, const GapExtend
|
|||
}
|
||||
|
||||
pal::advertising_channel_map_t channel_map(params->getChannel37(), params->getChannel38(), params->getChannel39());
|
||||
pal::advertising_event_properties_t event_properties;//TODO
|
||||
//params->getAdvertisingType()
|
||||
pal::advertising_event_properties_t event_properties((pal::advertising_type_t::type)params->getType());
|
||||
|
||||
return _pal_gap.set_extended_advertising_parameters(
|
||||
handle,
|
||||
|
@ -1669,10 +1668,8 @@ ble_error_t GenericGap::setAdvertisingParams(AdvHandle_t handle, const GapExtend
|
|||
(pal::advertising_interval_t)params->getMinPrimaryInterval(),
|
||||
(pal::advertising_interval_t)params->getMaxPrimaryInterval(),
|
||||
channel_map,
|
||||
params->getOwnAddressType(),
|
||||
pal::own_address_type_t::PUBLIC_ADDRESS,
|
||||
params->getPeerAddressType(),
|
||||
pal::advertising_peer_address_type_t::PUBLIC_ADDRESS,
|
||||
(pal::own_address_type_t::type)params->getOwnAddressType().value(),
|
||||
(pal::advertising_peer_address_type_t::type)params->getPeerAddressType().value(),
|
||||
params->getPeerAddress(),
|
||||
(pal::advertising_filter_policy_t::type) params->getPolicyMode(),
|
||||
(pal::advertising_power_t) params->getTxPower(),
|
||||
|
|
Loading…
Reference in New Issue