Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EthernetCompat - static IP auto gw,mask,dns as in Arduino libraries #9024

Merged
merged 2 commits into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions libraries/lwIP_Ethernet/src/EthernetCompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,29 @@ class ArduinoEthernet: public LwipIntfDev<RawDev>
// Arduino-Ethernet API compatibility, order can be either:
// mac, ip, gateway, netmask, dns (esp8266 or natural order)
// mac, ip, dns, gateway, netmask (Arduino legacy)
boolean begin(const uint8_t* macAddress, const IPAddress& local_ip = IPADDR_NONE,
const IPAddress& arg1 = IPADDR_NONE, const IPAddress& arg2 = IPADDR_NONE,
const IPAddress& arg3 = IPADDR_NONE)
boolean begin(const uint8_t* macAddress, IPAddress local_ip = IPADDR_NONE,
IPAddress arg1 = IPADDR_NONE, IPAddress arg2 = IPADDR_NONE,
IPAddress arg3 = IPADDR_NONE)
{
if (local_ip.isSet() && local_ip.isV4())
{
// setting auto values using arduino ordering of parameters
if (arg1 == IPADDR_NONE) // else dns or gw
{
arg1 = local_ip;
arg1[3] = 1;
}
if (arg2 == IPADDR_NONE) // else gw or mask
{
arg2 = local_ip;
arg2[3] = 1;
}
// if arg2 is mask (esp ordering), let DNS IP unconfigured
if (arg3 == IPADDR_NONE && arg2[0] != 255) // else mask or dns
{
arg3 = IPAddress(255, 255, 255, 0);
}
}
SPI4EthInit(); // Arduino Ethernet self-initializes SPI
bool ret = true;
if (local_ip.isSet())
Expand Down