[nRF5_SDK13] fix:

Gap::setAddress implementation
Gap::getPermittedTxPowerValues implemnetation
pull/3841/head
Andrzej Puzdrowski 2017-02-08 17:18:14 +01:00
parent 3a81e23cf2
commit f32da7a9ee
3 changed files with 11 additions and 9 deletions

View File

@ -165,6 +165,9 @@ error_t btle_init(void)
return ERROR_INVALID_PARAM; return ERROR_INVALID_PARAM;
} }
// Peer Manger must been initialised prior any other call to its API (this file and btle_security_pm.cpp)
pm_init();
#if (NRF_SD_BLE_API_VERSION <= 2) #if (NRF_SD_BLE_API_VERSION <= 2)
ble_gap_addr_t addr; ble_gap_addr_t addr;
if (sd_ble_gap_address_get(&addr) != NRF_SUCCESS) { if (sd_ble_gap_address_get(&addr) != NRF_SUCCESS) {

View File

@ -94,10 +94,6 @@ btle_initializeSecurity(bool enableBonding,
} }
} }
if (pm_init() != NRF_SUCCESS) {
return BLE_ERROR_UNSPECIFIED;
}
// update default security parameters with function call parameters // update default security parameters with function call parameters
securityParameters.bond = enableBonding; securityParameters.bond = enableBonding;
securityParameters.mitm = requireMITM; securityParameters.mitm = requireMITM;

View File

@ -561,12 +561,15 @@ ble_error_t nRF5xGap::setAddress(AddressType_t type, const Address_t address)
*/ */
if ((type == BLEProtocol::AddressType::PUBLIC) || (type == BLEProtocol::AddressType::RANDOM_STATIC)) if ((type == BLEProtocol::AddressType::PUBLIC) || (type == BLEProtocol::AddressType::RANDOM_STATIC))
{ {
memcpy(dev_addr.addr, address, ADDR_LEN);
#if (NRF_SD_BLE_API_VERSION <= 2) #if (NRF_SD_BLE_API_VERSION <= 2)
cycle_mode = BLE_GAP_ADDR_CYCLE_MODE_NONE; cycle_mode = BLE_GAP_ADDR_CYCLE_MODE_NONE;
#else #else
privacy_params.privacy_mode = BLE_GAP_PRIVACY_MODE_OFF; privacy_params.privacy_mode = BLE_GAP_PRIVACY_MODE_OFF;
ASSERT_INT(ERROR_NONE, pm_id_addr_set(&dev_addr), BLE_ERROR_PARAM_OUT_OF_RANGE);
ASSERT_INT(ERROR_NONE, pm_privacy_set(&privacy_params), BLE_ERROR_PARAM_OUT_OF_RANGE);
#endif #endif
memcpy(dev_addr.addr, address, ADDR_LEN);
} }
else if ((type == BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE) || (type == BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE)) else if ((type == BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE) || (type == BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE))
{ {
@ -575,6 +578,8 @@ ble_error_t nRF5xGap::setAddress(AddressType_t type, const Address_t address)
#else #else
privacy_params.privacy_mode = BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY; privacy_params.privacy_mode = BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY;
privacy_params.private_addr_type = type; privacy_params.private_addr_type = type;
ASSERT_INT(ERROR_NONE, pm_privacy_set(&privacy_params), BLE_ERROR_PARAM_OUT_OF_RANGE);
#endif #endif
// address is ignored when in auto mode // address is ignored when in auto mode
} }
@ -586,9 +591,6 @@ ble_error_t nRF5xGap::setAddress(AddressType_t type, const Address_t address)
dev_addr.addr_type = type; dev_addr.addr_type = type;
#if (NRF_SD_BLE_API_VERSION <= 2) #if (NRF_SD_BLE_API_VERSION <= 2)
ASSERT_INT(ERROR_NONE, sd_ble_gap_address_set(cycle_mode, &dev_addr), BLE_ERROR_PARAM_OUT_OF_RANGE); ASSERT_INT(ERROR_NONE, sd_ble_gap_address_set(cycle_mode, &dev_addr), BLE_ERROR_PARAM_OUT_OF_RANGE);
#else
ASSERT_INT(ERROR_NONE, pm_privacy_set(&privacy_params), BLE_ERROR_PARAM_OUT_OF_RANGE);
ASSERT_INT(ERROR_NONE, pm_id_addr_set(&dev_addr), BLE_ERROR_PARAM_OUT_OF_RANGE);
#endif #endif
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
@ -678,7 +680,7 @@ void nRF5xGap::getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *co
}; };
#elif defined(NRF52840_XXAA) #elif defined(NRF52840_XXAA)
static const int8_t permittedTxValues[] = { static const int8_t permittedTxValues[] = {
-40, -20, -16, -12, -8, -4, 0, 4, 5, 6, 7, 8, 9 -40, -20, -16, -12, -8, -4, 0, 2, 3, 4, 5, 6, 7, 8, 9
}; };
#else #else
#error permitted TX power values unknown for this SOC #error permitted TX power values unknown for this SOC
@ -1118,6 +1120,7 @@ ble_error_t nRF5xGap::getStackWhiteIdentityList(GapWhiteAndIdentityList_t &gapAd
if (!irk_found[i]) if (!irk_found[i])
{ {
memcpy(&gapAdrHelper.addrs[i], &whitelistAddresses[i], sizeof(ble_gap_addr_t)); memcpy(&gapAdrHelper.addrs[i], &whitelistAddresses[i], sizeof(ble_gap_addr_t));
gapAdrHelper.addrs[i].addr_id_peer = 0;
gapAdrHelper.addrs_cnt++; gapAdrHelper.addrs_cnt++;
} }
} }