Skip to content

Commit dbf4cdb

Browse files
committed
Replace deprecated BLE API calls
As the `LegacyGap` class has been deprecated, in favor of the `Gap` class, all references of its references in the code base has been replaced.
1 parent 9243abb commit dbf4cdb

File tree

5 files changed

+54
-39
lines changed

5 files changed

+54
-39
lines changed

features/FEATURE_BLE/targets/TARGET_CORDIO/driver/CordioHCIDriver.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,17 @@ void CordioHCIDriver::handle_reset_sequence(uint8_t *pMsg)
144144
/* parse and store event parameters */
145145
BdaCpy(hciCoreCb.bdAddr, pMsg);
146146

147-
ble::address_t static_address;
148-
149-
if (get_random_static_address(static_address)) {
147+
const ble::peripheral_privacy_configuration_t configuration = {
148+
.use_non_resolvable_random_address = false,
149+
.resolution_strategy = ble::peripheral_privacy_configuration_t::DO_NOT_RESOLVE
150+
};
151+
152+
if (
153+
cordio::BLE::deviceInstance().getGap(
154+
).setPeripheralPrivacyConfiguration(&configuration)
155+
) {
150156
// note: will send the HCI command to send the random address
151-
cordio::BLE::deviceInstance().getGap().setAddress(
152-
BLEProtocol::AddressType::RANDOM_STATIC,
153-
static_address.data()
154-
);
157+
cordio::BLE::deviceInstance().getGap().enablePrivacy(false);
155158
} else {
156159
/* send next command in sequence */
157160
HciLeReadBufSizeCmd();

features/FEATURE_BLE/targets/TARGET_CORDIO_ODIN_W2/HCIDriver.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,17 @@ void ble::vendor::odin_w2::HCIDriver::handle_reset_sequence(uint8_t *pMsg)
337337
randCnt++;
338338
HciLeRandCmd();
339339
} else {
340-
uint8_t addr[6] = { 0 };
341-
memcpy(addr, pMsg, sizeof(addr));
342-
DM_RAND_ADDR_SET(addr, DM_RAND_ADDR_STATIC);
343-
// note: will invoke set rand address
344-
cordio::BLE::deviceInstance().getGap().setAddress(
345-
BLEProtocol::AddressType::RANDOM_STATIC,
346-
addr
347-
);
340+
const ble::peripheral_privacy_configuration_t configuration = {
341+
.use_non_resolvable_random_address = false,
342+
.resolution_strategy = ble::peripheral_privacy_configuration_t::DO_NOT_RESOLVE
343+
};
344+
if (
345+
cordio::BLE::deviceInstance().getGap(
346+
).setPeripheralPrivacyConfiguration(&configuration)
347+
) {
348+
// note: will invoke set rand address
349+
cordio::BLE::deviceInstance().getGap().enablePrivacy(false);
350+
}
348351
}
349352
break;
350353

features/FEATURE_BLE/targets/TARGET_Cypress/COMPONENT_CYW43XXX/HCIDriver.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,17 @@ class HCIDriver : public cordio::CordioHCIDriver {
297297
randCnt++;
298298
HciLeRandCmd();
299299
} else {
300-
uint8_t addr[6] = { 0 };
301-
memcpy(addr, pMsg, sizeof(addr));
302-
DM_RAND_ADDR_SET(addr, DM_RAND_ADDR_STATIC);
303-
// note: will invoke set rand address
304-
cordio::BLE::deviceInstance().getGap().setAddress(
305-
BLEProtocol::AddressType::RANDOM_STATIC,
306-
addr
307-
);
300+
const ble::peripheral_privacy_configuration_t configuration = {
301+
.use_non_resolvable_random_address = false,
302+
.resolution_strategy = ble::peripheral_privacy_configuration_t::DO_NOT_RESOLVE
303+
};
304+
if (
305+
cordio::BLE::deviceInstance().getGap(
306+
).setPeripheralPrivacyConfiguration(&configuration)
307+
) {
308+
// note: will invoke set rand address
309+
cordio::BLE::deviceInstance().getGap().enablePrivacy(false);
310+
}
308311
}
309312
break;
310313

features/FEATURE_BLE/targets/TARGET_STM/TARGET_CYW4343X/HCIDriver.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,17 @@ class HCIDriver : public cordio::CordioHCIDriver {
261261
randCnt++;
262262
HciLeRandCmd();
263263
} else {
264-
uint8_t addr[6] = { 0 };
265-
memcpy(addr, pMsg, sizeof(addr));
266-
DM_RAND_ADDR_SET(addr, DM_RAND_ADDR_STATIC);
267-
// note: will invoke set rand address
268-
cordio::BLE::deviceInstance().getGap().setAddress(
269-
BLEProtocol::AddressType::RANDOM_STATIC,
270-
addr
271-
);
264+
const ble::peripheral_privacy_configuration_t configuration = {
265+
.use_non_resolvable_random_address = false,
266+
.resolution_strategy = ble::peripheral_privacy_configuration_t::DO_NOT_RESOLVE
267+
};
268+
if (
269+
cordio::BLE::deviceInstance().getGap(
270+
).setPeripheralPrivacyConfiguration(&configuration)
271+
) {
272+
// note: will invoke set rand address
273+
cordio::BLE::deviceInstance().getGap().enablePrivacy(false);
274+
}
272275
}
273276
break;
274277

features/FEATURE_BLE/targets/TARGET_STM/TARGET_NUCLEO_WB55RG/stm32wb_HCIDriver.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,14 +307,17 @@ class HCIDriver : public cordio::CordioHCIDriver
307307
randCnt++;
308308
HciLeRandCmd();
309309
} else {
310-
uint8_t addr[6] = { 0 };
311-
memcpy(addr, pMsg, sizeof(addr));
312-
DM_RAND_ADDR_SET(addr, DM_RAND_ADDR_STATIC);
313-
// note: will invoke set rand address
314-
cordio::BLE::deviceInstance().getGap().setAddress(
315-
BLEProtocol::AddressType::RANDOM_STATIC,
316-
addr
317-
);
310+
const ble::peripheral_privacy_configuration_t configuration = {
311+
.use_non_resolvable_random_address = false,
312+
.resolution_strategy = ble::peripheral_privacy_configuration_t::DO_NOT_RESOLVE
313+
};
314+
if (
315+
cordio::BLE::deviceInstance().getGap(
316+
).setPeripheralPrivacyConfiguration(&configuration)
317+
) {
318+
// note: will invoke set rand address
319+
cordio::BLE::deviceInstance().getGap().enablePrivacy(false);
320+
}
318321
}
319322
break;
320323

0 commit comments

Comments
 (0)