@@ -63,9 +63,14 @@ class LwipIntfDev: public LwipIntf, public RawDev
63
63
memset (&_netif, 0 , sizeof (_netif));
64
64
}
65
65
66
+ // The argument order for ESP is not the same as for Arduino. However, there is compatibility code under the hood
67
+ // to detect Arduino arg order, and handle it correctly.
66
68
boolean config (const IPAddress& local_ip, const IPAddress& arg1, const IPAddress& arg2,
67
69
const IPAddress& arg3 = IPADDR_NONE, const IPAddress& dns2 = IPADDR_NONE);
68
70
71
+ // two and one parameter version. 2nd parameter is DNS like in Arduino. IPv4 only
72
+ boolean config (IPAddress local_ip, IPAddress dns = INADDR_ANY);
73
+
69
74
// default mac-address is inferred from esp8266's STA interface
70
75
boolean begin (const uint8_t * macAddress = nullptr , const uint16_t mtu = DEFAULT_MTU);
71
76
void end ();
@@ -209,6 +214,24 @@ boolean LwipIntfDev<RawDev>::config(const IPAddress& localIP, const IPAddress& g
209
214
return true ;
210
215
}
211
216
217
+ template <class RawDev >
218
+ boolean LwipIntfDev<RawDev>::config(IPAddress local_ip, IPAddress dns)
219
+ {
220
+ if (!local_ip.isSet ())
221
+ return config (INADDR_ANY, INADDR_ANY, INADDR_ANY);
222
+
223
+ if (!local_ip.isV4 ())
224
+ return false ;
225
+
226
+ IPAddress gw (local_ip);
227
+ gw[3 ] = 1 ;
228
+ if (!dns.isSet ())
229
+ {
230
+ dns = gw;
231
+ }
232
+ return config (local_ip, gw, IPAddress (255 , 255 , 255 , 0 ), dns);
233
+ }
234
+
212
235
template <class RawDev >
213
236
boolean LwipIntfDev<RawDev>::begin(const uint8_t * macAddress, const uint16_t mtu)
214
237
{
@@ -336,9 +359,6 @@ template<class RawDev>
336
359
void LwipIntfDev<RawDev>::end()
337
360
{
338
361
netif_remove (&_netif);
339
- ip_addr_copy (_netif.ip_addr , ip_addr_any); // to allow DHCP at next begin
340
- ip_addr_copy (_netif.netmask , ip_addr_any);
341
- ip_addr_copy (_netif.gw , ip_addr_any);
342
362
_started = false ;
343
363
RawDev::end ();
344
364
}
0 commit comments