WLED_CONNECTED macro

This commit is contained in:
cschwinne 2019-10-18 13:26:39 +02:00
parent d4c921ea2e
commit 733996772b
8 changed files with 15 additions and 12 deletions

View File

@ -99,7 +99,7 @@
//version code in format yymmddb (b = daily build) //version code in format yymmddb (b = daily build)
#define VERSION 1910174 #define VERSION 1910181
char versionString[] = "0.8.5"; char versionString[] = "0.8.5";
@ -433,6 +433,8 @@ E131* e131;
//led fx library object //led fx library object
WS2812FX strip = WS2812FX(); WS2812FX strip = WS2812FX();
#define WLED_CONNECTED (WiFi.status() == WL_CONNECTED)
//debug macros //debug macros
#ifdef WLED_DEBUG #ifdef WLED_DEBUG
#define DEBUG_PRINT(x) Serial.print (x) #define DEBUG_PRINT(x) Serial.print (x)
@ -504,6 +506,7 @@ void setup() {
//main program loop //main program loop
void loop() { void loop() {
handleConnection();
handleSerial(); handleSerial();
handleNotifications(); handleNotifications();
handleTransitions(); handleTransitions();

View File

@ -214,7 +214,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
utcOffsetSecs = request->arg("UO").toInt(); utcOffsetSecs = request->arg("UO").toInt();
//start ntp if not already connected //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")){ if (request->hasArg("OL")){
overlayDefault = request->arg("OL").toInt(); overlayDefault = request->arg("OL").toInt();

View File

@ -63,7 +63,7 @@ void wledInit()
udpConnected = notifierUdp.begin(udpPort); udpConnected = notifierUdp.begin(udpPort);
if (udpConnected && udpRgbPort != udpPort) udpRgbConnected = rgbUdp.begin(udpRgbPort); if (udpConnected && udpRgbPort != udpPort) udpRgbConnected = rgbUdp.begin(udpRgbPort);
} }
if (ntpEnabled && WiFi.status() == WL_CONNECTED) if (ntpEnabled && WLED_CONNECTED)
ntpConnected = ntpUdp.begin(ntpLocalPort); ntpConnected = ntpUdp.begin(ntpLocalPort);
//start captive portal if AP active //start captive portal if AP active
@ -227,7 +227,7 @@ void initCon()
handleOverlays(); handleOverlays();
if (briT) strip.service(); if (briT) strip.service();
if (millis()-lastTry > 499) { if (millis()-lastTry > 499) {
con = (WiFi.status() == WL_CONNECTED); con = WLED_CONNECTED;
lastTry = millis(); lastTry = millis();
DEBUG_PRINTLN("C_NC"); DEBUG_PRINTLN("C_NC");
if (!recoveryAPDisabled && fail_count > apWaitTimeSecs*2) if (!recoveryAPDisabled && fail_count > apWaitTimeSecs*2)

View File

@ -87,7 +87,7 @@ void arlsLock(uint32_t timeoutMs)
void initE131(){ void initE131(){
if (WiFi.status() == WL_CONNECTED && e131Enabled) if (WLED_CONNECTED && e131Enabled)
{ {
e131 = new E131(); e131 = new E131();
e131->begin((e131Multicast) ? E131_MULTICAST : E131_UNICAST , e131Universe); e131->begin((e131Multicast) ? E131_MULTICAST : E131_UNICAST , e131Universe);

View File

@ -56,7 +56,7 @@ Timezone* timezones[] = {&tzUTC, &tzUK, &tzEUCentral, &tzEUEastern, &tzUSEastern
void handleNetworkTime() void handleNetworkTime()
{ {
if (ntpEnabled && ntpConnected && millis() - ntpLastSyncTime > 50000000L && WiFi.status() == WL_CONNECTED) if (ntpEnabled && ntpConnected && millis() - ntpLastSyncTime > 50000000L && WLED_CONNECTED)
{ {
if (millis() - ntpPacketSentTime > 10000) if (millis() - ntpPacketSentTime > 10000)
{ {

View File

@ -16,7 +16,7 @@ void onAlexaChange(EspalexaDevice* dev);
void alexaInit() void alexaInit()
{ {
if (alexaEnabled && WiFi.status() == WL_CONNECTED) if (alexaEnabled && WLED_CONNECTED)
{ {
if (espalexaDevice == nullptr) //only init once if (espalexaDevice == nullptr) //only init once
{ {
@ -31,7 +31,7 @@ void alexaInit()
void handleAlexa() void handleAlexa()
{ {
if (!alexaEnabled || WiFi.status() != WL_CONNECTED) return; if (!alexaEnabled || !WLED_CONNECTED) return;
espalexa.loop(); espalexa.loop();
} }

View File

@ -4,7 +4,7 @@
#ifndef WLED_DISABLE_HUESYNC #ifndef WLED_DISABLE_HUESYNC
void handleHue() void handleHue()
{ {
if (hueClient != nullptr && millis() - hueLastRequestSent > huePollIntervalMs && WiFi.status() == WL_CONNECTED) if (hueClient != nullptr && millis() - hueLastRequestSent > huePollIntervalMs && WLED_CONNECTED)
{ {
hueLastRequestSent = millis(); hueLastRequestSent = millis();
if (huePollingEnabled) if (huePollingEnabled)
@ -29,7 +29,7 @@ void handleHue()
void reconnectHue() void reconnectHue()
{ {
if (WiFi.status() != WL_CONNECTED || !huePollingEnabled) return; if (!WLED_CONNECTED || !huePollingEnabled) return;
DEBUG_PRINTLN("Hue reconnect"); DEBUG_PRINTLN("Hue reconnect");
if (hueClient == nullptr) { if (hueClient == nullptr) {
hueClient = new AsyncClient(); hueClient = new AsyncClient();

View File

@ -8,7 +8,7 @@ byte blSat = 255;
void initBlynk(const char* auth) void initBlynk(const char* auth)
{ {
#ifndef WLED_DISABLE_BLYNK #ifndef WLED_DISABLE_BLYNK
if (WiFi.status() != WL_CONNECTED) return; if (!WLED_CONNECTED) return;
blynkEnabled = (auth[0] != 0); blynkEnabled = (auth[0] != 0);
if (blynkEnabled) Blynk.config(auth); if (blynkEnabled) Blynk.config(auth);
#endif #endif
@ -17,7 +17,7 @@ void initBlynk(const char* auth)
void handleBlynk() void handleBlynk()
{ {
#ifndef WLED_DISABLE_BLYNK #ifndef WLED_DISABLE_BLYNK
if (WiFi.status() == WL_CONNECTED && blynkEnabled) if (WLED_CONNECTED && blynkEnabled)
Blynk.run(); Blynk.run();
#endif #endif
} }