Browse Source

Removed DEFAULT from all constants

tags/v1.4.2^2
Bertrand Lemasle 6 years ago
parent
commit
506ecc3e49
15 changed files with 69 additions and 69 deletions
  1. +18
    -18
      src/Config.cpp
  2. +9
    -9
      src/Core.cpp
  3. +1
    -1
      src/Debug.cpp
  4. +2
    -2
      src/Gps.cpp
  5. +4
    -4
      src/Network.cpp
  6. +4
    -4
      src/NetworkPositionsBackup.cpp
  7. +1
    -1
      src/Positions.cpp
  8. +2
    -2
      src/SdPositionsConfig.cpp
  9. +5
    -5
      src/config/Alerts.h
  10. +5
    -5
      src/config/BackupNetwork.h
  11. +2
    -2
      src/config/BackupSd.h
  12. +6
    -6
      src/config/Gps.h
  13. +1
    -1
      src/config/Hardware.h
  14. +4
    -4
      src/config/Network.h
  15. +5
    -5
      src/config/Sleeps.h

+ 18
- 18
src/Config.cpp View File

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


+ 9
- 9
src/Core.cpp View File

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


+ 1
- 1
src/Debug.cpp View File

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


+ 2
- 2
src/Gps.cpp View File

@@ -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) {


+ 4
- 4
src/Network.cpp View File

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


+ 4
- 4
src/NetworkPositionsBackup.cpp View File

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


+ 1
- 1
src/Positions.cpp View File

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


+ 2
- 2
src/SdPositionsConfig.cpp View File

@@ -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,


+ 5
- 5
src/config/Alerts.h View File

@@ -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.


+ 5
- 5
src/config/BackupNetwork.h View File

@@ -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.


+ 2
- 2
src/config/BackupSd.h View File

@@ -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
#define POSITIONS_CONFIG_SAVE_THRESHOLD 10
#define POSITIONS_CONFIG_MAX_RECORDS_PER_FILE 5

+ 6
- 6
src/config/Gps.h View File

@@ -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.
#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.

+ 1
- 1
src/config/Hardware.h View File

@@ -5,7 +5,7 @@
#include <E24.h>
#include <SoftwareSerial.h>
#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


+ 4
- 4
src/config/Network.h View File

@@ -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.

+ 5
- 5
src/config/Sleeps.h View File

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


Loading…
Cancel
Save