Module esp_at_nal::stack

source ·
Expand description

§TCP client stack

This crate fully implements TcpClientStack of embedded_nal.

Block/chunk size is defined a const generics, s. Adapter for more details.


let client = AtClient::default();
let mut adapter: Adapter<_, _, 1_000_000, 1024, 1024> = Adapter::new(client, ExampleTimer::default());

// Creating a TCP connection
let mut  socket = adapter.socket().unwrap();
adapter.connect(&mut socket, SocketAddr::from_str("").unwrap()).unwrap();

// Sending some data
adapter.send(&mut socket, b"hallo!").unwrap();

// Receiving some data
let mut  rx_buffer = [0x0; 64];
let length = adapter.receive(&mut socket, &mut rx_buffer).unwrap();
assert_eq!(16, length);
assert_eq!(b"nice to see you!", &rx_buffer[..16]);

// Closing socket


  • Unique socket for a network connection


  • Network related errors