@@ -38,10 +38,29 @@ class ArduinoEthernet: public LwipIntfDev<RawDev>
38
38
// Arduino-Ethernet API compatibility, order can be either:
39
39
// mac, ip, gateway, netmask, dns (esp8266 or natural order)
40
40
// mac, ip, dns, gateway, netmask (Arduino legacy)
41
- boolean begin (const uint8_t * macAddress, const IPAddress& local_ip = IPADDR_NONE,
42
- const IPAddress& arg1 = IPADDR_NONE, const IPAddress& arg2 = IPADDR_NONE,
43
- const IPAddress& arg3 = IPADDR_NONE)
41
+ boolean begin (const uint8_t * macAddress, IPAddress local_ip = IPADDR_NONE,
42
+ IPAddress arg1 = IPADDR_NONE, IPAddress arg2 = IPADDR_NONE,
43
+ IPAddress arg3 = IPADDR_NONE)
44
44
{
45
+ if (local_ip.isSet () && local_ip.isV4 ())
46
+ {
47
+ // setting auto values using arduino ordering of parameters
48
+ if (arg1 == IPADDR_NONE) // else dns or gw
49
+ {
50
+ arg1 = local_ip;
51
+ arg1[3 ] = 1 ;
52
+ }
53
+ if (arg2 == IPADDR_NONE) // else gw or mask
54
+ {
55
+ arg2 = local_ip;
56
+ arg2[3 ] = 1 ;
57
+ }
58
+ // if arg2 is mask (esp ordering), let DNS IP unconfigured
59
+ if (arg3 == IPADDR_NONE && arg2[0 ] != 255 ) // else mask or dns
60
+ {
61
+ arg3 = IPAddress (255 , 255 , 255 , 0 );
62
+ }
63
+ }
45
64
SPI4EthInit (); // Arduino Ethernet self-initializes SPI
46
65
bool ret = true ;
47
66
if (local_ip.isSet ())
0 commit comments