Merge branch 'master' into RGBLED

This commit is contained in:
Ben Meadors 2024-04-18 07:32:25 -05:00 committed by GitHub
commit 2e13aeeacb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 13 additions and 12 deletions

View File

@ -106,20 +106,26 @@ static NimbleBluetoothFromRadioCallback *fromRadioCallbacks;
void NimbleBluetooth::shutdown() void NimbleBluetooth::shutdown()
{ {
// No measurable power saving for ESP32 during light-sleep(?)
#ifndef ARCH_ESP32
// Shutdown bluetooth for minimum power draw // Shutdown bluetooth for minimum power draw
LOG_INFO("Disable bluetooth\n"); LOG_INFO("Disable bluetooth\n");
// Bluefruit.Advertising.stop();
NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising(); NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising();
pAdvertising->reset(); pAdvertising->reset();
pAdvertising->stop(); pAdvertising->stop();
#endif
} }
// Extra power-saving on some devices // Proper shutdown for ESP32. Needs reboot to reverse.
void NimbleBluetooth::deinit() void NimbleBluetooth::deinit()
{ {
#ifdef ARCH_ESP32
LOG_INFO("Disable bluetooth until reboot\n");
NimBLEDevice::deinit(); NimBLEDevice::deinit();
#endif
} }
// Has initial setup been completed
bool NimbleBluetooth::isActive() bool NimbleBluetooth::isActive()
{ {
return bleServer; return bleServer;

View File

@ -30,9 +30,10 @@ void setBluetoothEnable(bool enable)
} }
if (enable && !nimbleBluetooth->isActive()) { if (enable && !nimbleBluetooth->isActive()) {
nimbleBluetooth->setup(); nimbleBluetooth->setup();
} else if (!enable) {
nimbleBluetooth->shutdown();
} }
// For ESP32, no way to recover from bluetooth shutdown without reboot
// BLE advertising automatically stops when MCU enters light-sleep(?)
// For deep-sleep, shutdown hardware with nimbleBluetooth->deinit(). Requires reboot to reverse
} }
} }
#else #else

View File

@ -207,8 +207,8 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false)
// esp_wifi_stop(); // esp_wifi_stop();
waitEnterSleep(skipPreflight); waitEnterSleep(skipPreflight);
#ifdef NIMBLE_DEINIT_FOR_DEEPSLEEP #ifdef ARCH_ESP32
// Extra power saving on some devices // Full shutdown of bluetooth hardware
nimbleBluetooth->deinit(); nimbleBluetooth->deinit();
#endif #endif

View File

@ -55,6 +55,3 @@
#define SX126X_DIO2_AS_RF_SWITCH #define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 1.8 #define SX126X_DIO3_TCXO_VOLTAGE 1.8
// Power management
#define NIMBLE_DEINIT_FOR_DEEPSLEEP // Required to reach manufacturers claim of 18uA

View File

@ -55,6 +55,3 @@
#define SX126X_DIO2_AS_RF_SWITCH #define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 1.8 #define SX126X_DIO3_TCXO_VOLTAGE 1.8
// Power management
#define NIMBLE_DEINIT_FOR_DEEPSLEEP // Required to reach manufacturers claim of 18uA