From 6c0d5fcc093e30c7ded6c66b11b6e26143d2a88b Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Mon, 31 Oct 2022 10:09:07 +0100 Subject: [PATCH] Some adjustments to wifi power saving option --- src/AmsConfiguration.cpp | 4 ++-- src/web/AmsWebServer.cpp | 14 ++++++++++---- web/wifi.html | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/AmsConfiguration.cpp b/src/AmsConfiguration.cpp index 93999f3b..13690168 100644 --- a/src/AmsConfiguration.cpp +++ b/src/AmsConfiguration.cpp @@ -24,7 +24,7 @@ bool AmsConfiguration::getWiFiConfig(WiFiConfig& config) { EEPROM.begin(EEPROM_SIZE); EEPROM.get(CONFIG_WIFI_START, config); EEPROM.end(); - if(config.sleep > 2) config.sleep = 0xFF; + if(config.sleep > 2) config.sleep = 1; return true; } else { clearWifi(config); @@ -34,7 +34,7 @@ bool AmsConfiguration::getWiFiConfig(WiFiConfig& config) { bool AmsConfiguration::setWiFiConfig(WiFiConfig& config) { WiFiConfig existing; - if(config.sleep > 2) config.sleep = 0xFF; + if(config.sleep > 2) config.sleep = 1; if(getWiFiConfig(existing)) { wifiChanged |= strcmp(config.ssid, existing.ssid) != 0; wifiChanged |= strcmp(config.psk, existing.psk) != 0; diff --git a/src/web/AmsWebServer.cpp b/src/web/AmsWebServer.cpp index ff28d2d6..e5592fea 100644 --- a/src/web/AmsWebServer.cpp +++ b/src/web/AmsWebServer.cpp @@ -1015,9 +1015,11 @@ void AmsWebServer::handleSetup() { DebugConfig debugConfig; config->getDebugConfig(debugConfig); - config->clear(); + WiFiConfig wifi; + config->clearWifi(wifi); + switch(sys.boardType) { case 0: // roarfred gpioConfig->hanPin = 3; @@ -1042,6 +1044,7 @@ void AmsWebServer::handleSetup() { gpioConfig->ledInverted = true; gpioConfig->tempSensorPin = 5; gpioConfig->vccBootLimit = 33; + wifi.sleep = 1; break; case 3: // Pow UART0 gpioConfig->hanPin = 3; @@ -1051,6 +1054,7 @@ void AmsWebServer::handleSetup() { gpioConfig->ledPinRed = 13; gpioConfig->ledPinGreen = 14; gpioConfig->ledRgbInverted = true; + wifi.sleep = 1; break; case 4: // Pow GPIO12 gpioConfig->hanPin = 12; @@ -1060,6 +1064,7 @@ void AmsWebServer::handleSetup() { gpioConfig->ledPinRed = 13; gpioConfig->ledPinGreen = 14; gpioConfig->ledRgbInverted = true; + wifi.sleep = 1; break; case 5: // Pow-K+ UART2 gpioConfig->hanPin = 16; @@ -1070,6 +1075,7 @@ void AmsWebServer::handleSetup() { gpioConfig->vccPin = 10; gpioConfig->vccResistorGnd = 22; gpioConfig->vccResistorVcc = 33; + wifi.sleep = 1; break; case 6: // Pow-P1 gpioConfig->hanPin = 16; @@ -1090,6 +1096,7 @@ void AmsWebServer::handleSetup() { gpioConfig->vccPin = 10; gpioConfig->vccResistorGnd = 22; gpioConfig->vccResistorVcc = 33; + wifi.sleep = 2; break; case 101: // D1 gpioConfig->hanPin = 5; @@ -1126,18 +1133,17 @@ void AmsWebServer::handleSetup() { break; case 50: // S2 gpioConfig->hanPin = 18; + wifi.sleep = 1; break; case 51: // S2-mini gpioConfig->hanPin = 18; gpioConfig->ledPin = 15; gpioConfig->ledInverted = false; gpioConfig->apPin = 0; + wifi.sleep = 1; break; } - WiFiConfig wifi; - config->clearWifi(wifi); - strcpy(wifi.ssid, server.arg(F("wifiSsid")).c_str()); strcpy(wifi.psk, server.arg(F("wifiPassword")).c_str()); diff --git a/web/wifi.html b/web/wifi.html index ae3c5b32..a99adc16 100644 --- a/web/wifi.html +++ b/web/wifi.html @@ -98,8 +98,8 @@