Skip to content

Commit d962fc0

Browse files
committed
BLE: factor code in GAP.
1 parent 28766bd commit d962fc0

File tree

1 file changed

+5
-9
lines changed
  • features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF52/source

1 file changed

+5
-9
lines changed

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,8 @@ nRF5xSecurityManager& get_sm() {
4444

4545
ble_error_t set_private_resolvable_address() {
4646
#if (NRF_SD_BLE_API_VERSION <= 2)
47-
ble_gap_addr_t addr = {
48-
BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE
49-
};
50-
51-
sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_AUTO, &addr);
52-
return BLE_ERROR_NONE;
47+
ble_gap_addr_t addr = { BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE };
48+
uint32_t err = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_AUTO, &addr);
5349
#else
5450
ble_gap_privacy_params_t privacy_config = { 0 };
5551
uint32_t err = sd_ble_gap_privacy_get(&privacy_config);
@@ -59,14 +55,14 @@ ble_error_t set_private_resolvable_address() {
5955

6056
privacy_config.private_addr_type = BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE;
6157
err = sd_ble_gap_privacy_set(&privacy_config);
62-
return err ? BLE_ERROR_UNSPECIFIED : BLE_ERROR_NONE;
6358
#endif
59+
return err ? BLE_ERROR_UNSPECIFIED : BLE_ERROR_NONE;
6460
}
6561

6662
ble_error_t set_private_non_resolvable_address() {
6763
#if (NRF_SD_BLE_API_VERSION <= 2)
6864
ble_gap_addr_t addr = { BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE };
69-
sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_AUTO, &addr);
65+
uint32_t err = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_AUTO, &addr);
7066
#else
7167
ble_gap_privacy_params_t privacy_config = { 0 };
7268
uint32_t err = sd_ble_gap_privacy_get(&privacy_config);
@@ -76,8 +72,8 @@ ble_error_t set_private_non_resolvable_address() {
7672

7773
privacy_config.private_addr_type = BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE;
7874
err = sd_ble_gap_privacy_set(&privacy_config);
79-
return err ? BLE_ERROR_UNSPECIFIED : BLE_ERROR_NONE;
8075
#endif
76+
return err ? BLE_ERROR_UNSPECIFIED : BLE_ERROR_NONE;
8177
}
8278

8379
bool is_advertising_non_connectable(const GapAdvertisingParams &params) {

0 commit comments

Comments
 (0)