@@ -2,6 +2,8 @@ | |||||
#include <Arduino.h> | #include <Arduino.h> | ||||
//#define BACKUP_ENABLE_SDCARD 1 | |||||
struct sleepTimings_t { | struct sleepTimings_t { | ||||
uint8_t speed; | uint8_t speed; | ||||
uint16_t seconds; | uint16_t seconds; | ||||
@@ -1,12 +1,10 @@ | |||||
#pragma once | #pragma once | ||||
#include <Arduino.h> | #include <Arduino.h> | ||||
#include <SoftwareSerial.h> | |||||
#include <SIM808.h> | #include <SIM808.h> | ||||
#include "Debug.h" | #include "Debug.h" | ||||
#include "Config.h" | #include "Config.h" | ||||
#include "Core.h" | #include "Core.h" | ||||
#include "SdCard.h" | |||||
#define LOGGER_NAME "GpsTracker" | #define LOGGER_NAME "GpsTracker" |
@@ -12,9 +12,7 @@ void setup() { | |||||
#endif | #endif | ||||
rtc::setup(); | rtc::setup(); | ||||
hardware::sdcard::setup(); | |||||
hardware::sim808::setup(); | hardware::sim808::setup(); | ||||
positions::setup(); | positions::setup(); | ||||
} | } | ||||
@@ -1,8 +1,15 @@ | |||||
#include "Config.h" | |||||
#include "Positions.h" | #include "Positions.h" | ||||
#if defined(BACKUP_ENABLE_SDCARD) | |||||
#define BACKUPS_ENABLED BACKUP_ENABLE_SDCARD | |||||
#endif | |||||
#ifdef BACKUP_ENABLE_SDCARD | |||||
#include "SdPositionsBackup.h" | #include "SdPositionsBackup.h" | ||||
#endif | |||||
#include "Debug.h" | #include "Debug.h" | ||||
#include "Config.h" | |||||
#include "Gps.h" | #include "Gps.h" | ||||
#include "Network.h" | #include "Network.h" | ||||
@@ -12,9 +19,9 @@ | |||||
#define ENTRIES_ADDR ENTRY_RESERVED_SIZE | #define ENTRIES_ADDR ENTRY_RESERVED_SIZE | ||||
namespace positions { | namespace positions { | ||||
#ifdef BACKUPS_ENABLED | |||||
backup::PositionsBackup **_backups; | backup::PositionsBackup **_backups; | ||||
size_t _backupLength; | |||||
#endif | |||||
namespace details { | namespace details { | ||||
uint16_t maxEntryIndex = (E24_MAX_ADDRESS(hardware::i2c::eeprom.getSize()) - ENTRIES_ADDR) / ENTRY_RESERVED_SIZE; | uint16_t maxEntryIndex = (E24_MAX_ADDRESS(hardware::i2c::eeprom.getSize()) - ENTRIES_ADDR) / ENTRY_RESERVED_SIZE; | ||||
@@ -27,11 +34,15 @@ namespace positions { | |||||
void setup() { | void setup() { | ||||
//TODO : enable/disable based on config | //TODO : enable/disable based on config | ||||
_backupLength = 1; | |||||
_backups = new backup::PositionsBackup*[_backupLength]; | |||||
_backups[0] = new backup::sd::SdPositionsBackup(); | |||||
_backups[0]->setup(); | |||||
#ifdef BACKUPS_ENABLED | |||||
uint8_t backupIdx = 0; | |||||
_backups = new backup::PositionsBackup*[BACKUPS_ENABLED]; | |||||
#ifdef BACKUP_ENABLE_SDCARD | |||||
_backups[backupIdx] = new backup::sd::SdPositionsBackup(); | |||||
_backups[backupIdx++]->setup(); | |||||
#endif | |||||
#endif | |||||
} | } | ||||
bool acquire(PositionEntryMetadata &metadata) { | bool acquire(PositionEntryMetadata &metadata) { | ||||
@@ -119,8 +130,10 @@ namespace positions { | |||||
} | } | ||||
void doBackup() { | void doBackup() { | ||||
for (int i = 0; i < _backupLength; i++) { | |||||
#ifdef BACKUPS_ENABLED | |||||
for (int i = 0; i < BACKUPS_ENABLED; i++) { | |||||
_backups[i]->backup(); | _backups[i]->backup(); | ||||
} | } | ||||
#endif | |||||
} | } | ||||
} | } |
@@ -1,3 +1,6 @@ | |||||
#include "Config.h" | |||||
#ifdef BACKUP_ENABLE_SDCARD | |||||
#include "SdCard.h" | #include "SdCard.h" | ||||
namespace hardware { | namespace hardware { | ||||
@@ -11,4 +14,5 @@ namespace hardware { | |||||
} | } | ||||
} | } | ||||
} | |||||
} | |||||
#endif |
@@ -3,12 +3,12 @@ | |||||
#include "SdCard.h" | #include "SdCard.h" | ||||
#include "Hardware.h" | #include "Hardware.h" | ||||
#include "Config.h" | #include "Config.h" | ||||
#include "SdFat.h" | |||||
#include "Positions.h" | #include "Positions.h" | ||||
#include "Debug.h" | #include "Debug.h" | ||||
#define LOGGER_NAME "Positions::backup::sd" | #define LOGGER_NAME "Positions::backup::sd" | ||||
#ifdef BACKUP_ENABLE_SDCARD | |||||
namespace positions { | namespace positions { | ||||
namespace backup { | namespace backup { | ||||
namespace sd { | namespace sd { | ||||
@@ -95,7 +95,9 @@ namespace positions { | |||||
} | } | ||||
} | } | ||||
void SdPositionsBackup::setup() { } | |||||
void SdPositionsBackup::setup() { | |||||
hardware::sdcard::setup(); | |||||
} | |||||
void SdPositionsBackup::backup() { | void SdPositionsBackup::backup() { | ||||
VERBOSE("backup"); | VERBOSE("backup"); | ||||
@@ -113,4 +115,5 @@ namespace positions { | |||||
} | } | ||||
} | } | ||||
} | |||||
} | |||||
#endif |
@@ -2,11 +2,6 @@ | |||||
#include "PositionsBackup.h" | #include "PositionsBackup.h" | ||||
#define POSITIONS_FOLDER "positions" | |||||
#define POSITIONS_FILENAME "positions-%05d.csv" | |||||
#define POSITIONS_FILENAME_LENGTH 19 | |||||
namespace positions { | namespace positions { | ||||
namespace backup { | namespace backup { | ||||
namespace sd { | namespace sd { | ||||
@@ -4,6 +4,7 @@ | |||||
#define LOGGER_NAME "Config::backup::sd" | #define LOGGER_NAME "Config::backup::sd" | ||||
#ifdef BACKUP_ENABLE_SDCARD | |||||
namespace config { | namespace config { | ||||
namespace backup { | namespace backup { | ||||
namespace sd { | namespace sd { | ||||
@@ -66,4 +67,5 @@ namespace config { | |||||
} | } | ||||
} | } | ||||
} | |||||
} | |||||
#endif |
@@ -2,6 +2,9 @@ | |||||
#include <Arduino.h> | #include <Arduino.h> | ||||
#define POSITIONS_FOLDER "positions" | |||||
#define POSITIONS_FILENAME "positions-%05d.csv" | |||||
#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_SAVE_THRESHOLD 10 | ||||