From b8ce313482fd2d08542fd59d5510892d5a372097 Mon Sep 17 00:00:00 2001 From: "jacob.eva" Date: Tue, 17 Sep 2024 17:17:53 +0100 Subject: [PATCH] Prevent double SerialBT init --- Bluetooth.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Bluetooth.h b/Bluetooth.h index 934024a..61505a5 100644 --- a/Bluetooth.h +++ b/Bluetooth.h @@ -32,6 +32,7 @@ BLEUart SerialBT; BLEDis bledis; BLEBas blebas; + bool SerialBT_init = false; #endif #define BT_PAIRING_TIMEOUT 35000 @@ -379,10 +380,14 @@ void bt_start() { // start device information service bledis.begin(); - SerialBT.bufferTXD(true); // enable buffering + if (!SerialBT_init) { - SerialBT.setPermission(SECMODE_ENC_WITH_MITM, SECMODE_ENC_WITH_MITM); // enable encryption for BLE serial - SerialBT.begin(); + SerialBT.bufferTXD(true); // enable buffering + + SerialBT.setPermission(SECMODE_ENC_WITH_MITM, SECMODE_ENC_WITH_MITM); // enable encryption for BLE serial + SerialBT.begin(); + SerialBT_init = true; + } blebas.begin();