GenericGap: Revert changes introduced to accomodate privacy.

pull/6932/head
Vincent Coubard 2018-05-17 10:56:29 +01:00
parent 7f05fc0e00
commit 0eb680a08b
1 changed files with 24 additions and 26 deletions

View File

@ -316,7 +316,7 @@ static bool is_whitelist_valid(const Gap::Whitelist_t& whitelist)
for (size_t i = 0; i < whitelist.size; ++i) {
const BLEProtocol::Address_t& address = whitelist.addresses[i];
if (address.type != BLEProtocol::AddressType::PUBLIC &&
address.type != BLEProtocol::AddressType::RANDOM
address.type != BLEProtocol::AddressType::RANDOM_STATIC
) {
return false;
}
@ -423,7 +423,6 @@ ble_error_t GenericGap::setAddress(
_address_type = type;
return BLE_ERROR_NONE;
case BLEProtocol::AddressType::RANDOM:
case BLEProtocol::AddressType::RANDOM_STATIC: {
if (is_random_static_address(address) == false) {
return BLE_ERROR_INVALID_PARAM;
@ -436,12 +435,18 @@ ble_error_t GenericGap::setAddress(
return err;
}
_address_type = BLEProtocol::AddressType::RANDOM;
_address_type = type;
_address = ble::address_t(address);
_random_static_identity_address = ble::address_t(address);
return BLE_ERROR_NONE;
}
case BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE:
case BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE:
// Note: it is not allowed to set directly these addresses
// privacy management handled it for users.
return BLE_ERROR_INVALID_PARAM;
default:
return BLE_ERROR_INVALID_PARAM;
}
@ -454,17 +459,10 @@ ble_error_t GenericGap::getAddress(
*type = _address_type;
ble::address_t address_value;
switch (_address_type) {
case BLEProtocol::AddressType::PUBLIC:
if (_address_type == BLEProtocol::AddressType::PUBLIC) {
address_value = _pal_gap.get_device_address();
break;
case BLEProtocol::AddressType::RANDOM:
} else {
address_value = _pal_gap.get_random_address();
break;
default:
return BLE_ERROR_INVALID_PARAM;
}
memcpy(address, address_value.data(), address_value.size());