Skip to content

Replace deprecated BLE API calls #12235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,17 @@ void CordioHCIDriver::handle_reset_sequence(uint8_t *pMsg)
/* parse and store event parameters */
BdaCpy(hciCoreCb.bdAddr, pMsg);

ble::address_t static_address;

if (get_random_static_address(static_address)) {
const ble::peripheral_privacy_configuration_t configuration = {
.use_non_resolvable_random_address = false,
.resolution_strategy = ble::peripheral_privacy_configuration_t::DO_NOT_RESOLVE
};

if (
cordio::BLE::deviceInstance().getGap(
).setPeripheralPrivacyConfiguration(&configuration)
) {
// note: will send the HCI command to send the random address
cordio::BLE::deviceInstance().getGap().setAddress(
BLEProtocol::AddressType::RANDOM_STATIC,
static_address.data()
);
cordio::BLE::deviceInstance().getGap().enablePrivacy(false);
} else {
/* send next command in sequence */
HciLeReadBufSizeCmd();
Expand Down
19 changes: 11 additions & 8 deletions features/FEATURE_BLE/targets/TARGET_CORDIO_ODIN_W2/HCIDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,17 @@ void ble::vendor::odin_w2::HCIDriver::handle_reset_sequence(uint8_t *pMsg)
randCnt++;
HciLeRandCmd();
} else {
uint8_t addr[6] = { 0 };
memcpy(addr, pMsg, sizeof(addr));
DM_RAND_ADDR_SET(addr, DM_RAND_ADDR_STATIC);
// note: will invoke set rand address
cordio::BLE::deviceInstance().getGap().setAddress(
BLEProtocol::AddressType::RANDOM_STATIC,
addr
);
const ble::peripheral_privacy_configuration_t configuration = {
.use_non_resolvable_random_address = false,
.resolution_strategy = ble::peripheral_privacy_configuration_t::DO_NOT_RESOLVE
};
if (
cordio::BLE::deviceInstance().getGap(
).setPeripheralPrivacyConfiguration(&configuration)
) {
// note: will invoke set rand address
cordio::BLE::deviceInstance().getGap().enablePrivacy(false);
}
}
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,17 @@ class HCIDriver : public cordio::CordioHCIDriver {
randCnt++;
HciLeRandCmd();
} else {
uint8_t addr[6] = { 0 };
memcpy(addr, pMsg, sizeof(addr));
DM_RAND_ADDR_SET(addr, DM_RAND_ADDR_STATIC);
// note: will invoke set rand address
cordio::BLE::deviceInstance().getGap().setAddress(
BLEProtocol::AddressType::RANDOM_STATIC,
addr
);
const ble::peripheral_privacy_configuration_t configuration = {
.use_non_resolvable_random_address = false,
.resolution_strategy = ble::peripheral_privacy_configuration_t::DO_NOT_RESOLVE
};
if (
cordio::BLE::deviceInstance().getGap(
).setPeripheralPrivacyConfiguration(&configuration)
) {
// note: will invoke set rand address
cordio::BLE::deviceInstance().getGap().enablePrivacy(false);
}
}
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,17 @@ class HCIDriver : public cordio::CordioHCIDriver {
randCnt++;
HciLeRandCmd();
} else {
uint8_t addr[6] = { 0 };
memcpy(addr, pMsg, sizeof(addr));
DM_RAND_ADDR_SET(addr, DM_RAND_ADDR_STATIC);
// note: will invoke set rand address
cordio::BLE::deviceInstance().getGap().setAddress(
BLEProtocol::AddressType::RANDOM_STATIC,
addr
);
const ble::peripheral_privacy_configuration_t configuration = {
.use_non_resolvable_random_address = false,
.resolution_strategy = ble::peripheral_privacy_configuration_t::DO_NOT_RESOLVE
};
if (
cordio::BLE::deviceInstance().getGap(
).setPeripheralPrivacyConfiguration(&configuration)
) {
// note: will invoke set rand address
cordio::BLE::deviceInstance().getGap().enablePrivacy(false);
}
}
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,17 @@ class HCIDriver : public cordio::CordioHCIDriver
randCnt++;
HciLeRandCmd();
} else {
uint8_t addr[6] = { 0 };
memcpy(addr, pMsg, sizeof(addr));
DM_RAND_ADDR_SET(addr, DM_RAND_ADDR_STATIC);
// note: will invoke set rand address
cordio::BLE::deviceInstance().getGap().setAddress(
BLEProtocol::AddressType::RANDOM_STATIC,
addr
);
const ble::peripheral_privacy_configuration_t configuration = {
.use_non_resolvable_random_address = false,
.resolution_strategy = ble::peripheral_privacy_configuration_t::DO_NOT_RESOLVE
};
if (
cordio::BLE::deviceInstance().getGap(
).setPeripheralPrivacyConfiguration(&configuration)
) {
// note: will invoke set rand address
cordio::BLE::deviceInstance().getGap().enablePrivacy(false);
}
}
break;

Expand Down