1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
//! Argument and parameter types used by Ethernet Commands and Responses

use atat::atat_derive::AtatEnum;
use no_std_net::Ipv4Addr;

#[derive(Clone, PartialEq, AtatEnum)]
#[repr(u8)]
pub enum OnOff {
    Off = 0,
    On = 1,
}

#[derive(Clone, PartialEq, AtatEnum)]
#[repr(u8)]
pub enum EthernetConfigParameter {
    /// <param_val> decides if the network is active on start up.
    /// • 0 (default): Inactive
    /// • 1: active
    ActiveOnStartup = 0,
    /// <param_val> Phy support mode
    /// • 0: disabled
    /// • 1 (default): enabled
    /// Not available for ODIN-W2 software versions 2.0.0 or 2.0.1. Default PHY values will be used.
    PhySupport = 1,
    /// <param_val> Ethernet speed
    /// • 0 (default): 100 Mbit/s
    /// • 1: 10 Mbit/s
    /// Not available for ODIN-W2 software versions 2.0.0 or 2.0.1. Default PHY values will be used.
    Speed = 2,
    /// <param_val> Ethernet Duplex mode
    /// • 0 (default): Full duplex
    /// • 1: Half duplex
    /// Not available for ODIN-W2 software versions 2.0.0 or 2.0.1. Default PHY values will be used.
    DuplexMode = 3,
    /// <param_val> Auto-negotiation (of speed and duplex mode)
    /// • 0: disabled
    /// • 1 (default): enabled
    /// Not available for ODIN-W2 software versions 2.0.0 or 2.0.1. Default PHY values will be used.
    AutoNegotiation = 4,
    /// <param_val> is the Phy address. The factory default value is 0x3 (for ODIN) and 0x0
    /// (for NINA-W13 and NINA-W15).
    PhyAddress = 5,
    /// IPv4 Mode - <param_val1> to set the way to retrieve an IP address
    /// • 1 (default): Static
    /// • 2: DHCP
    IPv4Mode = 100,
    /// <param_val> is the IPv4 address. The factory default value is 0.0.0.0
    IPv4Address = 101,
    /// <param_val> is the subnet mask. The factory default value is 0.0.0.0
    SubnetMask = 102,
    /// <param_val> is the default gateway. The factory default value is 0.0.0.0
    DefaultGateway = 103,
    /// <param_val> is the primary DNS server IP address. The factory default value is 0
    /// .0.0.0
    PrimaryDNS = 104,
    /// <param_val> is the secondary DNS server IP address. The factory default value is
    /// 0.0.0.0
    SecondaryDNS = 105,
    /// Address conflict detection. The factory default value is 0 (disabled). This tag is
    /// supported by ODIN-W2 from software version 6.0.0 onwards only.
    /// • 0: Disabled
    /// • 1: Enabled
    AddressConflictDetection = 107,
}

