From f5b38feed376dd21bb77f403fba4c7e02fadcd20 Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Mon, 19 Mar 2018 22:44:29 +1300 Subject: [PATCH] Do not wait the full time when no gsm signal can be found --- GpsTracker/Network.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/GpsTracker/Network.cpp b/GpsTracker/Network.cpp index 589baa1..fd57245 100644 --- a/GpsTracker/Network.cpp +++ b/GpsTracker/Network.cpp @@ -12,6 +12,7 @@ namespace network { SIM808RegistrationStatus waitForRegistered(uint32_t timeout) { SIM808RegistrationStatus currentStatus; + uint8_t noNetwork = 0; do { currentStatus = hardware::sim808::device.getNetworkRegistrationStatus(); @@ -19,6 +20,14 @@ namespace network { SIM808SignalQualityReport report = hardware::sim808::device.getSignalQuality(); VERBOSE_FORMAT("waitForRegistered", "%d, [%d %ddBm]", currentStatus.stat, report.ssri, report.attenuation); + + if (report.ssri == 0) noNetwork++; + else noNetwork = 0; + if (noNetwork > 3) { + VERBOSE_MSG("waitForRegistered", "No signal"); + break; //after a while, not network really means no network. Bailing out + } + mainunit::deepSleep(NETWORK_DEFAULT_INTERMEDIATE_TIMEOUT_MS / 1000); timeout -= NETWORK_DEFAULT_INTERMEDIATE_TIMEOUT_MS; } while (timeout > 1);