@@ -79,12 +79,17 @@ typedef enum {
7979 NI_ETHERNET
8080} NetIfType_t;
8181
82- enum EthernetLinkStatus {
82+ enum LinkStatus {
8383 Unknown,
8484 LinkON,
8585 LinkOFF
8686};
8787
88+ enum EthernetHardwareStatus {
89+ EthernetNoHardware,
90+ EthernetLwip = 7
91+ };
92+
8893#define MAX_CLIENT MEMP_NUM_TCP_PCB
8994#define MAX_DHCP_TRIES 4
9095#define TIMEOUT_DNS_REQUEST 10000U
@@ -148,7 +153,7 @@ class CNetIf: public NetworkInterface {
148153
149154 inline int disconnect () { this ->down (); return 0 ; }
150155
151- inline EthernetLinkStatus linkStatus () { return netif_is_link_up (&ni) ? LinkON : LinkOFF; }
156+ inline LinkStatus linkStatus () { return netif_is_link_up (&ni) ? LinkON : LinkOFF; }
152157
153158 bool isLinkUp () { return (bool )netif_is_link_up (&ni); }
154159
@@ -164,16 +169,10 @@ class CNetIf: public NetworkInterface {
164169 IPAddress gatewayIP () { return IPAddress (this ->getGwAdd ()); }
165170 IPAddress dnsServerIP () { /* FIXME understand where dns should be managed */ }
166171
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- // }
173172 void config (IPAddress _ip, IPAddress _gw, IPAddress _nm);
174173
175-
176174 virtual int getMacAddress (uint8_t * mac) = 0;
175+ virtual int setMacAddress (uint8_t * mac) = 0;
177176
178177 friend CLwipIf;
179178protected:
@@ -216,13 +215,40 @@ class CEth : public CNetIf {
216215 const IPAddress &gw = INADDR_NONE,
217216 const IPAddress &dns = INADDR_NONE);
218217
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+
219237 virtual int getMacAddress (uint8_t * mac) override {
220238 UNUSED (mac); // FIXME not implemented
221239 return 1 ;
222240 }
223241
242+ virtual int setMacAddress (uint8_t * mac) override {
243+ UNUSED (mac); // FIXME not implemented
244+ return 1 ;
245+ }
246+
247+
224248 int maintain () {} // Deprecated method for retrocompatibility
225249 void schedule (void ) {} // Deprecated method for retrocompatibility
250+
251+ inline EthernetHardwareStatus hardwareStatus () { return EthernetLwip; }
226252protected:
227253 /*
228254 * this function is used to initialize the netif structure of lwip
@@ -262,6 +288,11 @@ class CWifiStation : public CNetIf {
262288 // FIXME not implemented
263289 }
264290
291+ virtual int setMacAddress (uint8_t * mac) override {
292+ UNUSED (mac); // FIXME not implemented
293+ return 1 ;
294+ }
295+
265296 virtual const char * getSSID ();
266297 virtual uint8_t * getBSSID (uint8_t * bssid);
267298 virtual int32_t getRSSI ();
@@ -276,6 +307,10 @@ class CWifiStation : public CNetIf {
276307
277308 int setLowPowerMode ();
278309 int resetLowPowerMode ();
310+
311+ inline WifiStatus_t status () {
312+ return wifi_status;
313+ }
279314protected:
280315 static const char wifistation_ifname[];
281316
@@ -293,6 +328,7 @@ class CWifiStation : public CNetIf {
293328 std::vector<AccessPoint_t> access_points;
294329 WifiApCfg_t access_point_cfg;
295330 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
296332};
297333
298334class CWifiSoftAp : public CNetIf {
@@ -312,6 +348,11 @@ class CWifiSoftAp : public CNetIf {
312348 // FIXME not implemented
313349 }
314350
351+ virtual int setMacAddress (uint8_t * mac) override {
352+ UNUSED (mac); // FIXME not implemented
353+ return 1 ;
354+ }
355+
315356 virtual const char * getSSID ();
316357 virtual uint8_t * getBSSID (uint8_t * bssid);
317358 virtual uint8_t getEncryptionType ();
0 commit comments