Defer the discovery of services using the system task.

This commit is contained in:
JF
2020-05-01 21:58:31 +02:00
parent 56b527925c
commit 87c6556ad0
8 changed files with 28 additions and 15 deletions

View File

@@ -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();

View File

@@ -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;
};
}