From 57ba626e4ce55f26dfd0b83ff987eb73ef6a2000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 31 Mar 2022 18:52:13 +0200 Subject: [PATCH] Fixes #1294 Bluetooth-Wifi Deadlock --- src/esp32/main-esp32.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/esp32/main-esp32.cpp b/src/esp32/main-esp32.cpp index 2e012297b..07b0eb9ee 100644 --- a/src/esp32/main-esp32.cpp +++ b/src/esp32/main-esp32.cpp @@ -6,6 +6,7 @@ #ifdef USE_NEW_ESP32_BLUETOOTH #include "ESP32Bluetooth.h" +#include "mesh/http/WiFiAPClient.h" #else #include "nimble/BluetoothUtil.h" #endif @@ -41,13 +42,15 @@ static void printBLEinfo() { #ifdef USE_NEW_ESP32_BLUETOOTH void setBluetoothEnable(bool on) { - if (!esp32Bluetooth) { - esp32Bluetooth = new ESP32Bluetooth(); - } - if (on) { - esp32Bluetooth->setup(); - } else { - esp32Bluetooth->shutdown(); + if (!isWifiAvailable()) { + if (!esp32Bluetooth) { + esp32Bluetooth = new ESP32Bluetooth(); + } + if (on) { + esp32Bluetooth->setup(); + } else { + esp32Bluetooth->shutdown(); + } } } #endif