Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented queue_msg_waiting. #1925

Merged
merged 6 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions esp-wifi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions esp-wifi/src/compat/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions esp-wifi/src/wifi/os_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}

/// **************************************************************************
Expand Down