From 8dfd7a4a713f5122276dcb64cffd3af72ae5902a Mon Sep 17 00:00:00 2001 From: geeksville Date: Sun, 23 Feb 2020 14:09:52 -0800 Subject: [PATCH] the ble goo is still leaking on destroy, but better --- TODO.md | 4 ++-- src/MeshBluetoothService.cpp | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/TODO.md b/TODO.md index 59fbd861..97608958 100644 --- a/TODO.md +++ b/TODO.md @@ -2,8 +2,7 @@ Items to complete before the first alpha release. -* fix BLE wake so that we still are announcing -* have sw update prevent BLE sleep +* the BLE stack is leaking about 7KB each time we go to light sleep * have state machine properly enter deep sleep based on loss of mesh and phone comms * default to enter deep sleep if no LORA received for two hours (indicates user has probably left the meshS) * implement CustomRF95::canSleep @@ -166,3 +165,4 @@ Items after the first final candidate release. * Use Neo-M8M API to put it in sleep mode (on hold until my new boards arrive) * update the prebuilt bins for different regulatory regions * don't enter NB state if we've recently talked to the phone (to prevent breaking syncing or bluetooth sw update) +* have sw update prevent BLE sleep \ No newline at end of file diff --git a/src/MeshBluetoothService.cpp b/src/MeshBluetoothService.cpp index e221ebc3..62567695 100644 --- a/src/MeshBluetoothService.cpp +++ b/src/MeshBluetoothService.cpp @@ -314,7 +314,13 @@ BLEService *createMeshBluetoothService(BLEServer *server) meshFromNumCharacteristic->addDescriptor(new (btPool) BLE2902()); // Needed so clients can request notification service->start(); - server->getAdvertising()->addServiceUUID(service->getUUID()); + + // We only add to advertisting once, because the ESP32 arduino code is dumb and that object never dies + static bool firstTime = true; + if(firstTime) { + firstTime = false; + server->getAdvertising()->addServiceUUID(service->getUUID()); + } DEBUG_MSG("*** Mesh service:\n"); service->dump();