瀏覽代碼

Adjusted log level : verbose is really in a case of a hard debugging session

tags/v1.2.0
Bertrand Lemasle 7 年之前
父節點
當前提交
f687c9d11a
共有 9 個檔案被更改,包括 20 行新增25 行删除
  1. +2
    -0
      GpsTracker/Config.cpp
  2. +0
    -1
      GpsTracker/Core.cpp
  3. +1
    -1
      GpsTracker/Gps.cpp
  4. +2
    -5
      GpsTracker/Hardware.cpp
  5. +1
    -1
      GpsTracker/MainUnit.cpp
  6. +2
    -1
      GpsTracker/Network.cpp
  7. +9
    -10
      GpsTracker/NetworkPositionsBackup.cpp
  8. +2
    -5
      GpsTracker/Positions.cpp
  9. +1
    -1
      GpsTracker/Rtc.cpp

+ 2
- 0
GpsTracker/Config.cpp 查看文件

@@ -13,6 +13,7 @@ namespace config {


void read() { void read() {
VERBOSE("read"); VERBOSE("read");

hardware::i2c::powerOn(); hardware::i2c::powerOn();
hardware::i2c::eeprom.readBlock(CONFIG_ADDR, value); hardware::i2c::eeprom.readBlock(CONFIG_ADDR, value);
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
@@ -53,6 +54,7 @@ namespace config {


void reset() { void reset() {
VERBOSE("reset"); VERBOSE("reset");

config_t config = { config_t config = {
CONFIG_SEED, CONFIG_SEED,
VERSION, VERSION,


+ 0
- 1
GpsTracker/Core.cpp 查看文件

@@ -11,7 +11,6 @@ namespace core {
uint8_t increaseInARow = 0; uint8_t increaseInARow = 0;


void main() { void main() {
VERBOSE("main");


PositionEntryMetadata metadata; PositionEntryMetadata metadata;
if (positions::acquire(metadata)) { if (positions::acquire(metadata)) {


+ 1
- 1
GpsTracker/Gps.cpp 查看文件

@@ -68,6 +68,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);


VERBOSE_FORMAT("getTime", "%d/%d/%d %d:%d:%d", tmYearToCalendar(time.Year), time.Month, time.Day, time.Hour, time.Minute, time.Second); NOTICE_FORMAT("getTime", "%d/%d/%d %d:%d:%d", tmYearToCalendar(time.Year), time.Month, time.Day, time.Hour, time.Minute, time.Second);
} }
} }

+ 2
- 5
GpsTracker/Hardware.cpp 查看文件

@@ -42,7 +42,7 @@ namespace hardware {
} }


void setup() { void setup() {
VERBOSE("setup"); NOTICE("setup");
simSerial.begin(SIM808_BAUDRATE); simSerial.begin(SIM808_BAUDRATE);
device.begin(simSerial); device.begin(simSerial);
powerOff(); //ensure powerOff on start powerOff(); //ensure powerOff on start
@@ -55,7 +55,7 @@ namespace hardware {
} }


void gpsPowerOff() { void gpsPowerOff() {
VERBOSE("gpsPowerOff"); NOTICE("gpsPowerOff");
device.disableGps(); device.disableGps();
powerOffIfUnused(); powerOffIfUnused();
} }
@@ -80,11 +80,8 @@ namespace hardware {
namespace i2c { namespace i2c {


E24 eeprom = E24(E24Size_t::E24_512K); E24 eeprom = E24(E24Size_t::E24_512K);

uint8_t poweredCount = 0; uint8_t poweredCount = 0;


//inline void powered() { digitalRead(I2C_PWR) == HIGH; } //TODO = replace enum with just reading the output pin ?

void powerOn() { void powerOn() {
if (!poweredCount) { if (!poweredCount) {
VERBOSE("powerOn"); VERBOSE("powerOn");


+ 1
- 1
GpsTracker/MainUnit.cpp 查看文件

@@ -17,7 +17,7 @@ namespace mainunit {
void wokeUp() { void wokeUp() {
tmElements_t wokeUpTime; tmElements_t wokeUpTime;
rtc::getTime(wokeUpTime); rtc::getTime(wokeUpTime);
NOTICE_FORMAT("wokeUp", "%d:%d:%d", wokeUpTime.Hour, wokeUpTime.Minute, wokeUpTime.Second); VERBOSE_FORMAT("wokeUp", "%d:%d:%d", wokeUpTime.Hour, wokeUpTime.Minute, wokeUpTime.Second);


hardware::sim808::simSerial.listen(); hardware::sim808::simSerial.listen();
} }


+ 2
- 1
GpsTracker/Network.cpp 查看文件

@@ -26,7 +26,7 @@ namespace network {
if (report.ssri < NETWORK_DEFAULT_NO_NETWORK_QUALIRY_THRESHOLD) noReliableNetwork++; if (report.ssri < NETWORK_DEFAULT_NO_NETWORK_QUALIRY_THRESHOLD) noReliableNetwork++;
else noReliableNetwork = 0; else noReliableNetwork = 0;
if (noReliableNetwork > NETWORK_DEFAULT_NO_NETWORK_TRIES) { if (noReliableNetwork > NETWORK_DEFAULT_NO_NETWORK_TRIES) {
VERBOSE_MSG("waitForRegistered", "No signal"); NOTICE_MSG("waitForRegistered", "No reliable signal");
break; //after a while, not network really means no network. Bailing out break; //after a while, not network really means no network. Bailing out
} }


@@ -34,6 +34,7 @@ namespace network {
timeout -= NETWORK_DEFAULT_INTERMEDIATE_TIMEOUT_MS; timeout -= NETWORK_DEFAULT_INTERMEDIATE_TIMEOUT_MS;
} while (timeout > 1); } while (timeout > 1);


NOTICE_FORMAT("waitForRegistered", "%d, [%d %ddBm]", currentStatus.stat, report.ssri, report.attenuation);
return currentStatus; return currentStatus;
} }




+ 9
- 10
GpsTracker/NetworkPositionsBackup.cpp 查看文件

@@ -25,8 +25,6 @@ namespace positions {
} }


bool appendPosition(PositionEntry &entry) { bool appendPosition(PositionEntry &entry) {
VERBOSE("appendPosition");

char buffer[BUFFER_SIZE]; char buffer[BUFFER_SIZE];
snprintf(buffer, BUFFER_SIZE, "%d,%d,%d,%d,%d,%d,", snprintf(buffer, BUFFER_SIZE, "%d,%d,%d,%d,%d,%d,",
debug::freeRam(), debug::freeRam(),
@@ -38,18 +36,20 @@ namespace positions {


strcat(buffer, entry.position); strcat(buffer, entry.position);


return hardware::sim808::device.httpPost( NOTICE_FORMAT("appendPosition", "Sending : %s", buffer);
uint16_t responseCode = hardware::sim808::device.httpPost(
config::main::value.network.url, config::main::value.network.url,
F("text/csv"), F("text/csv"),
buffer, buffer,
buffer, buffer,
BUFFER_SIZE BUFFER_SIZE
) == POSITIONS_CONFIG_NET_DEFAULT_EXPECTED_RESPONSE; ) == POSITIONS_CONFIG_NET_DEFAULT_EXPECTED_RESPONSE;

NOTICE_FORMAT("appendPosition", "Response : %d", responseCode);
return responseCode;
} }


void appendPositions() { void appendPositions() {
VERBOSE("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; SIM808RegistrationStatus networkStatus;
@@ -57,13 +57,12 @@ 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)) VERBOSE_MSG("appendPositions", "network unavailable"); if (!network::isAvailable(networkStatus.stat)) NOTICE_MSG("appendPositions", "network unavailable");
else if (!network::enableGprs()) VERBOSE_MSG("appendPositions", "gprs unavailable"); else if (!network::enableGprs()) NOTICE_MSG("appendPositions", "gprs unavailable");
else { else {
hardware::i2c::powerOn(); hardware::i2c::powerOn();
do { do {
if (!positions::get(currentEntryIndex, currentEntry)) break; if (!positions::get(currentEntryIndex, currentEntry)) break;

if (!appendPosition(currentEntry)) break; if (!appendPosition(currentEntry)) break;


config::main::value.network.lastSavedEntry = currentEntryIndex; config::main::value.network.lastSavedEntry = currentEntryIndex;
@@ -79,11 +78,11 @@ namespace positions {
} }


void NetworkPositionsBackup::setup() { void NetworkPositionsBackup::setup() {
VERBOSE("setup"); NOTICE("setup");
} }


void NetworkPositionsBackup::backup() { void NetworkPositionsBackup::backup() {
VERBOSE("backup"); NOTICE("backup");


if (!details::isBackupNeeded()) return; if (!details::isBackupNeeded()) return;
details::appendPositions(); details::appendPositions();


+ 2
- 5
GpsTracker/Positions.cpp 查看文件

@@ -64,7 +64,7 @@ namespace positions {
SIM808ChargingStatus battery = hardware::sim808::device.getChargingState(); SIM808ChargingStatus battery = hardware::sim808::device.getChargingState();
gps::powerOff(); gps::powerOff();


NOTICE_FORMAT("acquire", "status : %d", gpsStatus); NOTICE_FORMAT("acquire", "Status : %d", gpsStatus);


if (gpsStatus < SIM808_GPS_STATUS::FIX) return false; if (gpsStatus < SIM808_GPS_STATUS::FIX) return false;


@@ -124,7 +124,7 @@ namespace positions {
hardware::i2c::eeprom.readBlock(entryAddress, entry); hardware::i2c::eeprom.readBlock(entryAddress, entry);
hardware::i2c::powerOff(); hardware::i2c::powerOff();


VERBOSE_FORMAT("get", "Read from EEPROM @ %X : [%d%% @ %dmV] [%f°C] [TTF : %d, Status : %d, Position : %s]", entryAddress, entry.metadata.batteryLevel, entry.metadata.batteryVoltage, entry.metadata.temperature, entry.metadata.timeToFix, entry.metadata.status, entry.position); NOTICE_FORMAT("get", "Read from EEPROM @ %X : [%d%% @ %dmV] [%f°C] [TTF : %d, Status : %d, Position : %s]", entryAddress, entry.metadata.batteryLevel, entry.metadata.batteryVoltage, entry.metadata.temperature, entry.metadata.timeToFix, entry.metadata.status, entry.position);
return true; return true;
} }


@@ -146,10 +146,7 @@ namespace positions {


void doBackup() { void doBackup() {
#ifdef BACKUPS_ENABLED #ifdef BACKUPS_ENABLED
VERBOSE_FORMAT("doBackup", "%d backups enabled", BACKUPS_ENABLED);

for (int i = 0; i < BACKUPS_ENABLED; i++) { for (int i = 0; i < BACKUPS_ENABLED; i++) {
VERBOSE_FORMAT("doBackup", "calling backup %d", i);
_backups[i]->backup(); _backups[i]->backup();
} }
#endif #endif


+ 1
- 1
GpsTracker/Rtc.cpp 查看文件

@@ -80,7 +80,7 @@ namespace rtc {
RTC.control(DS3231_A1_INT_ENABLE, DS3231_ON); //Alarm 1 ON RTC.control(DS3231_A1_INT_ENABLE, DS3231_ON); //Alarm 1 ON
RTC.control(DS3231_INT_ENABLE, DS3231_ON); //INTCN ON RTC.control(DS3231_INT_ENABLE, DS3231_ON); //INTCN ON


VERBOSE_FORMAT("setAlarm", "Next alarm : %d:%d:%d", time.Hour, time.Minute, time.Second); NOTICE_FORMAT("setAlarm", "Next alarm : %d:%d:%d", time.Hour, time.Minute, time.Second);


hardware::i2c::powerOff(); hardware::i2c::powerOff();
} }


||||||
x
 
000:0
Loading…
取消
儲存