mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
LwipImtfDev - add DNS IP getters/setters and MAC getters (#9022)
Ethernet styles getters/setters and WiFi styles getters/setters
This commit is contained in:
parent
31c1592ad6
commit
097e59f2e1
@ -74,6 +74,15 @@ public:
|
||||
return &_netif;
|
||||
}
|
||||
|
||||
uint8_t* macAddress(uint8_t* mac) // WiFi lib way
|
||||
{
|
||||
memcpy(mac, &_netif.hwaddr, 6);
|
||||
return mac;
|
||||
}
|
||||
void MACAddress(uint8_t* mac) // Ethernet lib way
|
||||
{
|
||||
macAddress(mac);
|
||||
}
|
||||
IPAddress localIP() const
|
||||
{
|
||||
return IPAddress(ip4_addr_get_u32(ip_2_ip4(&_netif.ip_addr)));
|
||||
@ -86,6 +95,29 @@ public:
|
||||
{
|
||||
return IPAddress(ip4_addr_get_u32(ip_2_ip4(&_netif.gw)));
|
||||
}
|
||||
IPAddress dnsIP(int n) const // WiFi lib way
|
||||
{
|
||||
return IPAddress(dns_getserver(n));
|
||||
}
|
||||
IPAddress dnsServerIP() const // Ethernet lib way
|
||||
{
|
||||
return dnsIP(0);
|
||||
}
|
||||
void setDNS(IPAddress dns1, IPAddress dns2 = INADDR_ANY) // WiFi lib way
|
||||
{
|
||||
if (dns1.isSet())
|
||||
{
|
||||
dns_setserver(0, dns1);
|
||||
}
|
||||
if (dns2.isSet())
|
||||
{
|
||||
dns_setserver(1, dns2);
|
||||
}
|
||||
}
|
||||
void setDnsServerIP(const IPAddress dnsIP) // Ethernet lib way
|
||||
{
|
||||
setDNS(dnsIP);
|
||||
}
|
||||
|
||||
// 1. Currently when no default is set, esp8266-Arduino uses the first
|
||||
// DHCP client interface receiving a valid address and gateway to
|
||||
|
Loading…
x
Reference in New Issue
Block a user