@@ -1,6 +1,10 @@ | |||
#include "Core.h" | |||
#include "Config.h" | |||
#include "Flash.h" | |||
#include "MainUnit.h" | |||
#include "Gps.h" | |||
#include "Network.h" | |||
#include "Rtc.h" | |||
#include "Alerts.h" | |||
#include "Logging.h" | |||
@@ -1,11 +1,6 @@ | |||
#pragma once | |||
#include <Arduino.h> | |||
#include "Gps.h" | |||
#include "MainUnit.h" | |||
#include "Network.h" | |||
#include "Rtc.h" | |||
#include "Positions.h" | |||
enum class TRACKER_MOVING_STATE : uint8_t { | |||
@@ -1,5 +1,8 @@ | |||
#include "Debug.h" | |||
#include "MainUnit.h" | |||
#include "Hardware.h" | |||
#include "Gps.h" | |||
#include "Rtc.h" | |||
#include "Flash.h" | |||
#include "Positions.h" | |||
#include "Core.h" | |||
@@ -1,25 +1,26 @@ | |||
#pragma once | |||
#include <SIM808.h> | |||
#include "Hardware.h" | |||
#include "Time2.h" | |||
#define GPS_POSITION_SIZE 128 | |||
namespace gps { | |||
extern char lastPosition[GPS_POSITION_SIZE]; | |||
extern SIM808_GPS_STATUS lastStatus; | |||
inline void powerOn() { hardware::sim808::gpsPowerOn(); } | |||
inline void powerOff() { hardware::sim808::gpsPowerOff(); } | |||
SIM808_GPS_STATUS acquireCurrentPosition(int32_t timeout); | |||
uint8_t getVelocity(); | |||
float getDistanceFromPrevious(); | |||
void getTime(tmElements_t &time); | |||
void preserveCurrentCoordinates(); | |||
#pragma once | |||
#include <Arduino.h> | |||
#include <SIM808_Types.h> | |||
#include "Hardware.h" | |||
#include "Time2.h" | |||
#define GPS_POSITION_SIZE 128 | |||
namespace gps { | |||
extern char lastPosition[GPS_POSITION_SIZE]; | |||
extern SIM808_GPS_STATUS lastStatus; | |||
inline void powerOn() { hardware::sim808::gpsPowerOn(); } | |||
inline void powerOff() { hardware::sim808::gpsPowerOff(); } | |||
SIM808_GPS_STATUS acquireCurrentPosition(int32_t timeout); | |||
uint8_t getVelocity(); | |||
float getDistanceFromPrevious(); | |||
void getTime(tmElements_t &time); | |||
void preserveCurrentCoordinates(); | |||
} |
@@ -2,6 +2,9 @@ | |||
#include <SIM808.h> | |||
#include "Debug.h" | |||
#include "MainUnit.h" | |||
#include "Hardware.h" | |||
#include "Gps.h" | |||
#include "Config.h" | |||
#include "Core.h" | |||
#include "Positions.h" | |||
@@ -1,8 +1,9 @@ | |||
#pragma once | |||
#include "config/Hardware.h" | |||
#include <Arduino.h> | |||
#include <SIM808.h> | |||
#include <E24.h> | |||
#include "config/Hardware.h" | |||
namespace hardware { | |||
@@ -1,35 +1,35 @@ | |||
#pragma once | |||
#include "Config.h" | |||
//#define DISABLE_LOGGING 1 | |||
#include <ArduinoLog.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")) | |||
#define LOG_FORMAT(level, f, msg, ...) Log.level(F("[" LOGGER_NAME "::" f "] " msg "\n"), __VA_ARGS__) | |||
#if _DEBUG | |||
#define VERBOSE(f) LOG(verbose, f) | |||
#define VERBOSE_MSG(f, msg) LOG_MSG(verbose, f, msg) | |||
#define VERBOSE_FORMAT(f, msg, ...) LOG_FORMAT(verbose, f, msg, __VA_ARGS__) | |||
#else | |||
#define VERBOSE(f) | |||
#define VERBOSE_MSG(f, msg) | |||
#define VERBOSE_FORMAT(f, msg, ...) | |||
#endif | |||
#define NOTICE(f) LOG(notice, f) | |||
#define NOTICE_MSG(f, msg) LOG_MSG(notice, f, msg) | |||
#define NOTICE_FORMAT(f, msg, ...) LOG_FORMAT(notice, f, msg, __VA_ARGS__) | |||
namespace logging { | |||
void setup(); | |||
#pragma once | |||
//#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")) | |||
#define LOG_FORMAT(level, f, msg, ...) Log.level(F("[" LOGGER_NAME "::" f "] " msg "\n"), __VA_ARGS__) | |||
#if _DEBUG | |||
#define VERBOSE(f) LOG(verbose, f) | |||
#define VERBOSE_MSG(f, msg) LOG_MSG(verbose, f, msg) | |||
#define VERBOSE_FORMAT(f, msg, ...) LOG_FORMAT(verbose, f, msg, __VA_ARGS__) | |||
#else | |||
#define VERBOSE(f) | |||
#define VERBOSE_MSG(f, msg) | |||
#define VERBOSE_FORMAT(f, msg, ...) | |||
#endif | |||
#define NOTICE(f) LOG(notice, f) | |||
#define NOTICE_MSG(f, msg) LOG_MSG(notice, f, msg) | |||
#define NOTICE_FORMAT(f, msg, ...) LOG_FORMAT(notice, f, msg, __VA_ARGS__) | |||
namespace logging { | |||
void setup(); | |||
} |
@@ -1,15 +1,16 @@ | |||
#pragma once | |||
#include "Hardware.h" | |||
namespace network { | |||
void powerOn(); | |||
void powerOff(); | |||
SIM808RegistrationStatus waitForRegistered(uint32_t timeout, bool relativeToPowerOnTime = true); | |||
bool isAvailable(SIM808_NETWORK_REGISTRATION_STATE state); | |||
bool enableGprs(); | |||
bool sendSms(const char * msg); | |||
#pragma once | |||
#include <Arduino.h> | |||
#include "Hardware.h" | |||
namespace network { | |||
void powerOn(); | |||
void powerOff(); | |||
SIM808RegistrationStatus waitForRegistered(uint32_t timeout, bool relativeToPowerOnTime = true); | |||
bool isAvailable(SIM808_NETWORK_REGISTRATION_STATE state); | |||
bool enableGprs(); | |||
bool sendSms(const char * msg); | |||
} |
@@ -1,7 +1,6 @@ | |||
#pragma once | |||
#include "PositionsBackup.h" | |||
#include "Time2.h" | |||
#include "Positions.h" | |||
namespace positions { | |||
@@ -1,32 +1,33 @@ | |||
#pragma once | |||
#include <SIM808_Types.h> | |||
#define POSITION_SIZE 115 | |||
struct PositionEntryMetadata { | |||
int8_t batteryLevel; //sizeof = 1 | |||
int16_t batteryVoltage; //sizeof = 2 | |||
int16_t temperature; //sizeof = 2 | |||
uint16_t timeToFix; //sizeof = 2 | |||
SIM808_GPS_STATUS status; //sizeof = 1 | |||
}; //sizeof = 8 | |||
struct PositionEntry { | |||
PositionEntryMetadata metadata; //sizeof = 8 | |||
char position[POSITION_SIZE]; //sizeof = 115 | |||
}; //sizeof = 123 | |||
namespace positions { | |||
void setup(); | |||
bool acquire(PositionEntryMetadata &metadata); | |||
void appendLast(const PositionEntryMetadata &metadata); | |||
bool get(uint16_t index, PositionEntry &entry); | |||
bool moveNext(uint16_t &index); | |||
uint16_t count(uint16_t fromIndex); | |||
void prepareBackup(); | |||
void doBackup(bool force); | |||
#pragma once | |||
#include <Arduino.h> | |||
#include <SIM808_Types.h> | |||
#define POSITION_SIZE 115 | |||
struct PositionEntryMetadata { | |||
int8_t batteryLevel; //sizeof = 1 | |||
int16_t batteryVoltage; //sizeof = 2 | |||
int16_t temperature; //sizeof = 2 | |||
uint16_t timeToFix; //sizeof = 2 | |||
SIM808_GPS_STATUS status; //sizeof = 1 | |||
}; //sizeof = 8 | |||
struct PositionEntry { | |||
PositionEntryMetadata metadata; //sizeof = 8 | |||
char position[POSITION_SIZE]; //sizeof = 115 | |||
}; //sizeof = 123 | |||
namespace positions { | |||
void setup(); | |||
bool acquire(PositionEntryMetadata &metadata); | |||
void appendLast(const PositionEntryMetadata &metadata); | |||
bool get(uint16_t index, PositionEntry &entry); | |||
bool moveNext(uint16_t &index); | |||
uint16_t count(uint16_t fromIndex); | |||
void prepareBackup(); | |||
void doBackup(bool force); | |||
} |
@@ -1,17 +1,18 @@ | |||
#pragma once | |||
#include "Time2.h" | |||
namespace rtc { | |||
void setup(); | |||
int16_t getTemperature(); | |||
bool isAccurate(); | |||
timestamp_t getTime(); | |||
void getTime(tmElements_t &time); | |||
void setTime(const tmElements_t &time); | |||
void setAlarm(uint16_t seconds); | |||
void setAlarm(const tmElements_t &time); | |||
#pragma once | |||
#include <Arduino.h> | |||
#include "Time2.h" | |||
namespace rtc { | |||
void setup(); | |||
int16_t getTemperature(); | |||
bool isAccurate(); | |||
timestamp_t getTime(); | |||
void getTime(tmElements_t &time); | |||
void setTime(const tmElements_t &time); | |||
void setAlarm(uint16_t seconds); | |||
void setAlarm(const tmElements_t &time); | |||
} |
@@ -1,35 +1,28 @@ | |||
#pragma once | |||
#include <Arduino.h> | |||
#define POSITIONS_FOLDER "positions" | |||
#define POSITIONS_FILENAME "positions-%05d.csv" | |||
#define POSITIONS_FILENAME_LENGTH 19 | |||
#define POSITIONS_CONFIG_FILENAME "positions.config" | |||
#define POSITIONS_CONFIG_SEED 45 | |||
#define POSITIONS_CONFIG_DEFAULT_SAVE_THRESHOLD 10 | |||
#define POSITIONS_CONFIG_DEFAULT_MAX_RECORDS_PER_FILE 5 | |||
struct SdPositionConfig_t { | |||
uint8_t seed; | |||
uint8_t saveThreshold; | |||
uint8_t maxRecordsPerFile; | |||
uint16_t lastSavedEntry; | |||
uint16_t fileIndex; | |||
uint32_t filePosition; | |||
size_t fileRecords; | |||
}; | |||
namespace config { | |||
namespace backup { | |||
namespace sd { | |||
void setup(); | |||
SdPositionConfig_t get(); | |||
void set(SdPositionConfig_t config); | |||
void reset(); | |||
} | |||
} | |||
#pragma once | |||
#include <Arduino.h> | |||
#include "config/BackupSd.h" | |||
struct SdPositionConfig_t { | |||
uint8_t seed; | |||
uint8_t saveThreshold; | |||
uint8_t maxRecordsPerFile; | |||
uint16_t lastSavedEntry; | |||
uint16_t fileIndex; | |||
uint32_t filePosition; | |||
size_t fileRecords; | |||
}; | |||
namespace config { | |||
namespace backup { | |||
namespace sd { | |||
void setup(); | |||
SdPositionConfig_t get(); | |||
void set(SdPositionConfig_t config); | |||
void reset(); | |||
} | |||
} | |||
} |
@@ -1,12 +1,12 @@ | |||
#pragma once | |||
#include <Arduino.h> | |||
#include <uDS3231.h> | |||
namespace utils { | |||
namespace time { | |||
void breakTime(const timestamp_t time, tmElements_t &tm); | |||
timestamp_t makeTimestamp(const tmElements_t &tm); | |||
} | |||
} | |||
#pragma once | |||
#include <Arduino.h> | |||
#include <uDS3231.h> | |||
namespace utils { | |||
namespace time { | |||
void breakTime(const timestamp_t time, tmElements_t &tm); | |||
timestamp_t makeTimestamp(const tmElements_t &tm); | |||
} | |||
} |
@@ -1 +1,9 @@ | |||
#pragma once | |||
#pragma once | |||
#define POSITIONS_FOLDER "positions" | |||
#define POSITIONS_FILENAME "positions-%05d.csv" | |||
#define POSITIONS_FILENAME_LENGTH 19 | |||
#define POSITIONS_CONFIG_FILENAME "positions.config" | |||
#define POSITIONS_CONFIG_SEED 45 | |||
#define POSITIONS_CONFIG_DEFAULT_SAVE_THRESHOLD 10 | |||
#define POSITIONS_CONFIG_DEFAULT_MAX_RECORDS_PER_FILE 5 |