From ca4fc1a38d919813e5e6d368d3b467e78b879da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 28 Feb 2018 16:31:45 +0100 Subject: [PATCH] Using wifiRegister instead of WifiHandlers in rf module --- code/espurna/rf.ino | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/code/espurna/rf.ino b/code/espurna/rf.ino index b1f19699..6708d790 100644 --- a/code/espurna/rf.ino +++ b/code/espurna/rf.ino @@ -75,24 +75,18 @@ void rfSetup() { RemoteReceiver::disable(); DEBUG_MSG_P(PSTR("[RF] Disabled\n")); - static WiFiEventHandler e1 = WiFi.onStationModeDisconnected([](const WiFiEventStationModeDisconnected& event) { - RemoteReceiver::disable(); - DEBUG_MSG_P(PSTR("[RF] Disabled\n")); - }); + wifiRegister([](justwifi_messages_t code, char * parameter) { - static WiFiEventHandler e2 = WiFi.onSoftAPModeStationDisconnected([](const WiFiEventSoftAPModeStationDisconnected& event) { - RemoteReceiver::disable(); - DEBUG_MSG_P(PSTR("[RF] Disabled\n")); - }); + if (code == MESSAGE_CONNECTED || code == MESSAGE_ACCESSPOINT_CREATED) { + RemoteReceiver::enable(); + DEBUG_MSG_P(PSTR("[RF] Enabled\n")); + } - static WiFiEventHandler e3 = WiFi.onStationModeConnected([](const WiFiEventStationModeConnected& event) { - RemoteReceiver::enable(); - DEBUG_MSG_P(PSTR("[RF] Enabled\n")); - }); + if (code == MESSAGE_DISCONNECTED) + RemoteReceiver::disable(); + DEBUG_MSG_P(PSTR("[RF] Disabled\n")); + } - static WiFiEventHandler e4 = WiFi.onSoftAPModeStationConnected([](const WiFiEventSoftAPModeStationConnected& event) { - RemoteReceiver::enable(); - DEBUG_MSG_P(PSTR("[RF] Enabled\n")); }); #if WEB_SUPPORT