From 0fecbbf86b83f45fd3faa66633ee20b2d22cb9bd Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Fri, 19 Sep 2025 18:54:41 -0500 Subject: [PATCH] nimble 2.x deinit workaround --- src/nimble/NimbleBluetooth.cpp | 5 +++++ src/nimble/NimbleBluetooth.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/nimble/NimbleBluetooth.cpp b/src/nimble/NimbleBluetooth.cpp index 0eb8e9bdd..544ea9905 100644 --- a/src/nimble/NimbleBluetooth.cpp +++ b/src/nimble/NimbleBluetooth.cpp @@ -231,6 +231,8 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks { LOG_INFO("BLE disconnect"); #endif + if (ble->isDeInit) + return; meshtastic::BluetoothStatus newStatus(meshtastic::BluetoothStatus::ConnectionState::DISCONNECTED); bluetoothStatus->updateStatus(&newStatus); @@ -270,6 +272,7 @@ void NimbleBluetooth::deinit() { #ifdef ARCH_ESP32 LOG_INFO("Disable bluetooth until reboot"); + isDeInit = true; #ifdef BLE_LED #ifdef BLE_LED_INVERTED @@ -278,8 +281,10 @@ void NimbleBluetooth::deinit() digitalWrite(BLE_LED, LOW); #endif #endif +#ifndef NIMBLE_TWO NimBLEDevice::deinit(); #endif +#endif } // Has initial setup been completed diff --git a/src/nimble/NimbleBluetooth.h b/src/nimble/NimbleBluetooth.h index 899355b4d..458fa4a67 100644 --- a/src/nimble/NimbleBluetooth.h +++ b/src/nimble/NimbleBluetooth.h @@ -15,6 +15,7 @@ class NimbleBluetooth : BluetoothApi #if defined(NIMBLE_TWO) void startAdvertising(); #endif + bool isDeInit = false; private: void setupService();