AP setup improvement

This commit is contained in:
fvanroie 2020-03-07 00:48:59 +01:00
parent 4b0e685e23
commit 737aef167b

View File

@ -135,20 +135,21 @@ void wifiSetup(JsonObject settings)
if(strlen(wifiSsid) == 0) { if(strlen(wifiSsid) == 0) {
String apSsdid = F("HASP-"); String apSsdid = F("HASP-");
apSsdid += wifiGetMacAddress(3, ""); apSsdid += wifiGetMacAddress(3, "");
snprintf_P(buffer, sizeof(buffer), PSTR("haspadmin"));
WiFi.mode(WIFI_AP); WiFi.mode(WIFI_AP);
WiFi.softAP(apSsdid.c_str(), "haspadmin"); WiFi.softAP(apSsdid.c_str(), buffer);
IPAddress IP = WiFi.softAPIP(); haspDisplayAP(apSsdid.c_str(), buffer);
/* Setup the DNS server redirecting all the domains to the apIP */ /* Setup the DNS server redirecting all the domains to the apIP */
// dnsServer.setErrorReplyCode(DNSReplyCode::NoError); // dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
// dnsServer.start(DNS_PORT, "*", apIP); // dnsServer.start(DNS_PORT, "*", apIP);
sprintf_P(buffer, PSTR("WIFI: Setting up temporary Access Point: %s"), apSsdid.c_str()); IPAddress IP = WiFi.softAPIP();
sprintf_P(buffer, PSTR("WIFI: Temporary Access Point %s password: %s"), apSsdid.c_str(), PSTR("haspadmin"));
debugPrintln(buffer); debugPrintln(buffer);
sprintf_P(buffer, PSTR("WIFI: AP IP address : %s"), IP.toString().c_str()); sprintf_P(buffer, PSTR("WIFI: AP IP address : %s"), IP.toString().c_str());
debugPrintln(buffer); debugPrintln(buffer);
haspDisplayAP(apSsdid.c_str(), "haspadmin");
httpReconnect(); httpReconnect();
} else { } else {
@ -225,7 +226,8 @@ bool wifiSetConfig(const JsonObject & settings)
strncpy(wifiSsid, settings[FPSTR(F_CONFIG_SSID)], sizeof(wifiSsid)); strncpy(wifiSsid, settings[FPSTR(F_CONFIG_SSID)], sizeof(wifiSsid));
} }
if(!settings[FPSTR(F_CONFIG_PASS)].isNull()) { if(!settings[FPSTR(F_CONFIG_PASS)].isNull() &&
settings[FPSTR(F_CONFIG_PASS)].as<String>() != String(FPSTR("********"))) {
changed |= strcmp(wifiPassword, settings[FPSTR(F_CONFIG_PASS)]) != 0; changed |= strcmp(wifiPassword, settings[FPSTR(F_CONFIG_PASS)]) != 0;
strncpy(wifiPassword, settings[FPSTR(F_CONFIG_PASS)], sizeof(wifiPassword)); strncpy(wifiPassword, settings[FPSTR(F_CONFIG_PASS)], sizeof(wifiPassword));
} }