GH-3: Dont require the local port in .blocking_send anymore

This commit is contained in:
Michael Watzko 2019-02-12 23:26:14 +01:00
commit c069211e72
2 changed files with 3 additions and 4 deletions

View file

@ -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[..]) { if let Ok(Some((ip, port, len))) = (w5500, socket).receive(&mut buffer[..]) {
let (request_buffer, response_buffer) = buffer.split_mut_at(len); 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();
} }
} }
``` ```

View file

@ -351,7 +351,6 @@ pub trait Udp<E> {
&mut self, &mut self,
host: &IpAddress, host: &IpAddress,
host_port: u16, host_port: u16,
local_port: u16,
data: &[u8], data: &[u8],
) -> Result<(), E>; ) -> Result<(), E>;
} }
@ -412,12 +411,12 @@ impl<E> Udp<E> for (&mut ActiveW5500<'_, '_, '_, E>, &UdpSocket) {
&mut self, &mut self,
host: &IpAddress, host: &IpAddress,
host_port: u16, host_port: u16,
local_port: u16,
data: &[u8], data: &[u8],
) -> Result<(), E> { ) -> Result<(), E> {
let (w5500, UdpSocket(socket)) = self; 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 local_port = u16_to_be_bytes(local_port);
let host_port = u16_to_be_bytes(host_port); let host_port = u16_to_be_bytes(host_port);