Changed parsing for entered IP addresses

pull/137/head
Hieromon Ikasamo 5 years ago
parent 650885f0cf
commit 2441c87483
  1. 33
      src/AutoConnect.cpp

@ -824,26 +824,19 @@ String AutoConnect::_induceConnect(PageArgument& args) {
} }
else { else {
_credential.dhcp = STA_STATIC; _credential.dhcp = STA_STATIC;
IPAddress cast; const String paramId[] = {
if (args.hasArg(String(F(AUTOCONNECT_PARAMID_STAIP)))) { String(F(AUTOCONNECT_PARAMID_STAIP)),
cast.fromString(args.arg(String(F(AUTOCONNECT_PARAMID_STAIP)))); String(F(AUTOCONNECT_PARAMID_GTWAY)),
_credential.config.sta.ip = static_cast<uint32_t>(cast); String(F(AUTOCONNECT_PARAMID_NTMSK)),
} String(F(AUTOCONNECT_PARAMID_DNS1)),
if (args.hasArg(String(F(AUTOCONNECT_PARAMID_GTWAY)))) { String(F(AUTOCONNECT_PARAMID_DNS2))
cast.fromString(args.arg(String(F(AUTOCONNECT_PARAMID_GTWAY)))); };
_credential.config.sta.gateway = static_cast<uint32_t>(cast); for (uint8_t i = 0; i < sizeof(station_config_t::_config::addr) / sizeof(uint32_t); i++) {
} if (args.hasArg(paramId[i])) {
if (args.hasArg(String(F(AUTOCONNECT_PARAMID_NTMSK)))) { IPAddress ip;
cast.fromString(args.arg(String(F(AUTOCONNECT_PARAMID_NTMSK)))); if (ip.fromString(args.arg(paramId[i])))
_credential.config.sta.netmask = static_cast<uint32_t>(cast); _credential.config.addr[i] = static_cast<uint32_t>(ip);
} }
if (args.hasArg(String(F(AUTOCONNECT_PARAMID_DNS1)))) {
cast.fromString(args.arg(String(F(AUTOCONNECT_PARAMID_DNS1))));
_credential.config.sta.dns1 = static_cast<uint32_t>(cast);
}
if (args.hasArg(String(F(AUTOCONNECT_PARAMID_DNS2)))) {
cast.fromString(args.arg(String(F(AUTOCONNECT_PARAMID_DNS2))));
_credential.config.sta.dns2 = static_cast<uint32_t>(cast);
} }
} }
} }

Loading…
Cancel
Save