mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-28 13:46:36 +00:00
Update wifiGetConfig
This commit is contained in:
parent
c1dbe6364d
commit
096f5c01ca
@ -200,11 +200,16 @@ bool wifiEvery5Seconds()
|
|||||||
|
|
||||||
bool wifiGetConfig(const JsonObject & settings)
|
bool wifiGetConfig(const JsonObject & settings)
|
||||||
{
|
{
|
||||||
settings[FPSTR(F_CONFIG_SSID)] = wifiSsid; // String(wifiSsid.c_str());
|
bool changed = false;
|
||||||
settings[FPSTR(F_CONFIG_PASS)] = wifiPassword; // String(wifiPassword.c_str());
|
|
||||||
|
if(strcmp(wifiSsid, settings[FPSTR(F_CONFIG_SSID)].as<String>().c_str()) != 0) changed = true;
|
||||||
|
settings[FPSTR(F_CONFIG_SSID)] = wifiSsid;
|
||||||
|
|
||||||
|
if(strcmp(wifiPassword, settings[FPSTR(F_CONFIG_PASS)].as<String>().c_str()) != 0) changed = true;
|
||||||
|
settings[FPSTR(F_CONFIG_PASS)] = wifiPassword;
|
||||||
|
|
||||||
configOutput(settings);
|
configOutput(settings);
|
||||||
return true;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set WIFI Configuration.
|
/** Set WIFI Configuration.
|
||||||
@ -238,12 +243,13 @@ bool wifiTestConnection()
|
|||||||
{
|
{
|
||||||
uint8_t attempt = 0;
|
uint8_t attempt = 0;
|
||||||
WiFi.begin(wifiSsid, wifiPassword);
|
WiFi.begin(wifiSsid, wifiPassword);
|
||||||
while(attempt < 10 && WiFi.localIP().toString() == F("0.0.0.0")) {
|
while(attempt < 10 && (WiFi.status() != WL_CONNECTED || WiFi.localIP().toString() == F("0.0.0.0"))) {
|
||||||
attempt++;
|
attempt++;
|
||||||
Log.verbose(F("WIFI: Trying to connect to %s... %u"), wifiSsid, attempt);
|
Log.verbose(F("WIFI: Trying to connect to %s... %u"), wifiSsid, attempt);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
if(WiFi.localIP().toString() != F("0.0.0.0")) return true;
|
Log.verbose(F("WIFI: Received IP addres %s"), WiFi.localIP().toString().c_str());
|
||||||
|
if((WiFi.status() == WL_CONNECTED && WiFi.localIP().toString() != F("0.0.0.0"))) return true;
|
||||||
|
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
return false;
|
return false;
|
||||||
@ -251,7 +257,8 @@ bool wifiTestConnection()
|
|||||||
|
|
||||||
void wifiStop()
|
void wifiStop()
|
||||||
{
|
{
|
||||||
Log.warning(F("WIFI: Stopped"));
|
wifiReconnectCounter = 0; // Prevent endless loop in wifiDisconnected
|
||||||
WiFi.mode(WIFI_OFF);
|
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
|
WiFi.mode(WIFI_OFF);
|
||||||
|
Log.warning(F("WIFI: Stopped"));
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user