From 733996772bc111920394d041cc3578b666604026 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Fri, 18 Oct 2019 13:26:39 +0200 Subject: [PATCH] WLED_CONNECTED macro --- wled00/wled00.ino | 5 ++++- wled00/wled03_set.ino | 2 +- wled00/wled05_init.ino | 4 ++-- wled00/wled07_notify.ino | 2 +- wled00/wled10_ntp.ino | 2 +- wled00/wled12_alexa.ino | 4 ++-- wled00/wled15_hue.ino | 4 ++-- wled00/wled16_blynk.ino | 4 ++-- 8 files changed, 15 insertions(+), 12 deletions(-) diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 545ce421..bad1db94 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -99,7 +99,7 @@ //version code in format yymmddb (b = daily build) -#define VERSION 1910174 +#define VERSION 1910181 char versionString[] = "0.8.5"; @@ -433,6 +433,8 @@ E131* e131; //led fx library object WS2812FX strip = WS2812FX(); +#define WLED_CONNECTED (WiFi.status() == WL_CONNECTED) + //debug macros #ifdef WLED_DEBUG #define DEBUG_PRINT(x) Serial.print (x) @@ -504,6 +506,7 @@ void setup() { //main program loop void loop() { + handleConnection(); handleSerial(); handleNotifications(); handleTransitions(); diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino index f46dc3b0..d0d9ff57 100644 --- a/wled00/wled03_set.ino +++ b/wled00/wled03_set.ino @@ -214,7 +214,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) utcOffsetSecs = request->arg("UO").toInt(); //start ntp if not already connected - if (ntpEnabled && WiFi.status() == WL_CONNECTED && !ntpConnected) ntpConnected = ntpUdp.begin(ntpLocalPort); + if (ntpEnabled && WLED_CONNECTED && !ntpConnected) ntpConnected = ntpUdp.begin(ntpLocalPort); if (request->hasArg("OL")){ overlayDefault = request->arg("OL").toInt(); diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index 6b7f4737..0eb712ee 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -63,7 +63,7 @@ void wledInit() udpConnected = notifierUdp.begin(udpPort); if (udpConnected && udpRgbPort != udpPort) udpRgbConnected = rgbUdp.begin(udpRgbPort); } - if (ntpEnabled && WiFi.status() == WL_CONNECTED) + if (ntpEnabled && WLED_CONNECTED) ntpConnected = ntpUdp.begin(ntpLocalPort); //start captive portal if AP active @@ -227,7 +227,7 @@ void initCon() handleOverlays(); if (briT) strip.service(); if (millis()-lastTry > 499) { - con = (WiFi.status() == WL_CONNECTED); + con = WLED_CONNECTED; lastTry = millis(); DEBUG_PRINTLN("C_NC"); if (!recoveryAPDisabled && fail_count > apWaitTimeSecs*2) diff --git a/wled00/wled07_notify.ino b/wled00/wled07_notify.ino index aea4b054..2756e720 100644 --- a/wled00/wled07_notify.ino +++ b/wled00/wled07_notify.ino @@ -87,7 +87,7 @@ void arlsLock(uint32_t timeoutMs) void initE131(){ - if (WiFi.status() == WL_CONNECTED && e131Enabled) + if (WLED_CONNECTED && e131Enabled) { e131 = new E131(); e131->begin((e131Multicast) ? E131_MULTICAST : E131_UNICAST , e131Universe); diff --git a/wled00/wled10_ntp.ino b/wled00/wled10_ntp.ino index efb46d6e..e9eec769 100644 --- a/wled00/wled10_ntp.ino +++ b/wled00/wled10_ntp.ino @@ -56,7 +56,7 @@ Timezone* timezones[] = {&tzUTC, &tzUK, &tzEUCentral, &tzEUEastern, &tzUSEastern void handleNetworkTime() { - if (ntpEnabled && ntpConnected && millis() - ntpLastSyncTime > 50000000L && WiFi.status() == WL_CONNECTED) + if (ntpEnabled && ntpConnected && millis() - ntpLastSyncTime > 50000000L && WLED_CONNECTED) { if (millis() - ntpPacketSentTime > 10000) { diff --git a/wled00/wled12_alexa.ino b/wled00/wled12_alexa.ino index c9aa5fc5..a9256b1c 100644 --- a/wled00/wled12_alexa.ino +++ b/wled00/wled12_alexa.ino @@ -16,7 +16,7 @@ void onAlexaChange(EspalexaDevice* dev); void alexaInit() { - if (alexaEnabled && WiFi.status() == WL_CONNECTED) + if (alexaEnabled && WLED_CONNECTED) { if (espalexaDevice == nullptr) //only init once { @@ -31,7 +31,7 @@ void alexaInit() void handleAlexa() { - if (!alexaEnabled || WiFi.status() != WL_CONNECTED) return; + if (!alexaEnabled || !WLED_CONNECTED) return; espalexa.loop(); } diff --git a/wled00/wled15_hue.ino b/wled00/wled15_hue.ino index eaa5047d..d13ce43a 100644 --- a/wled00/wled15_hue.ino +++ b/wled00/wled15_hue.ino @@ -4,7 +4,7 @@ #ifndef WLED_DISABLE_HUESYNC void handleHue() { - if (hueClient != nullptr && millis() - hueLastRequestSent > huePollIntervalMs && WiFi.status() == WL_CONNECTED) + if (hueClient != nullptr && millis() - hueLastRequestSent > huePollIntervalMs && WLED_CONNECTED) { hueLastRequestSent = millis(); if (huePollingEnabled) @@ -29,7 +29,7 @@ void handleHue() void reconnectHue() { - if (WiFi.status() != WL_CONNECTED || !huePollingEnabled) return; + if (!WLED_CONNECTED || !huePollingEnabled) return; DEBUG_PRINTLN("Hue reconnect"); if (hueClient == nullptr) { hueClient = new AsyncClient(); diff --git a/wled00/wled16_blynk.ino b/wled00/wled16_blynk.ino index a430bedc..5b04da9e 100644 --- a/wled00/wled16_blynk.ino +++ b/wled00/wled16_blynk.ino @@ -8,7 +8,7 @@ byte blSat = 255; void initBlynk(const char* auth) { #ifndef WLED_DISABLE_BLYNK - if (WiFi.status() != WL_CONNECTED) return; + if (!WLED_CONNECTED) return; blynkEnabled = (auth[0] != 0); if (blynkEnabled) Blynk.config(auth); #endif @@ -17,7 +17,7 @@ void initBlynk(const char* auth) void handleBlynk() { #ifndef WLED_DISABLE_BLYNK - if (WiFi.status() == WL_CONNECTED && blynkEnabled) + if (WLED_CONNECTED && blynkEnabled) Blynk.run(); #endif }