diff --git a/src/nimble/NimbleBluetooth.cpp b/src/nimble/NimbleBluetooth.cpp index 0b91bf44f..092aef470 100644 --- a/src/nimble/NimbleBluetooth.cpp +++ b/src/nimble/NimbleBluetooth.cpp @@ -112,12 +112,12 @@ void NimbleBluetooth::shutdown() NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising(); pAdvertising->reset(); pAdvertising->stop(); +} -#if defined(HELTEC_WIRELESS_PAPER) || defined(HELTEC_WIRELESS_PAPER_V1_0) - // Saving of ~1mA - // Probably applicable to other ESP32 boards - unverified +// Extra power-saving on some devices +void NimbleBluetooth::deinit() +{ NimBLEDevice::deinit(); -#endif } bool NimbleBluetooth::isActive() diff --git a/src/nimble/NimbleBluetooth.h b/src/nimble/NimbleBluetooth.h index df2d3e45a..d1e347830 100644 --- a/src/nimble/NimbleBluetooth.h +++ b/src/nimble/NimbleBluetooth.h @@ -6,6 +6,7 @@ class NimbleBluetooth : BluetoothApi public: void setup(); void shutdown(); + void deinit(); void clearBonds(); bool isActive(); bool isConnected(); diff --git a/src/sleep.cpp b/src/sleep.cpp index 6abe535d7..860a676df 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -206,6 +206,12 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false) // not using wifi yet, but once we are this is needed to shutoff the radio hw // esp_wifi_stop(); waitEnterSleep(skipPreflight); + +#ifdef NIMBLE_DEINIT_FOR_DEEPSLEEP + // Extra power saving on some devices + nimbleBluetooth->deinit(); +#endif + #ifdef ARCH_ESP32 if (shouldLoraWake(msecToWake)) { notifySleep.notifyObservers(NULL); diff --git a/variants/heltec_wireless_paper/variant.h b/variants/heltec_wireless_paper/variant.h index 29b8bbbd1..466925a2e 100644 --- a/variants/heltec_wireless_paper/variant.h +++ b/variants/heltec_wireless_paper/variant.h @@ -55,3 +55,6 @@ #define SX126X_DIO2_AS_RF_SWITCH #define SX126X_DIO3_TCXO_VOLTAGE 1.8 + +// Power management +#define NIMBLE_DEINIT_FOR_DEEPSLEEP // Required to reach manufacturers claim of 18uA diff --git a/variants/heltec_wireless_paper_v1/variant.h b/variants/heltec_wireless_paper_v1/variant.h index 29b8bbbd1..466925a2e 100644 --- a/variants/heltec_wireless_paper_v1/variant.h +++ b/variants/heltec_wireless_paper_v1/variant.h @@ -55,3 +55,6 @@ #define SX126X_DIO2_AS_RF_SWITCH #define SX126X_DIO3_TCXO_VOLTAGE 1.8 + +// Power management +#define NIMBLE_DEINIT_FOR_DEEPSLEEP // Required to reach manufacturers claim of 18uA