Skip to content

Commit

Permalink
Added impl BLEDevice.set_rnd_addr function.
Browse files Browse the repository at this point in the history
  • Loading branch information
taks committed Nov 14, 2023
1 parent a22125a commit 5b603eb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ble_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ impl BLEDevice {
&mut self.security
}

/// Set the own address type.
pub fn set_own_addr_type(&mut self, own_addr_type: OwnAddrType, use_nrpa: bool) {
unsafe {
OWN_ADDR_TYPE = own_addr_type;
Expand All @@ -214,6 +215,14 @@ impl BLEDevice {
}
}

/// Set the own address to be used when the address type is random.
pub fn set_rnd_addr(&mut self, mut addr: [u8; 6]) -> Result<(), BLEReturnCode> {
addr.reverse();
unsafe {
ble!(esp_idf_sys::ble_hs_id_set_rnd(addr.as_ptr()))
}
}

#[allow(temporary_cstring_as_ptr)]
pub fn set_device_name(device_name: &str) -> Result<(), BLEReturnCode> {
unsafe {
Expand Down

0 comments on commit 5b603eb

Please sign in to comment.