Skip to content

Commit a5acc67

Browse files
committed
Updated to latest embedded-nal
1 parent 40a908c commit a5acc67

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ edition = "2018"
1313
[dependencies]
1414
byteorder = { version = "1.3.4", default-features = false }
1515
embedded-hal = "0.2.4"
16-
embedded-nal = "0.2.0"
16+
embedded-nal = { git = "https://github.com/rust-embedded-community/embedded-nal.git", rev = "0bc4d77" }
1717
bit_field = "0.10.1"
1818
nb = "1.0.0"

src/udp.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::interface::Interface;
44
use crate::register::socketn;
55
use crate::socket::Socket;
66
use core::fmt::Debug;
7-
use embedded_nal::{nb, IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4, UdpClient, UdpServer};
7+
use embedded_nal::{nb, IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4, UdpClientStack, UdpFullStack};
88

99
pub struct UdpSocket {
1010
socket: Socket,
@@ -178,15 +178,15 @@ impl<E: Debug> From<NbError<E>> for nb::Error<E> {
178178
}
179179
}
180180

181-
impl<SpiBus, HostImpl> UdpClient for Interface<SpiBus, HostImpl>
181+
impl<SpiBus, HostImpl> UdpClientStack for Interface<SpiBus, HostImpl>
182182
where
183183
SpiBus: ActiveBus,
184184
HostImpl: Host,
185185
{
186186
type UdpSocket = UdpSocket;
187187
type Error = UdpSocketError<SpiBus::Error>;
188188

189-
fn socket(&self) -> Result<Self::UdpSocket, Self::Error> {
189+
fn socket(&mut self) -> Result<Self::UdpSocket, Self::Error> {
190190
let mut device = self.device.borrow_mut();
191191
if let Some(socket) = device.take_socket() {
192192
Ok(UdpSocket::new(socket))
@@ -195,7 +195,7 @@ where
195195
}
196196
}
197197

198-
fn connect(&self, socket: &mut Self::UdpSocket, remote: SocketAddr) -> Result<(), Self::Error> {
198+
fn connect(&mut self, socket: &mut Self::UdpSocket, remote: SocketAddr) -> Result<(), Self::Error> {
199199
let mut device = self.device.borrow_mut();
200200
if let SocketAddr::V4(remote) = remote {
201201
// TODO find a random port
@@ -206,37 +206,37 @@ where
206206
Err(Self::Error::UnsupportedAddress)
207207
}
208208
}
209-
fn send(&self, socket: &mut Self::UdpSocket, buffer: &[u8]) -> nb::Result<(), Self::Error> {
209+
fn send(&mut self, socket: &mut Self::UdpSocket, buffer: &[u8]) -> nb::Result<(), Self::Error> {
210210
socket.send(&mut self.device.borrow_mut().bus, buffer)?;
211211
Ok(())
212212
}
213213
fn receive(
214-
&self,
214+
&mut self,
215215
socket: &mut Self::UdpSocket,
216216
buffer: &mut [u8],
217217
) -> nb::Result<(usize, SocketAddr), Self::Error> {
218218
Ok(socket.receive(&mut self.device.borrow_mut().bus, buffer)?)
219219
}
220-
fn close(&self, socket: Self::UdpSocket) -> Result<(), Self::Error> {
220+
fn close(&mut self, socket: Self::UdpSocket) -> Result<(), Self::Error> {
221221
let mut device = self.device.borrow_mut();
222222
socket.close(&mut device.bus)?;
223223
device.release_socket(socket.socket);
224224
Ok(())
225225
}
226226
}
227227

228-
impl<SpiBus, HostImpl> UdpServer for Interface<SpiBus, HostImpl>
228+
impl<SpiBus, HostImpl> UdpFullStack for Interface<SpiBus, HostImpl>
229229
where
230230
SpiBus: ActiveBus,
231231
HostImpl: Host,
232232
{
233-
fn bind(&self, socket: &mut Self::UdpSocket, local_port: u16) -> Result<(), Self::Error> {
233+
fn bind(&mut self, socket: &mut Self::UdpSocket, local_port: u16) -> Result<(), Self::Error> {
234234
let mut device = self.device.borrow_mut();
235235
socket.open(&mut device.bus, local_port)?;
236236
Ok(())
237237
}
238238
fn send_to(
239-
&self,
239+
&mut self,
240240
socket: &mut Self::UdpSocket,
241241
remote: SocketAddr,
242242
buffer: &[u8],

0 commit comments

Comments
 (0)