(ESP32) Fix bluetooth after light-sleep; de-init for deep sleep (#3655)

pull/3648/head^2
todd-herbert 2024-04-19 00:27:18 +12:00 zatwierdzone przez GitHub
rodzic 2e14234b77
commit 747c713ba9
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
5 zmienionych plików z 13 dodań i 12 usunięć

Wyświetl plik

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

Wyświetl plik

@ -30,9 +30,10 @@ void setBluetoothEnable(bool enable)
}
if (enable && !nimbleBluetooth->isActive()) {
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

Wyświetl plik

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

Wyświetl plik

@ -55,6 +55,3 @@
#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

Wyświetl plik

@ -55,6 +55,3 @@
#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