Skip to content

Commit

Permalink
Merge pull request #44 from taks/fix-link-error
Browse files Browse the repository at this point in the history
Fix link error for esp32c3
  • Loading branch information
taks authored Nov 15, 2023
2 parents 8250ca8 + 1736674 commit 217ef0d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ble_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ type BLEAdvertising = crate::BLEExtAdvertising;

extern "C" {
fn ble_store_config_init();
}

#[cfg(esp32)]
extern "C" {
fn ble_hs_pvcy_rpa_config(enable: u8) -> core::ffi::c_int;
}
#[cfg(esp32)]
const NIMBLE_HOST_DISABLE_PRIVACY: u8 = 0x00;
#[cfg(esp32)]
const NIMBLE_HOST_ENABLE_RPA: u8 = 0x01;
#[cfg(esp32)]
const NIMBLE_HOST_ENABLE_NRPA: u8 = 0x02;

static mut BLE_DEVICE: Lazy<BLEDevice> = Lazy::new(|| {
Expand Down Expand Up @@ -197,6 +204,7 @@ impl BLEDevice {
}

/// Set the own address type to non-resolvable random address.
#[cfg(esp32)]
pub fn set_own_addr_type_to_non_resolvable_random(&mut self) {
self._set_own_addr_type(OwnAddrType::Random, true);
}
Expand All @@ -206,10 +214,12 @@ impl BLEDevice {
OWN_ADDR_TYPE = own_addr_type;
match own_addr_type {
OwnAddrType::Public => {
#[cfg(esp32)]
ble_hs_pvcy_rpa_config(NIMBLE_HOST_DISABLE_PRIVACY);
}
OwnAddrType::Random => {
self.security().resolve_rpa();
#[cfg(esp32)]
ble_hs_pvcy_rpa_config(if use_nrpa {
NIMBLE_HOST_ENABLE_NRPA
} else {
Expand All @@ -218,6 +228,7 @@ impl BLEDevice {
}
OwnAddrType::RpaPublicDefault | OwnAddrType::RpaRandomDefault => {
self.security().resolve_rpa();
#[cfg(esp32)]
ble_hs_pvcy_rpa_config(NIMBLE_HOST_ENABLE_RPA);
}
}
Expand Down

0 comments on commit 217ef0d

Please sign in to comment.