@@ -21,8 +21,8 @@ | |||||
#define GPS_DEFAULT_INTERMEDIATE_TIMEOUT_MS 10000 | #define GPS_DEFAULT_INTERMEDIATE_TIMEOUT_MS 10000 | ||||
#define GPS_DEFAULT_TOTAL_TIMEOUT_MS 180000 | #define GPS_DEFAULT_TOTAL_TIMEOUT_MS 180000 | ||||
#define NETWORK_DEFAULT_INTERMEDIATE_TIMEOUT_MS 2000 | |||||
#define NETWORK_DEFAULT_TOTAL_TIMEOUT_MS 60000 | |||||
#define NETWORK_DEFAULT_INTERMEDIATE_TIMEOUT_MS 6000 | |||||
#define NETWORK_DEFAULT_TOTAL_TIMEOUT_MS 1800000 | |||||
struct sleepTimings_t { | struct sleepTimings_t { | ||||
uint8_t speed; | uint8_t speed; | ||||
@@ -48,30 +48,25 @@ namespace positions { | |||||
PositionEntry currentEntry; | PositionEntry currentEntry; | ||||
SIM808RegistrationStatus networkStatus; | SIM808RegistrationStatus networkStatus; | ||||
hardware::i2c::powerOn(); | |||||
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)) { | |||||
VERBOSE_MSG("appendPositions", "network unavailable"); | |||||
return; | |||||
} | |||||
if (!network::enableGprs()) { | |||||
VERBOSE_MSG("appendPositions", "gprs unavailable"); | |||||
return; | |||||
} | |||||
if (!network::isAvailable(networkStatus.stat)) VERBOSE_MSG("appendPositions", "network unavailable"); | |||||
else if (!network::enableGprs()) VERBOSE_MSG("appendPositions", "gprs unavailable"); | |||||
else { | |||||
/*hardware::i2c::powerOn(); | |||||
do { | |||||
if (!positions::get(currentEntryIndex, currentEntry)) break; | |||||
if (!appendPosition(config, currentEntry)) break; | |||||
do { | |||||
if (!positions::get(currentEntryIndex, currentEntry)) break; | |||||
if (!appendPosition(config, currentEntry)) break; | |||||
config.network.lastSavedEntry = currentEntryIndex; | |||||
config::main::set(config); | |||||
config.network.lastSavedEntry = currentEntryIndex; | |||||
config::main::set(config); | |||||
} while (positions::moveNext(currentEntryIndex)); | |||||
hardware::i2c::powerOff(); */ | |||||
} | |||||
} while (positions::moveNext(currentEntryIndex)); | |||||
network::powerOff(); | network::powerOff(); | ||||
hardware::i2c::powerOff(); | |||||
} | } | ||||
} | } | ||||
@@ -41,14 +41,13 @@ namespace positions { | |||||
#if BACKUP_ENABLE_SDCARD | #if BACKUP_ENABLE_SDCARD | ||||
_backups[backupIdx] = new backup::sd::SdPositionsBackup(); | _backups[backupIdx] = new backup::sd::SdPositionsBackup(); | ||||
_backups[backupIdx++]->setup(); | |||||
_backups[backupIdx]->setup(); | |||||
backupIdx++; | |||||
#endif | #endif | ||||
#if BACKUP_ENABLE_NETWORK | #if BACKUP_ENABLE_NETWORK | ||||
_backups[backupIdx] = new backup::net::NetworkPositionsBackup(); | _backups[backupIdx] = new backup::net::NetworkPositionsBackup(); | ||||
_backups[backupIdx]->setup(); | _backups[backupIdx]->setup(); | ||||
//_backups[backupIdx]->backup(); | |||||
backupIdx++; | backupIdx++; | ||||
#endif | #endif | ||||
#endif | #endif | ||||
} | } | ||||
@@ -140,7 +139,7 @@ namespace positions { | |||||
void doBackup() { | void doBackup() { | ||||
#ifdef BACKUPS_ENABLED | #ifdef BACKUPS_ENABLED | ||||
VERBOSE_FORMAT("doBackup", "%d backups enabled", BACKUPS_ENABLED); | VERBOSE_FORMAT("doBackup", "%d backups enabled", BACKUPS_ENABLED); | ||||
Serial.println((unsigned int)_backups[0], HEX); | |||||
_backups[0]->backup(); | _backups[0]->backup(); | ||||
/*for (int i = 0; i < BACKUPS_ENABLED; i++) { | /*for (int i = 0; i < BACKUPS_ENABLED; i++) { | ||||
@@ -17,7 +17,7 @@ namespace rtc { | |||||
hardware::i2c::powerOn(); | hardware::i2c::powerOn(); | ||||
RTC.control(DS3231_12H, DS3231_OFF); //24 hours clock | RTC.control(DS3231_12H, DS3231_OFF); //24 hours clock | ||||
RTC.control(DS3231_A1_INT_ENABLE, DS3231_OFF); //Alarm 1 OFF | RTC.control(DS3231_A1_INT_ENABLE, DS3231_OFF); //Alarm 1 OFF | ||||
RTC.control(DS3231_INT_ENABLE, DS3231_ON); //INTCN OFF | |||||
RTC.control(DS3231_INT_ENABLE, DS3231_ON); //INTCN ON | |||||
hardware::i2c::powerOff(); | hardware::i2c::powerOff(); | ||||
//TODO : check wether the osc has been halted (meaning the battery could be dead) | //TODO : check wether the osc has been halted (meaning the battery could be dead) | ||||