From 6bcbf34cd7d9b60f808d0d3ab329c5d851373201 Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Wed, 26 Dec 2018 16:42:43 +1300 Subject: [PATCH 1/6] Reformatted config header files comments --- src/config/Alerts.h | 21 ++++++--------------- src/config/BackupNetwork.h | 16 ++++++---------- src/config/Gps.h | 13 ++++--------- src/config/Hardware.h | 4 ++-- src/config/Main.h | 20 ++++++-------------- src/config/System.h | 25 ++++--------------------- 6 files changed, 28 insertions(+), 71 deletions(-) diff --git a/src/config/Alerts.h b/src/config/Alerts.h index 61247f8..0c7aa4c 100644 --- a/src/config/Alerts.h +++ b/src/config/Alerts.h @@ -10,24 +10,15 @@ * between readings. Setting a clearance level much higher avoid * clearing the levels and retriggering them the next time. */ + +#define ALERTS_ON_SERIAL _DEBUG ///< Display alerts on serial when connected rather than sending an SMS. #define CONFIG_DEFAULT_BATTERY_ALERT_LEVEL1 45 ///< Battery percentage at which to trigger the first low battery alert. #define CONFIG_DEFAULT_BATTERY_ALERT_LEVEL2 38 ///< Battery percentage at which to trigger the final low battery alert. #define CONFIG_DEFAULT_BATTERY_ALERT_CLEAR 60 ///< Battery percentage at which to clear all battery alerts. #define CONFIG_DEFAULT_ACTIVE_ALERTS 0 ///< Default active alerts -#define CONFIG_DEFAULT_CONTACT_PHONE "+642568452" ///< Default phone number to send the alert SMS to. - +#define CONFIG_DEFAULT_CONTACT_PHONE "+642568452" ///< Default phone number to send the alert SMS to. -/** - \def ALERTS_ON_SERIAL - Display alerts on serial when connected rather than sending an SMS. - Useful for debugging purpose and avoid costs related to SMS sending. -*/ -#define ALERTS_ON_SERIAL _DEBUG -/** - \def ALERT_SUSPICIOUS_RTC_TEMPERATURE - Temperature at which to consider the RTC module as failling. - When the backup battery is dead or nearly dead, the reading - of the temperature fails and returns 0. -*/ -#define ALERT_SUSPICIOUS_RTC_TEMPERATURE 0 \ No newline at end of file +#define ALERT_SUSPICIOUS_RTC_TEMPERATURE 0 ///< Temperature at which to consider the RTC module as failling. + ///< When the backup battery is dead or nearly dead, the reading + ///< of the temperature fails and returns 0. \ No newline at end of file diff --git a/src/config/BackupNetwork.h b/src/config/BackupNetwork.h index dd72aef..86c0394 100644 --- a/src/config/BackupNetwork.h +++ b/src/config/BackupNetwork.h @@ -4,17 +4,13 @@ #pragma once -#define POSITIONS_CONFIG_NET_DEFAULT_SAVE_THRESHOLD 30 ///< Determines how many positions will be saved before a network backup is needed (only when not moving though). -#define POSITIONS_CONFIG_NET_DEFAULT_APN "Vodafone" ///< APN used for GPRS context +#define POSITIONS_CONFIG_NET_DEFAULT_SAVE_THRESHOLD 30 ///< Determines how many positions will be saved before a network backup is needed (only when not moving though). +#define POSITIONS_CONFIG_NET_DEFAULT_APN "Vodafone" ///< APN used for GPRS context #define POSITIONS_CONFIG_NET_DEFAULT_URL "http://yourserver.com/endpoint" ///< URL to which positions data will be send through an HTTP POST request -#define POSITIONS_CONFIG_NET_DEFAULT_EXPECTED_RESPONSE 201 ///< Expected response code from the server that indicates that the positions has been successfully backuped. -/** - \def POSITIONS_CONFIG_NET_DEFAULT_UNAVAILABLE_NETWORK_POSTPONE_THRESHOLD - Determines how many times to deal with an unreliable network before postponing the backup. - In an area where cell reception isn't good, this avoid to try to backup the positions - every single time, which would rapidly consumes all the batty. -*/ -#define POSITIONS_CONFIG_NET_DEFAULT_UNAVAILABLE_NETWORK_POSTPONE_THRESHOLD 5 +#define POSITIONS_CONFIG_NET_DEFAULT_EXPECTED_RESPONSE 201 ///< Expected response code from the server that indicates that the positions has been successfully backuped. +#define POSITIONS_CONFIG_NET_DEFAULT_UNAVAILABLE_NETWORK_POSTPONE_THRESHOLD 5 ///< Determines how many times to deal with an unreliable network before postponing the backup. + ///< In an area where cell reception isn't good, this avoid to try to backup the positions + ///< every single time, which would rapidly consumes all the battery. struct networkConfig_t { uint8_t saveThreshold; //sizeof = 1 diff --git a/src/config/Gps.h b/src/config/Gps.h index a1cfee7..18b0ab0 100644 --- a/src/config/Gps.h +++ b/src/config/Gps.h @@ -6,12 +6,7 @@ #define GPS_DEFAULT_INTERMEDIATE_TIMEOUT_MS 10000L ///< Time to sleeps between each GPS signal assessment. #define GPS_DEFAULT_TOTAL_TIMEOUT_MS 80000L ///< Timeout after which to stop trying to get a GPS signal. - -/** - \def GPS_DEFAULT_MISSED_POSITION_GAP_KM - Gap between the current and previous position above which to consider - that the tracker has moved. Even if stopped, this will trigger a whole - new "cycle" of positions acquisition, and will avoid missing positions - because while moving, the tracker woke up while stopped at a light traffic for instance. -*/ -#define GPS_DEFAULT_MISSED_POSITION_GAP_KM 2 \ No newline at end of file +#define GPS_DEFAULT_MISSED_POSITION_GAP_KM 2 ///< Gap between the current and previous position above which to consider + ///< that the tracker has moved. Even if stopped, this will trigger a whole + ///< new "cycle" of positions acquisition, and will avoid missing positions + ///< because while moving, the tracker woke up while stopped at a light traffic for instance. \ No newline at end of file diff --git a/src/config/Hardware.h b/src/config/Hardware.h index e3c0d4b..7560219 100644 --- a/src/config/Hardware.h +++ b/src/config/Hardware.h @@ -5,8 +5,8 @@ #include #include -#define E24_ADDRESS E24_DEFAULT_ADDR ///< I2C address of the 24xxx chip -#define E24_SIZE E24Size_t::E24_512K ///< 24xxx chip size +#define E24_ADDRESS E24_DEFAULT_ADDR ///< I2C address of the 24xxx chip +#define E24_SIZE E24Size_t::E24_512K ///< 24xxx chip size #define SIM808_BAUDRATE 4800 ///< Control the baudrate use to communicate with the SIM808 module #define SIM_SERIAL_TYPE SoftwareSerial ///< Type of variable that holds the Serial communication with SIM808 diff --git a/src/config/Main.h b/src/config/Main.h index dc15095..d5fcfc6 100644 --- a/src/config/Main.h +++ b/src/config/Main.h @@ -7,23 +7,15 @@ #include "Sleeps.h" #include "Alerts.h" -/** - \def BACKUP_ENABLE_SDCARD - Enable (1) or disable (0) the backup of positions using an sd card. - Note: This code has never been finished properly because of the lack of space - on the ATMega -*/ -#define BACKUP_ENABLE_SDCARD 0 -/** - \def BACKUP_ENABLE_NETWORK - Enable (1) or disable (0) the backup of positions using the network. -*/ -#define BACKUP_ENABLE_NETWORK 1 +#define BACKUP_ENABLE_SDCARD 0 ///< Enable (1) or disable (0) the backup of positions using an sd card. + ///< Note: This code has never been finished properly because of the lack of space + ///< on the ATMega +#define BACKUP_ENABLE_NETWORK 1 ///< Enable (1) or disable (0) the backup of positions using the network. #if BACKUP_ENABLE_SDCARD -#include "BackupSd.h" + #include "BackupSd.h" #endif #if BACKUP_ENABLE_NETWORK -#include "BackupNetwork.h" + #include "BackupNetwork.h" #endif \ No newline at end of file diff --git a/src/config/System.h b/src/config/System.h index 8538e08..3105d49 100644 --- a/src/config/System.h +++ b/src/config/System.h @@ -1,26 +1,9 @@ #pragma once -/** - \def CONFIG_ADDR - Address of the config block in the I2C EEPROM chip. - */ -#define CONFIG_ADDR 0 -/** - \def CONFIG_RESERVED_SIZE - Reserved size for the config block in the I2C EEPROM chip. - */ -#define CONFIG_RESERVED_SIZE 128 -/** - \def CONFIG_SEED - Seed use to detect invalid or outdate configuration data. - Changing this value will reset the configuration block. - */ -#define CONFIG_SEED 14 -/** - \def VERSION - Version string, only used for indicative purpose - */ -#define VERSION "1.41" +#define CONFIG_ADDR 0 ///< Address of the config block in the I2C EEPROM chip. +#define CONFIG_RESERVED_SIZE 128 ///< Reserved size for the config block in the I2C EEPROM chip. +#define CONFIG_SEED 14 ///< Seed use to detect invalid or outdate configuration data. +#define VERSION "1.41" /// Version string, only used for indicative purpose. /** From 506ecc3e49253f75afa55e88c4769b835657f71f Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Wed, 26 Dec 2018 16:49:53 +1300 Subject: [PATCH 2/6] Removed DEFAULT from all constants --- src/Config.cpp | 36 +++++++++++++++++----------------- src/Core.cpp | 18 ++++++++--------- src/Debug.cpp | 2 +- src/Gps.cpp | 4 ++-- src/Network.cpp | 8 ++++---- src/NetworkPositionsBackup.cpp | 8 ++++---- src/Positions.cpp | 2 +- src/SdPositionsConfig.cpp | 4 ++-- src/config/Alerts.h | 10 +++++----- src/config/BackupNetwork.h | 10 +++++----- src/config/BackupSd.h | 4 ++-- src/config/Gps.h | 12 ++++++------ src/config/Hardware.h | 2 +- src/config/Network.h | 8 ++++---- src/config/Sleeps.h | 10 +++++----- 15 files changed, 69 insertions(+), 69 deletions(-) diff --git a/src/Config.cpp b/src/Config.cpp index 2d63a50..5eff62b 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -4,24 +4,24 @@ #include "Flash.h" const char VERSION_STRING[] PROGMEM = VERSION; -const config_t DEFAULT_CONFIG PROGMEM = { +const config_t CONFIG PROGMEM = { CONFIG_SEED, VERSION, 0xFFFF, 0xFFFF, #if BACKUP_ENABLE_NETWORK { - POSITIONS_CONFIG_NET_DEFAULT_SAVE_THRESHOLD, + POSITIONS_CONFIG_NET_SAVE_THRESHOLD, 0xFFFF, - POSITIONS_CONFIG_NET_DEFAULT_APN, - POSITIONS_CONFIG_NET_DEFAULT_URL + POSITIONS_CONFIG_NET_APN, + POSITIONS_CONFIG_NET_URL }, #endif - CONFIG_DEFAULT_BATTERY_ALERT_LEVEL1, - CONFIG_DEFAULT_BATTERY_ALERT_LEVEL2, - CONFIG_DEFAULT_BATTERY_ALERT_CLEAR, - CONFIG_DEFAULT_ACTIVE_ALERTS, - CONFIG_DEFAULT_CONTACT_PHONE + CONFIG_BATTERY_ALERT_LEVEL1, + CONFIG_BATTERY_ALERT_LEVEL2, + CONFIG_BATTERY_ALERT_CLEAR, + CONFIG_ACTIVE_ALERTS, + CONFIG_CONTACT_PHONE }; namespace config { @@ -45,19 +45,19 @@ namespace config { #if BACKUP_ENABLE_NETWORK //networkConfig_t c = { - // POSITIONS_CONFIG_NET_DEFAULT_SAVE_THRESHOLD, + // POSITIONS_CONFIG_NET_SAVE_THRESHOLD, // 0xFFFF, - // POSITIONS_CONFIG_NET_DEFAULT_APN, - // POSITIONS_CONFIG_NET_DEFAULT_URL, + // POSITIONS_CONFIG_NET_APN, + // POSITIONS_CONFIG_NET_URL, //}; //value.network = c; #endif /*strcpy_P(value.version, VERSION_STRING); - value.alertBatteryLevel1 = CONFIG_DEFAULT_BATTERY_ALERT_LEVEL1; - value.alertBatteryLevel2 = CONFIG_DEFAULT_BATTERY_ALERT_LEVEL2; - value.alertBatteryLevelClear = CONFIG_DEFAULT_BATTERY_ALERT_CLEAR; - value.activeAlerts = CONFIG_DEFAULT_ACTIVE_ALERTS; - strcpy_P(config.contactPhone, PSTR(CONFIG_DEFAULT_CONTACT_PHONE));*/ + value.alertBatteryLevel1 = CONFIG_BATTERY_ALERT_LEVEL1; + value.alertBatteryLevel2 = CONFIG_BATTERY_ALERT_LEVEL2; + value.alertBatteryLevelClear = CONFIG_BATTERY_ALERT_CLEAR; + value.activeAlerts = CONFIG_ACTIVE_ALERTS; + strcpy_P(config.contactPhone, PSTR(CONFIG_CONTACT_PHONE));*/ } void write() { @@ -88,7 +88,7 @@ namespace config { #define CURRENT_LOGGER_FUNCTION "reset" NOTICE; - utils::flash::read(&DEFAULT_CONFIG, value); + utils::flash::read(&CONFIG, value); save(); } diff --git a/src/Core.cpp b/src/Core.cpp index e9c3304..8d83215 100644 --- a/src/Core.cpp +++ b/src/Core.cpp @@ -16,8 +16,8 @@ using namespace utils; namespace core { #define CURRENT_LOGGER "core" - uint16_t sleepTime = SLEEP_DEFAULT_TIME_SECONDS; - uint8_t stoppedInARow = SLEEP_DEFAULT_STOPPED_THRESHOLD - 1; + uint16_t sleepTime = SLEEP_TIME_SECONDS; + uint8_t stoppedInARow = SLEEP_STOPPED_THRESHOLD - 1; TRACKER_MOVING_STATE movingState = TRACKER_MOVING_STATE::MOVING; namespace details { @@ -78,7 +78,7 @@ namespace core { if (!triggered) return NO_ALERTS_NOTIFIED; network::powerOn(); - networkStatus = network::waitForRegistered(NETWORK_DEFAULT_TOTAL_TIMEOUT_MS); + networkStatus = network::waitForRegistered(NETWORK_TOTAL_TIMEOUT_MS); if (network::isAvailable(networkStatus)) { strncpy_P(buffer, PSTR("Alerts !"), SMS_BUFFER_SIZE); @@ -123,16 +123,16 @@ namespace core { if (velocity < SLEEP_TIMING_MIN_MOVING_VELOCITY) { float distance = gps::getDistanceFromPrevious(); //did we missed positions because we were sleeping ? - if (distance > GPS_DEFAULT_MISSED_POSITION_GAP_KM) stoppedInARow = 0; - else stoppedInARow = min(stoppedInARow + 1, SLEEP_DEFAULT_STOPPED_THRESHOLD + 1); //avoid overflow on REALLY long stops + if (distance > GPS_MISSED_POSITION_GAP_KM) stoppedInARow = 0; + else stoppedInARow = min(stoppedInARow + 1, SLEEP_STOPPED_THRESHOLD + 1); //avoid overflow on REALLY long stops - if (stoppedInARow < SLEEP_DEFAULT_STOPPED_THRESHOLD) { - sleepTime = SLEEP_DEFAULT_PAUSING_TIME_SECONDS; - state = stoppedInARow == SLEEP_DEFAULT_STOPPED_THRESHOLD - 1 ? + if (stoppedInARow < SLEEP_STOPPED_THRESHOLD) { + sleepTime = SLEEP_PAUSING_TIME_SECONDS; + state = stoppedInARow == SLEEP_STOPPED_THRESHOLD - 1 ? TRACKER_MOVING_STATE::ABOUT_TO_STOP : TRACKER_MOVING_STATE::PAUSED; } - else if (stoppedInARow == SLEEP_DEFAULT_STOPPED_THRESHOLD) state = TRACKER_MOVING_STATE::STOPPED; + else if (stoppedInARow == SLEEP_STOPPED_THRESHOLD) state = TRACKER_MOVING_STATE::STOPPED; else state = TRACKER_MOVING_STATE::STATIC; } else stoppedInARow = 0; diff --git a/src/Debug.cpp b/src/Debug.cpp index 5b3e617..09f4688 100644 --- a/src/Debug.cpp +++ b/src/Debug.cpp @@ -163,7 +163,7 @@ namespace debug { void getAndDisplayGpsPosition() { #define CURRENT_LOGGER_FUNCTION "getAndDisplayGpsPosition" - SIM808_GPS_STATUS gpsStatus = gps::acquireCurrentPosition(GPS_DEFAULT_TOTAL_TIMEOUT_MS); + SIM808_GPS_STATUS gpsStatus = gps::acquireCurrentPosition(GPS_TOTAL_TIMEOUT_MS); NOTICE_FORMAT("%d %s", gpsStatus, gps::lastPosition); } diff --git a/src/Gps.cpp b/src/Gps.cpp index c53dde8..016c0ce 100644 --- a/src/Gps.cpp +++ b/src/Gps.cpp @@ -42,8 +42,8 @@ namespace gps { if (currentStatus > SIM808_GPS_STATUS::FIX) break; //if we have an accurate fix, break right now NOTICE_FORMAT("%d", currentStatus); - mainunit::deepSleep(GPS_DEFAULT_INTERMEDIATE_TIMEOUT_MS / 1000); - timeout -= GPS_DEFAULT_INTERMEDIATE_TIMEOUT_MS; + mainunit::deepSleep(GPS_INTERMEDIATE_TIMEOUT_MS / 1000); + timeout -= GPS_INTERMEDIATE_TIMEOUT_MS; } while (timeout > 1); if (currentStatus > SIM808_GPS_STATUS::NO_FIX) { diff --git a/src/Network.cpp b/src/Network.cpp index 129c20b..f8a61eb 100644 --- a/src/Network.cpp +++ b/src/Network.cpp @@ -44,15 +44,15 @@ namespace network { if (isAvailable(currentStatus)) break; details::print(currentStatus, report); - if (report.rssi < NETWORK_DEFAULT_NO_NETWORK_QUALITY_THRESHOLD) noReliableNetwork++; + if (report.rssi < NETWORK_NO_NETWORK_QUALITY_THRESHOLD) noReliableNetwork++; else noReliableNetwork = 0; - if (noReliableNetwork > NETWORK_DEFAULT_NO_NETWORK_TRIES) { + if (noReliableNetwork > NETWORK_NO_NETWORK_TRIES) { NOTICE_MSG("No reliable signal"); break; //after a while, no network really means no network. Bailing out } - mainunit::deepSleep(NETWORK_DEFAULT_INTERMEDIATE_TIMEOUT_MS / 1000); - timeout -= NETWORK_DEFAULT_INTERMEDIATE_TIMEOUT_MS; + mainunit::deepSleep(NETWORK_INTERMEDIATE_TIMEOUT_MS / 1000); + timeout -= NETWORK_INTERMEDIATE_TIMEOUT_MS; currentStatus = hardware::sim808::device.getNetworkRegistrationStatus(); report = hardware::sim808::device.getSignalQuality(); diff --git a/src/NetworkPositionsBackup.cpp b/src/NetworkPositionsBackup.cpp index b208fca..cebf8a8 100644 --- a/src/NetworkPositionsBackup.cpp +++ b/src/NetworkPositionsBackup.cpp @@ -53,7 +53,7 @@ namespace positions { ); NOTICE_FORMAT("Response : %d", responseCode); - return responseCode == POSITIONS_CONFIG_NET_DEFAULT_EXPECTED_RESPONSE; + return responseCode == POSITIONS_CONFIG_NET_EXPECTED_RESPONSE; } void NetworkPositionsBackup::appendPositions() { @@ -67,14 +67,14 @@ namespace positions { if (!positions::count(config::main::value.network.lastSavedEntry)) return; network::powerOn(); - networkStatus = network::waitForRegistered(NETWORK_DEFAULT_TOTAL_TIMEOUT_MS); + networkStatus = network::waitForRegistered(NETWORK_TOTAL_TIMEOUT_MS); if (networkStatus == SIM808_NETWORK_REGISTRATION_STATE::ERROR || (!network::isAvailable(networkStatus) || !network::enableGprs())) { - networkUnavailableInARow = min(networkUnavailableInARow + 1, POSITIONS_CONFIG_NET_DEFAULT_UNAVAILABLE_NETWORK_POSTPONE_THRESHOLD + 1); //avoid increment overflow + networkUnavailableInARow = min(networkUnavailableInARow + 1, POSITIONS_CONFIG_NET_UNAVAILABLE_NETWORK_POSTPONE_THRESHOLD + 1); //avoid increment overflow NOTICE_MSG("network or gprs unavailable"); - if (networkUnavailableInARow > POSITIONS_CONFIG_NET_DEFAULT_UNAVAILABLE_NETWORK_POSTPONE_THRESHOLD) { + if (networkUnavailableInARow > POSITIONS_CONFIG_NET_UNAVAILABLE_NETWORK_POSTPONE_THRESHOLD) { networkUnavailablePostpone++; } } diff --git a/src/Positions.cpp b/src/Positions.cpp index 67aca18..fffa7b7 100644 --- a/src/Positions.cpp +++ b/src/Positions.cpp @@ -80,7 +80,7 @@ namespace positions { gps::powerOn(); before = rtc::getTime(); - SIM808_GPS_STATUS gpsStatus = gps::acquireCurrentPosition(GPS_DEFAULT_TOTAL_TIMEOUT_MS); + SIM808_GPS_STATUS gpsStatus = gps::acquireCurrentPosition(GPS_TOTAL_TIMEOUT_MS); uint16_t timeToFix = rtc::getTime() - before; SIM808ChargingStatus battery = hardware::sim808::device.getChargingState(); gps::powerOff(); diff --git a/src/SdPositionsConfig.cpp b/src/SdPositionsConfig.cpp index 416bee3..1b94cf6 100644 --- a/src/SdPositionsConfig.cpp +++ b/src/SdPositionsConfig.cpp @@ -60,8 +60,8 @@ namespace config { SdPositionConfig_t config = { POSITIONS_CONFIG_SEED, - POSITIONS_CONFIG_DEFAULT_SAVE_THRESHOLD, - POSITIONS_CONFIG_DEFAULT_MAX_RECORDS_PER_FILE, + POSITIONS_CONFIG_SAVE_THRESHOLD, + POSITIONS_CONFIG_MAX_RECORDS_PER_FILE, 0xFFFF, 0, 0, diff --git a/src/config/Alerts.h b/src/config/Alerts.h index 0c7aa4c..14e9ef6 100644 --- a/src/config/Alerts.h +++ b/src/config/Alerts.h @@ -12,11 +12,11 @@ */ #define ALERTS_ON_SERIAL _DEBUG ///< Display alerts on serial when connected rather than sending an SMS. -#define CONFIG_DEFAULT_BATTERY_ALERT_LEVEL1 45 ///< Battery percentage at which to trigger the first low battery alert. -#define CONFIG_DEFAULT_BATTERY_ALERT_LEVEL2 38 ///< Battery percentage at which to trigger the final low battery alert. -#define CONFIG_DEFAULT_BATTERY_ALERT_CLEAR 60 ///< Battery percentage at which to clear all battery alerts. -#define CONFIG_DEFAULT_ACTIVE_ALERTS 0 ///< Default active alerts -#define CONFIG_DEFAULT_CONTACT_PHONE "+642568452" ///< Default phone number to send the alert SMS to. +#define CONFIG_BATTERY_ALERT_LEVEL1 45 ///< Battery percentage at which to trigger the first low battery alert. +#define CONFIG_BATTERY_ALERT_LEVEL2 38 ///< Battery percentage at which to trigger the final low battery alert. +#define CONFIG_BATTERY_ALERT_CLEAR 60 ///< Battery percentage at which to clear all battery alerts. +#define CONFIG_ACTIVE_ALERTS 0 ///< Default active alerts +#define CONFIG_CONTACT_PHONE "+642568452" ///< Default phone number to send the alert SMS to. #define ALERT_SUSPICIOUS_RTC_TEMPERATURE 0 ///< Temperature at which to consider the RTC module as failling. diff --git a/src/config/BackupNetwork.h b/src/config/BackupNetwork.h index 86c0394..edf8f8f 100644 --- a/src/config/BackupNetwork.h +++ b/src/config/BackupNetwork.h @@ -4,11 +4,11 @@ #pragma once -#define POSITIONS_CONFIG_NET_DEFAULT_SAVE_THRESHOLD 30 ///< Determines how many positions will be saved before a network backup is needed (only when not moving though). -#define POSITIONS_CONFIG_NET_DEFAULT_APN "Vodafone" ///< APN used for GPRS context -#define POSITIONS_CONFIG_NET_DEFAULT_URL "http://yourserver.com/endpoint" ///< URL to which positions data will be send through an HTTP POST request -#define POSITIONS_CONFIG_NET_DEFAULT_EXPECTED_RESPONSE 201 ///< Expected response code from the server that indicates that the positions has been successfully backuped. -#define POSITIONS_CONFIG_NET_DEFAULT_UNAVAILABLE_NETWORK_POSTPONE_THRESHOLD 5 ///< Determines how many times to deal with an unreliable network before postponing the backup. +#define POSITIONS_CONFIG_NET_SAVE_THRESHOLD 30 ///< Determines how many positions will be saved before a network backup is needed (only when not moving though). +#define POSITIONS_CONFIG_NET_APN "Vodafone" ///< APN used for GPRS context +#define POSITIONS_CONFIG_NET_URL "http://yourserver.com/endpoint" ///< URL to which positions data will be send through an HTTP POST request +#define POSITIONS_CONFIG_NET_EXPECTED_RESPONSE 201 ///< Expected response code from the server that indicates that the positions has been successfully backuped. +#define POSITIONS_CONFIG_NET_UNAVAILABLE_NETWORK_POSTPONE_THRESHOLD 5 ///< Determines how many times to deal with an unreliable network before postponing the backup. ///< In an area where cell reception isn't good, this avoid to try to backup the positions ///< every single time, which would rapidly consumes all the battery. diff --git a/src/config/BackupSd.h b/src/config/BackupSd.h index 9142470..3052e62 100644 --- a/src/config/BackupSd.h +++ b/src/config/BackupSd.h @@ -5,5 +5,5 @@ #define POSITIONS_FILENAME_LENGTH 19 #define POSITIONS_CONFIG_FILENAME "positions.config" #define POSITIONS_CONFIG_SEED 45 -#define POSITIONS_CONFIG_DEFAULT_SAVE_THRESHOLD 10 -#define POSITIONS_CONFIG_DEFAULT_MAX_RECORDS_PER_FILE 5 \ No newline at end of file +#define POSITIONS_CONFIG_SAVE_THRESHOLD 10 +#define POSITIONS_CONFIG_MAX_RECORDS_PER_FILE 5 \ No newline at end of file diff --git a/src/config/Gps.h b/src/config/Gps.h index 18b0ab0..e0b45ae 100644 --- a/src/config/Gps.h +++ b/src/config/Gps.h @@ -4,9 +4,9 @@ #pragma once -#define GPS_DEFAULT_INTERMEDIATE_TIMEOUT_MS 10000L ///< Time to sleeps between each GPS signal assessment. -#define GPS_DEFAULT_TOTAL_TIMEOUT_MS 80000L ///< Timeout after which to stop trying to get a GPS signal. -#define GPS_DEFAULT_MISSED_POSITION_GAP_KM 2 ///< Gap between the current and previous position above which to consider - ///< that the tracker has moved. Even if stopped, this will trigger a whole - ///< new "cycle" of positions acquisition, and will avoid missing positions - ///< because while moving, the tracker woke up while stopped at a light traffic for instance. \ No newline at end of file +#define GPS_INTERMEDIATE_TIMEOUT_MS 10000L ///< Time to sleeps between each GPS signal assessment. +#define GPS_TOTAL_TIMEOUT_MS 80000L ///< Timeout after which to stop trying to get a GPS signal. +#define GPS_MISSED_POSITION_GAP_KM 2 ///< Gap between the current and previous position above which to consider + ///< that the tracker has moved. Even if stopped, this will trigger a whole + ///< new "cycle" of positions acquisition, and will avoid missing positions + ///< because while moving, the tracker woke up while stopped at a light traffic for instance. \ No newline at end of file diff --git a/src/config/Hardware.h b/src/config/Hardware.h index 7560219..a585d49 100644 --- a/src/config/Hardware.h +++ b/src/config/Hardware.h @@ -5,7 +5,7 @@ #include #include -#define E24_ADDRESS E24_DEFAULT_ADDR ///< I2C address of the 24xxx chip +#define E24_ADDRESS E24_ADDR ///< I2C address of the 24xxx chip #define E24_SIZE E24Size_t::E24_512K ///< 24xxx chip size #define SIM808_BAUDRATE 4800 ///< Control the baudrate use to communicate with the SIM808 module diff --git a/src/config/Network.h b/src/config/Network.h index a5da437..608b6c6 100644 --- a/src/config/Network.h +++ b/src/config/Network.h @@ -4,7 +4,7 @@ #pragma onces -#define NETWORK_DEFAULT_NO_NETWORK_QUALITY_THRESHOLD 8 ///< Minimum signal quality to consider the cellphone reception as reliable. -#define NETWORK_DEFAULT_NO_NETWORK_TRIES 5 ///< Maximum tries before considering an unreliable cellphone reception as no reception at all. -#define NETWORK_DEFAULT_INTERMEDIATE_TIMEOUT_MS 10000L ///< Intermediate time to sleep between each cellphone reception assessment. -#define NETWORK_DEFAULT_TOTAL_TIMEOUT_MS 80000L ///< Timeout after which to stop trying to register to the network. +#define NETWORK_NO_NETWORK_QUALITY_THRESHOLD 8 ///< Minimum signal quality to consider the cellphone reception as reliable. +#define NETWORK_NO_NETWORK_TRIES 5 ///< Maximum tries before considering an unreliable cellphone reception as no reception at all. +#define NETWORK_INTERMEDIATE_TIMEOUT_MS 10000L ///< Intermediate time to sleep between each cellphone reception assessment. +#define NETWORK_TOTAL_TIMEOUT_MS 80000L ///< Timeout after which to stop trying to register to the network. diff --git a/src/config/Sleeps.h b/src/config/Sleeps.h index b728531..e186306 100644 --- a/src/config/Sleeps.h +++ b/src/config/Sleeps.h @@ -6,10 +6,10 @@ #define SLEEP_TIMING_TIME(hours, minutes) hours * 60 + minutes -#define SLEEP_DEFAULT_TIME_SECONDS 1800 ///< Default sleep time +#define SLEEP_TIME_SECONDS 1800 ///< Default sleep time #define SLEEP_TIMING_MIN_MOVING_VELOCITY 5 ///< Speed under which to consider the tracker as not moving -#define SLEEP_DEFAULT_PAUSING_TIME_SECONDS 270 ///< Sleep time to use when not moving -#define SLEEP_DEFAULT_STOPPED_THRESHOLD 5 ///< Number of successive positions acquired as not moving before considering the tracker as stopped +#define SLEEP_PAUSING_TIME_SECONDS 270 ///< Sleep time to use when not moving +#define SLEEP_STOPPED_THRESHOLD 5 ///< Number of successive positions acquired as not moving before considering the tracker as stopped #define SLEEP_TIMING_MIN SLEEP_TIMING_TIME(0, 0) #define SLEEP_TIMING_MAX SLEEP_TIMING_TIME(23, 59) @@ -36,8 +36,8 @@ namespace config { static const sleepTimings_t defaultSleepTimings[] PROGMEM = { // Sleep timings when not moving { 0, SLEEP_TIMING_TIME(16, 00), SLEEP_TIMING_TIME(19, 59), 3600 }, ///< 1 hour between 16:00 and 20:00 UTC (04:00 to 08:00 UTC+12) - { 0, SLEEP_TIMING_TIME(20, 00), SLEEP_TIMING_MAX, SLEEP_DEFAULT_TIME_SECONDS }, ///< default (30 minutes) between 20:00 and 00:00 UTC (08:00 to 12:00 UTC+12) - { 0, SLEEP_TIMING_MIN, SLEEP_TIMING_TIME(8, 29), SLEEP_DEFAULT_TIME_SECONDS }, ///< default (30 minutes) between 00:00 and 8:30 UTC (12:00 to 20:30 UTC+12) + { 0, SLEEP_TIMING_TIME(20, 00), SLEEP_TIMING_MAX, SLEEP_TIME_SECONDS }, ///< default (30 minutes) between 20:00 and 00:00 UTC (08:00 to 12:00 UTC+12) + { 0, SLEEP_TIMING_MIN, SLEEP_TIMING_TIME(8, 29), SLEEP_TIME_SECONDS }, ///< default (30 minutes) between 00:00 and 8:30 UTC (12:00 to 20:30 UTC+12) { 0, SLEEP_TIMING_TIME(8, 30), SLEEP_TIMING_TIME(15, 59), 10800 }, ///< 3 hours between 20:30 and 16:00 UTC (20:30 to 04:00 UTC+12) // Sleep timings while moving From b888fff3e692277098f0d680d3ba1e2f69622f70 Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Wed, 26 Dec 2018 17:00:18 +1300 Subject: [PATCH 3/6] More comments formatting --- src/config/Alerts.h | 2 +- src/config/BackupNetwork.h | 4 ++-- src/config/Gps.h | 2 +- src/config/Hardware.h | 2 +- src/config/Sleeps.h | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/config/Alerts.h b/src/config/Alerts.h index 14e9ef6..9baf6fc 100644 --- a/src/config/Alerts.h +++ b/src/config/Alerts.h @@ -11,7 +11,7 @@ * clearing the levels and retriggering them the next time. */ -#define ALERTS_ON_SERIAL _DEBUG ///< Display alerts on serial when connected rather than sending an SMS. +#define ALERTS_ON_SERIAL _DEBUG ///< Display alerts on serial when connected rather than sending an SMS. #define CONFIG_BATTERY_ALERT_LEVEL1 45 ///< Battery percentage at which to trigger the first low battery alert. #define CONFIG_BATTERY_ALERT_LEVEL2 38 ///< Battery percentage at which to trigger the final low battery alert. #define CONFIG_BATTERY_ALERT_CLEAR 60 ///< Battery percentage at which to clear all battery alerts. diff --git a/src/config/BackupNetwork.h b/src/config/BackupNetwork.h index edf8f8f..afc3855 100644 --- a/src/config/BackupNetwork.h +++ b/src/config/BackupNetwork.h @@ -9,8 +9,8 @@ #define POSITIONS_CONFIG_NET_URL "http://yourserver.com/endpoint" ///< URL to which positions data will be send through an HTTP POST request #define POSITIONS_CONFIG_NET_EXPECTED_RESPONSE 201 ///< Expected response code from the server that indicates that the positions has been successfully backuped. #define POSITIONS_CONFIG_NET_UNAVAILABLE_NETWORK_POSTPONE_THRESHOLD 5 ///< Determines how many times to deal with an unreliable network before postponing the backup. - ///< In an area where cell reception isn't good, this avoid to try to backup the positions - ///< every single time, which would rapidly consumes all the battery. + ///< In an area where cell reception isn't good, this avoid to try to backup the positions + ///< every single time, which would rapidly consumes all the battery. struct networkConfig_t { uint8_t saveThreshold; //sizeof = 1 diff --git a/src/config/Gps.h b/src/config/Gps.h index e0b45ae..e5d56bb 100644 --- a/src/config/Gps.h +++ b/src/config/Gps.h @@ -6,7 +6,7 @@ #define GPS_INTERMEDIATE_TIMEOUT_MS 10000L ///< Time to sleeps between each GPS signal assessment. #define GPS_TOTAL_TIMEOUT_MS 80000L ///< Timeout after which to stop trying to get a GPS signal. -#define GPS_MISSED_POSITION_GAP_KM 2 ///< Gap between the current and previous position above which to consider +#define GPS_MISSED_POSITION_GAP_KM 2 ///< Gap between the current and previous position above which to consider ///< that the tracker has moved. Even if stopped, this will trigger a whole ///< new "cycle" of positions acquisition, and will avoid missing positions ///< because while moving, the tracker woke up while stopped at a light traffic for instance. \ No newline at end of file diff --git a/src/config/Hardware.h b/src/config/Hardware.h index a585d49..f0c7255 100644 --- a/src/config/Hardware.h +++ b/src/config/Hardware.h @@ -5,7 +5,7 @@ #include #include -#define E24_ADDRESS E24_ADDR ///< I2C address of the 24xxx chip +#define E24_ADDRESS E24_ADDR ///< I2C address of the 24xxx chip #define E24_SIZE E24Size_t::E24_512K ///< 24xxx chip size #define SIM808_BAUDRATE 4800 ///< Control the baudrate use to communicate with the SIM808 module diff --git a/src/config/Sleeps.h b/src/config/Sleeps.h index e186306..4405eb9 100644 --- a/src/config/Sleeps.h +++ b/src/config/Sleeps.h @@ -7,7 +7,7 @@ #define SLEEP_TIMING_TIME(hours, minutes) hours * 60 + minutes #define SLEEP_TIME_SECONDS 1800 ///< Default sleep time -#define SLEEP_TIMING_MIN_MOVING_VELOCITY 5 ///< Speed under which to consider the tracker as not moving +#define SLEEP_TIMING_MIN_MOVING_VELOCITY 5 ///< Speed under which to consider the tracker as not moving #define SLEEP_PAUSING_TIME_SECONDS 270 ///< Sleep time to use when not moving #define SLEEP_STOPPED_THRESHOLD 5 ///< Number of successive positions acquired as not moving before considering the tracker as stopped @@ -35,10 +35,10 @@ namespace config { */ static const sleepTimings_t defaultSleepTimings[] PROGMEM = { // Sleep timings when not moving - { 0, SLEEP_TIMING_TIME(16, 00), SLEEP_TIMING_TIME(19, 59), 3600 }, ///< 1 hour between 16:00 and 20:00 UTC (04:00 to 08:00 UTC+12) + { 0, SLEEP_TIMING_TIME(16, 00), SLEEP_TIMING_TIME(19, 59), 3600 }, ///< 1 hour between 16:00 and 20:00 UTC (04:00 to 08:00 UTC+12) { 0, SLEEP_TIMING_TIME(20, 00), SLEEP_TIMING_MAX, SLEEP_TIME_SECONDS }, ///< default (30 minutes) between 20:00 and 00:00 UTC (08:00 to 12:00 UTC+12) { 0, SLEEP_TIMING_MIN, SLEEP_TIMING_TIME(8, 29), SLEEP_TIME_SECONDS }, ///< default (30 minutes) between 00:00 and 8:30 UTC (12:00 to 20:30 UTC+12) - { 0, SLEEP_TIMING_TIME(8, 30), SLEEP_TIMING_TIME(15, 59), 10800 }, ///< 3 hours between 20:30 and 16:00 UTC (20:30 to 04:00 UTC+12) + { 0, SLEEP_TIMING_TIME(8, 30), SLEEP_TIMING_TIME(15, 59), 10800 }, ///< 3 hours between 20:30 and 16:00 UTC (20:30 to 04:00 UTC+12) // Sleep timings while moving { SLEEP_TIMING_MIN_MOVING_VELOCITY, SLEEP_TIMING_MIN, SLEEP_TIMING_MAX, 540 }, ///< 540 seconds when speed > SLEEP_TIMING_MIN_MOVING_VELOCITY (5km/h) From 239386a2dc952dfae3294d84a10da9983e44a51d Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Wed, 26 Dec 2018 17:09:44 +1300 Subject: [PATCH 4/6] That DEFAULT should not have been removed. --- src/config/Hardware.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/Hardware.h b/src/config/Hardware.h index f0c7255..7560219 100644 --- a/src/config/Hardware.h +++ b/src/config/Hardware.h @@ -5,7 +5,7 @@ #include #include -#define E24_ADDRESS E24_ADDR ///< I2C address of the 24xxx chip +#define E24_ADDRESS E24_DEFAULT_ADDR ///< I2C address of the 24xxx chip #define E24_SIZE E24Size_t::E24_512K ///< 24xxx chip size #define SIM808_BAUDRATE 4800 ///< Control the baudrate use to communicate with the SIM808 module From a0f46058082790fe4fb2311f099d5330b902bf7a Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Wed, 26 Dec 2018 17:13:38 +1300 Subject: [PATCH 5/6] Moved sensible configuration to an unversionned dedicated file --- .gitignore | 5 ++++- src/config/Alerts.h | 3 ++- src/config/BackupNetwork.h | 3 ++- src/config/User.h | 17 +++++++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 src/config/User.h diff --git a/.gitignore b/.gitignore index 371c8d7..518c361 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ [Bb]in/ #Visual Studio code -.vscode/ \ No newline at end of file +.vscode/ + +#Unversionned sensitive data configuration file +/src/config/Sensitive.h diff --git a/src/config/Alerts.h b/src/config/Alerts.h index 9baf6fc..7790153 100644 --- a/src/config/Alerts.h +++ b/src/config/Alerts.h @@ -1,5 +1,7 @@ #pragma once +#include "User.h" + /** * Configure the values used for alerts triggering. * Note that the battery level percentage are quite high, @@ -16,7 +18,6 @@ #define CONFIG_BATTERY_ALERT_LEVEL2 38 ///< Battery percentage at which to trigger the final low battery alert. #define CONFIG_BATTERY_ALERT_CLEAR 60 ///< Battery percentage at which to clear all battery alerts. #define CONFIG_ACTIVE_ALERTS 0 ///< Default active alerts -#define CONFIG_CONTACT_PHONE "+642568452" ///< Default phone number to send the alert SMS to. #define ALERT_SUSPICIOUS_RTC_TEMPERATURE 0 ///< Temperature at which to consider the RTC module as failling. diff --git a/src/config/BackupNetwork.h b/src/config/BackupNetwork.h index afc3855..03575b4 100644 --- a/src/config/BackupNetwork.h +++ b/src/config/BackupNetwork.h @@ -4,9 +4,10 @@ #pragma once +#include "User.h" + #define POSITIONS_CONFIG_NET_SAVE_THRESHOLD 30 ///< Determines how many positions will be saved before a network backup is needed (only when not moving though). #define POSITIONS_CONFIG_NET_APN "Vodafone" ///< APN used for GPRS context -#define POSITIONS_CONFIG_NET_URL "http://yourserver.com/endpoint" ///< URL to which positions data will be send through an HTTP POST request #define POSITIONS_CONFIG_NET_EXPECTED_RESPONSE 201 ///< Expected response code from the server that indicates that the positions has been successfully backuped. #define POSITIONS_CONFIG_NET_UNAVAILABLE_NETWORK_POSTPONE_THRESHOLD 5 ///< Determines how many times to deal with an unreliable network before postponing the backup. ///< In an area where cell reception isn't good, this avoid to try to backup the positions diff --git a/src/config/User.h b/src/config/User.h new file mode 100644 index 0000000..38dfb4c --- /dev/null +++ b/src/config/User.h @@ -0,0 +1,17 @@ +#pragma once + +/** + * Holds all the sensitive data. Provided values are example only. + * Changes values according to your setup. This file changes are untracked so data + * will never go further than your local working copy. + */ + +#include "Sensitive.h" + +/** + * Copy and uncomment the following lines to a new User.h file. Edit the values according to your setup + */ +// #pragma once + +// #define POSITIONS_CONFIG_NET_URL "http://yourserver.com/endpoint" ///< URL to which positions data will be send through an HTTP POST request. +// #define CONFIG_CONTACT_PHONE "+642568452" ///< Phone number to send the alert SMS to. From 421d070fc190a2d33291ea9aea1c9cc28d3c088e Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Wed, 26 Dec 2018 18:29:09 +1300 Subject: [PATCH 6/6] Version bump to 1.42 --- src/config/System.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/System.h b/src/config/System.h index 3105d49..5fc3938 100644 --- a/src/config/System.h +++ b/src/config/System.h @@ -3,7 +3,7 @@ #define CONFIG_ADDR 0 ///< Address of the config block in the I2C EEPROM chip. #define CONFIG_RESERVED_SIZE 128 ///< Reserved size for the config block in the I2C EEPROM chip. #define CONFIG_SEED 14 ///< Seed use to detect invalid or outdate configuration data. -#define VERSION "1.41" /// Version string, only used for indicative purpose. +#define VERSION "1.42" /// Version string, only used for indicative purpose. /**