From 349bc68180cbc1d06dee6d2f02ab94e0f5c3f665 Mon Sep 17 00:00:00 2001 From: Pavel Brychta Date: Tue, 7 Apr 2020 07:30:51 +0200 Subject: [PATCH] Oprava padu ESP32 pri pokusu o iskani adresy pres DHCP (odkaz na popis chyby do githubu je v kodu) --- src/WiFiConfig.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/WiFiConfig.cpp b/src/WiFiConfig.cpp index 953d592..9b8797f 100644 --- a/src/WiFiConfig.cpp +++ b/src/WiFiConfig.cpp @@ -700,6 +700,7 @@ wificonfigresult_t WiFiConfig::_setupAP(wificonfig_cb cb) WiFi.disconnect(); // pro jistotu se odpojime // WiFi.mode(WIFI_AP); +#if defined(ARDUINO_ARCH_ESP8266) WiFi.softAPConfig(apIP, apIP, netMsk); if (ssid.endsWith(F("?"))) { char lmac[16]; @@ -710,7 +711,17 @@ wificonfigresult_t WiFiConfig::_setupAP(wificonfig_cb cb) 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) +#else + // osetreni padu ESP32 - https://github.com/espressif/arduino-esp32/issues/2025 + if (ssid.endsWith(F("?"))) { + char lmac[16]; + sprintf_P(lmac, PSTR("%06X"), ESP_getChipId()); + ssid.replace(F("?"), String(lmac)); + } + WiFi.softAP(ssid.c_str(), NULL, SETUP_CHANNEL); + WiFi.softAPConfig(apIP, apIP, netMsk); +#endif dnsServer->setErrorReplyCode(DNSReplyCode::NoError); dnsServer->start(DNS_PORT, "*", WiFi.softAPIP()); // spustime tzv. Captive portal - vsechny DNS dotazy jsou smerovany na nasi ip adresu if (cb)