diff options
Diffstat (limited to 'src/SystemTask')
-rw-r--r-- | src/SystemTask/SystemTask.cpp | 16 | ||||
-rw-r--r-- | src/SystemTask/SystemTask.h | 5 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/SystemTask/SystemTask.cpp b/src/SystemTask/SystemTask.cpp index 6516f68b..43ac73f9 100644 --- a/src/SystemTask/SystemTask.cpp +++ b/src/SystemTask/SystemTask.cpp @@ -100,9 +100,25 @@ void SystemTask::Work() { case Messages::OnNewNotification: displayApp->PushMessage(Pinetime::Applications::DisplayApp::Messages::NewNotification); break; + case Messages::BleConnected: + isBleDiscoveryTimerRunning = true; + bleDiscoveryTimer = 5; + break; default: break; } } + + if(isBleDiscoveryTimerRunning) { + if(bleDiscoveryTimer == 0) { + isBleDiscoveryTimerRunning = false; + // Services discovery is deffered from 3 seconds to avoid the conflicts between the host communicating with the + // tharget and vice-versa. I'm not sure if this is the right way to handle this... + nimbleController.StartDiscovery(); + } else { + bleDiscoveryTimer--; + } + } + uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG); dateTimeController.UpdateTime(systick_counter); batteryController.Update(); diff --git a/src/SystemTask/SystemTask.h b/src/SystemTask/SystemTask.h index 5eba391b..65cfdd8f 100644 --- a/src/SystemTask/SystemTask.h +++ b/src/SystemTask/SystemTask.h @@ -14,7 +14,7 @@ namespace Pinetime { namespace System { class SystemTask { public: - enum class Messages {GoToSleep, GoToRunning, OnNewTime, OnNewNotification + enum class Messages {GoToSleep, GoToRunning, OnNewTime, OnNewNotification, BleConnected }; SystemTask(Drivers::SpiMaster &spi, Drivers::St7789 &lcd, Drivers::Cst816S &touchPanel, @@ -58,7 +58,8 @@ namespace Pinetime { static void Process(void* instance); void Work(); - + bool isBleDiscoveryTimerRunning = false; + uint8_t bleDiscoveryTimer = 0; }; } |