aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ble/NimbleController.cpp
diff options
context:
space:
mode:
authormark9064 <30447455+mark9064@users.noreply.github.com>2024-08-22 21:24:04 +0100
committerNeroBurner <pyro4hell@gmail.com>2024-09-21 21:08:07 +0200
commitc3d05901a05a274f30c15b8c0640b6ecdd973ac3 (patch)
treed63aaacce475f495670787f79019df8af6e2af7d /src/components/ble/NimbleController.cpp
parentb3756e45fa50ce81255dc3bb21cbce4af3254f2f (diff)
Refactor SystemTask state handling for resilience
State transitions now happen immediately where possible This simplifies state management in general, and prevents bugs such as the chime issue from occurring in the first place
Diffstat (limited to 'src/components/ble/NimbleController.cpp')
-rw-r--r--src/components/ble/NimbleController.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/components/ble/NimbleController.cpp b/src/components/ble/NimbleController.cpp
index f1411a3e..5059007a 100644
--- a/src/components/ble/NimbleController.cpp
+++ b/src/components/ble/NimbleController.cpp
@@ -454,9 +454,15 @@ void NimbleController::PersistBond(struct ble_gap_conn_desc& desc) {
/* Wakeup Spi and SpiNorFlash before accessing the file system
* This should be fixed in the FS driver
*/
- systemTask.PushMessage(Pinetime::System::Messages::GoToRunning);
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
- vTaskDelay(10);
+
+ // This isn't quite correct
+ // SystemTask could receive EnableSleeping right after passing this check
+ // We need some guarantee that the SystemTask has processed the above message
+ // before we can continue
+ while (!systemTask.IsSleepDisabled()) {
+ vTaskDelay(pdMS_TO_TICKS(5));
+ }
lfs_file_t file_p;