From 8893be57df21a4e4d93801299797da03783ca360 Mon Sep 17 00:00:00 2001 From: geeksville Date: Mon, 24 Feb 2020 18:09:58 -0800 Subject: [PATCH] kinda ugly but BLE sw update seems reliable again --- TODO.md | 3 ++- lib/BluetoothOTA/src/BluetoothSoftwareUpdate.cpp | 9 +++++++++ src/MeshBluetoothService.cpp | 12 ++++++++++++ src/MeshBluetoothService.h | 6 ++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index 9571e984f..76fc50051 100644 --- a/TODO.md +++ b/TODO.md @@ -24,6 +24,7 @@ being I have it set at 2 minutes to ensure enough time for a GPS lock from scrat Items to complete before the first beta release. +* use fuse bits to store the board type and region. So one load can be used on all boards * "AXP192 interrupt is not firing, remove this temporary polling of battery state" * make mesh aware network timing state machine (sync wake windows to gps time) * turn light sleep on aggressively (while lora is on but BLE off) @@ -78,6 +79,7 @@ until the phone pulls those packets. Ever so often power on bluetooth just so w Items after the first final candidate release. +* split out the software update utility so other projects can use it. Have the appload specify the URL for downloads. * Use CAD mode of the RF95 to automatically find low noise channels * read the PMU battery fault indicators and blink/led/warn user on screen * make a no bluetooth configured yet screen - include this screen in the loop if the user hasn't yet paired @@ -89,7 +91,6 @@ Items after the first final candidate release. * We let anyone BLE scan for us (FIXME, perhaps only allow that until we are paired with a phone and configured) * use two different buildenv flags for ttgo vs lora32. https://docs.platformio.org/en/latest/ide/vscode.html#key-bindings * sim gps data for testing nodes that don't have hardware -* have android provide position data for nodes that don't have gps * do debug serial logging to android over bluetooth * break out my bluetooth OTA software as a seperate library so others can use it * Heltec LoRa32 has 8MB flash, use a bigger partition table if needed - TTGO is 4MB but has PSRAM diff --git a/lib/BluetoothOTA/src/BluetoothSoftwareUpdate.cpp b/lib/BluetoothOTA/src/BluetoothSoftwareUpdate.cpp index 1bd5d5336..022b355f9 100644 --- a/lib/BluetoothOTA/src/BluetoothSoftwareUpdate.cpp +++ b/lib/BluetoothOTA/src/BluetoothSoftwareUpdate.cpp @@ -31,6 +31,13 @@ public: if (!canBegin) // Indicate failure by forcing the size to 0 c->setValue(0UL); + else { + // This totally breaks abstraction to up up into the app layer for this, but quick hack to make sure we only + // talk to one service during the sw update. + //DEBUG_MSG("FIXME, crufty shutdown of mesh bluetooth for sw update."); + //void stopMeshBluetoothService(); + //stopMeshBluetoothService(); + } } }; @@ -101,6 +108,8 @@ public: } }; + + void bluetoothRebootCheck() { if (rebootAtMsec && millis() > rebootAtMsec) diff --git a/src/MeshBluetoothService.cpp b/src/MeshBluetoothService.cpp index a5db6ca25..94c71587d 100644 --- a/src/MeshBluetoothService.cpp +++ b/src/MeshBluetoothService.cpp @@ -336,4 +336,16 @@ void destroyMeshBluetoothService() delete meshService; meshFromNumCharacteristic = NULL; +} + +/** + * Super skanky FIXME - when we start a software update we force the mesh service to shutdown. + * If the sw update fails, the user will have to manually reset the board to get things running again. + */ +void stopMeshBluetoothService() +{ + if (meshService) + meshService->stop(); + + meshFromNumCharacteristic = NULL; // don't try to notify anymore } \ No newline at end of file diff --git a/src/MeshBluetoothService.h b/src/MeshBluetoothService.h index 8c9330b9e..2231a5fef 100644 --- a/src/MeshBluetoothService.h +++ b/src/MeshBluetoothService.h @@ -11,3 +11,9 @@ void destroyMeshBluetoothService(); * Tell any bluetooth clients that the number of rx packets has changed */ void bluetoothNotifyFromNum(uint32_t newValue); + +/** + * Super skanky FIXME - when we start a software update we force the mesh service to shutdown. + * If the sw update fails, the user will have to manually reset the board to get things running again. + */ +void stopMeshBluetoothService(); \ No newline at end of file