From a5b21a76975ec21b9f761c8d48aea07b71df63d8 Mon Sep 17 00:00:00 2001 From: Softonik Date: Tue, 22 Nov 2022 23:56:46 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B0=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BA=20Wifi=20=D1=81=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D1=83=20=D0=BF=D1=80=D0=B8=20=D0=B2=D0=BA=D0=BB=D1=8E?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.h | 1 + lestnica_dvizh.ino | 7 ++++--- wifi.cpp | 9 +++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) 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