Bladeren bron

Merge branch 'trim-main'

tags/v1.4.0
Bertrand Lemasle 6 jaren geleden
bovenliggende
commit
b48c7cc53e
28 gewijzigde bestanden met toevoegingen van 334 en 229 verwijderingen
  1. +1
    -2
      src/Alerts.cpp
  2. +25
    -13
      src/Config.cpp
  3. +2
    -0
      src/Config.h
  4. +24
    -12
      src/Core.cpp
  5. +3
    -2
      src/Core.h
  6. +29
    -37
      src/Debug.cpp
  7. +1
    -2
      src/Debug.h
  8. +20
    -11
      src/Gps.cpp
  9. +1
    -1
      src/Gps.h
  10. +5
    -4
      src/GpsTracker.ino
  11. +38
    -15
      src/Hardware.cpp
  12. +26
    -16
      src/Logging.h
  13. +7
    -3
      src/MainUnit.cpp
  14. +19
    -12
      src/Network.cpp
  15. +1
    -1
      src/Network.h
  16. +22
    -15
      src/NetworkPositionsBackup.cpp
  17. +1
    -1
      src/NetworkPositionsBackup.h
  18. +30
    -27
      src/Positions.cpp
  19. +4
    -2
      src/Positions.h
  20. +15
    -15
      src/PositionsBackup.h
  21. +16
    -5
      src/Rtc.cpp
  22. +1
    -0
      src/RtcAbstraction.cpp
  23. +2
    -0
      src/RtcAbstraction.h
  24. +10
    -7
      src/SdPositionsBackup.cpp
  25. +17
    -17
      src/SdPositionsBackup.h
  26. +11
    -4
      src/SdPositionsConfig.cpp
  27. +2
    -4
      src/Time2.cpp
  28. +1
    -1
      src/config/System.h

+ 1
- 2
src/Alerts.cpp Bestand weergeven

