@@ -116,19 +116,6 @@ using namespace utils; | |||||
namespace debug { | namespace debug { | ||||
#define CURRENT_LOGGER "debug" | #define CURRENT_LOGGER "debug" | ||||
namespace details { | |||||
inline void displayPosition(PositionEntry entry) { | |||||
#define CURRENT_LOGGER_FUNCTION "displayPosition" | |||||
NOTICE_FORMAT("%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); | |||||
} | |||||
} | |||||
void displayFreeRam() { | void displayFreeRam() { | ||||
#define CURRENT_LOGGER_FUNCTION "displayFreeRam" | #define CURRENT_LOGGER_FUNCTION "displayFreeRam" | ||||
NOTICE_FORMAT("%d", mainunit::freeRam()); | NOTICE_FORMAT("%d", mainunit::freeRam()); | ||||
@@ -249,27 +236,18 @@ namespace debug { | |||||
NOTICE_MSG("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() { | |||||
#define CURRENT_LOGGER_FUNCTION "getAndDisplayEepromLastPosition" | |||||
uint16_t lastEntryIndex = config::main::value.lastEntry; | |||||
PositionEntry lastEntry; | |||||
if(positions::get(lastEntryIndex, lastEntry)) details::displayPosition(lastEntry); | |||||
else NOTICE_MSG("No position recorded"); | |||||
} | |||||
void addLastPositionToEeprom() { | void addLastPositionToEeprom() { | ||||
hardware::sim808::powerOn(); | hardware::sim808::powerOn(); | ||||
SIM808ChargingStatus status = hardware::sim808::device.getChargingState(); | SIM808ChargingStatus status = hardware::sim808::device.getChargingState(); | ||||
@@ -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(); | ||||
@@ -75,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(); | ||||
@@ -116,14 +116,8 @@ namespace positions { | |||||
hardware::i2c::powerOn(); | hardware::i2c::powerOn(); | ||||
hardware::i2c::eeprom.writeBlock(entryAddress, entry); | hardware::i2c::eeprom.writeBlock(entryAddress, entry); | ||||
NOTICE_FORMAT("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"); | |||||
print(entryIndex, entry); | |||||
config->lastEntry++; | config->lastEntry++; | ||||
if (config->lastEntry > details::maxEntryIndex) config->lastEntry = 0; | if (config->lastEntry > details::maxEntryIndex) config->lastEntry = 0; | ||||
@@ -147,15 +141,7 @@ namespace positions { | |||||
hardware::i2c::eeprom.readBlock(entryAddress, entry); | hardware::i2c::eeprom.readBlock(entryAddress, entry); | ||||
hardware::i2c::powerOff(); | hardware::i2c::powerOff(); | ||||
NOTICE_FORMAT("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; | ||||
} | } | ||||
@@ -196,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); | |||||
} | |||||
} | } |
@@ -30,4 +30,6 @@ namespace positions { | |||||
void prepareBackup(); | void prepareBackup(); | ||||
void doBackup(bool force); | void doBackup(bool force); | ||||
void print(uint16_t index, PositionEntry &entry); | |||||
} | } |