improve WIFI event disconnect/connect register on emulator

This commit is contained in:
amarofarinha 2024-09-19 09:02:17 +01:00
parent 5d8c20ee0f
commit 23c9f8c3c3

View file

@ -139,6 +139,7 @@ static void connectToWiFi() {
// Event handler for successful Wi-Fi connection
static void onWifiConnect(WiFiEvent_t event, WiFiEventInfo_t info) {
clear_event(EVENT_WIFI_DISCONNECT);
set_event(EVENT_WIFI_CONNECT, 0);
#ifdef DEBUG_VIA_USB
Serial.println("Wi-Fi connected.");
@ -167,16 +168,14 @@ static void onWifiDisconnect(WiFiEvent_t event, WiFiEventInfo_t info) {
#ifdef DEBUG_VIA_USB
Serial.println("Wi-Fi disconnected.");
#endif
//do not do anything here, the reconnect will be handled by the monitor
//we dont do anything here, the reconnect will be handled by the monitor
//too many events received when the connection is lost
//normal reconnects start at fit second
clear_event(EVENT_WIFI_DISCONNECT);
//normal reconnect retry start at first 2 seconds
}
#ifdef MDNSRESPONDER
// Initialise mDNS
void init_mDNS() {
// Calulate the host name using the last two chars from the MAC address so each one is likely unique on a network.
// e.g batteryemulator8C.local where the mac address is 08:F9:E0:D1:06:8C
String mac = WiFi.macAddress();