Skip to content

Commit d911a34

Browse files
committed
Used esp_wifi_get_mode instead of WiFi.getMode() to reduce the code size
1 parent 33b1e7e commit d911a34

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/helpers/ESP32Board.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <rom/rtc.h>
99
#include <sys/time.h>
1010
#include <Wire.h>
11-
#include <WiFi.h>
11+
#include "esp_wifi.h"
1212
#include "driver/rtc_io.h"
1313

1414
class ESP32Board : public mesh::MainBoard {
@@ -65,8 +65,12 @@ class ESP32Board : public mesh::MainBoard {
6565
}
6666

6767
void sleep(uint32_t secs) override {
68-
if (WiFi.getMode() == WIFI_MODE_NULL) { // WiFi is off ~ No active OTA, safe to go to sleep
69-
enterLightSleep(secs); // To wake up after "secs" seconds or when receiving a LoRa packet
68+
// To check for WiFi status to see if there is active OTA
69+
wifi_mode_t mode;
70+
esp_err_t err = esp_wifi_get_mode(&mode);
71+
72+
if (err != ESP_OK) { // WiFi is off ~ No active OTA, safe to go to sleep
73+
enterLightSleep(secs); // To wake up after "secs" seconds or when receiving a LoRa packet
7074
}
7175
}
7276

0 commit comments

Comments
 (0)