@@ -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,25 @@ 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
+
221
+ if (!local_ip.isSet ())
222
+ return config (INADDR_ANY, INADDR_ANY, INADDR_ANY);
223
+
224
+ if (!local_ip.isV4 ())
225
+ return false ;
226
+
227
+ IPAddress gw (local_ip);
228
+ gw[3 ] = 1 ;
229
+ if (!dns.isSet ())
230
+ {
231
+ dns = gw;
232
+ }
233
+ return config (local_ip, gw, IPAddress (255 , 255 , 255 , 0 ), dns);
234
+ }
235
+
212
236
template <class RawDev >
213
237
boolean LwipIntfDev<RawDev>::begin(const uint8_t * macAddress, const uint16_t mtu)
214
238
{
@@ -336,9 +360,6 @@ template<class RawDev>
336
360
void LwipIntfDev<RawDev>::end()
337
361
{
338
362
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
363
_started = false ;
343
364
RawDev::end ();
344
365
}
0 commit comments