@@ -5,9 +5,8 @@
#include "Rtc.h" #include "Rtc.h"
#include "Logging.h" #include "Logging.h"
#define LOGGER_NAME "Alerts"
namespace alerts { namespace alerts {
#define CURRENT_LOGGER "alerts"
uint8_t getTriggered(PositionEntryMetadata &metadata) { uint8_t getTriggered(PositionEntryMetadata &metadata) {
config_t* config = &config::main::value; config_t* config = &config::main::value;


+ 25
- 13
src/Config.cpp Bestand weergeven

@@ -2,9 +2,11 @@
#include "Hardware.h" #include "Hardware.h"
#include "Logging.h" #include "Logging.h"
#define LOGGER_NAME "Config"
namespace config { namespace config {
#define CURRENT_LOGGER "config"
const char VERSION_STRING[] PROGMEM = VERSION;
namespace main { namespace main {
config_t value; config_t value;
@@ -12,16 +14,16 @@ namespace config {
namespace details { namespace details {
void read() { void read() {
VERBOSE("read");
#define CURRENT_LOGGER_FUNCTION "read"
NOTICE;
hardware::i2c::powerOn(); hardware::i2c::powerOn();
hardware::i2c::eeprom.readBlock(CONFIG_ADDR, value); hardware::i2c::eeprom.readBlock(CONFIG_ADDR, value);
print();
if (CONFIG_SEED != value.seed) reset(); //todo : reset network if seed for network is not right if (CONFIG_SEED != value.seed) reset(); //todo : reset network if seed for network is not right
hardware::i2c::powerOff(); hardware::i2c::powerOff();
NOTICE_FORMAT("read", "%d, %s, %d, %d, %d, %d, %d, %B, %s", value.seed, value.version, value.firstEntry, value.lastEntry, value.alertBatteryLevel1, value.alertBatteryLevel2, value.alertBatteryLevelClear, value.activeAlerts, value.contactPhone);
#if BACKUP_ENABLE_NETWORK #if BACKUP_ENABLE_NETWORK
NOTICE_FORMAT("read", "%d, %d, %s, %s", value.network.saveThreshold, value.network.lastSavedEntry, value.network.apn, value.network.url);
//networkConfig_t c = { //networkConfig_t c = {
// POSITIONS_CONFIG_NET_DEFAULT_SAVE_THRESHOLD, // POSITIONS_CONFIG_NET_DEFAULT_SAVE_THRESHOLD,
// 0xFFFF, // 0xFFFF,
@@ -30,7 +32,7 @@ namespace config {
//}; //};
//value.network = c; //value.network = c;
#endif #endif
/*strcpy_P(value.version, PSTR(VERSION));
/*strcpy_P(value.version, VERSION_STRING);
value.alertBatteryLevel1 = CONFIG_DEFAULT_BATTERY_ALERT_LEVEL1; value.alertBatteryLevel1 = CONFIG_DEFAULT_BATTERY_ALERT_LEVEL1;
value.alertBatteryLevel2 = CONFIG_DEFAULT_BATTERY_ALERT_LEVEL2; value.alertBatteryLevel2 = CONFIG_DEFAULT_BATTERY_ALERT_LEVEL2;
value.alertBatteryLevelClear = CONFIG_DEFAULT_BATTERY_ALERT_CLEAR; value.alertBatteryLevelClear = CONFIG_DEFAULT_BATTERY_ALERT_CLEAR;
@@ -39,10 +41,10 @@ namespace config {
} }
void write() { void write() {
NOTICE_FORMAT("write", "%d, %s, %d, %d, %d, %d, %d, %B, %s", value.seed, value.version, value.firstEntry, value.lastEntry, value.alertBatteryLevel1, value.alertBatteryLevel2, value.alertBatteryLevelClear, value.activeAlerts, value.contactPhone);
#if BACKUP_ENABLE_NETWORK
NOTICE_FORMAT("write", "%d, %d, %s, %s", value.network.saveThreshold, value.network.lastSavedEntry, value.network.apn, value.network.url);
#endif
#define CURRENT_LOGGER_FUNCTION "write"
NOTICE;
print();
hardware::i2c::powerOn(); hardware::i2c::powerOn();
int written = hardware::i2c::eeprom.writeBlock(CONFIG_ADDR, value); int written = hardware::i2c::eeprom.writeBlock(CONFIG_ADDR, value);
hardware::i2c::powerOff(); hardware::i2c::powerOff();
@@ -52,8 +54,8 @@ namespace config {
void setup() { void setup() {
details::read(); details::read();
if(strcasecmp_P(value.version, PSTR(VERSION))) {
strcpy_P(value.version, PSTR(VERSION));
if(strcasecmp_P(value.version, VERSION_STRING)) {
strcpy_P(value.version, VERSION_STRING);
details::write(); details::write();
} }
} }
@@ -63,11 +65,12 @@ namespace config {
} }
void reset() { void reset() {
VERBOSE("reset");
#define CURRENT_LOGGER_FUNCTION "reset"
NOTICE;
config_t config = {}; config_t config = {};
config.seed = CONFIG_SEED; config.seed = CONFIG_SEED;
strcpy_P(config.version, PSTR(VERSION));
strcpy_P(config.version, VERSION_STRING);
config.firstEntry = config.lastEntry = 0xFFFF; config.firstEntry = config.lastEntry = 0xFFFF;
config.alertBatteryLevel1 = CONFIG_DEFAULT_BATTERY_ALERT_LEVEL1; config.alertBatteryLevel1 = CONFIG_DEFAULT_BATTERY_ALERT_LEVEL1;
config.alertBatteryLevel2 = CONFIG_DEFAULT_BATTERY_ALERT_LEVEL2; config.alertBatteryLevel2 = CONFIG_DEFAULT_BATTERY_ALERT_LEVEL2;
@@ -86,5 +89,14 @@ namespace config {
save(); save();
} }
void print() {
#define CURRENT_LOGGER_FUNCTION "print"
NOTICE_FORMAT("%d, %s, %d, %d, %d, %d, %d, %B, %s", value.seed, value.version, value.firstEntry, value.lastEntry, value.alertBatteryLevel1, value.alertBatteryLevel2, value.alertBatteryLevelClear, value.activeAlerts, value.contactPhone);
#if BACKUP_ENABLE_NETWORK
NOTICE_FORMAT("%d, %d, %s, %s", value.network.saveThreshold, value.network.lastSavedEntry, value.network.apn, value.network.url);
#endif
}
} }
} }

+ 2
- 0
src/Config.h Bestand weergeven

@@ -29,5 +29,7 @@ namespace config {
void save(); void save();
void reset(); void reset();
void print();
} }
} }

+ 24
- 12
src/Core.cpp Bestand weergeven

@@ -8,13 +8,13 @@
#include "Alerts.h" #include "Alerts.h"
#include "Logging.h" #include "Logging.h"
#define LOGGER_NAME "Core"
#define SMS_BUFFER_SIZE 140 #define SMS_BUFFER_SIZE 140
#define NO_ALERTS_NOTIFIED 0 #define NO_ALERTS_NOTIFIED 0
using namespace utils; using namespace utils;
namespace core { namespace core {
#define CURRENT_LOGGER "core"
uint16_t sleepTime = SLEEP_DEFAULT_TIME_SECONDS; uint16_t sleepTime = SLEEP_DEFAULT_TIME_SECONDS;
uint8_t stoppedInARow = SLEEP_DEFAULT_STOPPED_THRESHOLD - 1; uint8_t stoppedInARow = SLEEP_DEFAULT_STOPPED_THRESHOLD - 1;
@@ -39,7 +39,11 @@ namespace core {
bool acquired = false; bool acquired = false;
PositionEntryMetadata metadata; PositionEntryMetadata metadata;
if(movingState >= TRACKER_MOVING_STATE::STOPPED) positions::prepareBackup();
if(movingState >= TRACKER_MOVING_STATE::ABOUT_TO_STOP) {
//forcing when the tracker is about to stop (which should result in STOPPED a few lines below)
positions::prepareBackup(movingState == TRACKER_MOVING_STATE::ABOUT_TO_STOP);
}
acquired = positions::acquire(metadata); acquired = positions::acquire(metadata);
if (acquired) { if (acquired) {
@@ -53,7 +57,7 @@ namespace core {
alerts::add(notifyFailures(metadata)); alerts::add(notifyFailures(metadata));
if(movingState >= TRACKER_MOVING_STATE::STOPPED) { if(movingState >= TRACKER_MOVING_STATE::STOPPED) {
positions::doBackup(movingState == TRACKER_MOVING_STATE::STOPPED); //do not force on STATIC
positions::doBackup(movingState == TRACKER_MOVING_STATE::STOPPED); //forcing at the moment the tracker stop
} }
if (acquired) updateRtcTime(); if (acquired) updateRtcTime();
@@ -61,20 +65,22 @@ namespace core {
} }
uint8_t notifyFailures(PositionEntryMetadata &metadata) { uint8_t notifyFailures(PositionEntryMetadata &metadata) {
SIM808RegistrationStatus networkStatus;
#define CURRENT_LOGGER_FUNCTION "notifyFailures"
SIM808_NETWORK_REGISTRATION_STATE networkStatus;
char buffer[SMS_BUFFER_SIZE]; char buffer[SMS_BUFFER_SIZE];
const __FlashStringHelper * backupFailureString = F(" Backup battery failure ?"); const __FlashStringHelper * backupFailureString = F(" Backup battery failure ?");
bool notified = false; bool notified = false;
uint8_t triggered = alerts::getTriggered(metadata); uint8_t triggered = alerts::getTriggered(metadata);
if (!triggered) return NO_ALERTS_NOTIFIED;
NOTICE_FORMAT("triggered : %B", triggered);
NOTICE_FORMAT("notifyFailures", "triggered : %B", triggered);
if (!triggered) return NO_ALERTS_NOTIFIED;
network::powerOn(); network::powerOn();
networkStatus = network::waitForRegistered(NETWORK_DEFAULT_TOTAL_TIMEOUT_MS); networkStatus = network::waitForRegistered(NETWORK_DEFAULT_TOTAL_TIMEOUT_MS);
if (network::isAvailable(networkStatus.stat)) {
if (network::isAvailable(networkStatus)) {
strncpy_P(buffer, PSTR("Alerts !"), SMS_BUFFER_SIZE); strncpy_P(buffer, PSTR("Alerts !"), SMS_BUFFER_SIZE);
if (bitRead(triggered, ALERT_BATTERY_LEVEL_1) || bitRead(triggered, ALERT_BATTERY_LEVEL_2)) { if (bitRead(triggered, ALERT_BATTERY_LEVEL_1) || bitRead(triggered, ALERT_BATTERY_LEVEL_2)) {
details::appendToSmsBuffer(buffer, PSTR("\n- Battery at %d%%."), metadata.batteryLevel); details::appendToSmsBuffer(buffer, PSTR("\n- Battery at %d%%."), metadata.batteryLevel);
@@ -89,12 +95,12 @@ namespace core {
} }
#if ALERTS_ON_SERIAL #if ALERTS_ON_SERIAL
NOTICE_FORMAT("notifyFailure", "%s", buffer);
NOTICE_FORMAT("%s", buffer);
notified = true; notified = true;
#else #else
notified = network::sendSms(buffer); notified = network::sendSms(buffer);
#endif #endif
if (!notified) NOTICE_MSG("notifyFailure", "SMS not sent !");
if (!notified) NOTICE_MSG("SMS not sent !");
} }
network::powerOff(); network::powerOff();
@@ -108,6 +114,8 @@ namespace core {
} }
TRACKER_MOVING_STATE updateSleepTime() { TRACKER_MOVING_STATE updateSleepTime() {
#define CURRENT_LOGGER_FUNCTION "updateSleepTime"
TRACKER_MOVING_STATE state = TRACKER_MOVING_STATE::MOVING; TRACKER_MOVING_STATE state = TRACKER_MOVING_STATE::MOVING;
uint8_t velocity = gps::getVelocity(); uint8_t velocity = gps::getVelocity();
@@ -120,18 +128,22 @@ namespace core {
if (stoppedInARow < SLEEP_DEFAULT_STOPPED_THRESHOLD) { if (stoppedInARow < SLEEP_DEFAULT_STOPPED_THRESHOLD) {
sleepTime = SLEEP_DEFAULT_PAUSING_TIME_SECONDS; sleepTime = SLEEP_DEFAULT_PAUSING_TIME_SECONDS;
state = TRACKER_MOVING_STATE::PAUSED;
state = stoppedInARow == SLEEP_DEFAULT_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_DEFAULT_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;
NOTICE_FORMAT("updateSleepTime", "%dkmh => %d seconds", velocity, sleepTime);
NOTICE_FORMAT("stop %d, state %d, %dkmh => %ds", stoppedInARow, state, velocity, sleepTime);
return state; return state;
} }
uint16_t mapSleepTime(uint8_t velocity) { uint16_t mapSleepTime(uint8_t velocity) {
#define CURRENT_LOGGER_FUNCTION "mapSleepTime"
uint16_t result; uint16_t result;
uint16_t currentTime = 0xFFFF; uint16_t currentTime = 0xFFFF;
@@ -154,7 +166,7 @@ namespace core {
} }
VERBOSE_FORMAT("mapSleepTime", "%d,%d", velocity, result);
VERBOSE_FORMAT("%d,%d", velocity, result);
return result; return result;
} }
} }

+ 3
- 2
src/Core.h Bestand weergeven

@@ -6,8 +6,9 @@
enum class TRACKER_MOVING_STATE : uint8_t { enum class TRACKER_MOVING_STATE : uint8_t {
MOVING = 0, MOVING = 0,
PAUSED = 1, PAUSED = 1,
STOPPED = 2,
STATIC = 3
ABOUT_TO_STOP = 2,
STOPPED = 3,
STATIC = 4
}; };
namespace core { namespace core {


+ 29
- 37
src/Debug.cpp Bestand weergeven

@@ -9,8 +9,6 @@
#include "Alerts.h" #include "Alerts.h"
#include "Logging.h" #include "Logging.h"
#define LOGGER_NAME "Debug"
#define MENU_ENTRY(name, text) const char MENU_##name[] PROGMEM = text #define MENU_ENTRY(name, text) const char MENU_##name[] PROGMEM = text
const char FAKE_GPS_ENTRY[] PROGMEM = "1,1,20170924184842.000,49.454862,1.144537,71.900,2.70,172.6,1,,1.3,2.2,1.8,,11,7,,,37,,"; const char FAKE_GPS_ENTRY[] PROGMEM = "1,1,20170924184842.000,49.454862,1.144537,71.900,2.70,172.6,1,,1.3,2.2,1.8,,11,7,,,37,,";
@@ -116,21 +114,11 @@ static const PositionEntryMetadata fakeMetadata PROGMEM = {
using namespace utils; using namespace utils;
namespace debug { namespace debug {
namespace details {
inline void displayPosition(PositionEntry entry) {
Log.notice(F("%d,%d,%d,%d,%d,%s"),
entry.metadata.batteryLevel,
entry.metadata.batteryVoltage,
entry.metadata.temperature,
static_cast<uint8_t>(entry.metadata.status),
entry.metadata.timeToFix,
entry.position);
}
}
#define CURRENT_LOGGER "debug"
void displayFreeRam() { void displayFreeRam() {
Log.notice(F("RAM: %d\n"), mainunit::freeRam());
#define CURRENT_LOGGER_FUNCTION "displayFreeRam"
NOTICE_FORMAT("%d", mainunit::freeRam());
} }
GPSTRACKER_DEBUG_COMMAND parseCommand(char id) { GPSTRACKER_DEBUG_COMMAND parseCommand(char id) {
@@ -146,6 +134,8 @@ namespace debug {
} }
GPSTRACKER_DEBUG_COMMAND menu(uint16_t timeout) { GPSTRACKER_DEBUG_COMMAND menu(uint16_t timeout) {
#define CURRENT_LOGGER_FUNCTION "menu"
GPSTRACKER_DEBUG_COMMAND command; GPSTRACKER_DEBUG_COMMAND command;
size_t menuSize = flash::getArraySize(MENU_ENTRIES); size_t menuSize = flash::getArraySize(MENU_ENTRIES);
@@ -159,7 +149,7 @@ namespace debug {
delay(MENU_INTERMEDIATE_TIMEOUT); delay(MENU_INTERMEDIATE_TIMEOUT);
timeout -= MENU_INTERMEDIATE_TIMEOUT; timeout -= MENU_INTERMEDIATE_TIMEOUT;
if (timeout <= 0) { if (timeout <= 0) {
NOTICE_MSG("menu", "Timeout expired.");
NOTICE_MSG("Timeout expired.");
return GPSTRACKER_DEBUG_COMMAND::RUN; return GPSTRACKER_DEBUG_COMMAND::RUN;
} }
} }
@@ -172,32 +162,36 @@ namespace debug {
} }
void getAndDisplayGpsPosition() { 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_DEFAULT_TOTAL_TIMEOUT_MS);
NOTICE_FORMAT("getAndDisplayGpsPosition", "%d %s", gpsStatus, gps::lastPosition);
NOTICE_FORMAT("%d %s", gpsStatus, gps::lastPosition);
} }
void setFakeGpsPosition() { void setFakeGpsPosition() {
#define CURRENT_LOGGER_FUNCTION "setFakeGpsPosition"
strlcpy_P(gps::lastPosition, FAKE_GPS_ENTRY, GPS_POSITION_SIZE); strlcpy_P(gps::lastPosition, FAKE_GPS_ENTRY, GPS_POSITION_SIZE);
NOTICE_FORMAT("setFakeGpsPosition", "Last position set to : %s", gps::lastPosition);
NOTICE_FORMAT("setFakeGpsPosition", "Speed : %d", gps::getVelocity());
NOTICE_FORMAT("setFakeGpsPosition", "Sleep time : %d", core::mapSleepTime(gps::getVelocity()));
NOTICE_FORMAT("Last position set to : %s", gps::lastPosition);
NOTICE_FORMAT("Speed : %d", gps::getVelocity());
NOTICE_FORMAT("Sleep time : %d", core::mapSleepTime(gps::getVelocity()));
} }
void getAndDisplayBattery() { void getAndDisplayBattery() {
#define CURRENT_LOGGER_FUNCTION "getAndDisplayBattery"
hardware::sim808::powerOn(); hardware::sim808::powerOn();
SIM808ChargingStatus status = hardware::sim808::device.getChargingState(); SIM808ChargingStatus status = hardware::sim808::device.getChargingState();
hardware::sim808::powerOff(); hardware::sim808::powerOff();
NOTICE_FORMAT("getAndDisplayBattery", "%d %d%% %dmV", status.state, status.level, status.voltage);
NOTICE_FORMAT("%d %d%% %dmV", status.state, status.level, status.voltage);
} }
void getAndDisplayRtcTime() { void getAndDisplayRtcTime() {
#define CURRENT_LOGGER_FUNCTION "getAndDisplayRtcTime"
tmElements_t time; tmElements_t time;
rtc::getTime(time); rtc::getTime(time);
NOTICE_FORMAT("getAndDisplayRtcTime", "%d/%d/%d %d:%d:%d %t %d", time.year, time.month, time.day, time.hour, time.minute, time.second, rtc::isAccurate(), rtc::getTemperature());
NOTICE_FORMAT("%d/%d/%d %d:%d:%d %t %d", time.year, time.month, time.day, time.hour, time.minute, time.second, rtc::isAccurate(), rtc::getTemperature());
} }
void setRtcTime() { void setRtcTime() {
@@ -207,6 +201,8 @@ namespace debug {
} }
void getAndDisplaySleepTimes() { void getAndDisplaySleepTimes() {
#define CURRENT_LOGGER_FUNCTION "getAndDisplaySleepTimes"
size_t arraySize = flash::getArraySize(config::defaultSleepTimings); size_t arraySize = flash::getArraySize(config::defaultSleepTimings);
sleepTimings_t maxSpeedTiming; sleepTimings_t maxSpeedTiming;
utils::flash::read(&config::defaultSleepTimings[arraySize - 1], maxSpeedTiming); utils::flash::read(&config::defaultSleepTimings[arraySize - 1], maxSpeedTiming);
@@ -215,7 +211,7 @@ namespace debug {
core::mapSleepTime(i); core::mapSleepTime(i);
} }
NOTICE_MSG("getAndDisplaySleepTimes", "Done");
NOTICE_MSG("Done");
} }
void getAndDisplayEepromConfig() { void getAndDisplayEepromConfig() {
@@ -223,6 +219,8 @@ namespace debug {
} }
void getAndDisplayEepromContent() { void getAndDisplayEepromContent() {
#define CURRENT_LOGGER_FUNCTION "getAndDisplayEepromContent"
char buffer[128]; char buffer[128];
hardware::i2c::powerOn(); hardware::i2c::powerOn();
@@ -235,29 +233,21 @@ namespace debug {
Serial.println(); Serial.println();
hardware::i2c::powerOff(); hardware::i2c::powerOff();
NOTICE_MSG("getAndDisplayEepromContent", "Done");
NOTICE_MSG("Done");
} }
void getAndDisplayEepromPositions() {
uint16_t currentEntryIndex = config::main::value.firstEntry;
void getAndDisplayEepromPositions(uint16_t firstIndex) {
uint16_t currentEntryIndex = firstIndex;
PositionEntry currentEntry; PositionEntry currentEntry;
hardware::i2c::powerOn(); hardware::i2c::powerOn();
do { do {
if (!positions::get(currentEntryIndex, currentEntry)) break; if (!positions::get(currentEntryIndex, currentEntry)) break;
details::displayPosition(currentEntry);
} while (positions::moveNext(currentEntryIndex));
positions::print(currentEntryIndex, currentEntry);
} while(positions::moveNext(currentEntryIndex));
hardware::i2c::powerOff(); hardware::i2c::powerOff();
} }
void getAndDisplayEepromLastPosition() {
uint16_t lastEntryIndex = config::main::value.lastEntry;
PositionEntry lastEntry;
if(positions::get(lastEntryIndex, lastEntry)) details::displayPosition(lastEntry);
else Log.notice(F("No position recorded\n"));
}
void addLastPositionToEeprom() { void addLastPositionToEeprom() {
hardware::sim808::powerOn(); hardware::sim808::powerOn();
SIM808ChargingStatus status = hardware::sim808::device.getChargingState(); SIM808ChargingStatus status = hardware::sim808::device.getChargingState();
@@ -275,13 +265,15 @@ namespace debug {
} }
void notifyFailures() { void notifyFailures() {
#define CURRENT_LOGGER_FUNCTION "notifyFailures"
PositionEntryMetadata metadata = {}; PositionEntryMetadata metadata = {};
flash::read(&fakeMetadata, metadata); flash::read(&fakeMetadata, metadata);
metadata.batteryLevel = 1; metadata.batteryLevel = 1;
metadata.temperature = ALERT_SUSPICIOUS_RTC_TEMPERATURE; metadata.temperature = ALERT_SUSPICIOUS_RTC_TEMPERATURE;
uint8_t alerts = core::notifyFailures(metadata); uint8_t alerts = core::notifyFailures(metadata);
NOTICE_FORMAT("notifyFailures", "result : %B", alerts);
NOTICE_FORMAT("result : %B", alerts);
alerts::add(alerts); alerts::add(alerts);
} }


+ 1
- 2
src/Debug.h Bestand weergeven

@@ -44,8 +44,7 @@ namespace debug {
void getAndDisplayEepromConfig(); void getAndDisplayEepromConfig();
void getAndDisplayEepromContent(); void getAndDisplayEepromContent();
void getAndDisplayEepromPositions();
void getAndDisplayEepromLastPosition();
void getAndDisplayEepromPositions(uint16_t firstIndex);
void addLastPositionToEeprom(); void addLastPositionToEeprom();
void notifyFailures(); void notifyFailures();


+ 20
- 11
src/Gps.cpp Bestand weergeven

@@ -5,8 +5,6 @@
#include "MainUnit.h" #include "MainUnit.h"
#include "Logging.h" #include "Logging.h"
#define LOGGER_NAME "Gps"
#define TIME_YEAR_OFFSET 0 #define TIME_YEAR_OFFSET 0
#define TIME_MONTH_OFFSET 4 #define TIME_MONTH_OFFSET 4
#define TIME_DAY_OFFSET 6 #define TIME_DAY_OFFSET 6
@@ -16,7 +14,9 @@
#define EARTH_RADIUS 6371 //kilometers #define EARTH_RADIUS 6371 //kilometers
namespace gps { namespace gps {
#define CURRENT_LOGGER "gps"
namespace details { namespace details {
uint16_t parseSubstring(char *buffer, char *start, uint8_t size) { uint16_t parseSubstring(char *buffer, char *start, uint8_t size) {
@@ -25,6 +25,7 @@ namespace gps {
} }
} }
char lastPosition[GPS_POSITION_SIZE]; char lastPosition[GPS_POSITION_SIZE];
SIM808_GPS_STATUS lastStatus; SIM808_GPS_STATUS lastStatus;
@@ -32,13 +33,15 @@ namespace gps {
float previousLng = 0; float previousLng = 0;
SIM808_GPS_STATUS acquireCurrentPosition(int32_t timeout) { SIM808_GPS_STATUS acquireCurrentPosition(int32_t timeout) {
#define CURRENT_LOGGER_FUNCTION "acquireCurrentPosition"
SIM808_GPS_STATUS currentStatus = SIM808_GPS_STATUS::OFF; SIM808_GPS_STATUS currentStatus = SIM808_GPS_STATUS::OFF;
do { do {
currentStatus = hardware::sim808::device.getGpsStatus(lastPosition);
currentStatus = hardware::sim808::device.getGpsStatus(lastPosition, GPS_POSITION_SIZE);
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("acquireCurrentPosition", "%d", currentStatus);
NOTICE_FORMAT("%d", currentStatus);
mainunit::deepSleep(GPS_DEFAULT_INTERMEDIATE_TIMEOUT_MS / 1000); mainunit::deepSleep(GPS_DEFAULT_INTERMEDIATE_TIMEOUT_MS / 1000);
timeout -= GPS_DEFAULT_INTERMEDIATE_TIMEOUT_MS; timeout -= GPS_DEFAULT_INTERMEDIATE_TIMEOUT_MS;
} while (timeout > 1); } while (timeout > 1);
@@ -47,7 +50,7 @@ namespace gps {
lastStatus = currentStatus; lastStatus = currentStatus;
} }
NOTICE_FORMAT("acquireCurrentPosition", "%d", currentStatus);
NOTICE_FORMAT("%d", currentStatus);
return currentStatus; return currentStatus;
} }
@@ -62,12 +65,14 @@ namespace gps {
} }
float getDistanceFromPrevious() { float getDistanceFromPrevious() {
#define CURRENT_LOGGER_FUNCTION "getDistanceFromPrevious"
float lat1, lng1, lat2, lng2; float lat1, lng1, lat2, lng2;
if(!hardware::sim808::device.getGpsField(lastPosition, SIM808_GPS_FIELD::LATITUDE, &lat2)) return 0; if(!hardware::sim808::device.getGpsField(lastPosition, SIM808_GPS_FIELD::LATITUDE, &lat2)) return 0;
if(!hardware::sim808::device.getGpsField(lastPosition, SIM808_GPS_FIELD::LONGITUDE, &lng2)) return 0; if(!hardware::sim808::device.getGpsField(lastPosition, SIM808_GPS_FIELD::LONGITUDE, &lng2)) return 0;
VERBOSE_FORMAT("distanceFromPrevious", "%s, %f, %f, %f, %f", lastPosition, previousLat, previousLng, lat2, lng2);
VERBOSE_FORMAT("%s, %F, %F, %F, %F", lastPosition, previousLat, previousLng, lat2, lng2);
lat1 = radians(previousLat); lat1 = radians(previousLat);
lng1 = radians(previousLng); lng1 = radians(previousLng);
@@ -85,25 +90,29 @@ namespace gps {
a = EARTH_RADIUS * (2 * atan2(sqrt(a), sqrt(1 - a))); //kilometers a = EARTH_RADIUS * (2 * atan2(sqrt(a), sqrt(1 - a))); //kilometers
NOTICE_FORMAT("distanceFromPrevious", "%fkm", a);
NOTICE_FORMAT("%Fkm", a);
return a; return a;
} }
uint8_t getVelocity() { uint8_t getVelocity() {
uint8_t velocity;
#define CURRENT_LOGGER_FUNCTION "getVelocity"
int16_t velocity;
if (!hardware::sim808::device.getGpsField(lastPosition, SIM808_GPS_FIELD::SPEED, &velocity)) velocity = 0; if (!hardware::sim808::device.getGpsField(lastPosition, SIM808_GPS_FIELD::SPEED, &velocity)) velocity = 0;
VERBOSE_FORMAT("getVelocity", "%d", velocity);
VERBOSE_FORMAT("%d", velocity);
return velocity; return velocity;
} }
void getTime(tmElements_t &time) { void getTime(tmElements_t &time) {
#define CURRENT_LOGGER_FUNCTION "getTime"
char *timeStr; char *timeStr;
char buffer[5]; char buffer[5];
hardware::sim808::device.getGpsField(lastPosition, SIM808_GPS_FIELD::UTC, &timeStr); hardware::sim808::device.getGpsField(lastPosition, SIM808_GPS_FIELD::UTC, &timeStr);
VERBOSE_FORMAT("getTime", "%s", timeStr);
VERBOSE_FORMAT("%s", timeStr);
time.year = details::parseSubstring(buffer, timeStr + TIME_YEAR_OFFSET, 4); time.year = details::parseSubstring(buffer, timeStr + TIME_YEAR_OFFSET, 4);
time.month = details::parseSubstring(buffer, timeStr + TIME_MONTH_OFFSET, 2); time.month = details::parseSubstring(buffer, timeStr + TIME_MONTH_OFFSET, 2);
@@ -112,6 +121,6 @@ namespace gps {
time.minute = details::parseSubstring(buffer, timeStr + TIME_MINUTE_OFFSET, 2); time.minute = details::parseSubstring(buffer, timeStr + TIME_MINUTE_OFFSET, 2);
time.second = details::parseSubstring(buffer, timeStr + TIME_SECOND_OFFSET, 2); time.second = details::parseSubstring(buffer, timeStr + TIME_SECOND_OFFSET, 2);
NOTICE_FORMAT("getTime", "%d/%d/%d %d:%d:%d", time.year, time.month, time.day, time.hour, time.minute, time.second);
NOTICE_FORMAT("%d/%d/%d %d:%d:%d", time.year, time.month, time.day, time.hour, time.minute, time.second);
} }
} }

+ 1
- 1
src/Gps.h Bestand weergeven

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include <Arduino.h> #include <Arduino.h>
#include <SIM808_Types.h>
#include <SIM808.Types.h>
#include "Hardware.h" #include "Hardware.h"
#include "Time2.h" #include "Time2.h"


+ 5
- 4
src/GpsTracker.ino Bestand weergeven

@@ -10,7 +10,7 @@
#include "Positions.h" #include "Positions.h"
#include "Logging.h" #include "Logging.h"
#define LOGGER_NAME "GpsTracker"
#define CURRENT_LOGGER "GpsTracker"
bool bypassMenu = false; bool bypassMenu = false;
uint16_t menuTimeout = MENU_TIMEOUT; uint16_t menuTimeout = MENU_TIMEOUT;
@@ -26,6 +26,7 @@ void setup() {
} }
void loop() { void loop() {
#define CURRENT_LOGGER_FUNCTION "loop"
debug::GPSTRACKER_DEBUG_COMMAND command = debug::GPSTRACKER_DEBUG_COMMAND::RUN; debug::GPSTRACKER_DEBUG_COMMAND command = debug::GPSTRACKER_DEBUG_COMMAND::RUN;
if (Serial && !bypassMenu) command = debug::menu(menuTimeout); if (Serial && !bypassMenu) command = debug::menu(menuTimeout);
@@ -74,10 +75,10 @@ void loop() {
debug::getAndDisplayEepromContent(); debug::getAndDisplayEepromContent();
break; break;
case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_GET_ENTRIES: case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_GET_ENTRIES:
debug::getAndDisplayEepromPositions();
debug::getAndDisplayEepromPositions(config::main::value.firstEntry);
break; break;
case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_GET_LAST_ENTRY: case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_GET_LAST_ENTRY:
debug::getAndDisplayEepromLastPosition();
debug::getAndDisplayEepromPositions(config::main::value.lastEntry);
break; break;
case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_ADD_ENTRY: case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_ADD_ENTRY:
debug::addLastPositionToEeprom(); debug::addLastPositionToEeprom();
@@ -95,6 +96,6 @@ void loop() {
mainunit::deepSleep(10); mainunit::deepSleep(10);
break; break;
default: default:
NOTICE_MSG("loop", "Unsupported");
NOTICE_MSG("Unsupported");
} }
} }

+ 38
- 15
src/Hardware.cpp Bestand weergeven

@@ -5,16 +5,18 @@
namespace hardware { namespace hardware {
#define LOGGER_NAME "Hardware::sim808"
namespace sim808 { namespace sim808 {
#define CURRENT_LOGGER "hardware::sim808"
SIM_SERIAL_TYPE simSerial = SIM_SERIAL; SIM_SERIAL_TYPE simSerial = SIM_SERIAL;
SIM808 device = SIM808(SIM_RST, SIM_PWR, SIM_STATUS); SIM808 device = SIM808(SIM_RST, SIM_PWR, SIM_STATUS);
uint8_t networkPoweredCount = 0; uint8_t networkPoweredCount = 0;
uint8_t gpsPoweredCount = 0; uint8_t gpsPoweredCount = 0;
void powerOn() { void powerOn() {
VERBOSE("powerOn");
#define CURRENT_LOGGER_FUNCTION "powerOn"
VERBOSE;
bool poweredOn = device.powerOnOff(true); bool poweredOn = device.powerOnOff(true);
if (!poweredOn) return; if (!poweredOn) return;
@@ -23,7 +25,9 @@ namespace hardware {
} }
void powerOff() { void powerOff() {
VERBOSE("powerOff");
#define CURRENT_LOGGER_FUNCTION "powerOff"
VERBOSE;
device.powerOnOff(false); device.powerOnOff(false);
networkPoweredCount = gpsPoweredCount = 0; networkPoweredCount = gpsPoweredCount = 0;
} }
@@ -41,28 +45,35 @@ namespace hardware {
} }
void setup() { void setup() {
NOTICE("setup");
#define CURRENT_LOGGER_FUNCTION "setup"
VERBOSE;
simSerial.begin(SIM808_BAUDRATE); simSerial.begin(SIM808_BAUDRATE);
device.begin(simSerial); device.begin(simSerial);
powerOff(); //ensure powerOff on start powerOff(); //ensure powerOff on start
} }
void gpsPowerOn() { void gpsPowerOn() {
#define CURRENT_LOGGER_FUNCTION "gpsPowerOn"
if(gpsPoweredCount) { if(gpsPoweredCount) {
gpsPoweredCount++; gpsPoweredCount++;
return; return;
} }
VERBOSE("gpsPowerOn");
VERBOSE;
powerOn(); powerOn();
if(!networkPoweredCount) { if(!networkPoweredCount) {
//SIM808 turns phone on by default but we don't need it for gps only //SIM808 turns phone on by default but we don't need it for gps only
device.setPhoneFunctionality(SIM808_PHONE_FUNCTIONALITY::MINIMUM); device.setPhoneFunctionality(SIM808_PHONE_FUNCTIONALITY::MINIMUM);
} }
device.enableGps();
device.powerOnOffGps(true);
gpsPoweredCount = 1;
} }
void gpsPowerOff() { void gpsPowerOff() {
#define CURRENT_LOGGER_FUNCTION "gpsPowerOff"
if (!device.powered()) { if (!device.powered()) {
networkPoweredCount = gpsPoweredCount = 0; //just to be sure counts == 0 networkPoweredCount = gpsPoweredCount = 0; //just to be sure counts == 0
return; return;
@@ -73,23 +84,30 @@ namespace hardware {
return; return;
} }
VERBOSE("gpsPowerOff");
device.disableGps();
VERBOSE;
device.powerOnOffGps(false);
gpsPoweredCount = 0;
powerOffIfUnused(); powerOffIfUnused();
} }
void networkPowerOn() { void networkPowerOn() {
#define CURRENT_LOGGER_FUNCTION "networkPowerOn"
if(networkPoweredCount) { if(networkPoweredCount) {
networkPoweredCount++; networkPoweredCount++;
return; return;
} }
VERBOSE("networkPowerOn");
VERBOSE;
powerOn(); powerOn();
device.setPhoneFunctionality(SIM808_PHONE_FUNCTIONALITY::FULL); device.setPhoneFunctionality(SIM808_PHONE_FUNCTIONALITY::FULL);
networkPoweredCount = 1;
} }
void networkPowerOff() { void networkPowerOff() {
#define CURRENT_LOGGER_FUNCTION "networkPowerOff"
if (!device.powered()) { if (!device.powered()) {
networkPoweredCount = gpsPoweredCount = 0; //just to be sure counts == 0 networkPoweredCount = gpsPoweredCount = 0; //just to be sure counts == 0
return; return;
@@ -100,27 +118,30 @@ namespace hardware {
return; return;
} }
VERBOSE("networkPowerOff");
VERBOSE;
device.disableGprs(); device.disableGprs();
device.setPhoneFunctionality(SIM808_PHONE_FUNCTIONALITY::MINIMUM); device.setPhoneFunctionality(SIM808_PHONE_FUNCTIONALITY::MINIMUM);
networkPoweredCount = 0;
powerOffIfUnused(); powerOffIfUnused();
} }
} }
#define LOGGER_NAME "Hardware::i2c"
namespace i2c { namespace i2c {
#define CURRENT_LOGGER "hardware::i2c"
E24 eeprom = E24(E24_SIZE, E24_ADDRESS); E24 eeprom = E24(E24_SIZE, E24_ADDRESS);
uint8_t poweredCount = 0; uint8_t poweredCount = 0;
void powerOn() { void powerOn() {
#define CURRENT_LOGGER_FUNCTION "powerOn"
if(poweredCount) { if(poweredCount) {
poweredCount++; poweredCount++;
return; return;
} }
VERBOSE("powerOn");
VERBOSE;
digitalWrite(I2C_PWR, HIGH); digitalWrite(I2C_PWR, HIGH);
pinMode(I2C_PWR, OUTPUT); pinMode(I2C_PWR, OUTPUT);
@@ -129,12 +150,14 @@ namespace hardware {
} }
void powerOff(bool forced = false) { void powerOff(bool forced = false) {
#define CURRENT_LOGGER_FUNCTION "powerOff"
if(poweredCount > 1 && !forced) { if(poweredCount > 1 && !forced) {
poweredCount--; poweredCount--;
return; return;
} }
VERBOSE("powerOff");
VERBOSE;
pinMode(I2C_PWR, INPUT); pinMode(I2C_PWR, INPUT);
digitalWrite(I2C_PWR, LOW); digitalWrite(I2C_PWR, LOW);


+ 26
- 16
src/Logging.h Bestand weergeven

@@ -2,33 +2,43 @@
//#define DISABLE_LOGGING 1 //#define DISABLE_LOGGING 1
#include <ArduinoLog.h> #include <ArduinoLog.h>
#include <SIMComAT.Common.h> //reusing flash string utilities
#include "Config.h" #include "Config.h"
#define LOG_SERIAL_SPEED 115200 #define LOG_SERIAL_SPEED 115200
#if _DEBUG #if _DEBUG
#define LOG_LEVEL LOG_LEVEL_VERBOSE
#define LOG_LEVEL LOG_LEVEL_VERBOSE
#define LOG_LEVEL_VERBOSE_ENABLED
#define LOG_LEVEL_NOTICE_ENABLED
#else #else
#define LOG_LEVEL LOG_LEVEL_NOTICE
#define LOG_LEVEL LOG_LEVEL_NOTICE
#define LOG_LEVEL_NOTICE_ENABLED
#endif #endif
#define LOG(level, f) Log.level(F("[" LOGGER_NAME "::" f "]\n"))
#define LOG_MSG(level, f, msg) Log.level(F("[" LOGGER_NAME "::" f "] " msg "\n"))
#define LOG_FORMAT(level, f, msg, ...) Log.level(F("[" LOGGER_NAME "::" f "] " msg "\n"), __VA_ARGS__)
#define NL "\n"
#define LOG(level) LOG_MSG(level, "")
#define LOG_MSG(level, msg) Log.level(F("[" CURRENT_LOGGER "::" CURRENT_LOGGER_FUNCTION "] " msg NL))
#define LOG_FORMAT(level, msg, ...) Log.level(F("[" CURRENT_LOGGER "::" CURRENT_LOGGER_FUNCTION "] " msg NL), __VA_ARGS__)
#if _DEBUG
#define VERBOSE(f) LOG(verbose, f)
#define VERBOSE_MSG(f, msg) LOG_MSG(verbose, f, msg)
#define VERBOSE_FORMAT(f, msg, ...) LOG_FORMAT(verbose, f, msg, __VA_ARGS__)
#if defined(LOG_LEVEL_VERBOSE_ENABLED)
#define VERBOSE LOG(verbose)
#define VERBOSE_MSG(msg) LOG_MSG(verbose, msg)
#define VERBOSE_FORMAT(msg, ...) LOG_FORMAT(verbose, msg, __VA_ARGS__)
#else #else
#define VERBOSE(f)
#define VERBOSE_MSG(f, msg)
#define VERBOSE_FORMAT(f, msg, ...)
#define VERBOSE
#define VERBOSE_MSG(msg)
#define VERBOSE_FORMAT(msg, ...)
#endif #endif
#define NOTICE(f) LOG(notice, f)
#define NOTICE_MSG(f, msg) LOG_MSG(notice, f, msg)
#define NOTICE_FORMAT(f, msg, ...) LOG_FORMAT(notice, f, msg, __VA_ARGS__)
#if defined(LOG_LEVEL_NOTICE_ENABLED)
#define NOTICE LOG(notice)
#define NOTICE_MSG(msg) LOG_MSG(notice, msg)
#define NOTICE_FORMAT(msg, ...) LOG_FORMAT(notice, msg, __VA_ARGS__)
#else
#define NOTICE
#define NOTICE_MSG(msg)
#define NOTICE_FORMAT(msg, ...)
#endif
namespace logging { namespace logging {
void setup(); void setup();

+ 7
- 3
src/MainUnit.cpp Bestand weergeven

@@ -4,11 +4,11 @@
#include "config/Pins.h" #include "config/Pins.h"
#include "Logging.h" #include "Logging.h"
#define LOGGER_NAME "MainUnit"
extern int __heap_start, *__brkval; extern int __heap_start, *__brkval;
namespace mainunit { namespace mainunit {
#define CURRENT_LOGGER "mainunit"
namespace details { namespace details {
@@ -18,9 +18,11 @@ namespace mainunit {
} }
void wokeUp() { void wokeUp() {
#define CURRENT_LOGGER_FUNCTION "wokeUp"
tmElements_t wokeUpTime; tmElements_t wokeUpTime;
rtc::getTime(wokeUpTime); rtc::getTime(wokeUpTime);
VERBOSE_FORMAT("wokeUp", "%d:%d:%d", wokeUpTime.hour, wokeUpTime.minute, wokeUpTime.second);
VERBOSE_FORMAT("%d:%d:%d", wokeUpTime.hour, wokeUpTime.minute, wokeUpTime.second);
hardware::sim808::simSerial.listen(); hardware::sim808::simSerial.listen();
} }
@@ -39,7 +41,9 @@ namespace mainunit {
} }
void deepSleep(uint16_t seconds) { void deepSleep(uint16_t seconds) {
NOTICE_FORMAT("deepSleep", "%d seconds", seconds);
#define CURRENT_LOGGER_FUNCTION "deepSleep"
NOTICE_FORMAT("%ds", seconds);
interruptIn(seconds); interruptIn(seconds);
details::prepareSleep(); details::prepareSleep();
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);


+ 19
- 12
src/Network.cpp Bestand weergeven

@@ -5,12 +5,18 @@
#include "Config.h" #include "Config.h"
#include "Logging.h" #include "Logging.h"
#define LOGGER_NAME "Network"
namespace network { namespace network {
#define CURRENT_LOGGER "network"
timestamp_t _poweredOnTime; timestamp_t _poweredOnTime;
namespace details {
void print(SIM808_NETWORK_REGISTRATION_STATE state, SIM808SignalQualityReport &report) {
#define CURRENT_LOGGER_FUNCTION "print"
NOTICE_FORMAT("%d, [%d %ddBm]", state, report.rssi, report.attenuation);
}
}
void powerOn() { void powerOn() {
hardware::sim808::networkPowerOn(); hardware::sim808::networkPowerOn();
_poweredOnTime = rtc::getTime(); _poweredOnTime = rtc::getTime();
@@ -21,10 +27,11 @@ namespace network {
_poweredOnTime = 0; _poweredOnTime = 0;
} }
__attribute__((__optimize__("O2")))
SIM808RegistrationStatus waitForRegistered(uint32_t timeout, bool relativeToPowerOnTime = true) {
SIM808_NETWORK_REGISTRATION_STATE waitForRegistered(uint32_t timeout, bool relativeToPowerOnTime = true) {
#define CURRENT_LOGGER_FUNCTION "waitForRegistered"
NOTICE;
SIM808RegistrationStatus currentStatus;
SIM808_NETWORK_REGISTRATION_STATE currentStatus;
SIM808SignalQualityReport report; SIM808SignalQualityReport report;
uint8_t noReliableNetwork = 0; uint8_t noReliableNetwork = 0;
@@ -34,14 +41,13 @@ namespace network {
report = hardware::sim808::device.getSignalQuality(); report = hardware::sim808::device.getSignalQuality();
do { do {
if (isAvailable(currentStatus.stat)) break;
NOTICE_FORMAT("waitForRegistered", "%d, [%d %ddBm]", currentStatus.stat, report.rssi, report.attenuation);
if (isAvailable(currentStatus)) break;
details::print(currentStatus, report);
if (report.rssi < NETWORK_DEFAULT_NO_NETWORK_QUALITY_THRESHOLD) noReliableNetwork++; if (report.rssi < NETWORK_DEFAULT_NO_NETWORK_QUALITY_THRESHOLD) noReliableNetwork++;
else noReliableNetwork = 0; else noReliableNetwork = 0;
if (noReliableNetwork > NETWORK_DEFAULT_NO_NETWORK_TRIES) { if (noReliableNetwork > NETWORK_DEFAULT_NO_NETWORK_TRIES) {
NOTICE_MSG("waitForRegistered", "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
} }
@@ -52,7 +58,7 @@ namespace network {
report = hardware::sim808::device.getSignalQuality(); report = hardware::sim808::device.getSignalQuality();
} while (timeout > 1); } while (timeout > 1);
NOTICE_FORMAT("waitForRegistered", "%d, [%d %ddBm]", currentStatus.stat, report.rssi, report.attenuation);
details::print(currentStatus, report);
return currentStatus; return currentStatus;
} }
@@ -69,9 +75,10 @@ namespace network {
#endif #endif
bool sendSms(const char * msg) { bool sendSms(const char * msg) {
#define CURRENT_LOGGER_FUNCTION "sendSms"
const char * phoneNumber = config::main::value.contactPhone; const char * phoneNumber = config::main::value.contactPhone;
NOTICE_FORMAT("sendSms", "%s, %s", phoneNumber, msg);
NOTICE_FORMAT("%s, %s", phoneNumber, msg);
return hardware::sim808::device.sendSms(phoneNumber, msg); return hardware::sim808::device.sendSms(phoneNumber, msg);
} }
} }

+ 1
- 1
src/Network.h Bestand weergeven

@@ -8,7 +8,7 @@ namespace network {
void powerOn(); void powerOn();
void powerOff(); void powerOff();
SIM808RegistrationStatus waitForRegistered(uint32_t timeout, bool relativeToPowerOnTime = true);
SIM808_NETWORK_REGISTRATION_STATE waitForRegistered(uint32_t timeout, bool relativeToPowerOnTime = true);
bool isAvailable(SIM808_NETWORK_REGISTRATION_STATE state); bool isAvailable(SIM808_NETWORK_REGISTRATION_STATE state);
#if BACKUP_ENABLE_NETWORK #if BACKUP_ENABLE_NETWORK
bool enableGprs(); bool enableGprs();


+ 22
- 15
src/NetworkPositionsBackup.cpp Bestand weergeven

@@ -9,11 +9,12 @@
#include "Network.h" #include "Network.h"
#include "Logging.h" #include "Logging.h"
#define LOGGER_NAME "Positions::backup::network"
#define BUFFER_SIZE 170 #define BUFFER_SIZE 170
namespace positions { namespace positions {
#define CURRENT_LOGGER "Positions::backup::network"
namespace backup { namespace backup {
namespace net { namespace net {
@@ -27,6 +28,8 @@ namespace positions {
} }
bool NetworkPositionsBackup::appendPosition(PositionEntry &entry, int8_t signalAttenuation = 0) { bool NetworkPositionsBackup::appendPosition(PositionEntry &entry, int8_t signalAttenuation = 0) {
#define CURRENT_LOGGER_FUNCTION "appendPosition"
char buffer[BUFFER_SIZE]; char buffer[BUFFER_SIZE];
if(signalAttenuation == 0) signalAttenuation = hardware::sim808::device.getSignalQuality().attenuation; if(signalAttenuation == 0) signalAttenuation = hardware::sim808::device.getSignalQuality().attenuation;
@@ -40,7 +43,7 @@ namespace positions {
entry.metadata.timeToFix, entry.metadata.timeToFix,
entry.position); entry.position);
NOTICE_FORMAT("appendPosition", "Sending : %s", buffer);
NOTICE_FORMAT("Sending : %s", buffer);
uint16_t responseCode = hardware::sim808::device.httpPost( uint16_t responseCode = hardware::sim808::device.httpPost(
config::main::value.network.url, config::main::value.network.url,
F("text/gpstracker"), F("text/gpstracker"),
@@ -49,15 +52,16 @@ namespace positions {
BUFFER_SIZE BUFFER_SIZE
); );
NOTICE_FORMAT("appendPosition", "Response : %d", responseCode);
NOTICE_FORMAT("Response : %d", responseCode);
return responseCode == POSITIONS_CONFIG_NET_DEFAULT_EXPECTED_RESPONSE; return responseCode == POSITIONS_CONFIG_NET_DEFAULT_EXPECTED_RESPONSE;
} }
//__attribute__((__optimize__("O2")))
void NetworkPositionsBackup::appendPositions() { void NetworkPositionsBackup::appendPositions() {
#define CURRENT_LOGGER_FUNCTION "appendPositions"
uint16_t currentEntryIndex = config::main::value.network.lastSavedEntry + 1; uint16_t currentEntryIndex = config::main::value.network.lastSavedEntry + 1;
PositionEntry currentEntry; PositionEntry currentEntry;
SIM808RegistrationStatus networkStatus;
SIM808_NETWORK_REGISTRATION_STATE networkStatus;
//avoid edge case where if 0, whole set of positions will be sent again //avoid edge case where if 0, whole set of positions will be sent again
if (!positions::count(config::main::value.network.lastSavedEntry)) return; if (!positions::count(config::main::value.network.lastSavedEntry)) return;
@@ -65,9 +69,10 @@ namespace positions {
network::powerOn(); network::powerOn();
networkStatus = network::waitForRegistered(NETWORK_DEFAULT_TOTAL_TIMEOUT_MS); networkStatus = network::waitForRegistered(NETWORK_DEFAULT_TOTAL_TIMEOUT_MS);
if (!network::isAvailable(networkStatus.stat) || !network::enableGprs()) {
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_DEFAULT_UNAVAILABLE_NETWORK_POSTPONE_THRESHOLD + 1); //avoid increment overflow
NOTICE_MSG("appendPositions", "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_DEFAULT_UNAVAILABLE_NETWORK_POSTPONE_THRESHOLD) {
networkUnavailablePostpone++; networkUnavailablePostpone++;
@@ -95,20 +100,22 @@ namespace positions {
void NetworkPositionsBackup::setup() {} void NetworkPositionsBackup::setup() {}
void NetworkPositionsBackup::prepare() {
NOTICE("prepare");
void NetworkPositionsBackup::prepare(bool force) {
#define CURRENT_LOGGER_FUNCTION "prepare"
if (!(force || isBackupNeeded(true))) return;
if (!isBackupNeeded(true)) return;
NOTICE;
network::powerOn(); network::powerOn();
} }
void NetworkPositionsBackup::backup(bool force) { void NetworkPositionsBackup::backup(bool force) {
NOTICE("backup");
#define CURRENT_LOGGER_FUNCTION "backup"
if (force || isBackupNeeded(false)) {
appendPositions();
}
if (!(force || isBackupNeeded(false))) return;
NOTICE;
appendPositions();
network::powerOff(); network::powerOff();
} }
} }


+ 1
- 1
src/NetworkPositionsBackup.h Bestand weergeven

@@ -16,7 +16,7 @@ namespace positions {
public: public:
void setup(); void setup();
void prepare();
void prepare(bool force);
void backup(bool force); void backup(bool force);
}; };


+ 30
- 27
src/Positions.cpp Bestand weergeven

@@ -16,12 +16,12 @@
#include "NetworkPositionsBackup.h" #include "NetworkPositionsBackup.h"
#endif #endif
#define LOGGER_NAME "Positions"
#define ENTRY_RESERVED_SIZE 128 #define ENTRY_RESERVED_SIZE 128
#define ENTRIES_ADDR CONFIG_RESERVED_SIZE #define ENTRIES_ADDR CONFIG_RESERVED_SIZE
namespace positions { namespace positions {
#define CURRENT_LOGGER "positions"
#if BACKUPS_ENABLED > 1 #if BACKUPS_ENABLED > 1
backup::PositionsBackup **_backups; backup::PositionsBackup **_backups;
#elif BACKUPS_ENABLED == 1 #elif BACKUPS_ENABLED == 1
@@ -73,7 +73,8 @@ namespace positions {
} }
bool acquire(PositionEntryMetadata &metadata) { bool acquire(PositionEntryMetadata &metadata) {
NOTICE("acquire");
#define CURRENT_LOGGER_FUNCTION "acquire"
NOTICE;
timestamp_t before; timestamp_t before;
@@ -85,7 +86,7 @@ namespace positions {
gps::powerOff(); gps::powerOff();
bool acquired = gpsStatus >= SIM808_GPS_STATUS::FIX; //prety useless wins 14 bytes on the hex size rather than return gpStatus >= ... bool acquired = gpsStatus >= SIM808_GPS_STATUS::FIX; //prety useless wins 14 bytes on the hex size rather than return gpStatus >= ...
NOTICE_FORMAT("acquire", "Status : %d", gpsStatus);
NOTICE_FORMAT("Status : %d", gpsStatus);
metadata = { metadata = {
battery.level, battery.level,
@@ -99,7 +100,8 @@ namespace positions {
} }
void appendLast(const PositionEntryMetadata &metadata) { void appendLast(const PositionEntryMetadata &metadata) {
VERBOSE("appendLast");
#define CURRENT_LOGGER_FUNCTION "appendLast"
VERBOSE;
uint16_t entryIndex; uint16_t entryIndex;
uint16_t entryAddress; uint16_t entryAddress;
@@ -110,18 +112,12 @@ namespace positions {
entryIndex = config->lastEntry + 1; entryIndex = config->lastEntry + 1;
entryAddress = details::getEntryAddress(entryIndex); entryAddress = details::getEntryAddress(entryIndex);
print(entryIndex, entry);
hardware::i2c::powerOn(); hardware::i2c::powerOn();
hardware::i2c::eeprom.writeBlock(entryAddress, entry); hardware::i2c::eeprom.writeBlock(entryAddress, entry);
NOTICE_FORMAT("appendLast", "Saved @ %X : %d,%d,%d,%d,%d,%s",
entryAddress,
entry.metadata.batteryLevel,
entry.metadata.batteryVoltage,
entry.metadata.temperature,
static_cast<uint8_t>(entry.metadata.status),
entry.metadata.timeToFix,
entry.position);
NOTICE_MSG("Saved");
config->lastEntry++; config->lastEntry++;
if (config->lastEntry > details::maxEntryIndex) config->lastEntry = 0; if (config->lastEntry > details::maxEntryIndex) config->lastEntry = 0;
@@ -133,26 +129,19 @@ namespace positions {
} }
bool get(uint16_t index, PositionEntry &entry) { bool get(uint16_t index, PositionEntry &entry) {
VERBOSE("get");
#define CURRENT_LOGGER_FUNCTION "get"
VERBOSE;
uint16_t entryAddress = details::getEntryAddress(index); uint16_t entryAddress = details::getEntryAddress(index);
if (entryAddress == -1) return false; if (entryAddress == -1) return false;
VERBOSE_FORMAT("get", "Reading entry %d @ %X", index, entryAddress);
VERBOSE_FORMAT("Reading entry %d @ %X", index, entryAddress);
hardware::i2c::powerOn(); hardware::i2c::powerOn();
hardware::i2c::eeprom.readBlock(entryAddress, entry); hardware::i2c::eeprom.readBlock(entryAddress, entry);
hardware::i2c::powerOff(); hardware::i2c::powerOff();
NOTICE_FORMAT("get", "Read from EEPROM @ %X : %d,%d,%d,%d,%d,%s",
entryAddress,
entry.metadata.batteryLevel,
entry.metadata.batteryVoltage,
entry.metadata.temperature,
static_cast<uint8_t>(entry.metadata.status),
entry.metadata.timeToFix,
entry.position);
print(index, entry);
return true; return true;
} }
@@ -174,13 +163,13 @@ namespace positions {
return lastEntry - fromIndex; return lastEntry - fromIndex;
} }
void prepareBackup() {
void prepareBackup(bool force) {
#if BACKUPS_ENABLED > 1 #if BACKUPS_ENABLED > 1
for (int i = 0; i < BACKUPS_ENABLED; i++) { for (int i = 0; i < BACKUPS_ENABLED; i++) {
_backups[i]->prepare();
_backups[i]->prepare(force);
} }
#elif BACKUPS_ENABLED == 1 #elif BACKUPS_ENABLED == 1
_backup->prepare();
_backup->prepare(force);
#endif #endif
} }
@@ -193,4 +182,18 @@ namespace positions {
_backup->backup(force); _backup->backup(force);
#endif #endif
} }
void print(uint16_t index, PositionEntry &entry) {
#define CURRENT_LOGGER_FUNCTION "print"
uint16_t address = details::getEntryAddress(index);
NOTICE_FORMAT("%X : %d,%d,%d,%d,%d,%s",
address,
entry.metadata.batteryLevel,
entry.metadata.batteryVoltage,
entry.metadata.temperature,
static_cast<uint8_t>(entry.metadata.status),
entry.metadata.timeToFix,
entry.position);
}
} }

+ 4
- 2
src/Positions.h Bestand weergeven

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include <Arduino.h> #include <Arduino.h>
#include <SIM808_Types.h>
#include <SIM808.Types.h>
#define POSITION_SIZE 115 #define POSITION_SIZE 115
@@ -28,6 +28,8 @@ namespace positions {
bool moveNext(uint16_t &index); bool moveNext(uint16_t &index);
uint16_t count(uint16_t fromIndex); uint16_t count(uint16_t fromIndex);
void prepareBackup();
void prepareBackup(bool force);
void doBackup(bool force); void doBackup(bool force);
void print(uint16_t index, PositionEntry &entry);
} }

+ 15
- 15
src/PositionsBackup.h Bestand weergeven

@@ -1,16 +1,16 @@
#pragma once
namespace positions {
namespace backup {
class PositionsBackup {
public:
~PositionsBackup();
virtual void setup() = 0;
virtual void prepare() = 0;
virtual void backup(bool force) = 0;
};
}
#pragma once
namespace positions {
namespace backup {
class PositionsBackup {
public:
~PositionsBackup();
virtual void setup() = 0;
virtual void prepare(bool force) = 0;
virtual void backup(bool force) = 0;
};
}
} }

+ 16
- 5
src/Rtc.cpp Bestand weergeven

@@ -5,15 +5,17 @@
#include <Wire.h> #include <Wire.h>
#define LOGGER_NAME "Rtc"
using namespace utils; using namespace utils;
namespace rtc { namespace rtc {
#define CURRENT_LOGGER "rtc"
RTC_A_CLASS RTC_A; RTC_A_CLASS RTC_A;
void setup() { void setup() {
VERBOSE("setup");
#define CURRENT_LOGGER_FUNCTION "setup"
VERBOSE;
hardware::i2c::powerOn(); hardware::i2c::powerOn();
RTC_A.control(DS3231_12H, DS3231_OFF); //24 hours clock RTC_A.control(DS3231_12H, DS3231_OFF); //24 hours clock
RTC_A.control(DS3231_A1_INT_ENABLE, DS3231_OFF); //Alarm 1 OFF RTC_A.control(DS3231_A1_INT_ENABLE, DS3231_OFF); //Alarm 1 OFF
@@ -44,15 +46,18 @@ namespace rtc {
} }
void getTime(tmElements_t &time) { void getTime(tmElements_t &time) {
#define CURRENT_LOGGER_FUNCTION "getTime"
hardware::i2c::powerOn(); hardware::i2c::powerOn();
RTC_A.readTime(time); RTC_A.readTime(time);
hardware::i2c::powerOff(); hardware::i2c::powerOff();
VERBOSE_FORMAT("getTime", "%d/%d/%d %d:%d:%d", time.year, time.month, time.day, time.hour, time.minute, time.second);
VERBOSE_FORMAT("%d/%d/%d %d:%d:%d", time.year, time.month, time.day, time.hour, time.minute, time.second);
} }
void setTime(const tmElements_t &time) { void setTime(const tmElements_t &time) {
VERBOSE_FORMAT("setTime", "%d/%d/%d %d:%d:%d", time.year, time.month, time.day, time.hour, time.minute, time.second);
#define CURRENT_LOGGER_FUNCTION "setTime"
VERBOSE_FORMAT("%d/%d/%d %d:%d:%d", time.year, time.month, time.day, time.hour, time.minute, time.second);
hardware::i2c::powerOn(); hardware::i2c::powerOn();
RTC_A.writeTime(time); RTC_A.writeTime(time);
@@ -64,13 +69,17 @@ namespace rtc {
tmElements_t currentTime; tmElements_t currentTime;
tmElements_t alarmTime; tmElements_t alarmTime;
hardware::i2c::powerOn();
getTime(currentTime); getTime(currentTime);
time::breakTime(time::makeTimestamp(currentTime) + seconds, alarmTime); time::breakTime(time::makeTimestamp(currentTime) + seconds, alarmTime);
setAlarm(alarmTime); setAlarm(alarmTime);
hardware::i2c::powerOff();
} }
void setAlarm(const tmElements_t &time) { void setAlarm(const tmElements_t &time) {
#define CURRENT_LOGGER_FUNCTION "setAlarm"
hardware::i2c::powerOn(); hardware::i2c::powerOn();
WRITE_ALARM_1(time); WRITE_ALARM_1(time);
@@ -78,7 +87,9 @@ namespace rtc {
RTC_A.control(DS3231_A1_INT_ENABLE, DS3231_ON); //Alarm 1 ON RTC_A.control(DS3231_A1_INT_ENABLE, DS3231_ON); //Alarm 1 ON
RTC_A.control(DS3231_INT_ENABLE, DS3231_ON); //INTCN ON RTC_A.control(DS3231_INT_ENABLE, DS3231_ON); //INTCN ON
NOTICE_FORMAT("setAlarm", "Next alarm : %d:%d:%d", time.hour, time.minute, time.second);
tmElements_t alarmTime;
READ_ALARM_1(alarmTime);
NOTICE_FORMAT("Next alarm : %d:%d:%d", alarmTime.hour, alarmTime.minute, alarmTime.second);
hardware::i2c::powerOff(); hardware::i2c::powerOff();
} }


+ 1
- 0
src/RtcAbstraction.cpp Bestand weergeven

@@ -35,6 +35,7 @@ boolean MD_DS3231_Ext::writeTime(const tmElements_t &time) {
boolean MD_DS3231_Ext::readAlarm1(almType_t &almType, tmElements_t &time) { boolean MD_DS3231_Ext::readAlarm1(almType_t &almType, tmElements_t &time) {
almType = MD_DS3231::getAlarm1Type(); almType = MD_DS3231::getAlarm1Type();
bool result = MD_DS3231::readAlarm1(); bool result = MD_DS3231::readAlarm1();
unpack(time);
return result; return result;
} }


+ 2
- 0
src/RtcAbstraction.h Bestand weergeven

@@ -12,6 +12,7 @@
#define RTC_A_CLASS uDS3231 #define RTC_A_CLASS uDS3231
#define WRITE_ALARM_1(t) RTC_A.writeAlarm1(DS3231_ALM_HMS, t) #define WRITE_ALARM_1(t) RTC_A.writeAlarm1(DS3231_ALM_HMS, t)
#define READ_ALARM_1(t) almType_t almDummy; RTC_A.readAlarm1(almDummy, t)
#else #else
#include <MD_DS3231.h> #include <MD_DS3231.h>
@@ -39,4 +40,5 @@
#define RTC_A_CLASS MD_DS3231_Ext #define RTC_A_CLASS MD_DS3231_Ext
#define WRITE_ALARM_1(t) RTC_A.writeAlarm1(DS3231_ALM_HMS, t) #define WRITE_ALARM_1(t) RTC_A.writeAlarm1(DS3231_ALM_HMS, t)
#define READ_ALARM_1(t) almType_t almDummy; RTC_A.readAlarm1(almDummy, t)
#endif #endif

+ 10
- 7
src/SdPositionsBackup.cpp Bestand weergeven

@@ -6,10 +6,10 @@
#include "Positions.h" #include "Positions.h"
#include "Logging.h" #include "Logging.h"
#define LOGGER_NAME "Positions::backup::sd"
#if BACKUP_ENABLE_SDCARD #if BACKUP_ENABLE_SDCARD
namespace positions { namespace positions {
#define CURRENT_LOGGER "positions::backup::sd"
namespace backup { namespace backup {
namespace sd { namespace sd {
@@ -60,7 +60,8 @@ namespace positions {
} }
void appendPosition(File &file, SdPositionConfig_t &sdConfig, PositionEntry &entry) { void appendPosition(File &file, SdPositionConfig_t &sdConfig, PositionEntry &entry) {
VERBOSE("appendPosition");
#define CURRENT_LOGGER_FUNCTION "appendPosition"
VERBOSE;
const char fieldTerminator = ','; const char fieldTerminator = ',';
@@ -75,7 +76,8 @@ namespace positions {
} }
void appendPositions(SdPositionConfig_t &sdConfig) { void appendPositions(SdPositionConfig_t &sdConfig) {
VERBOSE("appendPositions");
#define CURRENT_LOGGER_FUNCTION "appendPositions"
VERBOSE;
uint16_t currentEntryIndex = sdConfig.lastSavedEntry + 1; uint16_t currentEntryIndex = sdConfig.lastSavedEntry + 1;
PositionEntry currentEntry; PositionEntry currentEntry;
@@ -95,15 +97,16 @@ namespace positions {
} }
} }
void SdPositionsBackup::setup() {
void SdPositionsBackup::setup(bool force) {
hardware::sdcard::setup(); hardware::sdcard::setup();
} }
void SdPositionsBackup::backup(bool force) { void SdPositionsBackup::backup(bool force) {
VERBOSE("backup");
#define CURRENT_LOGGER_FUNCTION "backup"
VERBOSE;
if (!hardware::sdcard::available) { if (!hardware::sdcard::available) {
VERBOSE_MSG("backup", "not available");
VERBOSE_MSG("not available");
return; return;
} }


+ 17
- 17
src/SdPositionsBackup.h Bestand weergeven

@@ -1,18 +1,18 @@
#pragma once
#include "PositionsBackup.h"
namespace positions {
namespace backup {
namespace sd {
class SdPositionsBackup : public PositionsBackup {
private:
public:
void setup();
void backup(bool force);
};
}
}
#pragma once
#include "PositionsBackup.h"
namespace positions {
namespace backup {
namespace sd {
class SdPositionsBackup : public PositionsBackup {
private:
public:
void setup(bool force);
void backup(bool force);
};
}
}
} }

+ 11
- 4
src/SdPositionsConfig.cpp Bestand weergeven

@@ -2,10 +2,11 @@
#include "SdCard.h" #include "SdCard.h"
#include "Logging.h" #include "Logging.h"
#define LOGGER_NAME "Config::backup::sd"
#if BACKUP_ENABLE_SDCARD #if BACKUP_ENABLE_SDCARD
namespace config { namespace config {
#define CURRENT_LOGGER "config::backup::sd"
namespace backup { namespace backup {
namespace sd { namespace sd {
@@ -24,14 +25,18 @@ namespace config {
} }
void read() { void read() {
VERBOSE("read");
#define CURRENT_LOGGER_FUNCTION "read"
VERBOSE;
ensureOpened(); ensureOpened();
configFile.read((void*)&value, sizeof(value)); configFile.read((void*)&value, sizeof(value));
if (value.seed != POSITIONS_CONFIG_SEED) reset(); if (value.seed != POSITIONS_CONFIG_SEED) reset();
} }
void write() { void write() {
VERBOSE("write");
#define CURRENT_LOGGER_FUNCTION "write"
VERBOSE;
ensureOpened(); ensureOpened();
configFile.write((void*)&value, sizeof(value)); configFile.write((void*)&value, sizeof(value));
} }
@@ -50,7 +55,9 @@ namespace config {
} }
void reset() { void reset() {
VERBOSE("reset");
#define CURRENT_LOGGER_FUNCTION "reset"
VERBOSE;
SdPositionConfig_t config = { SdPositionConfig_t config = {
POSITIONS_CONFIG_SEED, POSITIONS_CONFIG_SEED,
POSITIONS_CONFIG_DEFAULT_SAVE_THRESHOLD, POSITIONS_CONFIG_DEFAULT_SAVE_THRESHOLD,


+ 2
- 4
src/Time2.cpp Bestand weergeven

@@ -16,8 +16,7 @@
namespace utils { namespace utils {
namespace time { namespace time {
__attribute__((__optimize__("O2")))
timestamp_t makeTimestamp(const tmElements_t &time) {
timestamp_t makeTimestamp(const tmElements_t &time) {
timestamp_t timestamp; timestamp_t timestamp;
timestamp += (time.day - 1) * SECS_PER_DAY; timestamp += (time.day - 1) * SECS_PER_DAY;
@@ -28,8 +27,7 @@ namespace utils {
return timestamp; return timestamp;
} }
__attribute__((__optimize__("O2")))
void breakTime(timestamp_t timestamp, tmElements_t &time) {
void breakTime(timestamp_t timestamp, tmElements_t &time) {
time.year = 0; time.year = 0;
time.month = 0; time.month = 0;


+ 1
- 1
src/config/System.h Bestand weergeven

@@ -20,7 +20,7 @@
\def VERSION \def VERSION
Version string, only used for indicative purpose Version string, only used for indicative purpose
*/ */
#define VERSION "1.30"
#define VERSION "1.40"
/** /**


Laden…
Annuleren
Opslaan