@@ -2,4 +2,7 @@ | |||||
[Bb]in/ | [Bb]in/ | ||||
#Visual Studio code | #Visual Studio code | ||||
.vscode/ | |||||
.vscode/ | |||||
#Unversionned sensitive data configuration file | |||||
/src/config/Sensitive.h |
@@ -4,24 +4,24 @@ | |||||
#include "Flash.h" | #include "Flash.h" | ||||
const char VERSION_STRING[] PROGMEM = VERSION; | const char VERSION_STRING[] PROGMEM = VERSION; | ||||
const config_t DEFAULT_CONFIG PROGMEM = { | |||||
const config_t CONFIG PROGMEM = { | |||||
CONFIG_SEED, | CONFIG_SEED, | ||||
VERSION, | VERSION, | ||||
0xFFFF, | 0xFFFF, | ||||
0xFFFF, | 0xFFFF, | ||||
#if BACKUP_ENABLE_NETWORK | #if BACKUP_ENABLE_NETWORK | ||||
{ | { | ||||
POSITIONS_CONFIG_NET_DEFAULT_SAVE_THRESHOLD, | |||||
POSITIONS_CONFIG_NET_SAVE_THRESHOLD, | |||||
0xFFFF, | 0xFFFF, | ||||
POSITIONS_CONFIG_NET_DEFAULT_APN, | |||||
POSITIONS_CONFIG_NET_DEFAULT_URL | |||||
POSITIONS_CONFIG_NET_APN, | |||||
POSITIONS_CONFIG_NET_URL | |||||
}, | }, | ||||
#endif | #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 { | namespace config { | ||||
@@ -45,19 +45,19 @@ namespace config { | |||||
#if BACKUP_ENABLE_NETWORK | #if BACKUP_ENABLE_NETWORK | ||||
//networkConfig_t c = { | //networkConfig_t c = { | ||||
// POSITIONS_CONFIG_NET_DEFAULT_SAVE_THRESHOLD, | |||||
// POSITIONS_CONFIG_NET_SAVE_THRESHOLD, | |||||
// 0xFFFF, | // 0xFFFF, | ||||
// POSITIONS_CONFIG_NET_DEFAULT_APN, | |||||
// POSITIONS_CONFIG_NET_DEFAULT_URL, | |||||
// POSITIONS_CONFIG_NET_APN, | |||||
// POSITIONS_CONFIG_NET_URL, | |||||
//}; | //}; | ||||
//value.network = c; | //value.network = c; | ||||
#endif | #endif | ||||
/*strcpy_P(value.version, VERSION_STRING); | /*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() { | void write() { | ||||
@@ -88,7 +88,7 @@ namespace config { | |||||
#define CURRENT_LOGGER_FUNCTION "reset" | #define CURRENT_LOGGER_FUNCTION "reset" | ||||
NOTICE; | NOTICE; | ||||
utils::flash::read(&DEFAULT_CONFIG, value); | |||||
utils::flash::read(&CONFIG, value); | |||||
save(); | save(); | ||||
} | } | ||||
@@ -16,8 +16,8 @@ using namespace utils; | |||||
namespace core { | namespace core { | ||||
#define CURRENT_LOGGER "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; | TRACKER_MOVING_STATE movingState = TRACKER_MOVING_STATE::MOVING; | ||||
namespace details { | namespace details { | ||||
@@ -78,7 +78,7 @@ namespace core { | |||||
if (!triggered) return NO_ALERTS_NOTIFIED; | if (!triggered) return NO_ALERTS_NOTIFIED; | ||||
network::powerOn(); | network::powerOn(); | ||||
networkStatus = network::waitForRegistered(NETWORK_DEFAULT_TOTAL_TIMEOUT_MS); | |||||
networkStatus = network::waitForRegistered(NETWORK_TOTAL_TIMEOUT_MS); | |||||
if (network::isAvailable(networkStatus)) { | if (network::isAvailable(networkStatus)) { | ||||
strncpy_P(buffer, PSTR("Alerts !"), SMS_BUFFER_SIZE); | strncpy_P(buffer, PSTR("Alerts !"), SMS_BUFFER_SIZE); | ||||
@@ -123,16 +123,16 @@ namespace core { | |||||
if (velocity < SLEEP_TIMING_MIN_MOVING_VELOCITY) { | if (velocity < SLEEP_TIMING_MIN_MOVING_VELOCITY) { | ||||
float distance = gps::getDistanceFromPrevious(); //did we missed positions because we were sleeping ? | 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::ABOUT_TO_STOP : | ||||
TRACKER_MOVING_STATE::PAUSED; | 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 state = TRACKER_MOVING_STATE::STATIC; | ||||
} | } | ||||
else stoppedInARow = 0; | else stoppedInARow = 0; | ||||
@@ -163,7 +163,7 @@ namespace debug { | |||||
void getAndDisplayGpsPosition() { | void getAndDisplayGpsPosition() { | ||||
#define CURRENT_LOGGER_FUNCTION "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); | NOTICE_FORMAT("%d %s", gpsStatus, gps::lastPosition); | ||||
} | } | ||||
@@ -42,8 +42,8 @@ namespace gps { | |||||
if (currentStatus > SIM808_GPS_STATUS::FIX) break; //if we have an accurate fix, break right now | if (currentStatus > SIM808_GPS_STATUS::FIX) break; //if we have an accurate fix, break right now | ||||
NOTICE_FORMAT("%d", currentStatus); | 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); | } while (timeout > 1); | ||||
if (currentStatus > SIM808_GPS_STATUS::NO_FIX) { | if (currentStatus > SIM808_GPS_STATUS::NO_FIX) { | ||||
@@ -44,15 +44,15 @@ namespace network { | |||||
if (isAvailable(currentStatus)) break; | if (isAvailable(currentStatus)) break; | ||||
details::print(currentStatus, report); | 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; | else noReliableNetwork = 0; | ||||
if (noReliableNetwork > NETWORK_DEFAULT_NO_NETWORK_TRIES) { | |||||
if (noReliableNetwork > NETWORK_NO_NETWORK_TRIES) { | |||||
NOTICE_MSG("No reliable signal"); | NOTICE_MSG("No reliable signal"); | ||||
break; //after a while, no network really means no network. Bailing out | 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(); | currentStatus = hardware::sim808::device.getNetworkRegistrationStatus(); | ||||
report = hardware::sim808::device.getSignalQuality(); | report = hardware::sim808::device.getSignalQuality(); | ||||
@@ -53,7 +53,7 @@ namespace positions { | |||||
); | ); | ||||
NOTICE_FORMAT("Response : %d", responseCode); | NOTICE_FORMAT("Response : %d", responseCode); | ||||
return responseCode == POSITIONS_CONFIG_NET_DEFAULT_EXPECTED_RESPONSE; | |||||
return responseCode == POSITIONS_CONFIG_NET_EXPECTED_RESPONSE; | |||||
} | } | ||||
void NetworkPositionsBackup::appendPositions() { | void NetworkPositionsBackup::appendPositions() { | ||||
@@ -67,14 +67,14 @@ namespace positions { | |||||
if (!positions::count(config::main::value.network.lastSavedEntry)) return; | if (!positions::count(config::main::value.network.lastSavedEntry)) return; | ||||
network::powerOn(); | network::powerOn(); | ||||
networkStatus = network::waitForRegistered(NETWORK_DEFAULT_TOTAL_TIMEOUT_MS); | |||||
networkStatus = network::waitForRegistered(NETWORK_TOTAL_TIMEOUT_MS); | |||||
if (networkStatus == SIM808_NETWORK_REGISTRATION_STATE::ERROR || | if (networkStatus == SIM808_NETWORK_REGISTRATION_STATE::ERROR || | ||||
(!network::isAvailable(networkStatus) || !network::enableGprs())) { | (!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"); | 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++; | networkUnavailablePostpone++; | ||||
} | } | ||||
} | } | ||||
@@ -80,7 +80,7 @@ namespace positions { | |||||
gps::powerOn(); | gps::powerOn(); | ||||
before = rtc::getTime(); | 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; | uint16_t timeToFix = rtc::getTime() - before; | ||||
SIM808ChargingStatus battery = hardware::sim808::device.getChargingState(); | SIM808ChargingStatus battery = hardware::sim808::device.getChargingState(); | ||||
gps::powerOff(); | gps::powerOff(); | ||||
@@ -60,8 +60,8 @@ namespace config { | |||||
SdPositionConfig_t config = { | SdPositionConfig_t config = { | ||||
POSITIONS_CONFIG_SEED, | 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, | 0xFFFF, | ||||
0, | 0, | ||||
0, | 0, | ||||
@@ -1,5 +1,7 @@ | |||||
#pragma once | #pragma once | ||||
#include "User.h" | |||||
/** | /** | ||||
* Configure the values used for alerts triggering. | * Configure the values used for alerts triggering. | ||||
* Note that the battery level percentage are quite high, | * Note that the battery level percentage are quite high, | ||||
@@ -10,24 +12,14 @@ | |||||
* between readings. Setting a clearance level much higher avoid | * between readings. Setting a clearance level much higher avoid | ||||
* clearing the levels and retriggering them the next time. | * clearing the levels and retriggering them the next time. | ||||
*/ | */ | ||||
#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 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. | |||||
#define CONFIG_ACTIVE_ALERTS 0 ///< Default active alerts | |||||
/** | |||||
\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 | |||||
#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. |
@@ -4,17 +4,14 @@ | |||||
#pragma once | #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. | |||||
/** | |||||
\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 | |||||
#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_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. | |||||
struct networkConfig_t { | struct networkConfig_t { | ||||
uint8_t saveThreshold; //sizeof = 1 | uint8_t saveThreshold; //sizeof = 1 | ||||
@@ -5,5 +5,5 @@ | |||||
#define POSITIONS_FILENAME_LENGTH 19 | #define POSITIONS_FILENAME_LENGTH 19 | ||||
#define POSITIONS_CONFIG_FILENAME "positions.config" | #define POSITIONS_CONFIG_FILENAME "positions.config" | ||||
#define POSITIONS_CONFIG_SEED 45 | #define POSITIONS_CONFIG_SEED 45 | ||||
#define POSITIONS_CONFIG_DEFAULT_SAVE_THRESHOLD 10 | |||||
#define POSITIONS_CONFIG_DEFAULT_MAX_RECORDS_PER_FILE 5 | |||||
#define POSITIONS_CONFIG_SAVE_THRESHOLD 10 | |||||
#define POSITIONS_CONFIG_MAX_RECORDS_PER_FILE 5 |
@@ -4,14 +4,9 @@ | |||||
#pragma once | #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. | |||||
/** | |||||
\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 | |||||
#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. |
@@ -5,8 +5,8 @@ | |||||
#include <E24.h> | #include <E24.h> | ||||
#include <SoftwareSerial.h> | #include <SoftwareSerial.h> | ||||
#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 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 | #define SIM_SERIAL_TYPE SoftwareSerial ///< Type of variable that holds the Serial communication with SIM808 |
@@ -7,23 +7,15 @@ | |||||
#include "Sleeps.h" | #include "Sleeps.h" | ||||
#include "Alerts.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 | #if BACKUP_ENABLE_SDCARD | ||||
#include "BackupSd.h" | |||||
#include "BackupSd.h" | |||||
#endif | #endif | ||||
#if BACKUP_ENABLE_NETWORK | #if BACKUP_ENABLE_NETWORK | ||||
#include "BackupNetwork.h" | |||||
#include "BackupNetwork.h" | |||||
#endif | #endif |
@@ -4,7 +4,7 @@ | |||||
#pragma onces | #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. |
@@ -6,10 +6,10 @@ | |||||
#define SLEEP_TIMING_TIME(hours, minutes) hours * 60 + minutes | #define SLEEP_TIMING_TIME(hours, minutes) hours * 60 + minutes | ||||
#define SLEEP_DEFAULT_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_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_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_MIN SLEEP_TIMING_TIME(0, 0) | ||||
#define SLEEP_TIMING_MAX SLEEP_TIMING_TIME(23, 59) | #define SLEEP_TIMING_MAX SLEEP_TIMING_TIME(23, 59) | ||||
@@ -35,10 +35,10 @@ namespace config { | |||||
*/ | */ | ||||
static const sleepTimings_t defaultSleepTimings[] PROGMEM = { | static const sleepTimings_t defaultSleepTimings[] PROGMEM = { | ||||
// Sleep timings when not moving | // 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(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(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) | |||||
// Sleep timings while moving | // 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) | { SLEEP_TIMING_MIN_MOVING_VELOCITY, SLEEP_TIMING_MIN, SLEEP_TIMING_MAX, 540 }, ///< 540 seconds when speed > SLEEP_TIMING_MIN_MOVING_VELOCITY (5km/h) | ||||
@@ -1,26 +1,9 @@ | |||||
#pragma once | #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.42" /// Version string, only used for indicative purpose. | |||||
/** | /** | ||||
@@ -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. |