@@ -20,14 +20,21 @@ namespace config { | |||||
NOTICE_FORMAT("read", "%d, %s, %d, %d", value.seed, value.version, value.firstEntry, value.lastEntry); | NOTICE_FORMAT("read", "%d, %s, %d, %d", value.seed, value.version, value.firstEntry, value.lastEntry); | ||||
#if BACKUP_ENABLE_NETWORK | #if BACKUP_ENABLE_NETWORK | ||||
VERBOSE_FORMAT("read", "%d, %d, %s, %s", value.network.saveThreshold, value.network.lastSavedEntry, value.network.apn, value.network.url); | NOTICE_FORMAT("read", "%d, %d, %s, %s", value.network.saveThreshold, value.network.lastSavedEntry, value.network.apn, value.network.url); | ||||
//networkConfig_t c = { | |||||
// POSITIONS_CONFIG_NET_DEFAULT_SAVE_THRESHOLD, | |||||
// 0xFFFF, | |||||
// POSITIONS_CONFIG_NET_DEFAULT_APN, | |||||
// POSITIONS_CONFIG_NET_DEFAULT_URL, | |||||
//}; | |||||
//value.network = c; | |||||
#endif | #endif | ||||
} | } | ||||
void write() { | void write() { | ||||
NOTICE_FORMAT("write", "%d, %s, %d, %d", value.seed, value.version, value.firstEntry, value.lastEntry); | NOTICE_FORMAT("write", "%d, %s, %d, %d", value.seed, value.version, value.firstEntry, value.lastEntry); | ||||
#if BACKUP_ENABLE_NETWORK | #if BACKUP_ENABLE_NETWORK | ||||
VERBOSE_FORMAT("write", "%d, %d, %s, %s", value.network.saveThreshold, value.network.lastSavedEntry, value.network.apn, value.network.url); | NOTICE_FORMAT("write", "%d, %d, %s, %s", value.network.saveThreshold, value.network.lastSavedEntry, value.network.apn, value.network.url); | ||||
#endif | #endif | ||||
hardware::i2c::powerOn(); | hardware::i2c::powerOn(); | ||||
int written = hardware::i2c::eeprom.writeBlock(CONFIG_ADDR, value); | int written = hardware::i2c::eeprom.writeBlock(CONFIG_ADDR, value); | ||||
@@ -37,6 +44,7 @@ namespace config { | |||||
void setup() { | void setup() { | ||||
details::read(); | details::read(); | ||||
//details::write(); | |||||
} | } | ||||
void save() { | void save() { | ||||
@@ -3,7 +3,7 @@ | |||||
#include <Arduino.h> | #include <Arduino.h> | ||||
#define BACKUP_ENABLE_SDCARD 0 | #define BACKUP_ENABLE_SDCARD 0 | ||||
#define BACKUP_ENABLE_NETWORK 0 | #define BACKUP_ENABLE_NETWORK 1 | ||||
#if BACKUP_ENABLE_NETWORK | #if BACKUP_ENABLE_NETWORK | ||||
#include "NetworkPositionsConfig.h" | #include "NetworkPositionsConfig.h" | ||||
@@ -26,7 +26,6 @@ namespace positions { | |||||
bool appendPosition(PositionEntry &entry) { | bool appendPosition(PositionEntry &entry) { | ||||
VERBOSE("appendPosition"); | VERBOSE("appendPosition"); | ||||
debug::displayFreeRam(); | |||||
char buffer[BUFFER_SIZE]; | char buffer[BUFFER_SIZE]; | ||||
snprintf(buffer, BUFFER_SIZE, "%d,%d,%d,%d,", | snprintf(buffer, BUFFER_SIZE, "%d,%d,%d,%d,", | ||||
@@ -36,7 +35,6 @@ namespace positions { | |||||
static_cast<uint8_t>(entry.metadata.status)); | static_cast<uint8_t>(entry.metadata.status)); | ||||
strcat(buffer, entry.position); | strcat(buffer, entry.position); | ||||
debug::displayFreeRam(); | |||||
return hardware::sim808::device.httpPost( | return hardware::sim808::device.httpPost( | ||||
config::main::value.network.url, | config::main::value.network.url, | ||||
@@ -49,7 +47,6 @@ namespace positions { | |||||
void appendPositions() { | void appendPositions() { | ||||
VERBOSE("appendPositions"); | VERBOSE("appendPositions"); | ||||
debug::displayFreeRam(); | |||||
uint16_t currentEntryIndex = config::main::value.network.lastSavedEntry + 1; | uint16_t currentEntryIndex = config::main::value.network.lastSavedEntry + 1; | ||||
PositionEntry currentEntry; | PositionEntry currentEntry; | ||||
@@ -64,7 +61,6 @@ namespace positions { | |||||
hardware::i2c::powerOn(); | hardware::i2c::powerOn(); | ||||
do { | do { | ||||
if (!positions::get(currentEntryIndex, currentEntry)) break; | if (!positions::get(currentEntryIndex, currentEntry)) break; | ||||
debug::displayFreeRam(); | |||||
if (!appendPosition(currentEntry)) break; | if (!appendPosition(currentEntry)) break; | ||||
@@ -72,12 +68,10 @@ namespace positions { | |||||
config::main::save(); | config::main::save(); | ||||
} while (positions::moveNext(currentEntryIndex)); | } while (positions::moveNext(currentEntryIndex)); | ||||
debug::displayFreeRam(); | |||||
hardware::i2c::powerOff(); | hardware::i2c::powerOff(); | ||||
} | } | ||||
network::powerOff(); | network::powerOff(); | ||||
debug::displayFreeRam(); | |||||
} | } | ||||
} | } | ||||
@@ -88,11 +82,8 @@ namespace positions { | |||||
void NetworkPositionsBackup::backup() { | void NetworkPositionsBackup::backup() { | ||||
VERBOSE("backup"); | VERBOSE("backup"); | ||||
debug::displayFreeRam(); | |||||
if (!details::isBackupNeeded()) return; | if (!details::isBackupNeeded()) return; | ||||
debug::displayFreeRam(); | |||||
details::appendPositions(); | details::appendPositions(); | ||||
} | } | ||||
} | } | ||||
@@ -113,6 +113,8 @@ namespace positions { | |||||
} | } | ||||
bool get(uint16_t index, PositionEntry &entry) { | bool get(uint16_t index, PositionEntry &entry) { | ||||
VERBOSE("get"); | |||||
uint16_t entryAddress = details::getEntryAddress(index); | uint16_t entryAddress = details::getEntryAddress(index); | ||||
if (entryAddress == -1) return false; | if (entryAddress == -1) return false; | ||||
@@ -144,15 +146,12 @@ namespace positions { | |||||
void doBackup() { | void doBackup() { | ||||
#ifdef BACKUPS_ENABLED | #ifdef BACKUPS_ENABLED | ||||
debug::displayFreeRam(); | |||||
VERBOSE_FORMAT("doBackup", "%d backups enabled", BACKUPS_ENABLED); | VERBOSE_FORMAT("doBackup", "%d backups enabled", BACKUPS_ENABLED); | ||||
//_backups[0]->backup(); //disabled for first real running test | for (int i = 0; i < BACKUPS_ENABLED; i++) { | ||||
debug::displayFreeRam(); | |||||
/*for (int i = 0; i < BACKUPS_ENABLED; i++) { | |||||
VERBOSE_FORMAT("doBackup", "calling backup %d", i); | VERBOSE_FORMAT("doBackup", "calling backup %d", i); | ||||
delay(1000); | |||||
_backups[i]->backup(); | _backups[i]->backup(); | ||||
}*/ | } | ||||
#endif | #endif | ||||
} | } | ||||
} | } |