Snaha o zprehledneni kodu.

This commit is contained in:
Pavel Brychta 2022-04-01 08:06:56 +02:00
parent 1ebcab01e7
commit 36e0ab5f3a
2 changed files with 55 additions and 57 deletions

View File

@ -5,8 +5,8 @@
#include <sysvars.hpp>
#include "embHTML.h"
#include <encString.hpp>
#include <FS.h>
#include <definefs.hpp>
#include <FS.h>
#ifdef USE_WIFICONFIG_FSEDITOR
# include <SPIFFSEditor.h>
# include <FSWebEditor.h>
@ -49,7 +49,7 @@ static bool _doReconfig = false; // TODO: mozna nejak elegantneji? Ale zase setr
String WifiConfigAPSSID(void)
{
String ssid = SETUP_SSID;
String ssid = F(SETUP_SSID);
return ssid;
}
@ -100,15 +100,12 @@ uint8_t * getOurMAC(uint8_t *mac)
WiFiConfigUsrParameter::WiFiConfigUsrParameter(const char *id, const char *label, const char *defaultValue, unsigned int length, storeparam_cb cb)
{
_next = NULL;
_cb = cb;
_id = id;
_label = label;
_length = length;
_value = new char[length + 1];
for (unsigned int i = 0; i < length; i++) {
_value[i] = 0;
}
_value[0] = 0;
if (defaultValue != NULL) {
strncpy(_value, defaultValue, length);
}
@ -303,69 +300,69 @@ String WiFiConfig::rootProcessor(const String &var)
String content;
if (var == "STATUS") {
switch (_status) {
switch (_status) {
#if defined(ESP8266)
case STATION_IDLE:
content = F("Klid");
break;
case STATION_IDLE:
content = F("Klid");
break;
case STATION_CONNECTING:
content = F("Připojování");
break;
case STATION_CONNECTING:
content = F("Připojování");
break;
case STATION_WRONG_PASSWORD:
content = F("Špatné heslo");
break;
case STATION_WRONG_PASSWORD:
content = F("Špatné heslo");
break;
case STATION_NO_AP_FOUND:
content = F("AP nenalezen");
break;
case STATION_NO_AP_FOUND:
content = F("AP nenalezen");
break;
case STATION_CONNECT_FAIL:
content = F("Připojení selhalo");
break;
case STATION_CONNECT_FAIL:
content = F("Připojení selhalo");
break;
case STATION_GOT_IP:
content = F("Získaná ip");
break;
case STATION_GOT_IP:
content = F("Získaná ip");
break;
case 0xfe:
content = F("Špatná konfigurace");
break;
case 0xfe:
content = F("Špatná konfigurace");
break;
case 0xff:
content = F("Vynucená konfigurace");
break;
case 0xff:
content = F("Vynucená konfigurace");
break;
default:
content = F("Neznámý");
break;
default:
content = F("Neznámý");
break;
#else
case WL_IDLE_STATUS:
content = F("Klid");
break;
case WL_IDLE_STATUS:
content = F("Klid");
break;
case WL_NO_SSID_AVAIL:
content = F("AP nenalezen");
break;
case WL_NO_SSID_AVAIL:
content = F("AP nenalezen");
break;
case WL_CONNECT_FAILED:
content = F("Připojení selhalo");
break;
case WL_CONNECT_FAILED:
content = F("Připojení selhalo");
break;
case 0xfe:
content = F("Špatná konfigurace");
break;
case 0xfe:
content = F("Špatná konfigurace");
break;
case 0xff:
content = F("Vynucená konfigurace");
break;
case 0xff:
content = F("Vynucená konfigurace");
break;
default:
content = F("Neznámý");
break;
default:
content = F("Neznámý");
break;
#endif
}
}
} else if (var == F("RESTORE")) {
if (USEDFS.exists(F(WIFICFG_OLD_FILE))) {
content = FPSTR(PAGE_RESTORE);

View File

@ -134,15 +134,16 @@ private:
int _length;
storeparam_cb _cb;
WiFiConfigUsrParameter *_next;
friend class WiFiConfig;
WiFiConfigUsrParameter *_next = nullptr;
};
class WiFiConfig
{
public:
WiFiConfig(): _params(nullptr), _timeout(0) {}
WiFiConfig()
: _params(nullptr)
, _timeout(0)
{}
wificonfigresult_t begin(int forceConfigure, wificonfig_cb cb);
wificonfigresult_t begin(int forceConfigure, int timeout, wificonfig_cb cb);
void addParameter(WiFiConfigUsrParameter *p);