mirror of https://github.com/ARMmbed/mbed-os.git
BLE: Fix address type in ::ble::Gap::connect
parent
c9e8501b22
commit
190b9bc125
|
@ -605,14 +605,6 @@ struct peer_address_type_t :SafeEnum<peer_address_type_t, uint8_t> {
|
|||
ANONYMOUS = 0xFF
|
||||
};
|
||||
|
||||
ble::target_peer_address_type_t getTargetAddressType() const {
|
||||
if (value() == RANDOM || value() == RANDOM_STATIC_IDENTITY) {
|
||||
return ble::target_peer_address_type_t::RANDOM;
|
||||
}
|
||||
|
||||
return ble::target_peer_address_type_t::PUBLIC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance of peer_address_type_t.
|
||||
*/
|
||||
|
|
|
@ -862,7 +862,7 @@ public:
|
|||
* ends.
|
||||
*/
|
||||
virtual ble_error_t connect(
|
||||
target_peer_address_type_t peerAddressType,
|
||||
peer_address_type_t peerAddressType,
|
||||
const address_t &peerAddress,
|
||||
const ConnectionParameters &connectionParams
|
||||
);
|
||||
|
|
|
@ -294,7 +294,7 @@ public:
|
|||
* @see Gap::connect
|
||||
*/
|
||||
virtual ble_error_t connect(
|
||||
target_peer_address_type_t peerAddressType,
|
||||
peer_address_type_t peerAddressType,
|
||||
const ble::address_t &peerAddress,
|
||||
const ConnectionParameters &connectionParams
|
||||
);
|
||||
|
|
|
@ -228,7 +228,7 @@ uint8_t Gap::getMaxPeriodicAdvertiserListSize()
|
|||
}
|
||||
|
||||
ble_error_t Gap::connect(
|
||||
target_peer_address_type_t peerAddressType,
|
||||
peer_address_type_t peerAddressType,
|
||||
const address_t &peerAddress,
|
||||
const ConnectionParameters &connectionParams
|
||||
)
|
||||
|
|
|
@ -638,7 +638,7 @@ ble_error_t GenericGap::connect(
|
|||
|
||||
|
||||
ble_error_t GenericGap::connect(
|
||||
target_peer_address_type_t peerAddressType,
|
||||
peer_address_type_t peerAddressType,
|
||||
const ble::address_t &peerAddress,
|
||||
const ConnectionParameters &connectionParams
|
||||
)
|
||||
|
@ -647,6 +647,10 @@ ble_error_t GenericGap::connect(
|
|||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (peerAddressType == peer_address_type_t::ANONYMOUS) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (!is_extended_advertising_available()) {
|
||||
phy_set_t set(connectionParams.getPhySet());
|
||||
if (set.count() != 1 || set.get_1m() == false) {
|
||||
|
@ -654,10 +658,19 @@ ble_error_t GenericGap::connect(
|
|||
}
|
||||
}
|
||||
|
||||
// reduce the address type to public or random
|
||||
peer_address_type_t adjusted_address_type(peer_address_type_t::PUBLIC);
|
||||
|
||||
if (peerAddressType == peer_address_type_t::RANDOM ||
|
||||
peerAddressType == peer_address_type_t::RANDOM_STATIC_IDENTITY
|
||||
) {
|
||||
adjusted_address_type = peer_address_type_t::RANDOM;
|
||||
}
|
||||
|
||||
return _pal_gap.extended_create_connection(
|
||||
connectionParams.getFilterPolicy(),
|
||||
connectionParams.getOwnAddressType(),
|
||||
(peer_address_type_t::type) peerAddressType.value(),
|
||||
adjusted_address_type,
|
||||
peerAddress,
|
||||
(phy_set_t) connectionParams.getPhySet(),
|
||||
connectionParams.getScanIntervalArray(),
|
||||
|
|
Loading…
Reference in New Issue