From f4f89151979768b008dcc8ed6164daeb0b35467d Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 18 Jul 2018 14:06:40 +0200 Subject: [PATCH 1/4] Pokus o sifrovani retezcu v EEPROM --- src/WiFiConfig.cpp | 51 +++++++++++++++++++++++++++++----------------- src/embHTML.h | 3 ++- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/WiFiConfig.cpp b/src/WiFiConfig.cpp index 78a9e7f..050f456 100644 --- a/src/WiFiConfig.cpp +++ b/src/WiFiConfig.cpp @@ -1,4 +1,6 @@ /* + * V5.9 - 18.7.2018 - Retezce, ukladane do EEPROM jsou primitivnim zpusobem sifrovany pro ztizeni odhaleni SSID a hesla pri dumpu pameti + * * V5.8 - 5.7.2018 - Opraveno spatne zobrazovani sily signalu v prehledu WiFi siti (spatne barvy) * * V5.7 - 4.7.2018 - BugFix - staticka konfigurace ip adresy se neuplatnila - vypada to, jako kdyby SDK ukladalo SSID a Password, ale uz neuklada @@ -139,11 +141,11 @@ uint8_t * getOurMAC(uint8_t *mac) return WiFi.softAPmacAddress(mac); } -uint32_t getEEPROMuint32(int start) +uint32_t getEEPROMuint32(unsigned int start) { uint32_t result = 0; - for (int i=0; i<4; ++i) + for (uint32_t i=0; i<4; ++i) { result <<= 8; result += EEPROM.read(start); @@ -152,24 +154,31 @@ uint32_t getEEPROMuint32(int start) return result; } -void setEEPROMuint32(int start, uint32_t val) +void setEEPROMuint32(unsigned int start, uint32_t val) { - for (int i=0; i<4; ++i) + for (unsigned int i=0; i<4; ++i) { EEPROM.write(start + 3 - i, (uint8_t)val); val >>= 8; } } -String getEEPROMString(int start, int len) +String getEEPROMString(unsigned int start, size_t maxlen) { + uint8_t mac[WL_MAC_ADDR_LENGTH]; + unsignd int enciphidx = 0; String string = ""; - for (int i = start; i < + start + len; ++i) + WiFi.softAPmacAddress(mac); + for (unsigned int i = start; i < + start + len; ++i) { uint8_t b = EEPROM.read(i); + b ^= mac[enciphidx]; + ++enciphidx; + enciphidx %= WL_MAC_ADDR_LENGTH; + if ((0xff == b) || (0 == b)) break; string.concat(char(b)); @@ -177,11 +186,14 @@ String getEEPROMString(int start, int len) return string; } -void setEEPROMString(int start, int len, String string) +void setEEPROMString(unsigned int start, size_t len, String &string) { + uint8_t mac[WL_MAC_ADDR_LENGTH]; + unsignd int enciphidx = 0; unsigned int si = 0; - for (int i = start; i < start + len; ++i) + WiFi.softAPmacAddress(mac); + for (unsigned int i = start; i < start + len; ++i) { char c; @@ -193,6 +205,9 @@ void setEEPROMString(int start, int len, String string) { c = 0; } + c ^= mac[enciphidx]; + ++enciphidx; + enciphidx %= WL_MAC_ADDR_LENGTH; EEPROM.write(i, c); ++si; } @@ -206,7 +221,7 @@ WiFiConfigUsrParameter::WiFiConfigUsrParameter(const char *id, const char *label _label = label; _length = length; _value = new char[length + 1]; - for (int i = 0; i < length; i++) + for (unsigned int i = 0; i < length; i++) { _value[i] = 0; } @@ -281,18 +296,16 @@ void WiFiConfig::addParameter(WiFiConfigUsrParameter *p) void WiFiConfig::_handleNotFound(void) { -// _time = millis() + (_timeout * 1000); // spocitame si novy cas, kdy budeme modul restartovat DEBUG_MSG("Requested URI: %s\r\n", server->uri().c_str()); if (server->uri().endsWith(String(F("favicon.ico")))) { - server->send(404, F("text/plain"), F("Err")); + server->send_P(404, FPSTR(TEXTPLAIN), PSTR("Err")); } else { server->sendHeader(F("Location"), String(F("http://")) + server->client().localIP().toString() + String(F("/index.htm")), true); -// server->sendHeader(F("Location"), String(F("http://")) + WiFi.softAPIP().toString() + String(F("/index.htm")), true); - server->send (302, F("text/plain"), F("Redirect")); + server->send_P(302, FPSTR(TEXTPLAIN), PSTR("Redirect")); } } @@ -306,7 +319,7 @@ void WiFiConfig::_handleReset(void) ESP.restart(); }); - server->send_P(200, TEXTHTML, PAGE_RESTART); + server->send_P(200, FPSTR(TEXTHTML), FPSTR(PAGE_RESTART)); } void WiFiConfig::_handleInfo(void) @@ -353,7 +366,7 @@ void WiFiConfig::_handleInfo(void) reply.concat(buff); reply.concat(F("")); - server->send(200, TEXTHTML, reply); + server->send(200, FPSTR(TEXTHTML), reply); } void WiFiConfig::_handleRoot(void) @@ -399,12 +412,12 @@ void WiFiConfig::_handleRoot(void) break; default: - content.concat(F("Neznámého")); + content.concat(F("Neznámý")); break; } content.concat(F("")); content.concat(FPSTR(PAGE_CAPTIVEPORTALCATCH2)); // 2. cast stranky (ukonceni) - server->send(200, TEXTHTML, content); + server->send(200, FPSTR(TEXTHTML), content); _time = millis() + (_timeout * 1000); // spocitame si novy cas, kdy budeme modul restartovat } @@ -498,7 +511,7 @@ void WiFiConfig::_handleDisplayAP(void) } content.concat(FPSTR(PAGE_END)); - server->send(200, TEXTHTML, content); + server->send(200, FPSTR(TEXTHTML), content); } void WiFiConfig::_handleSetAP(void) @@ -566,7 +579,7 @@ void WiFiConfig::_handleSetAP(void) } EEPROM.commit(); // skutecne ulozime data } - server->send(200, F("text/html"), FPSTR(PAGE_SAVED)); + server->send_P(200, FPSTR(TEXTHTML), FPSTR(PAGE_SAVED)); delay(2000); // cekame na odeslani dat // nakonfigurujeme ESP dle nove nastavenych parametru WiFi.disconnect(); // vsechno odpojime diff --git a/src/embHTML.h b/src/embHTML.h index 3c48688..6d6bf77 100644 --- a/src/embHTML.h +++ b/src/embHTML.h @@ -1,5 +1,6 @@ -// file:///I:/MyProjects/PB_ESP8266_WiFiConfig_Vyvoj/doc/_testy/s?_s=SSID1&_p=heslo&_n=jmeno_zarizeni&_a=on&_st=on&_i=192.168.1.1&_m=255.255.255.0&_g=192.168.1.3&_d=192.168.1.3&{n}={v} +// HTML data static const char TEXTHTML[] PROGMEM = "text/html"; +static const char TEXTPLAIN[] PROGMEM = "text/plain"; static const char PAGE_INDEX1[] PROGMEM = R"=====( From 242238a1f0dc806247a61d05e7cb5834f71894ae Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 19 Jul 2018 08:47:12 +0200 Subject: [PATCH 2/4] Opraven i header. --- src/WiFiConfig.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/WiFiConfig.h b/src/WiFiConfig.h index b479a75..3fdfce4 100644 --- a/src/WiFiConfig.h +++ b/src/WiFiConfig.h @@ -2,7 +2,7 @@ * @file WiFiConfig.h * @author Pavel Brychta, http://www.xpablo.cz * - * Copyright (c) 2015,16,17 Pavel Brychta. All rights reserved. + * Copyright (c) 2015-18 Pavel Brychta. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -24,6 +24,7 @@ * 1. Pokud je forceConfigure ==0, tak se aktivuje WiFi v rezimu AP a cele ESP je mozne nastavit webovym rozhranim (pocitam s prenosem hodnoty nouzoveho tlacitka pri startu). * 2. Neni-li tlacitko stisknute, tak se vezme rezim prace a AP se nastavi dle nej (WIFI_STA a WIFI_AP) * 3. Pokud byl rezim prace WIFI_STA a ESP se nepripoji k zadne siti do casu WIFI_STA_CONNECT_TIMEOUT, tak se pokracuje jako kdyby bylo stisknute rekonfiguracni tlacitko + * Podrobnejsi informace o upravach chovani v jednotlivych verzich jsou v zahlavi .cpp souboru. */ #ifndef __WiFiConfig_h__ @@ -93,7 +94,7 @@ typedef void (*storeparam_cb)(const char *newvalue); // callback pro ulozeni uzi * \param [in] len Delka retezce * \return Vycteny retezec */ -String getEEPROMString(int start, int len); +String getEEPROMString(unsigned int start, size_t len); /** * \brief Ulozeni retezce do EEPROM @@ -102,7 +103,7 @@ String getEEPROMString(int start, int len); * \param [in] len Maximalni delka ulozeneho retezce * \param [in] string Ukladany retezec */ -void setEEPROMString(int start, int len, String string); +void setEEPROMString(unsigned int start, size_t len, String string); /** * \brief Ziskani nasi ip adresy @@ -121,8 +122,21 @@ IPAddress getOurIP(void); */ uint8_t * getOurMAC(uint8_t *mac); +/** + * @brief Ziskani 32 bitoveho cisla z EEPROM + * + * @param[in] start Pocatecni adresa, ze ktere se ziskava cislo. + * + * @return Ziskane cislo. + */ uint32_t getEEPROMuint32(int start); +/** + * @brief Ulozeni 32 bitoveho cisla do EEPROM + * + * @param[in] start Pocatecni adresa, kam cislo ukladame. + * @param[in] val Ukladana hodnota + */ void setEEPROMuint32(int start, uint32_t val); extern char WiFiDeviceName[]; // jmeno zarizeni, pouzivane i pro DHCP From a742f624fb36fca51253db2ca61b63c5226dea3c Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 19 Jul 2018 12:19:54 +0200 Subject: [PATCH 3/4] Opravy pro preklad. --- src/WiFiConfig.cpp | 20 ++++++++++---------- src/WiFiConfig.h | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/WiFiConfig.cpp b/src/WiFiConfig.cpp index 050f456..be6c72e 100644 --- a/src/WiFiConfig.cpp +++ b/src/WiFiConfig.cpp @@ -167,11 +167,11 @@ void setEEPROMuint32(unsigned int start, uint32_t val) String getEEPROMString(unsigned int start, size_t maxlen) { uint8_t mac[WL_MAC_ADDR_LENGTH]; - unsignd int enciphidx = 0; + unsigned int enciphidx = 0; String string = ""; WiFi.softAPmacAddress(mac); - for (unsigned int i = start; i < + start + len; ++i) + for (unsigned int i = start; i < + start + maxlen; ++i) { uint8_t b = EEPROM.read(i); @@ -186,14 +186,14 @@ String getEEPROMString(unsigned int start, size_t maxlen) return string; } -void setEEPROMString(unsigned int start, size_t len, String &string) +void setEEPROMString(unsigned int start, size_t maxlen, String &string) { uint8_t mac[WL_MAC_ADDR_LENGTH]; - unsignd int enciphidx = 0; + unsigned int enciphidx = 0; unsigned int si = 0; WiFi.softAPmacAddress(mac); - for (unsigned int i = start; i < start + len; ++i) + for (unsigned int i = start; i < start + maxlen; ++i) { char c; @@ -213,7 +213,7 @@ void setEEPROMString(unsigned int start, size_t len, String &string) } } -WiFiConfigUsrParameter::WiFiConfigUsrParameter(const char *id, const char *label, const char *defaultValue, int length, storeparam_cb cb) +WiFiConfigUsrParameter::WiFiConfigUsrParameter(const char *id, const char *label, const char *defaultValue, unsigned int length, storeparam_cb cb) { _next = NULL; _cb = cb; @@ -300,12 +300,12 @@ void WiFiConfig::_handleNotFound(void) if (server->uri().endsWith(String(F("favicon.ico")))) { - server->send_P(404, FPSTR(TEXTPLAIN), PSTR("Err")); + server->send_P(404, TEXTPLAIN, PSTR("Err")); } else { server->sendHeader(F("Location"), String(F("http://")) + server->client().localIP().toString() + String(F("/index.htm")), true); - server->send_P(302, FPSTR(TEXTPLAIN), PSTR("Redirect")); + server->send_P(302, TEXTPLAIN, PSTR("Redirect")); } } @@ -319,7 +319,7 @@ void WiFiConfig::_handleReset(void) ESP.restart(); }); - server->send_P(200, FPSTR(TEXTHTML), FPSTR(PAGE_RESTART)); + server->send_P(200, TEXTHTML, PAGE_RESTART); } void WiFiConfig::_handleInfo(void) @@ -579,7 +579,7 @@ void WiFiConfig::_handleSetAP(void) } EEPROM.commit(); // skutecne ulozime data } - server->send_P(200, FPSTR(TEXTHTML), FPSTR(PAGE_SAVED)); + server->send_P(200, TEXTHTML, PAGE_SAVED); delay(2000); // cekame na odeslani dat // nakonfigurujeme ESP dle nove nastavenych parametru WiFi.disconnect(); // vsechno odpojime diff --git a/src/WiFiConfig.h b/src/WiFiConfig.h index 3fdfce4..ad089c2 100644 --- a/src/WiFiConfig.h +++ b/src/WiFiConfig.h @@ -94,7 +94,7 @@ typedef void (*storeparam_cb)(const char *newvalue); // callback pro ulozeni uzi * \param [in] len Delka retezce * \return Vycteny retezec */ -String getEEPROMString(unsigned int start, size_t len); +String getEEPROMString(unsigned int start, size_t maxlen); /** * \brief Ulozeni retezce do EEPROM @@ -103,7 +103,7 @@ String getEEPROMString(unsigned int start, size_t len); * \param [in] len Maximalni delka ulozeneho retezce * \param [in] string Ukladany retezec */ -void setEEPROMString(unsigned int start, size_t len, String string); +void setEEPROMString(unsigned int start, size_t maxlen, String &string); /** * \brief Ziskani nasi ip adresy @@ -144,7 +144,7 @@ extern char WiFiDeviceName[]; // jmeno zarizeni, pouzivane i pro DHCP class WiFiConfigUsrParameter { public: - WiFiConfigUsrParameter(const char *id, const char *label, const char *defaultValue, int length, storeparam_cb cb); + WiFiConfigUsrParameter(const char *id, const char *label, const char *defaultValue, unsigned int length, storeparam_cb cb); const char *getID(); const char *getValue(); From 51ae416dd02d9d7124426feb7947f3c8eee517e2 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 20 Jul 2018 06:59:43 +0200 Subject: [PATCH 4/4] Interni metody pro sifrovane ukladani (zpetna kompatibilita) --- src/WiFiConfig.cpp | 108 +++++++++++++++++++++++++++++++++------------ src/WiFiConfig.h | 24 +++++----- 2 files changed, 93 insertions(+), 39 deletions(-) diff --git a/src/WiFiConfig.cpp b/src/WiFiConfig.cpp index be6c72e..82b9421 100644 --- a/src/WiFiConfig.cpp +++ b/src/WiFiConfig.cpp @@ -164,36 +164,26 @@ void setEEPROMuint32(unsigned int start, uint32_t val) } } -String getEEPROMString(unsigned int start, size_t maxlen) +String getEEPROMString(unsigned int start, size_t len) { - uint8_t mac[WL_MAC_ADDR_LENGTH]; - unsigned int enciphidx = 0; String string = ""; - WiFi.softAPmacAddress(mac); - for (unsigned int i = start; i < + start + maxlen; ++i) + for (unsigned int i = start; i < + start + len; ++i) { uint8_t b = EEPROM.read(i); - b ^= mac[enciphidx]; - ++enciphidx; - enciphidx %= WL_MAC_ADDR_LENGTH; - if ((0xff == b) || (0 == b)) break; - string.concat(char(b)); + string += char(b); } return string; } -void setEEPROMString(unsigned int start, size_t maxlen, String &string) +void setEEPROMString(unsigned int start, size_t len, String &string) { - uint8_t mac[WL_MAC_ADDR_LENGTH]; - unsigned int enciphidx = 0; unsigned int si = 0; - WiFi.softAPmacAddress(mac); - for (unsigned int i = start; i < start + maxlen; ++i) + for (unsigned int i = start; i < start + len; ++i) { char c; @@ -205,9 +195,6 @@ void setEEPROMString(unsigned int start, size_t maxlen, String &string) { c = 0; } - c ^= mac[enciphidx]; - ++enciphidx; - enciphidx %= WL_MAC_ADDR_LENGTH; EEPROM.write(i, c); ++si; } @@ -456,17 +443,17 @@ void WiFiConfig::_handleDisplayAP(void) } } s = FPSTR(PAGE_INDEX2); - v = getEEPROMString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid)); + v = _readString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid)); if (v.length()) s.replace(F("{s}"), String(FPSTR(VALUE)) + v + F("'")); else s.replace(F("{s}"), F("placeholder='SSID'")); - v = getEEPROMString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass)); + v = _readString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass)); if (v.length()) s.replace(F("{p}"), String(FPSTR(VALUE)) + v + F("'")); else s.replace(F("{p}"), F("placeholder='password'")); - v = getEEPROMString(configBase + offsetof(wificonfigarea_t, devname), elementSize(wificonfigarea_t, devname)); + v = _readString(configBase + offsetof(wificonfigarea_t, devname), elementSize(wificonfigarea_t, devname)); if (v.length()) s.replace(F("{n}"), String(FPSTR(VALUE)) + v + F("'")); else @@ -523,13 +510,13 @@ void WiFiConfig::_handleSetAP(void) str = server->arg(F("_s")); if (str.length() > 0) { - setEEPROMString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid), str); + _storeString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid), str); str = server->arg(F("_p")); - setEEPROMString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass), str); + _storeString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass), str); str = server->arg(F("_n")); - setEEPROMString(configBase + offsetof(wificonfigarea_t, devname), elementSize(wificonfigarea_t, devname), str); + _storeString(configBase + offsetof(wificonfigarea_t, devname), elementSize(wificonfigarea_t, devname), str); str = server->arg(F("_a")); if (str.length() > 0) @@ -585,10 +572,10 @@ void WiFiConfig::_handleSetAP(void) WiFi.disconnect(); // vsechno odpojime WiFi.persistent(true); // chceme, aby si modul zapamatoval konfiguraci - String s = getEEPROMString(configBase + offsetof(wificonfigarea_t, devname), elementSize(wificonfigarea_t, devname)); + String s = _readString(configBase + offsetof(wificonfigarea_t, devname), elementSize(wificonfigarea_t, devname)); strcpy(WiFiDeviceName, s.c_str()); - s = getEEPROMString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid)); - String pass = getEEPROMString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass)); + s = _readString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid)); + String pass = _readString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass)); switch (EEPROM.read(configBase + offsetof(wificonfigarea_t, mode))) { @@ -709,6 +696,71 @@ wificonfigresult_t WiFiConfig::_setupAP(wificonfig_cb cb) return WCR_TIMEOUT; // nepripojeno, vyprsel timeout konfiguracniho AP } +String WiFiConfig::_readString(unsigned int start, size_t maxlen) +{ + uint8_t mac[WL_MAC_ADDR_LENGTH]; + unsigned int enciphidx = 0; + String result; + unsigned int top = EEPROM.read(start); + unsigned int i; + + result.reserve(maxlen); + WiFi.softAPmacAddress(mac); + if ((top > 0) && (top < (maxlen - 2))) + { + uint8_t b; + for (i = start + 1; i < + start + top + 1; ++i) + { + b = EEPROM.read(i); + + b ^= mac[enciphidx]; + ++enciphidx; + enciphidx %= WL_MAC_ADDR_LENGTH; + + result.concat(char(b)); + } + b = EEPROM.read(i) ^ mac[enciphidx]; + if (b != 0) + result = F(""); // spatna ukoncovaci nula - neplatny retezec + } + return result; +} + +bool WiFiConfig::_storeString(unsigned int start, size_t maxlen, String &string) +{ + uint8_t mac[WL_MAC_ADDR_LENGTH]; + unsigned int enciphidx = 0; + unsigned int si = 0; + unsigned int top; + char c; + bool result = false; // retezec nebyl ulozeny cely (nevesel s do bufferu) + unsigned int i; + + if (string.length() > maxlen - 2) + top = maxlen - 2; + else + { + result = true; // retezec se do urceneho mista vejde + top = string.length(); + } + + WiFi.softAPmacAddress(mac); + EEPROM.write(start, (uint8_t)top); // ulozime delku retezce (pouzite pr kontrolu pri vycitani) + for (i = start + 1; i < start + maxlen + 1; ++i) + { + c = string[si]; + c ^= mac[enciphidx]; + ++enciphidx; + enciphidx %= WL_MAC_ADDR_LENGTH; + EEPROM.write(i, c); + ++si; + } + c = 0 ^ mac[enciphidx]; + EEPROM.write(i, c); // ukoncovaci a kontrolni nula + + return result; +} + // Testovani, zda se modul pripojil k AP bool WiFiConfig::_testWifi(wificonfig_cb cb) { @@ -756,7 +808,7 @@ wificonfigresult_t WiFiConfig::begin(int configarea, uint8_t forceConfigure, wif } else { - String s = getEEPROMString(configBase + offsetof(wificonfigarea_t, devname), elementSize(wificonfigarea_t, devname)); + String s = _readString(configBase + offsetof(wificonfigarea_t, devname), elementSize(wificonfigarea_t, devname)); strcpy(WiFiDeviceName, s.c_str()); switch (EEPROM.read(configBase + offsetof(wificonfigarea_t, mode))) diff --git a/src/WiFiConfig.h b/src/WiFiConfig.h index ad089c2..6dc2609 100644 --- a/src/WiFiConfig.h +++ b/src/WiFiConfig.h @@ -42,9 +42,9 @@ typedef struct { uint8_t mode; // rezim prace AP/STA uint8_t ip; // konfigurace ip (staticka/DHCP) - char ssid[32]; // SSID site - char pass[64]; // heslo - char devname[32]; // jmeno zarizeni (pro NBNS plati jen 16 znaku) + char ssid[32 + 2]; // SSID site + char pass[64 + 2]; // heslo + char devname[32 + 2]; // jmeno zarizeni (pro NBNS plati jen 16 znaku) uint32_t ipaddr; // ip adresa v pripade staticke konfigurace uint32_t netmask; // sitova maska v pripade staticke konfigurace uint32_t gateway; // sitova brana v pripade staticke konfigurace @@ -94,7 +94,7 @@ typedef void (*storeparam_cb)(const char *newvalue); // callback pro ulozeni uzi * \param [in] len Delka retezce * \return Vycteny retezec */ -String getEEPROMString(unsigned int start, size_t maxlen); +String getEEPROMString(unsigned int start, size_t len); /** * \brief Ulozeni retezce do EEPROM @@ -103,7 +103,7 @@ String getEEPROMString(unsigned int start, size_t maxlen); * \param [in] len Maximalni delka ulozeneho retezce * \param [in] string Ukladany retezec */ -void setEEPROMString(unsigned int start, size_t maxlen, String &string); +void setEEPROMString(unsigned int start, size_t len, String &string); /** * \brief Ziskani nasi ip adresy @@ -149,18 +149,18 @@ class WiFiConfigUsrParameter const char *getID(); const char *getValue(); const char *getLabel(); - int getValueLength(); - void setNext(WiFiConfigUsrParameter *n); + int getValueLength(); + void setNext(WiFiConfigUsrParameter *n); WiFiConfigUsrParameter *getNext(); - void setNewValue(const char *newval); + void setNewValue(const char *newval); private: const char *_id; const char *_label; char *_value; int _length; - storeparam_cb _cb; - WiFiConfigUsrParameter *_next; + storeparam_cb _cb; + WiFiConfigUsrParameter *_next; friend class WiFiConfig; }; @@ -171,7 +171,7 @@ public: WiFiConfig(): _params(NULL), _timeout(0) {} wificonfigresult_t begin(int configarea, uint8_t forceConfigure, wificonfig_cb cb); wificonfigresult_t begin(int configarea, uint8_t forceConfigure, int timeout, wificonfig_cb cb); - void addParameter(WiFiConfigUsrParameter *p); + void addParameter(WiFiConfigUsrParameter *p); private: wificonfigresult_t _setupAP(wificonfig_cb cb); void _handleDisplayAP(void); @@ -181,6 +181,8 @@ private: void _handleNotFound(); // CaptivePortal redirector void _handleRoot(); // jen jednoducha stranka kvuli CaptivePortalu umoznuje prejit na spravnou stranku (ale nedela to...) bool _testWifi(wificonfig_cb cb); + bool _storeString(unsigned int start, size_t maxlen, String &string); // sifrovany retezec, max 255 znaku + String _readString(unsigned int start, size_t maxlen); // sifrovany retezec, max. 255 znaku WiFiConfigUsrParameter *_searchUsrParameter(const char *name); WiFiConfigUsrParameter *_params; // ukazatel na posledni zadany uzivatelsky parametr