Last active
June 11, 2025 23:55
-
-
Save kanehekili/b889ce0b37438be3bc59e07d27186d18 to your computer and use it in GitHub Desktop.
Revisions
-
kanehekili revised this gist
Jun 11, 2025 . 1 changed file with 0 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,9 +39,3 @@ static WiFiEventHandler onGotIPHandler = WiFi.onStationModeGotIP(&onConnected); Do not rely on onStationModeDisconnected -> won't work on the second disconnection. Always use while (WiFi.status() != WL_CONNECTED){ -
kanehekili revised this gist
Jun 11, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,7 +34,7 @@ void onConnected(const WiFiEventStationModeGotIP& event) { digitalWrite(LED_BUILTIN, HIGH); // LED off (connected) } defined in setup() by: static WiFiEventHandler onGotIPHandler = WiFi.onStationModeGotIP(&onConnected); Do not rely on onStationModeDisconnected -> won't work on the second disconnection. -
kanehekili created this gist
Jun 11, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ ## Verified ESP8266 WiFi Event Behavior **Test Setup:** - D1 Mini (ESP-12F) - Arduino Core 3.1.2 - 50+ reboot cycles **Reliable:** ✅ `onStationModeGotIP` (when stored statically) **Broken:** ❌ `onStationModeDisconnected` (fails after 1st trigger/ESP.reboot) **Test Code:** ## Verified ESP8266 WiFi Event Behavior **Test Setup:** - D1 Mini (ESP-12F) - Arduino Core 3.1.2 - 50+ reboot cycles **Reliable:** ✅ `onStationModeGotIP` (when stored statically) **Broken:** ❌ `onStationModeDisconnected` (fails after 1st trigger) **Full Test Code:** // ===== WiFi Event Handlers ===== // void onConnected(const WiFiEventStationModeGotIP& event) { //Serial.println("WiFi connected!"); Serial.printf("Wifi connected. IP: %s \n", WiFi.localIP().toString().c_str()); setmDNS(); digitalWrite(LED_BUILTIN, HIGH); // LED off (connected) } defineed in setup() by: static WiFiEventHandler onGotIPHandler = WiFi.onStationModeGotIP(&onConnected); Do not rely on onStationModeDisconnected -> won't work on the second disconnection. Always use while (WiFi.status() != WL_CONNECTED){ **Recommendation:** Use this hybrid approach for 100% reliability... **Recommendation:** Use this hybrid approach for 100% reliability...