diff options
Diffstat (limited to 'embassy-net/src/tcp.rs')
| -rw-r--r-- | embassy-net/src/tcp.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index 0dc8da73a..0fbf0c91b 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs | |||
| @@ -3,12 +3,12 @@ use core::future::poll_fn; | |||
| 3 | use core::mem; | 3 | use core::mem; |
| 4 | use core::task::Poll; | 4 | use core::task::Poll; |
| 5 | 5 | ||
| 6 | use embassy_net_driver::Driver; | ||
| 6 | use smoltcp::iface::{Interface, SocketHandle}; | 7 | use smoltcp::iface::{Interface, SocketHandle}; |
| 7 | use smoltcp::socket::tcp; | 8 | use smoltcp::socket::tcp; |
| 8 | use smoltcp::time::Duration; | 9 | use smoltcp::time::Duration; |
| 9 | use smoltcp::wire::{IpEndpoint, IpListenEndpoint}; | 10 | use smoltcp::wire::{IpEndpoint, IpListenEndpoint}; |
| 10 | 11 | ||
| 11 | use crate::device::Device; | ||
| 12 | use crate::{SocketStack, Stack}; | 12 | use crate::{SocketStack, Stack}; |
| 13 | 13 | ||
| 14 | #[derive(PartialEq, Eq, Clone, Copy, Debug)] | 14 | #[derive(PartialEq, Eq, Clone, Copy, Debug)] |
| @@ -66,7 +66,7 @@ impl<'a> TcpWriter<'a> { | |||
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | impl<'a> TcpSocket<'a> { | 68 | impl<'a> TcpSocket<'a> { |
| 69 | pub fn new<D: Device>(stack: &'a Stack<D>, rx_buffer: &'a mut [u8], tx_buffer: &'a mut [u8]) -> Self { | 69 | pub fn new<D: Driver>(stack: &'a Stack<D>, rx_buffer: &'a mut [u8], tx_buffer: &'a mut [u8]) -> Self { |
| 70 | let s = &mut *stack.socket.borrow_mut(); | 70 | let s = &mut *stack.socket.borrow_mut(); |
| 71 | let rx_buffer: &'static mut [u8] = unsafe { mem::transmute(rx_buffer) }; | 71 | let rx_buffer: &'static mut [u8] = unsafe { mem::transmute(rx_buffer) }; |
| 72 | let tx_buffer: &'static mut [u8] = unsafe { mem::transmute(tx_buffer) }; | 72 | let tx_buffer: &'static mut [u8] = unsafe { mem::transmute(tx_buffer) }; |
| @@ -336,19 +336,19 @@ pub mod client { | |||
| 336 | use super::*; | 336 | use super::*; |
| 337 | 337 | ||
| 338 | /// TCP client capable of creating up to N multiple connections with tx and rx buffers according to TX_SZ and RX_SZ. | 338 | /// TCP client capable of creating up to N multiple connections with tx and rx buffers according to TX_SZ and RX_SZ. |
| 339 | pub struct TcpClient<'d, D: Device, const N: usize, const TX_SZ: usize = 1024, const RX_SZ: usize = 1024> { | 339 | pub struct TcpClient<'d, D: Driver, const N: usize, const TX_SZ: usize = 1024, const RX_SZ: usize = 1024> { |
| 340 | stack: &'d Stack<D>, | 340 | stack: &'d Stack<D>, |
| 341 | state: &'d TcpClientState<N, TX_SZ, RX_SZ>, | 341 | state: &'d TcpClientState<N, TX_SZ, RX_SZ>, |
| 342 | } | 342 | } |
| 343 | 343 | ||
| 344 | impl<'d, D: Device, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpClient<'d, D, N, TX_SZ, RX_SZ> { | 344 | impl<'d, D: Driver, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpClient<'d, D, N, TX_SZ, RX_SZ> { |
| 345 | /// Create a new TcpClient | 345 | /// Create a new TcpClient |
| 346 | pub fn new(stack: &'d Stack<D>, state: &'d TcpClientState<N, TX_SZ, RX_SZ>) -> Self { | 346 | pub fn new(stack: &'d Stack<D>, state: &'d TcpClientState<N, TX_SZ, RX_SZ>) -> Self { |
| 347 | Self { stack, state } | 347 | Self { stack, state } |
| 348 | } | 348 | } |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | impl<'d, D: Device, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_nal_async::TcpConnect | 351 | impl<'d, D: Driver, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_nal_async::TcpConnect |
| 352 | for TcpClient<'d, D, N, TX_SZ, RX_SZ> | 352 | for TcpClient<'d, D, N, TX_SZ, RX_SZ> |
| 353 | { | 353 | { |
| 354 | type Error = Error; | 354 | type Error = Error; |
| @@ -386,7 +386,7 @@ pub mod client { | |||
| 386 | } | 386 | } |
| 387 | 387 | ||
| 388 | impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpConnection<'d, N, TX_SZ, RX_SZ> { | 388 | impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpConnection<'d, N, TX_SZ, RX_SZ> { |
| 389 | fn new<D: Device>(stack: &'d Stack<D>, state: &'d TcpClientState<N, TX_SZ, RX_SZ>) -> Result<Self, Error> { | 389 | fn new<D: Driver>(stack: &'d Stack<D>, state: &'d TcpClientState<N, TX_SZ, RX_SZ>) -> Result<Self, Error> { |
| 390 | let mut bufs = state.pool.alloc().ok_or(Error::ConnectionReset)?; | 390 | let mut bufs = state.pool.alloc().ok_or(Error::ConnectionReset)?; |
| 391 | Ok(Self { | 391 | Ok(Self { |
| 392 | socket: unsafe { TcpSocket::new(stack, &mut bufs.as_mut().0, &mut bufs.as_mut().1) }, | 392 | socket: unsafe { TcpSocket::new(stack, &mut bufs.as_mut().0, &mut bufs.as_mut().1) }, |
