From 26a65f00ac45dec6b081355dc4348e7b8bb29396 Mon Sep 17 00:00:00 2001 From: Pavel Brychta Date: Tue, 24 Mar 2020 08:13:56 +0100 Subject: [PATCH] Staticka ip konfigurace v rezimu AP je funkcni. --- src/WiFiConfig.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/WiFiConfig.cpp b/src/WiFiConfig.cpp index 54b86b0..953d592 100644 --- a/src/WiFiConfig.cpp +++ b/src/WiFiConfig.cpp @@ -1,4 +1,6 @@ /* + * v6.3.4-23.3.2020 - staticka konfigurace v AP rezimu funkcni + * * v6.3.3-27.10.2019 - volani WS_CONNECTED i v pripade, ze bezi AP * * v6.3.2- 4.10.2019 - Informace o aplikaci a jeji verzi do footeru, zrychlen restart z 10 na 5 sekund, vylepsena stranka pro reset @@ -616,8 +618,8 @@ void WiFiConfig::_handleSetAP(void) server->send_P(200, TEXTHTML, PAGE_SAVED); delay(2000); // cekame na odeslani dat // nakonfigurujeme ESP dle nove nastavenych parametru - WiFi.disconnect(); // vsechno odpojime WiFi.persistent(true); // chceme, aby si modul zapamatoval konfiguraci + WiFi.disconnect(); // vsechno odpojime String s = EES_readString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid)); String pass = EES_readString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass)); @@ -696,7 +698,7 @@ wificonfigresult_t WiFiConfig::_setupAP(wificonfig_cb cb) IPAddress netMsk(255, 255, 255, 0); WiFi.disconnect(); // pro jistotu se odpojime - WiFi.mode(WIFI_AP); +// WiFi.mode(WIFI_AP); WiFi.softAPConfig(apIP, apIP, netMsk); if (ssid.endsWith(F("?"))) { @@ -706,6 +708,7 @@ wificonfigresult_t WiFiConfig::_setupAP(wificonfig_cb cb) ssid.replace(F("?"), String(lmac)); } WiFi.softAP(ssid.c_str(), NULL, SETUP_CHANNEL); + WiFi.mode(WIFI_AP); delay(500); // dulezite - jinak se nevraci spravna IP adresa !!! (udajne od verze 2.3.0 uz neni nutne) dnsServer->setErrorReplyCode(DNSReplyCode::NoError); @@ -894,6 +897,10 @@ wificonfigresult_t WiFiConfig::begin(int configarea, int forceConfigure, wificon case WIFIMODE_AP: DEBUG_MSG("AP mode.\r\n"); + 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)))); + } if (cb) cb(WCS_CONNECTED); // signalizujeme pripojeni (zde se nic jineho stejne nestane...) break;