From dfae1a9a343605b58b3f80a7b6f54f3d5aa000a7 Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Wed, 14 Mar 2018 16:56:55 +1300 Subject: [PATCH] Fixed timeout for gsm and gps overflow uint16 --- GpsTracker/Config.h | 2 +- GpsTracker/Gps.cpp | 2 +- GpsTracker/Gps.h | 2 +- GpsTracker/Network.cpp | 2 +- GpsTracker/Network.h | 2 +- GpsTracker/NetworkPositionsBackup.cpp | 10 ++++++---- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/GpsTracker/Config.h b/GpsTracker/Config.h index ebecca3..4ca382c 100644 --- a/GpsTracker/Config.h +++ b/GpsTracker/Config.h @@ -22,7 +22,7 @@ #define GPS_DEFAULT_TOTAL_TIMEOUT_MS 180000 #define NETWORK_DEFAULT_INTERMEDIATE_TIMEOUT_MS 6000 -#define NETWORK_DEFAULT_TOTAL_TIMEOUT_MS 1800000 +#define NETWORK_DEFAULT_TOTAL_TIMEOUT_MS 180000 struct sleepTimings_t { uint8_t speed; diff --git a/GpsTracker/Gps.cpp b/GpsTracker/Gps.cpp index 5a62010..e5840f1 100644 --- a/GpsTracker/Gps.cpp +++ b/GpsTracker/Gps.cpp @@ -25,7 +25,7 @@ namespace gps { char lastPosition[GPS_POSITION_SIZE]; SIM808_GPS_STATUS lastStatus; - SIM808_GPS_STATUS acquireCurrentPosition(uint16_t timeout) { + SIM808_GPS_STATUS acquireCurrentPosition(uint32_t timeout) { SIM808_GPS_STATUS currentStatus = SIM808_GPS_STATUS::OFF; do { diff --git a/GpsTracker/Gps.h b/GpsTracker/Gps.h index f5be055..f698af8 100644 --- a/GpsTracker/Gps.h +++ b/GpsTracker/Gps.h @@ -15,7 +15,7 @@ namespace gps { inline void powerOn() { hardware::sim808::gpsPowerOn(); } inline void powerOff() { hardware::sim808::gpsPowerOff(); } - SIM808_GPS_STATUS acquireCurrentPosition(uint16_t timeout); + SIM808_GPS_STATUS acquireCurrentPosition(uint32_t timeout); uint8_t getVelocity(); void getTime(tmElements_t &time); diff --git a/GpsTracker/Network.cpp b/GpsTracker/Network.cpp index f9e5992..b77f4e9 100644 --- a/GpsTracker/Network.cpp +++ b/GpsTracker/Network.cpp @@ -8,7 +8,7 @@ namespace network { - SIM808RegistrationStatus waitForRegistered(uint16_t timeout) { + SIM808RegistrationStatus waitForRegistered(uint32_t timeout) { SIM808RegistrationStatus currentStatus; do { diff --git a/GpsTracker/Network.h b/GpsTracker/Network.h index 79ba1ee..33ee41e 100644 --- a/GpsTracker/Network.h +++ b/GpsTracker/Network.h @@ -7,7 +7,7 @@ namespace network { inline void powerOn() { hardware::sim808::networkPowerOn(); } inline void powerOff() { hardware::sim808::networkPowerOff(); } - SIM808RegistrationStatus waitForRegistered(uint16_t timeout); + SIM808RegistrationStatus waitForRegistered(uint32_t timeout); bool isAvailable(SIM808_NETWORK_REGISTRATION_STATE state); bool enableGprs(); } \ No newline at end of file diff --git a/GpsTracker/NetworkPositionsBackup.cpp b/GpsTracker/NetworkPositionsBackup.cpp index 10b9636..3a0e0ab 100644 --- a/GpsTracker/NetworkPositionsBackup.cpp +++ b/GpsTracker/NetworkPositionsBackup.cpp @@ -24,7 +24,9 @@ namespace positions { } bool appendPosition(config_t &config, PositionEntry &entry) { - char buffer[BUFFER_SIZE]; + debug::displayFreeRam(); + return false; + /*char buffer[BUFFER_SIZE]; snprintf_P(buffer, BUFFER_SIZE, PSTR("%d,%d,%.2f,%d,%s,%d"), entry.metadata.batteryLevel, entry.metadata.batteryVoltage, @@ -38,7 +40,7 @@ namespace positions { buffer, buffer, BUFFER_SIZE - ) == POSITIONS_CONFIG_NET_DEFAULT_EXPECTED_RESPONSE; + ) == POSITIONS_CONFIG_NET_DEFAULT_EXPECTED_RESPONSE;*/ } void appendPositions(config_t &config) { @@ -54,7 +56,7 @@ namespace positions { if (!network::isAvailable(networkStatus.stat)) VERBOSE_MSG("appendPositions", "network unavailable"); else if (!network::enableGprs()) VERBOSE_MSG("appendPositions", "gprs unavailable"); else { - /*hardware::i2c::powerOn(); + hardware::i2c::powerOn(); do { if (!positions::get(currentEntryIndex, currentEntry)) break; if (!appendPosition(config, currentEntry)) break; @@ -63,7 +65,7 @@ namespace positions { config::main::set(config); } while (positions::moveNext(currentEntryIndex)); - hardware::i2c::powerOff(); */ + hardware::i2c::powerOff(); } network::powerOff();