diff --git a/esp-wifi/Cargo.toml b/esp-wifi/Cargo.toml index cdc2fcf9bd4..1b9bedb31b8 100644 --- a/esp-wifi/Cargo.toml +++ b/esp-wifi/Cargo.toml @@ -6,7 +6,6 @@ license = "MIT OR Apache-2.0" [dependencies] defmt = { workspace = true, optional = true } -embedded-hal.workspace = true esp32c3-hal = { workspace = true, optional = true } esp32c2-hal = { workspace = true, optional = true } esp32c6-hal = { workspace = true, optional = true } diff --git a/esp-wifi/src/common_adapter/mod.rs b/esp-wifi/src/common_adapter/mod.rs index f89d5cfb683..c5e1e09c0d7 100644 --- a/esp-wifi/src/common_adapter/mod.rs +++ b/esp-wifi/src/common_adapter/mod.rs @@ -2,8 +2,7 @@ use crate::binary::include::esp_event_base_t; use crate::binary::include::esp_timer_create_args_t; use crate::binary::include::esp_timer_handle_t; use crate::compat::timer_compat::*; -use crate::{trace, unwrap}; -use embedded_hal::prelude::_embedded_hal_blocking_rng_Read; +use crate::trace; use crate::compat::common::*; @@ -146,9 +145,7 @@ pub unsafe extern "C" fn random() -> crate::binary::c_types::c_ulong { trace!("random"); if let Some(ref mut rng) = RANDOM_GENERATOR { - let mut buffer = [0u8; 4]; - unwrap!(rng.read(&mut buffer)); - u32::from_le_bytes(buffer) + rng.random() } else { 0 } @@ -436,7 +433,10 @@ pub unsafe extern "C" fn esp_fill_random(dst: *mut u8, len: u32) { let dst = core::slice::from_raw_parts_mut(dst, len as usize); if let Some(ref mut rng) = RANDOM_GENERATOR { - unwrap!(rng.read(dst)); + for chunk in dst.chunks_mut(4) { + let bytes = rng.random().to_le_bytes(); + chunk.copy_from_slice(&bytes[..chunk.len()]); + } } }