diff --git a/library.json b/library.json index 87050fc..a01f845 100644 --- a/library.json +++ b/library.json @@ -12,7 +12,7 @@ "type": "git", "url": "http://git.xpablo.cz/pablo2048/WiFiConfig.git" }, - "version": "5.5", + "version": "5.7", "license": "MIT", "frameworks": "arduino", "platforms": "espressif8266", diff --git a/library.properties b/library.properties index 5c863c7..ea69dd0 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=WiFiConfig -version=5.4.0 +version=5.7 author=Pavel Brychta maintainer=Pavel Brychta sentence=Enables seamless module configuration. diff --git a/src/WiFiConfig.cpp b/src/WiFiConfig.cpp index 88fc617..f881edb 100644 --- a/src/WiFiConfig.cpp +++ b/src/WiFiConfig.cpp @@ -1,4 +1,9 @@ /* + * V5.7 - 4.7.2018 - BugFix - staticka konfigurace ip adresy se neuplatnila - vypada to, jako kdyby SDK ukladalo SSID a Password, ale uz neuklada + * konfiguraci ip adres, takze je treba je vzdycky nastavit znovu + * + * V5.6 - 1.7.2018 - BugFix - odstraneno volani _plusDecode, protoze parametry jsou nyni predavany v 'ciste' forme uz z weboveho serveru a tato metoda znehodnotila retezce, ktere obsahovaly ynak '+' + * * V5.5 - 3.6.2018 - Flash Chip ID a ESP Chip ID jsou zobrazeny hexadecimalne v prehledove strance * * V5.4 - 9.1.2018 - na titulni stranku pridan duvod, proc je spusteny konfiguracni AP. Usnadni to diagnostiku pripadu, kdy se ESP nechce pripojit k AP. @@ -494,14 +499,6 @@ void WiFiConfig::_handleDisplayAP(void) server->send(200, TEXTHTML, content); } -// Deal with (potentially) plus-encoded ssid/pass -void WiFiConfig::_plusDecode(String &s) -{ - - for (unsigned int i = 0; i < s.length(); i++) - s[i] = (s[i] == '+' ? ' ' : s[i]); -} - void WiFiConfig::_handleSetAP(void) { uint8_t mode; @@ -511,11 +508,9 @@ void WiFiConfig::_handleSetAP(void) str = server->arg(F("_s")); if (str.length() > 0) { - _plusDecode(str); setEEPROMString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid), str); str = server->arg(F("_p")); - _plusDecode(str); setEEPROMString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass), str); str = server->arg(F("_n")); @@ -585,17 +580,21 @@ void WiFiConfig::_handleSetAP(void) case WIFIMODE_STA: { DEBUG_MSG("STA mode.\r\n"); - WiFi.mode(WIFI_STA); // startujeme WiFi v rezimu klienta if (strlen(WiFiDeviceName)) + { WiFi.hostname(WiFiDeviceName); // nastavime jmeno zarizeni - WiFi.begin(s.c_str(), pass.c_str()); + } if (IPCONFIG_STATIC == EEPROM.read(configBase + offsetof(wificonfigarea_t, ip))) { DEBUG_MSG("Static configuration.\r\n"); WiFi.config(IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, ipaddr))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, gateway))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, netmask))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, dns)))); + delay(100); } + WiFi.mode(WIFI_STA); // startujeme WiFi v rezimu klienta + WiFi.begin(s.c_str(), pass.c_str()); wifi_station_set_auto_connect(true); + delay(1000); } break; @@ -603,14 +602,20 @@ void WiFiConfig::_handleSetAP(void) DEBUG_MSG("AP mode.\r\n"); WiFi.mode(WIFI_AP); // startujeme AP if (pass.length()) - // je zadane heslo do AP + { + // je zadane heslo do AP WiFi.softAP(s.c_str(), pass.c_str(), EEPROM.read(configBase + offsetof(wificonfigarea_t, apchannel))); + } else - // otevreny AP - WiFi.softAP(s.c_str(), NULL, EEPROM.read(configBase + offsetof(wificonfigarea_t, apchannel))); + { + // otevreny AP + WiFi.softAP(s.c_str(), NULL, EEPROM.read(configBase + offsetof(wificonfigarea_t, apchannel))); + } if (IPCONFIG_STATIC == EEPROM.read(configBase + offsetof(wificonfigarea_t, ip))) + { WiFi.softAPConfig(IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, ipaddr))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, gateway))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, netmask)))); + } break; default: // jakykoliv neznamy rezim (mozna zavada na EEPROM???) @@ -744,6 +749,12 @@ wificonfigresult_t WiFiConfig::begin(int configarea, uint8_t forceConfigure, wif case WIFIMODE_STA: { WiFi.hostname(WiFiDeviceName); // nastavime jmeno zarizeni + if (IPCONFIG_STATIC == EEPROM.read(configBase + offsetof(wificonfigarea_t, ip))) + { + DEBUG_MSG("Static configuration SET.\r\n"); + WiFi.config(IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, ipaddr))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, gateway))), + IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, netmask))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, dns)))); + } DEBUG_MSG("STA mode.\r\n"); if (WC_DONT_RUN_CONFIGAP == _timeout) result = WCR_CONFIGAP_NOT_STARTED; // nemame spoustet konfiguracni AP - vracime se hned diff --git a/src/WiFiConfig.h b/src/WiFiConfig.h index e9b0b61..b479a75 100644 --- a/src/WiFiConfig.h +++ b/src/WiFiConfig.h @@ -168,7 +168,6 @@ private: void _handleRoot(); // jen jednoducha stranka kvuli CaptivePortalu umoznuje prejit na spravnou stranku (ale nedela to...) bool _testWifi(wificonfig_cb cb); WiFiConfigUsrParameter *_searchUsrParameter(const char *name); - void _plusDecode(String &s); WiFiConfigUsrParameter *_params; // ukazatel na posledni zadany uzivatelsky parametr int _timeout; // timeout pri cekani na konfiguraci diff --git a/src/embHTML.h b/src/embHTML.h index f9423b6..4f805f1 100644 --- a/src/embHTML.h +++ b/src/embHTML.h @@ -56,7 +56,7 @@ static const char PAGE_INDEX2[] PROGMEM = R"=====(
- +