summaryrefslogtreecommitdiff
path: root/src/SystemTask/SystemTask.cpp
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2020-05-01 19:58:31 (GMT)
committerJF <jf@codingfield.com>2020-05-01 19:58:31 (GMT)
commit87c6556ad049077ab14398637031ea029b321baf (patch)
tree55fbc74c2ea30425a5def6deab44433581445958 /src/SystemTask/SystemTask.cpp
parent56b527925ce64bc0a9ef4b0ca51a1648b6400e04 (diff)
Defer the discovery of services using the system task.
Diffstat (limited to 'src/SystemTask/SystemTask.cpp')
-rw-r--r--src/SystemTask/SystemTask.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/SystemTask/SystemTask.cpp b/src/SystemTask/SystemTask.cpp
index 6516f68..43ac73f 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();