Staticka ip konfigurace v rezimu AP je funkcni.

This commit is contained in:
Pavel Brychta 2020-03-24 08:13:56 +01:00
parent 48f3d58f7e
commit 26a65f00ac

View File

@ -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;