From d911a34eeb959c566d7d1c4751eb361db5b7b24f Mon Sep 17 00:00:00 2001 From: Kevin Le Date: Mon, 29 Dec 2025 22:38:05 +0700 Subject: [PATCH] Used esp_wifi_get_mode instead of WiFi.getMode() to reduce the code size --- src/helpers/ESP32Board.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/helpers/ESP32Board.h b/src/helpers/ESP32Board.h index cfc403cd..5d28b6da 100644 --- a/src/helpers/ESP32Board.h +++ b/src/helpers/ESP32Board.h @@ -8,7 +8,7 @@ #include #include #include -#include +#include "esp_wifi.h" #include "driver/rtc_io.h" class ESP32Board : public mesh::MainBoard { @@ -65,8 +65,12 @@ public: } void sleep(uint32_t secs) override { - if (WiFi.getMode() == WIFI_MODE_NULL) { // WiFi is off ~ No active OTA, safe to go to sleep - enterLightSleep(secs); // To wake up after "secs" seconds or when receiving a LoRa packet + // To check for WiFi status to see if there is active OTA + wifi_mode_t mode; + esp_err_t err = esp_wifi_get_mode(&mode); + + if (err != ESP_OK) { // WiFi is off ~ No active OTA, safe to go to sleep + enterLightSleep(secs); // To wake up after "secs" seconds or when receiving a LoRa packet } }