Skip to content

Commit b5d9db7

Browse files
nvlsianpuadbridge
authored andcommitted
fix: Gap::setAddress implementation Gap::getPermittedTxPowerValues implemnetation
1 parent bb1f316 commit b5d9db7

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5_SDK13/source/btle/btle.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ error_t btle_init(void)
165165
return ERROR_INVALID_PARAM;
166166
}
167167

168+
// Peer Manger must been initialised prior any other call to its API (this file and btle_security_pm.cpp)
169+
pm_init();
170+
168171
#if (NRF_SD_BLE_API_VERSION <= 2)
169172
ble_gap_addr_t addr;
170173
if (sd_ble_gap_address_get(&addr) != NRF_SUCCESS) {

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5_SDK13/source/btle/btle_security_pm.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ btle_initializeSecurity(bool enableBonding,
9494
}
9595
}
9696

97-
if (pm_init() != NRF_SUCCESS) {
98-
return BLE_ERROR_UNSPECIFIED;
99-
}
100-
10197
// update default security parameters with function call parameters
10298
securityParameters.bond = enableBonding;
10399
securityParameters.mitm = requireMITM;

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5_SDK13/source/nRF5xGap.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,12 +561,15 @@ ble_error_t nRF5xGap::setAddress(AddressType_t type, const Address_t address)
561561
*/
562562
if ((type == BLEProtocol::AddressType::PUBLIC) || (type == BLEProtocol::AddressType::RANDOM_STATIC))
563563
{
564+
memcpy(dev_addr.addr, address, ADDR_LEN);
564565
#if (NRF_SD_BLE_API_VERSION <= 2)
565566
cycle_mode = BLE_GAP_ADDR_CYCLE_MODE_NONE;
566567
#else
567568
privacy_params.privacy_mode = BLE_GAP_PRIVACY_MODE_OFF;
569+
570+
ASSERT_INT(ERROR_NONE, pm_id_addr_set(&dev_addr), BLE_ERROR_PARAM_OUT_OF_RANGE);
571+
ASSERT_INT(ERROR_NONE, pm_privacy_set(&privacy_params), BLE_ERROR_PARAM_OUT_OF_RANGE);
568572
#endif
569-
memcpy(dev_addr.addr, address, ADDR_LEN);
570573
}
571574
else if ((type == BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE) || (type == BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE))
572575
{
@@ -575,6 +578,8 @@ ble_error_t nRF5xGap::setAddress(AddressType_t type, const Address_t address)
575578
#else
576579
privacy_params.privacy_mode = BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY;
577580
privacy_params.private_addr_type = type;
581+
582+
ASSERT_INT(ERROR_NONE, pm_privacy_set(&privacy_params), BLE_ERROR_PARAM_OUT_OF_RANGE);
578583
#endif
579584
// address is ignored when in auto mode
580585
}
@@ -586,9 +591,6 @@ ble_error_t nRF5xGap::setAddress(AddressType_t type, const Address_t address)
586591
dev_addr.addr_type = type;
587592
#if (NRF_SD_BLE_API_VERSION <= 2)
588593
ASSERT_INT(ERROR_NONE, sd_ble_gap_address_set(cycle_mode, &dev_addr), BLE_ERROR_PARAM_OUT_OF_RANGE);
589-
#else
590-
ASSERT_INT(ERROR_NONE, pm_privacy_set(&privacy_params), BLE_ERROR_PARAM_OUT_OF_RANGE);
591-
ASSERT_INT(ERROR_NONE, pm_id_addr_set(&dev_addr), BLE_ERROR_PARAM_OUT_OF_RANGE);
592594
#endif
593595

594596
return BLE_ERROR_NONE;
@@ -678,7 +680,7 @@ void nRF5xGap::getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *co
678680
};
679681
#elif defined(NRF52840_XXAA)
680682
static const int8_t permittedTxValues[] = {
681-
-40, -20, -16, -12, -8, -4, 0, 4, 5, 6, 7, 8, 9
683+
-40, -20, -16, -12, -8, -4, 0, 2, 3, 4, 5, 6, 7, 8, 9
682684
};
683685
#else
684686
#error permitted TX power values unknown for this SOC
@@ -1118,6 +1120,7 @@ ble_error_t nRF5xGap::getStackWhiteIdentityList(GapWhiteAndIdentityList_t &gapAd
11181120
if (!irk_found[i])
11191121
{
11201122
memcpy(&gapAdrHelper.addrs[i], &whitelistAddresses[i], sizeof(ble_gap_addr_t));
1123+
gapAdrHelper.addrs[i].addr_id_peer = 0;
11211124
gapAdrHelper.addrs_cnt++;
11221125
}
11231126
}

0 commit comments

Comments
 (0)