#[derive(Clone, PartialEq, AtatEnum)]
pub enum EthernetConfig {
    /// <param_val> decides if the network is active on start up.
    /// • 0 (default): Inactive
    /// • 1: active
    #[at_arg(value = 0)]
    ActiveOnStartup(OnOff),
    /// <param_val> Phy support mode
    /// • 0: disabled
    /// • 1 (default): enabled
    /// Not available for ODIN-W2 software versions 2.0.0 or 2.0.1. Default PHY values will be used.
    #[at_arg(value = 1)]
    PhySupport(OnOff),
    /// <param_val> Ethernet speed
    /// • 0 (default): 100 Mbit/s
    /// • 1: 10 Mbit/s
    /// Not available for ODIN-W2 software versions 2.0.0 or 2.0.1. Default PHY values will be used.
    #[at_arg(value = 2)]
    Speed(EthernetSpeed),
    /// <param_val> Ethernet Duplex mode
    /// • 0 (default): Full duplex
    /// • 1: Half duplex
    /// Not available for ODIN-W2 software versions 2.0.0 or 2.0.1. Default PHY values will be used.
    #[at_arg(value = 3)]
    DuplexMode(EthernetDuplexMode),
    /// <param_val> Auto-negotiation (of speed and duplex mode)
    /// • 0: disabled
    /// • 1 (default): enabled
    /// Not available for ODIN-W2 software versions 2.0.0 or 2.0.1. Default PHY values will be used.
    #[at_arg(value = 4)]
    AutoNegotiation(OnOff),
    /// <param_val> is the Phy address. The factory default value is 0x3 (for ODIN) and 0x0
    /// (for NINA-W13 and NINA-W15).
    #[at_arg(value = 5)]
    PhyAddress(u32),
    /// IPv4 Mode - <param_val1> to set the way to retrieve an IP address
    /// • 1 (default): Static
    /// • 2: DHCP
    #[at_arg(value = 100)]
    IPv4Mode(IPv4Mode),
    /// <param_val> is the IPv4 address. The factory default value is 0.0.0.0
    #[at_arg(value = 101)]
    IPv4Address(#[at_arg(len = 16)] Ipv4Addr),
    /// <param_val> is the subnet mask. The factory default value is 0.0.0.0
    #[at_arg(value = 102)]
    SubnetMask(#[at_arg(len = 16)] Ipv4Addr),
    /// <param_val> is the default gateway. The factory default value is 0.0.0.0
    #[at_arg(value = 103)]
    DefaultGateway(#[at_arg(len = 16)] Ipv4Addr),
    /// <param_val> is the primary DNS server IP address. The factory default value is 0
    /// .0.0.0
    #[at_arg(value = 104)]
    PrimaryDNS(#[at_arg(len = 16)] Ipv4Addr),
    /// <param_val> is the secondary DNS server IP address. The factory default value is
    /// 0.0.0.0
    #[at_arg(value = 105)]
    SecondaryDNS(#[at_arg(len = 16)] Ipv4Addr),
    /// Address conflict detection. The factory default value is 0 (disabled). This tag is
    /// supported by ODIN-W2 from software version 6.0.0 onwards only.
    /// • 0: Disabled
    /// • 1: Enabled
    #[at_arg(value = 107)]
    AddressConflictDetection(OnOff),
}

#[derive(Clone, PartialEq, AtatEnum)]
pub enum EthernetConfigR {
    /// <param_val> decides if the network is active on start up.
    /// • 0 (default): Inactive
    /// • 1: active
    #[at_arg(value = 0)]
    ActiveOnStartup(OnOff),
    /// <param_val> Phy support mode
    /// • 0: disabled
    /// • 1 (default): enabled
    /// Not available for ODIN-W2 software versions 2.0.0 or 2.0.1. Default PHY values will be used.
    #[at_arg(value = 1)]
    PhySupport(OnOff),
    /// <param_val> Ethernet speed
    /// • 0 (default): 100 Mbit/s
    /// • 1: 10 Mbit/s
    /// Not available for ODIN-W2 software versions 2.0.0 or 2.0.1. Default PHY values will be used.
    #[at_arg(value = 2)]
    Speed(EthernetSpeed),
    /// <param_val> Ethernet Duplex mode
    /// • 0 (default): Full duplex
    /// • 1: Half duplex
    /// Not available for ODIN-W2 software versions 2.0.0 or 2.0.1. Default PHY values will be used.
    #[at_arg(value = 3)]
    DuplexMode(EthernetDuplexMode),
    /// <param_val> Auto-negotiation (of speed and duplex mode)
    /// • 0: disabled
    /// • 1 (default): enabled
    /// Not available for ODIN-W2 software versions 2.0.0 or 2.0.1. Default PHY values will be used.
    #[at_arg(value = 4)]
    AutoNegotiation(OnOff),
    /// <param_val> is the Phy address. The factory default value is 0x3 (for ODIN) and 0x0
    /// (for NINA-W13 and NINA-W15).
    #[at_arg(value = 5)]
    PhyAddress(u32),
    /// IPv4 Mode - <param_val1> to set the way to retrieve an IP address
    /// • 1 (default): Static
    /// • 2: DHCP
    #[at_arg(value = 100)]
    IPv4Mode(IPv4Mode),
    /// <param_val> is the IPv4 address. The factory default value is 0.0.0.0
    #[at_arg(value = 101)]
    IPv4Address(#[at_arg(len = 16)] Ipv4Addr),
    /// <param_val> is the subnet mask. The factory default value is 0.0.0.0
    #[at_arg(value = 102)]
    SubnetMask(#[at_arg(len = 16)] Ipv4Addr),
    /// <param_val> is the default gateway. The factory default value is 0.0.0.0
    #[at_arg(value = 103)]
    DefaultGateway(#[at_arg(len = 16)] Ipv4Addr),
    /// <param_val> is the primary DNS server IP address. The factory default value is 0
    /// .0.0.0
    #[at_arg(value = 104)]
    PrimaryDNS(#[at_arg(len = 16)] Ipv4Addr),
    /// <param_val> is the secondary DNS server IP address. The factory default value is
    /// 0.0.0.0
    #[at_arg(value = 105)]
    SecondaryDNS(#[at_arg(len = 16)] Ipv4Addr),
    /// Address conflict detection. The factory default value is 0 (disabled). This tag is
    /// supported by ODIN-W2 from software version 6.0.0 onwards only.
    /// • 0: Disabled
    /// • 1: Enabled
    #[at_arg(value = 107)]
    AddressConflictDetection(OnOff),
}

#[derive(Clone, PartialEq, AtatEnum)]
#[repr(u8)]
pub enum EthernetSpeed {
    Mbps10 = 1,
    Mbps100 = 0,
}

#[derive(Clone, PartialEq, AtatEnum)]
#[repr(u8)]
pub enum EthernetDuplexMode {
    FullDuplex = 0,
    HalfDuplex = 1,
}

#[derive(Clone, PartialEq, AtatEnum)]
#[repr(u8)]
pub enum IPv4Mode {
    Static = 1,
    DHCP = 2,
}

#[derive(Clone, PartialEq, AtatEnum)]
#[repr(u8)]
pub enum EthernetConfigAction {
    /// Reset; it clears the specified profile, resetting all the parameters to their factory
    /// programmed values
    Reset = 0,
    /// Store; it saves all the current parameters
    Store = 1,
    /// Load: it reads all the parameters
    Load = 2,
    /// Activate; it activates the Ethernet, using the current parameters.
    Activate = 3,
    /// Deactivate; it deactivates the Ethernet.
    Deactivate = 4,
}