Ver código fonte

Adjusted log levels

tags/v1.2.0
Bertrand Lemasle 7 anos atrás
pai
commit
6a2a305cd1
10 arquivos alterados com 40 adições e 42 exclusões
  1. +1
    -0
      GpsTracker/Core.cpp
  2. +3
    -3
      GpsTracker/Debug.cpp
  3. +1
    -3
      GpsTracker/Debug.h
  4. +1
    -1
      GpsTracker/GpsTracker.ino
  5. +0
    -27
      GpsTracker/Log.cpp
  6. +18
    -0
      GpsTracker/Logging.cpp
  7. +9
    -3
      GpsTracker/Logging.h
  8. +2
    -2
      GpsTracker/MainUnit.cpp
  9. +4
    -2
      GpsTracker/Positions.cpp
  10. +1
    -1
      GpsTracker/Rtc.cpp

+ 1
- 0
GpsTracker/Core.cpp Ver arquivo

@@ -34,6 +34,7 @@ namespace core {
else increaseInARow = 0;

sleepTime = result;
NOTICE_FORMAT("updateSleepTime", "%dkmh => %d seconds", velocity, sleepTime);
}

uint16_t computeSleepTime(uint8_t velocity) {


+ 3
- 3
GpsTracker/Debug.cpp Ver arquivo

@@ -9,7 +9,7 @@

const char FAKE_GPS_ENTRY[] PROGMEM = "1,1,20170924184842.000,49.454862,1.144537,71.900,67.99,172.6,1,,1.3,2.2,1.8,,11,7,,,37,,";

MENU_ENTRY(HEADER, "-- Debug Menu --");
MENU_ENTRY(HEADER, "-- Menu --");
MENU_ENTRY(SEPARATOR, "----");

MENU_ENTRY(RUN, "[R] Run");
@@ -244,8 +244,8 @@ namespace debug {
uint16_t lastEntryIndex = config::main::value.lastEntry;
PositionEntry lastEntry;

positions::get(lastEntryIndex, lastEntry);
details::displayPosition(lastEntry);
if(positions::get(lastEntryIndex, lastEntry)) details::displayPosition(lastEntry);
else Log.notice(F("No position recorded\n"));
}

void addLastPositionToEeprom() {


+ 1
- 3
GpsTracker/Debug.h Ver arquivo

@@ -2,7 +2,7 @@

#include <Arduino.h>
#include "Config.h"
#include "Log.h"
#include "Logging.h"

#include "Core.h"

@@ -10,8 +10,6 @@
#include "Gps.h"
#include "Rtc.h"

#define DEBUG_SERIAL_SPEED 115200

namespace debug {

enum class GPSTRACKER_DEBUG_COMMAND : uint8_t {


+ 1
- 1
GpsTracker/GpsTracker.ino Ver arquivo

@@ -10,7 +10,7 @@
bool bypassMenu = false;

void setup() {
log::setup();
logging::setup();

config::main::setup();
rtc::setup();


+ 0
- 27
GpsTracker/Log.cpp Ver arquivo

@@ -1,27 +0,0 @@
#include "Log.h"

namespace log {

namespace details {

void waitForSerial() {
while (!Serial);
Serial.begin(DEBUG_SERIAL_SPEED);
}

}
void setup() {
#if _DEBUG
details::waitForSerial();
Log.begin(LOG_LEVEL_VERBOSE, &Serial);
#else
if (Serial) {
Serial.begin(DEBUG_SERIAL_SPEED);
Log.begin(LOG_LEVEL_NOTICE, &Serial);
}
#endif

if (Serial) Serial.println(F("============================="));
}

}

+ 18
- 0
GpsTracker/Logging.cpp Ver arquivo

@@ -0,0 +1,18 @@
#include "Logging.h"

namespace logging {

void setup() {
#if _DEBUG
while (!Serial);
#endif

if (Serial) {
Serial.begin(LOG_SERIAL_SPEED);
Serial.println(F("============================="));

Log.begin(LOG_LEVEL, &Serial);
}
}

}

GpsTracker/Log.h → GpsTracker/Logging.h Ver arquivo

@@ -1,9 +1,15 @@
#pragma once
#include "Config.h"

#define DISABLE_LOGGING 1
//#define DISABLE_LOGGING 1
#include <ArduinoLog.h>

#include "Config.h"
#define LOG_SERIAL_SPEED 115200
#if _DEBUG
#define LOG_LEVEL LOG_LEVEL_VERBOSE
#else
#define LOG_LEVEL LOG_LEVEL_NOTICE
#endif

#define LOG(level, f) Log.level(F("[" LOGGER_NAME "::" f "]\n"))
#define LOG_MSG(level, f, msg) Log.level(F("[" LOGGER_NAME "::" f "] " msg "\n"))
@@ -24,6 +30,6 @@
#define NOTICE_FORMAT(f, msg, ...) LOG_FORMAT(notice, f, msg, __VA_ARGS__)


namespace log {
namespace logging {
void setup();
}

+ 2
- 2
GpsTracker/MainUnit.cpp Ver arquivo

@@ -36,7 +36,7 @@ namespace mainunit {
}

void sleep(period_t period) {
NOTICE_FORMAT("sleep", "Sleeping for period : %d", period);
NOTICE_FORMAT("sleep", "Period : %d", period);
details::prepareSleep();
LowPower.powerDown(period, ADC_OFF, BOD_OFF);
details::wokeUp();
@@ -44,7 +44,7 @@ namespace mainunit {
}

void deepSleep(uint16_t seconds) {
NOTICE_FORMAT("deepSleep", "Deep sleeping for %d seconds", seconds);
NOTICE_FORMAT("deepSleep", "%d seconds", seconds);
interruptIn(seconds);
details::prepareSleep();
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);


+ 4
- 2
GpsTracker/Positions.cpp Ver arquivo

@@ -53,7 +53,7 @@ namespace positions {
}

bool acquire(PositionEntryMetadata &metadata) {
VERBOSE("acquire");
NOTICE("acquire");

timestamp_t before;

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

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

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

uint16_t timeToFix = rtc::getTime() - before;
@@ -98,7 +100,7 @@ namespace positions {
hardware::i2c::powerOn();
hardware::i2c::eeprom.writeBlock(entryAddress, entry);

VERBOSE_FORMAT("appendLast", "Written to 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("appendLast", "Saved @ %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);

config->lastEntry++;
if (config->lastEntry > details::maxEntryIndex) config->lastEntry = 0;


+ 1
- 1
GpsTracker/Rtc.cpp Ver arquivo

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

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

hardware::i2c::powerOff();
}


Carregando…
Cancelar
Salvar