From: Mark Qvist Date: Fri, 11 Oct 2024 10:49:02 +0000 (+0200) Subject: Gracefully close bluetooth on device sleep X-Git-Url: https://git.tnoah.ca/?a=commitdiff_plain;h=2ab1d4b1aca5d1873237fba9079965d7b17babe1;p=lora-radio.git Gracefully close bluetooth on device sleep --- diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index 089e82f..8e1c6d9 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -1457,6 +1457,12 @@ void sleep_now() { pinMode(PIN_DISP_SLEEP, OUTPUT); digitalWrite(PIN_DISP_SLEEP, DISP_SLEEP_LEVEL); #endif + #if HAS_BLUETOOTH + if (bt_state == BT_STATE_CONNECTED) { + bt_stop(); + delay(100); + } + #endif esp_sleep_enable_ext0_wakeup(PIN_WAKEUP, WAKEUP_LEVEL); esp_deep_sleep_start(); #endif