diff --git a/config.h b/config.h index 35738f7..782fd9b 100644 --- a/config.h +++ b/config.h @@ -5,6 +5,7 @@ #include "_config.priv.h" #define UPDATES_ENABLED 1 +#define WIFI_INITIALLY_STARTED 0 #define DEBUG 0 // Prod diff --git a/lestnica_dvizh.ino b/lestnica_dvizh.ino index 02af58e..da47ede 100644 --- a/lestnica_dvizh.ino +++ b/lestnica_dvizh.ino @@ -2,10 +2,10 @@ #include "config.h" void setup_dvizh(); - void setup_BLE(); +void setup_Wifi(); +bool isWifiEnabled(); void handleWifi(); -extern bool wifiEnabled; SET_LOOP_TASK_STACK_SIZE(16 * 1024); @@ -14,6 +14,7 @@ void setup() { if (DEBUG) Serial.begin(115200); #if UPDATES_ENABLED + setup_Wifi(); setup_BLE(); #endif } @@ -23,7 +24,7 @@ void loop() { handleWifi(); #endif - if (!wifiEnabled) { + if (!isWifiEnabled()) { delay(60000); } else { delay(1000); diff --git a/wifi.cpp b/wifi.cpp index f359b99..d1d40e6 100644 --- a/wifi.cpp +++ b/wifi.cpp @@ -75,4 +75,13 @@ void handleWifi() { } ArduinoOTA.handle(); +} + +bool isWifiEnabled() { + return wifiEnabled; +} + +void setup_Wifi() { + if (WIFI_INITIALLY_STARTED) + startWifi(); } \ No newline at end of file