@@ -79,12 +79,17 @@ typedef enum {
79
79
NI_ETHERNET
80
80
} NetIfType_t;
81
81
82
- enum EthernetLinkStatus {
82
+ enum LinkStatus {
83
83
Unknown,
84
84
LinkON,
85
85
LinkOFF
86
86
};
87
87
88
+ enum EthernetHardwareStatus {
89
+ EthernetNoHardware,
90
+ EthernetLwip = 7
91
+ };
92
+
88
93
#define MAX_CLIENT MEMP_NUM_TCP_PCB
89
94
#define MAX_DHCP_TRIES 4
90
95
#define TIMEOUT_DNS_REQUEST 10000U
@@ -148,7 +153,7 @@ class CNetIf: public NetworkInterface {
148
153
149
154
inline int disconnect () { this ->down (); return 0 ; }
150
155
151
- inline EthernetLinkStatus linkStatus () { return netif_is_link_up (&ni) ? LinkON : LinkOFF; }
156
+ inline LinkStatus linkStatus () { return netif_is_link_up (&ni) ? LinkON : LinkOFF; }
152
157
153
158
bool isLinkUp () { return (bool )netif_is_link_up (&ni); }
154
159
@@ -164,16 +169,10 @@ class CNetIf: public NetworkInterface {
164
169
IPAddress gatewayIP () { return IPAddress (this ->getGwAdd ()); }
165
170
IPAddress dnsServerIP () { /* FIXME understand where dns should be managed */ }
166
171
167
- // FIXME hostname should be defined in the NetworkStack singleton
168
- // void setHostname(const char* name)
169
- // {
170
- // memset(hostname, 0x00, MAX_HOSTNAME_DIM);
171
- // memcpy(hostname, name, strlen(name) < MAX_HOSTNAME_DIM ? strlen(name) : MAX_HOSTNAME_DIM);
172
- // }
173
172
void config (IPAddress _ip, IPAddress _gw, IPAddress _nm);
174
173
175
-
176
174
virtual int getMacAddress (uint8_t * mac) = 0;
175
+ virtual int setMacAddress (uint8_t * mac) = 0;
177
176
178
177
friend CLwipIf;
179
178
protected:
@@ -216,13 +215,40 @@ class CEth : public CNetIf {
216
215
const IPAddress &gw = INADDR_NONE,
217
216
const IPAddress &dns = INADDR_NONE);
218
217
218
+ // The following are overloaded begin methods kept for retrocompatibility with other Arduino cores
219
+ // Initialise the Ethernet shield to use the provided MAC address and gain the rest of the
220
+ // configuration through DHCP.
221
+ // Returns 0 if the DHCP configuration failed, and 1 if it succeeded
222
+ virtual int begin (
223
+ uint8_t *mac_address,
224
+ const IPAddress &local_ip = INADDR_NONE,
225
+ const IPAddress &dns_server = INADDR_NONE,
226
+ const IPAddress &gateway = INADDR_NONE,
227
+ const IPAddress &subnet = INADDR_NONE,
228
+ const unsigned long timeout = 60000 ,
229
+ const unsigned long responseTimeout = 4000 );
230
+
231
+ virtual int begin (
232
+ uint8_t *mac_address,
233
+ const unsigned long timeout = 60000 ,
234
+ const unsigned long responseTimeout = 4000 );
235
+
236
+
219
237
virtual int getMacAddress (uint8_t * mac) override {
220
238
UNUSED (mac); // FIXME not implemented
221
239
return 1 ;
222
240
}
223
241
242
+ virtual int setMacAddress (uint8_t * mac) override {
243
+ UNUSED (mac); // FIXME not implemented
244
+ return 1 ;
245
+ }
246
+
247
+
224
248
int maintain () {} // Deprecated method for retrocompatibility
225
249
void schedule (void ) {} // Deprecated method for retrocompatibility
250
+
251
+ inline EthernetHardwareStatus hardwareStatus () { return EthernetLwip; }
226
252
protected:
227
253
/*
228
254
* this function is used to initialize the netif structure of lwip
@@ -262,6 +288,11 @@ class CWifiStation : public CNetIf {
262
288
// FIXME not implemented
263
289
}
264
290
291
+ virtual int setMacAddress (uint8_t * mac) override {
292
+ UNUSED (mac); // FIXME not implemented
293
+ return 1 ;
294
+ }
295
+
265
296
virtual const char * getSSID ();
266
297
virtual uint8_t * getBSSID (uint8_t * bssid);
267
298
virtual int32_t getRSSI ();
@@ -276,6 +307,10 @@ class CWifiStation : public CNetIf {
276
307
277
308
int setLowPowerMode ();
278
309
int resetLowPowerMode ();
310
+
311
+ inline WifiStatus_t status () {
312
+ return wifi_status;
313
+ }
279
314
protected:
280
315
static const char wifistation_ifname[];
281
316
@@ -293,6 +328,7 @@ class CWifiStation : public CNetIf {
293
328
std::vector<AccessPoint_t> access_points;
294
329
WifiApCfg_t access_point_cfg;
295
330
bool hw_init; // TODO this should be moved to the wifi driver class
331
+ WifiStatus_t wifi_status = WL_IDLE_STATUS; // TODO this should be moved to the wifi driver class
296
332
};
297
333
298
334
class CWifiSoftAp : public CNetIf {
@@ -312,6 +348,11 @@ class CWifiSoftAp : public CNetIf {
312
348
// FIXME not implemented
313
349
}
314
350
351
+ virtual int setMacAddress (uint8_t * mac) override {
352
+ UNUSED (mac); // FIXME not implemented
353
+ return 1 ;
354
+ }
355
+
315
356
virtual const char * getSSID ();
316
357
virtual uint8_t * getBSSID (uint8_t * bssid);
317
358
virtual uint8_t getEncryptionType ();
0 commit comments