Keep BLE-only sleep checks lean and exercise role deadlines

This commit is contained in:
mikecarper committed 2026-10-21 17:53:57 -07:00
1 parent 61eecbd971
commit fe7f2ef05b
5 files changed
+341 -22

No files matched your search

+19 -1
View File
@@ -1,8 +1,22 @@
#pragma once
#include <esp_wifi.h>
#include <sdkconfig.h>
#include <helpers/PowerSavingDiagnostics.h>
// ENABLE_OTA alone also describes LoRa OTA on BLE-only images. Only link the
// WiFi SDK check when a compiled service can own that driver. Use build flags,
// rather than WITH_WEBCONFIG, which is defined by header inclusion order.
#if defined(WIFI_SSID) || defined(ENABLE_WIFI_INTERFACE) \
|| defined(WITH_MQTT_BRIDGE) || defined(WITH_ESPNOW_BRIDGE) \
|| (defined(MESH_PRIMARY_ESPNOW) && MESH_PRIMARY_ESPNOW) \
|| defined(WIFI_OTA_SEEDER) || defined(ADMIN_PASSWORD) \
|| defined(COMPANION_RADIO_FULL)
#define MESH_ESP32_SLEEP_CHECK_WIFI 1
#include <esp_wifi.h>
#else
#define MESH_ESP32_SLEEP_CHECK_WIFI 0
#endif
#if defined(CONFIG_BT_ENABLED) && CONFIG_BT_ENABLED
#include <esp_bt.h>
#if defined(CONFIG_BLUEDROID_ENABLED) && CONFIG_BLUEDROID_ENABLED \
@@ -32,6 +46,7 @@ inline powerdiag::Reason manualLightSleepBlocker() {
return powerdiag::Reason::Wireless;
#endif
#endif
#if MESH_ESP32_SLEEP_CHECK_WIFI
wifi_mode_t mode = WIFI_MODE_NULL;
const esp_err_t result = esp_wifi_get_mode(&mode);
if (result == ESP_OK)
@@ -40,6 +55,9 @@ inline powerdiag::Reason manualLightSleepBlocker() {
if (result == ESP_ERR_WIFI_NOT_INIT || result == ESP_ERR_WIFI_NOT_STARTED)
return powerdiag::Reason::Count;
return powerdiag::Reason::Network; // An unknown driver state is not off.
#else
return powerdiag::Reason::Count;
#endif
}
inline bool manualLightSleepReady() {