Skip to content

Commit

Permalink
Implemented queue_msg_waiting. (#1925)
Browse files Browse the repository at this point in the history
* Implemented queue_msg_waiting.

* Fmt.

* Adjusted changelog.

* Fixed CI.

* Fixed pointer mutability.
  • Loading branch information
Frostie314159 authored Aug 14, 2024
1 parent 6b6e628 commit 1173aac
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
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

0 comments on commit 1173aac

Please sign in to comment.