Skip to content

Commit

Permalink
Enforce BLEClient creation via BLEDevice instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
codepainters committed Oct 6, 2024
1 parent 39354a0 commit 1077209
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/ble_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use esp_idf_sys::{esp, esp_nofail, EspError};
use once_cell::sync::Lazy;

use crate::{
ble, enums::*, utilities::mutex::Mutex, BLEAddress, BLEAddressType, BLEError, BLESecurity,
BLEServer,
ble, enums::*, utilities::mutex::Mutex, BLEAddress, BLEAddressType, BLEClient, BLEError,
BLESecurity, BLEServer,
};

#[cfg(not(esp_idf_bt_nimble_ext_adv))]
Expand Down Expand Up @@ -149,6 +149,10 @@ impl BLEDevice {
Ok(())
}

pub fn new_client(&self) -> BLEClient {
BLEClient::new()
}

pub fn get_server(&self) -> &'static mut BLEServer {
unsafe { Lazy::force_mut(&mut BLE_SERVER) }
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/ble_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct BLEClient {
}

impl BLEClient {
pub fn new() -> Self {
pub(crate) fn new() -> Self {
Self {
state: ArcUnsafeCell::new(BLEClientState {
address: None,
Expand Down

0 comments on commit 1077209

Please sign in to comment.