diff --git a/esp-wifi/CHANGELOG.md b/esp-wifi/CHANGELOG.md index 7cb45eb81de..b11a898719f 100644 --- a/esp-wifi/CHANGELOG.md +++ b/esp-wifi/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Implement `embedded_io::{ReadReady, WriteReady}` traits for `WifiStack` (#1882) +- Implement `queue_msg_waiting` on the os_adapter (#1925) ### Changed diff --git a/esp-wifi/src/compat/common.rs b/esp-wifi/src/compat/common.rs index 5fa4a8f4f06..c8a3781eb54 100644 --- a/esp-wifi/src/compat/common.rs +++ b/esp-wifi/src/compat/common.rs @@ -308,6 +308,14 @@ pub fn receive_queued(queue: *mut c_void, item: *mut c_void, block_time_tick: u3 yield_task(); } } +pub fn number_of_messages_in_queue(queue: *const c_void) -> u32 { + trace!("queue_msg_waiting {:?}", queue); + if queue != unsafe { addr_of!(REAL_WIFI_QUEUE).cast() } { + warn!("queue_msg_waiting: Unknown queue."); + return 0; + } + critical_section::with(|_| unsafe { REAL_WIFI_QUEUE.len() as u32 }) +} /// Implementation of sleep() from newlib in esp-idf. /// components/newlib/time.c diff --git a/esp-wifi/src/wifi/os_adapter.rs b/esp-wifi/src/wifi/os_adapter.rs index 805aa64f35c..a9b44bacb6a 100644 --- a/esp-wifi/src/wifi/os_adapter.rs +++ b/esp-wifi/src/wifi/os_adapter.rs @@ -20,6 +20,7 @@ use crate::{ create_recursive_mutex, create_wifi_queue, lock_mutex, + number_of_messages_in_queue, receive_queued, send_queued, str_from_c, @@ -530,8 +531,8 @@ pub unsafe extern "C" fn queue_recv( /// Message number /// /// ************************************************************************* -pub unsafe extern "C" fn queue_msg_waiting(_queue: *mut crate::binary::c_types::c_void) -> u32 { - todo!("queue_msg_waiting") +pub unsafe extern "C" fn queue_msg_waiting(queue: *mut crate::binary::c_types::c_void) -> u32 { + number_of_messages_in_queue(queue) } /// **************************************************************************