mirror of https://github.com/ARMmbed/mbed-os.git
BLE: Generic Gap - fix address management.
parent
c8747aad0f
commit
70e5a14a4d
|
@ -282,7 +282,6 @@ private:
|
|||
pal::Gap &_pal_gap;
|
||||
pal::GenericAccessService &_gap_service;
|
||||
BLEProtocol::AddressType_t _address_type;
|
||||
pal::address_t _address;
|
||||
pal::initiator_policy_t _initiator_policy_mode;
|
||||
pal::scanning_filter_policy_t _scanning_filter_policy;
|
||||
pal::advertising_filter_policy_t _advertising_filter_policy;
|
||||
|
|
|
@ -376,7 +376,6 @@ GenericGap::GenericGap(
|
|||
_pal_gap(pal_gap),
|
||||
_gap_service(generic_access_service),
|
||||
_address_type(BLEProtocol::AddressType::PUBLIC),
|
||||
_address(),
|
||||
_initiator_policy_mode(pal::initiator_policy_t::NO_FILTER),
|
||||
_scanning_filter_policy(pal::scanning_filter_policy_t::NO_FILTER),
|
||||
_advertising_filter_policy(pal::advertising_filter_policy_t::NO_FILTER),
|
||||
|
@ -416,7 +415,6 @@ ble_error_t GenericGap::setAddress(
|
|||
}
|
||||
|
||||
_address_type = type;
|
||||
_address = pal::address_t(address, true);
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
@ -439,7 +437,14 @@ ble_error_t GenericGap::getAddress(
|
|||
BLEProtocol::AddressBytes_t address
|
||||
) {
|
||||
*type = _address_type;
|
||||
memcpy(address, _address.data(), _address.size());
|
||||
pal::address_t address_value;
|
||||
if (_address_type == BLEProtocol::AddressType::PUBLIC) {
|
||||
address_value = _pal_gap.get_device_address();
|
||||
} else {
|
||||
address_value = _pal_gap.get_random_address();
|
||||
}
|
||||
|
||||
memcpy(address, address_value.data(), address_value.size());
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
@ -990,6 +995,12 @@ void GenericGap::on_connection_complete(const pal::GapConnectionCompleteEvent& e
|
|||
e.connection_latency,
|
||||
e.supervision_timeout
|
||||
};
|
||||
pal::address_t address;
|
||||
if (_address_type == BLEProtocol::AddressType::PUBLIC) {
|
||||
address = _pal_gap.get_device_address();
|
||||
} else {
|
||||
address = _pal_gap.get_random_address();
|
||||
}
|
||||
|
||||
processConnectionEvent(
|
||||
e.connection_handle,
|
||||
|
@ -997,7 +1008,7 @@ void GenericGap::on_connection_complete(const pal::GapConnectionCompleteEvent& e
|
|||
(BLEProtocol::AddressType_t) e.peer_address_type.value(),
|
||||
e.peer_address.data(),
|
||||
_address_type,
|
||||
_address.data(),
|
||||
address.data(),
|
||||
&connection_params
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
}
|
||||
|
||||
virtual ble_error_t set_random_address(const address_t& address) {
|
||||
device_random_address = address;
|
||||
DmDevSetRandAddr(const_cast<uint8_t*>(address.data()));
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue