use IPAddress for IPConfiguratio
This commit is contained in:
@@ -10,6 +10,11 @@ IPConfiguration::IPConfiguration(Preferences *preferences, const bool& firstStar
|
||||
_preferences->putBool(preference_ip_dhcp_enabled, true);
|
||||
}
|
||||
|
||||
_ipAddress.fromString(_preferences->getString(preference_ip_address));
|
||||
_subnet.fromString(_preferences->getString(preference_ip_subnet));
|
||||
_gateway.fromString(_preferences->getString(preference_ip_gateway));
|
||||
_dnsServer.fromString(_preferences->getString(preference_ip_dns_server));
|
||||
|
||||
Log->print(F("IP configuration: "));
|
||||
if(dhcpEnabled())
|
||||
{
|
||||
@@ -29,22 +34,22 @@ bool IPConfiguration::dhcpEnabled() const
|
||||
return _preferences->getBool(preference_ip_dhcp_enabled);
|
||||
}
|
||||
|
||||
String IPConfiguration::ipAddress() const
|
||||
const IPAddress IPConfiguration::ipAddress() const
|
||||
{
|
||||
return _preferences->getString(preference_ip_address);
|
||||
return _ipAddress;
|
||||
}
|
||||
|
||||
String IPConfiguration::subnet() const
|
||||
const IPAddress IPConfiguration::subnet() const
|
||||
{
|
||||
return _preferences->getString(preference_ip_subnet);
|
||||
return _subnet;
|
||||
}
|
||||
|
||||
String IPConfiguration::defaultGateway() const
|
||||
const IPAddress IPConfiguration::defaultGateway() const
|
||||
{
|
||||
return _preferences->getString(preference_ip_gateway);
|
||||
return _gateway;
|
||||
}
|
||||
|
||||
String IPConfiguration::dnsServer() const
|
||||
const IPAddress IPConfiguration::dnsServer() const
|
||||
{
|
||||
return _preferences->getString(preference_ip_dns_server);
|
||||
return _dnsServer;
|
||||
}
|
||||
|
||||
@@ -8,12 +8,17 @@ public:
|
||||
explicit IPConfiguration(Preferences* preferences, const bool& firstStart);
|
||||
|
||||
bool dhcpEnabled() const;
|
||||
String ipAddress() const;
|
||||
String subnet() const;
|
||||
String defaultGateway() const;
|
||||
String dnsServer() const;
|
||||
const IPAddress ipAddress() const;
|
||||
const IPAddress subnet() const;
|
||||
const IPAddress defaultGateway() const;
|
||||
const IPAddress dnsServer() const;
|
||||
|
||||
private:
|
||||
Preferences* _preferences = nullptr;
|
||||
|
||||
IPAddress _ipAddress;
|
||||
IPAddress _subnet;
|
||||
IPAddress _gateway;
|
||||
IPAddress _dnsServer;
|
||||
};
|
||||
|
||||
|
||||
@@ -71,16 +71,7 @@ void WifiDevice::initialize()
|
||||
|
||||
if(!_ipConfiguration->dhcpEnabled())
|
||||
{
|
||||
IPAddress address;
|
||||
address.fromString(_ipConfiguration->ipAddress());
|
||||
IPAddress gateway;
|
||||
gateway.fromString(_ipConfiguration->defaultGateway());
|
||||
IPAddress subnet;
|
||||
subnet.fromString(_ipConfiguration->subnet());
|
||||
IPAddress dns;
|
||||
dns.fromString(_ipConfiguration->dnsServer());
|
||||
|
||||
_wm.setSTAStaticIPConfig(address, gateway, subnet, dns);
|
||||
_wm.setSTAStaticIPConfig(_ipConfiguration->ipAddress(), _ipConfiguration->defaultGateway(), _ipConfiguration->subnet(), _ipConfiguration->dnsServer());
|
||||
}
|
||||
|
||||
_wm.setAPCallback(clearRtcInitVar);
|
||||
|
||||
Reference in New Issue
Block a user