-
Notifications
You must be signed in to change notification settings - Fork 12
Description
To improve compatibility of RIOT Sockets with more libraries and applications, I want to propose implementing the following functions for riot_wrappers::socket_embedded_nal_async_udp::UnconnectedUdpSocket, similar to the API of async-io
pub async fn send_to(&mut self, data: &[u8], addr: SocketAddr) -> Result<(), Error>(like this one)pub async fn recv_from(&mut self, buffer: &mut [u8]) -> Result<(usize, SocketAddr), Error>(like this one fromasync-io)- something like
pub async fn peek_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>(like this one to receive a packet without removing it from the queue
Background:
While integrating the (experimental) Rust Matter Library into RIOT OS (see PR) I had to deal with incompatibilities between the Traits NetworkSend and NetworkReceive and the provided functions by UnconnectedUdpSocket. As a workaround I developed a "Wrapper" where I just called the corresponding functions send/receive_into and did some coordination between them. After my implementation, there were some changes in rs-matter, where the traits got renamed and additionally required the wait_available function to enable sharing one buffer between two UDP sockets.
I don't know if there are any other popular libraries in "Rust Embedded" where the same problem arises, but for using the rs-matter Library in RIOT OS it is required. I think it would also be a great benefit in general, if an async_io socket could easily be swapped out by a RIOT Socket.