From c069211e72cfe7a0fd60b070fcf09239e9f6a5f2 Mon Sep 17 00:00:00 2001 From: Michael Watzko Date: Tue, 12 Feb 2019 23:26:14 +0100 Subject: [PATCH] GH-3: Dont require the local port in .blocking_send anymore --- README.md | 4 ++-- src/lib.rs | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9356f25..c8df125 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,9 @@ Below some really basic usage how I am ca using it: if let Ok(Some((ip, port, len))) = (w5500, socket).receive(&mut buffer[..]) { let (request_buffer, response_buffer) = buffer.split_mut_at(len); - //... + // ... fill the response_buffer with some data ... - (w5500, socket).blocking_send(ip, port, 1234, response_buffer[..response_len]).unwrap(); + (w5500, socket).blocking_send(ip, port, response_buffer[..response_len]).unwrap(); } } ``` diff --git a/src/lib.rs b/src/lib.rs index eacab2c..b51ef3f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -351,7 +351,6 @@ pub trait Udp { &mut self, host: &IpAddress, host_port: u16, - local_port: u16, data: &[u8], ) -> Result<(), E>; } @@ -412,12 +411,12 @@ impl Udp for (&mut ActiveW5500<'_, '_, '_, E>, &UdpSocket) { &mut self, host: &IpAddress, host_port: u16, - local_port: u16, data: &[u8], ) -> Result<(), E> { let (w5500, UdpSocket(socket)) = self; { + let local_port = w5500.read_u16(socket.at(SocketRegister::LocalPort))?; let local_port = u16_to_be_bytes(local_port); let host_port = u16_to_be_bytes(host_port);