wurth_calypso/command/
socket.rs1use super::EmptyResponse;
2use atat::atat_derive::{AtatCmd, AtatEnum};
3use heapless::String;
4
5#[derive(Debug, Clone, Copy, AtatEnum)]
6pub enum SocketFamily {
7 Inet,
8 Inet6,
9}
10
11impl Into<String<5>> for SocketFamily {
12 fn into(self) -> String<5> {
13 String::from(match self {
14 SocketFamily::Inet => "INET",
15 SocketFamily::Inet6 => "INET6",
16 })
17 }
18}
19
20#[derive(Debug, Clone, Copy, AtatEnum)]
21pub enum SocketType {
22 Stream,
23 Dgram,
24}
25
26impl Into<String<6>> for SocketType {
27 fn into(self) -> String<6> {
28 String::from(match self {
29 SocketType::Stream => "STREAM",
30 SocketType::Dgram => "DGRAM",
31 })
32 }
33}
34
35#[derive(Debug, Clone, Copy, AtatEnum)]
36pub enum SocketProtocol {
37 Tcp,
38 Udp,
39 Sec,
40}
41
42impl Into<String<3>> for SocketProtocol {
43 fn into(self) -> String<3> {
44 String::from(match self {
45 SocketProtocol::Tcp => "TCP",
46 SocketProtocol::Udp => "UDP",
47 SocketProtocol::Sec => "SEC",
48 })
49 }
50}
51
52#[derive(AtatCmd)]
54#[at_cmd(
55 "+socket",
56 EmptyResponse,
57 timeout_ms = 100,
58 quote_escape_strings = false
59)]
60pub struct Socket {
61 #[at_arg(position = 0)]
62 pub family: String<5>,
63 #[at_arg(position = 1)]
64 pub type_: String<6>,
65 #[at_arg(position = 2)]
66 pub protocol: String<3>,
67}
68
69#[derive(AtatCmd)]
71#[at_cmd("+close", EmptyResponse, timeout_ms = 100)]
72pub struct Close {
73 #[at_arg(position = 0)]
74 pub socket_id: u8,
75}
76
77#[derive(AtatCmd)]
79#[at_cmd("+bind", EmptyResponse, timeout_ms = 100)]
80pub struct Bind {
81 #[at_arg(position = 0)]
82 pub socket_id: u8,
83 #[at_arg(position = 1)]
84 pub family: String<5>,
85 #[at_arg(position = 2)]
86 pub local_port: u16,
87 #[at_arg(position = 3)]
88 pub local_address: String<15>,
89}