diff --git a/src/nimble/NimbleBluetooth.cpp b/src/nimble/NimbleBluetooth.cpp index bc94abf6eb..0b91bf44f4 100644 --- a/src/nimble/NimbleBluetooth.cpp +++ b/src/nimble/NimbleBluetooth.cpp @@ -112,6 +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 + NimBLEDevice::deinit(); +#endif } bool NimbleBluetooth::isActive() diff --git a/src/sleep.cpp b/src/sleep.cpp index ddea9942ce..0d36112c1b 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -277,6 +277,17 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false) if (shouldLoraWake(msecToWake)) { enableLoraInterrupt(); } + +#if defined(HELTEC_WIRELESS_PAPER) || defined(HELTEC_WIRELESS_PAPER_V1_0) // Applicable to most ESP32 boards? + // Avoid leakage through button pin + pinMode(BUTTON_PIN, INPUT); + rtc_gpio_hold_en((gpio_num_t)BUTTON_PIN); + + // LoRa CS (RADIO_NSS) needs to stay HIGH, even during deep sleep + pinMode(LORA_CS, OUTPUT); + digitalWrite(LORA_CS, HIGH); + rtc_gpio_hold_en((gpio_num_t)LORA_CS); +#endif #endif cpuDeepSleep(msecToWake); }