mirror of
https://github.com/lora-aprs/LoRa_APRS_iGate.git
synced 2025-12-06 07:42:00 +01:00
Merge branch 'master' into master
This commit is contained in:
commit
7e2993cf19
|
|
@ -50,7 +50,7 @@
|
||||||
"spreading_factor": 12,
|
"spreading_factor": 12,
|
||||||
"signal_bandwidth": 125000,
|
"signal_bandwidth": 125000,
|
||||||
"coding_rate4": 5,
|
"coding_rate4": 5,
|
||||||
"txok": true
|
"tx_enable": false
|
||||||
},
|
},
|
||||||
"display": {
|
"display": {
|
||||||
"always_on": true,
|
"always_on": true,
|
||||||
|
|
@ -75,5 +75,10 @@
|
||||||
"password": "",
|
"password": "",
|
||||||
"topic": "LoraAPRS/Data"
|
"topic": "LoraAPRS/Data"
|
||||||
},
|
},
|
||||||
|
"syslog": {
|
||||||
|
"active": true,
|
||||||
|
"server": "syslog.lora-aprs.info",
|
||||||
|
"port": 514
|
||||||
|
},
|
||||||
"ntp_server": "pool.ntp.org"
|
"ntp_server": "pool.ntp.org"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,34 +8,32 @@ void APRS_IS::setup(const String &user, const String &passcode, const String &to
|
||||||
_version = version;
|
_version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APRS_IS::connect(const String &server, const int port) {
|
APRS_IS::ConnectionStatus APRS_IS::connect(const String &server, const int port) {
|
||||||
const String login = "user " + _user + " pass " + _passcode + " vers " + _tool_name + " " + _version + "\n\r";
|
const String login = "user " + _user + " pass " + _passcode + " vers " + _tool_name + " " + _version + "\n\r";
|
||||||
return _connect(server, port, login);
|
return _connect(server, port, login);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APRS_IS::connect(const String &server, const int port, const String &filter) {
|
APRS_IS::ConnectionStatus APRS_IS::connect(const String &server, const int port, const String &filter) {
|
||||||
const String login = "user " + _user + " pass " + _passcode + " vers " + _tool_name + " " + _version + " filter " + filter + "\n\r";
|
const String login = "user " + _user + " pass " + _passcode + " vers " + _tool_name + " " + _version + " filter " + filter + "\n\r";
|
||||||
return _connect(server, port, login);
|
return _connect(server, port, login);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APRS_IS::_connect(const String &server, const int port, const String &login_line) {
|
APRS_IS::ConnectionStatus APRS_IS::_connect(const String &server, const int port, const String &login_line) {
|
||||||
if (!_client.connect(server.c_str(), port)) {
|
if (!_client.connect(server.c_str(), port)) {
|
||||||
logPrintlnE("Something went wrong on connecting! Is the server reachable?");
|
return ERROR_CONNECTION;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
sendMessage(login_line);
|
sendMessage(login_line);
|
||||||
while (true) {
|
while (true) {
|
||||||
String line = _client.readStringUntil('\n');
|
String line = _client.readStringUntil('\n');
|
||||||
if (line.indexOf("logresp") != -1) {
|
if (line.indexOf("logresp") != -1) {
|
||||||
if (line.indexOf("unverified") == -1) {
|
if (line.indexOf("unverified") == -1) {
|
||||||
return true;
|
return SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
logPrintlnE("User can not be verified with passcode!");
|
return ERROR_PASSCODE;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APRS_IS::connected() {
|
bool APRS_IS::connected() {
|
||||||
|
|
@ -76,7 +74,6 @@ std::shared_ptr<APRSMessage> APRS_IS::getAPRSMessage() {
|
||||||
line = _client.readStringUntil('\n');
|
line = _client.readStringUntil('\n');
|
||||||
}
|
}
|
||||||
if (line.startsWith("#")) {
|
if (line.startsWith("#")) {
|
||||||
logPrintlnD(line);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (line.length() == 0) {
|
if (line.length() == 0) {
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,16 @@ class APRS_IS {
|
||||||
public:
|
public:
|
||||||
void setup(const String &user, const String &passcode, const String &tool_name, const String &version);
|
void setup(const String &user, const String &passcode, const String &tool_name, const String &version);
|
||||||
|
|
||||||
bool connect(const String &server, const int port);
|
enum ConnectionStatus
|
||||||
bool connect(const String &server, const int port, const String &filter);
|
{
|
||||||
bool connected();
|
SUCCESS,
|
||||||
|
ERROR_CONNECTION,
|
||||||
|
ERROR_PASSCODE,
|
||||||
|
};
|
||||||
|
|
||||||
|
ConnectionStatus connect(const String &server, const int port);
|
||||||
|
ConnectionStatus connect(const String &server, const int port, const String &filter);
|
||||||
|
bool connected();
|
||||||
|
|
||||||
bool sendMessage(const String &message);
|
bool sendMessage(const String &message);
|
||||||
bool sendMessage(const std::shared_ptr<APRSMessage> message);
|
bool sendMessage(const std::shared_ptr<APRSMessage> message);
|
||||||
|
|
@ -28,7 +35,7 @@ private:
|
||||||
String _version;
|
String _version;
|
||||||
WiFiClient _client;
|
WiFiClient _client;
|
||||||
|
|
||||||
bool _connect(const String &server, const int port, const String &login_line);
|
ConnectionStatus _connect(const String &server, const int port, const String &login_line);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
#include <logger.h>
|
#include <logger.h>
|
||||||
#include <power_management.h>
|
#include <power_management.h>
|
||||||
|
|
||||||
|
#define MODULE_NAME "BoardFinder"
|
||||||
|
|
||||||
BoardConfig::BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t oledscl, uint8_t oledaddr, uint8_t oledreset, uint8_t lorasck, uint8_t loramiso, uint8_t loramosi, uint8_t loracs, uint8_t lorareset, uint8_t lorairq, uint8_t gpsrx, uint8_t gpstx, bool needcheckpowerchip, bool powercheckstatus)
|
BoardConfig::BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t oledscl, uint8_t oledaddr, uint8_t oledreset, uint8_t lorasck, uint8_t loramiso, uint8_t loramosi, uint8_t loracs, uint8_t lorareset, uint8_t lorairq, uint8_t gpsrx, uint8_t gpstx, bool needcheckpowerchip, bool powercheckstatus)
|
||||||
: Name(name), Type(type), OledSda(oledsda), OledScl(oledscl), OledAddr(oledaddr), OledReset(oledreset), LoraSck(lorasck), LoraMiso(loramiso), LoraMosi(loramosi), LoraCS(loracs), LoraReset(lorareset), LoraIRQ(lorairq), GpsRx(gpsrx), GpsTx(gpstx), needCheckPowerChip(needcheckpowerchip), powerCheckStatus(powercheckstatus) {
|
: Name(name), Type(type), OledSda(oledsda), OledScl(oledscl), OledAddr(oledaddr), OledReset(oledreset), LoraSck(lorasck), LoraMiso(loramiso), LoraMosi(loramosi), LoraCS(loracs), LoraReset(lorareset), LoraIRQ(lorairq), GpsRx(gpsrx), GpsTx(gpstx), needCheckPowerChip(needcheckpowerchip), powerCheckStatus(powercheckstatus) {
|
||||||
}
|
}
|
||||||
|
|
@ -9,12 +11,12 @@ BoardConfig::BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t o
|
||||||
BoardFinder::BoardFinder(const std::list<BoardConfig const *> &boardConfigs) : _boardConfigs(boardConfigs) {
|
BoardFinder::BoardFinder(const std::list<BoardConfig const *> &boardConfigs) : _boardConfigs(boardConfigs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BoardConfig const *BoardFinder::searchBoardConfig() {
|
BoardConfig const *BoardFinder::searchBoardConfig(logging::Logger &logger) {
|
||||||
logPrintlnI("looking for a board config.");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "looking for a board config.");
|
||||||
logPrintlnI("searching for OLED...");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "searching for OLED...");
|
||||||
|
|
||||||
for (BoardConfig const *boardconf : _boardConfigs) {
|
for (BoardConfig const *boardconf : _boardConfigs) {
|
||||||
if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf) == boardconf->powerCheckStatus) {
|
if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf, logger) == boardconf->powerCheckStatus) {
|
||||||
PowerManagement powerManagement;
|
PowerManagement powerManagement;
|
||||||
Wire.begin(boardconf->OledSda, boardconf->OledScl);
|
Wire.begin(boardconf->OledSda, boardconf->OledScl);
|
||||||
powerManagement.begin(Wire);
|
powerManagement.begin(Wire);
|
||||||
|
|
@ -22,30 +24,28 @@ BoardConfig const *BoardFinder::searchBoardConfig() {
|
||||||
} else if (boardconf->needCheckPowerChip) {
|
} else if (boardconf->needCheckPowerChip) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (checkOledConfig(boardconf)) {
|
if (checkOledConfig(boardconf, logger)) {
|
||||||
logPrintI("found a board config: ");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "found a board config: %s", boardconf->Name.c_str());
|
||||||
logPrintlnI(boardconf->Name);
|
|
||||||
return boardconf;
|
return boardconf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logPrintlnI("could not find OLED, will search for the modem now...");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "could not find OLED, will search for the modem now...");
|
||||||
|
|
||||||
for (BoardConfig const *boardconf : _boardConfigs) {
|
for (BoardConfig const *boardconf : _boardConfigs) {
|
||||||
if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf) == boardconf->powerCheckStatus) {
|
if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf, logger) == boardconf->powerCheckStatus) {
|
||||||
PowerManagement powerManagement;
|
PowerManagement powerManagement;
|
||||||
Wire.begin(boardconf->OledSda, boardconf->OledScl);
|
Wire.begin(boardconf->OledSda, boardconf->OledScl);
|
||||||
powerManagement.begin(Wire);
|
powerManagement.begin(Wire);
|
||||||
powerManagement.activateLoRa();
|
powerManagement.activateLoRa();
|
||||||
}
|
}
|
||||||
if (checkModemConfig(boardconf)) {
|
if (checkModemConfig(boardconf)) {
|
||||||
logPrintI("found a board config: ");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "found a board config: %s", boardconf->Name.c_str());
|
||||||
logPrintlnI(boardconf->Name);
|
|
||||||
return boardconf;
|
return boardconf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logPrintlnE("could not find a board config!");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, MODULE_NAME, "could not find a board config!");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -60,7 +60,7 @@ BoardConfig const *BoardFinder::getBoardConfig(String name) {
|
||||||
return *elem;
|
return *elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoardFinder::checkOledConfig(BoardConfig const *boardConfig) {
|
bool BoardFinder::checkOledConfig(BoardConfig const *boardConfig, logging::Logger &logger) {
|
||||||
if (boardConfig->OledReset > 0) {
|
if (boardConfig->OledReset > 0) {
|
||||||
pinMode(boardConfig->OledReset, OUTPUT);
|
pinMode(boardConfig->OledReset, OUTPUT);
|
||||||
digitalWrite(boardConfig->OledReset, HIGH);
|
digitalWrite(boardConfig->OledReset, HIGH);
|
||||||
|
|
@ -70,7 +70,7 @@ bool BoardFinder::checkOledConfig(BoardConfig const *boardConfig) {
|
||||||
digitalWrite(boardConfig->OledReset, HIGH);
|
digitalWrite(boardConfig->OledReset, HIGH);
|
||||||
}
|
}
|
||||||
if (!Wire.begin(boardConfig->OledSda, boardConfig->OledScl)) {
|
if (!Wire.begin(boardConfig->OledSda, boardConfig->OledScl)) {
|
||||||
logPrintlnW("issue with wire");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, MODULE_NAME, "issue with wire");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Wire.beginTransmission(boardConfig->OledAddr);
|
Wire.beginTransmission(boardConfig->OledAddr);
|
||||||
|
|
@ -107,9 +107,9 @@ bool BoardFinder::checkModemConfig(BoardConfig const *boardConfig) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoardFinder::checkPowerConfig(BoardConfig const *boardConfig) {
|
bool BoardFinder::checkPowerConfig(BoardConfig const *boardConfig, logging::Logger &logger) {
|
||||||
if (!Wire.begin(boardConfig->OledSda, boardConfig->OledScl)) {
|
if (!Wire.begin(boardConfig->OledSda, boardConfig->OledScl)) {
|
||||||
logPrintlnW("issue with wire");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, MODULE_NAME, "issue with wire");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Wire.beginTransmission(0x34);
|
Wire.beginTransmission(0x34);
|
||||||
|
|
@ -120,12 +120,12 @@ bool BoardFinder::checkPowerConfig(BoardConfig const *boardConfig) {
|
||||||
int response = Wire.read();
|
int response = Wire.read();
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
|
|
||||||
logPrintlnD(String(response));
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, MODULE_NAME, "wire response: %d", response);
|
||||||
if (response == 0x03) {
|
if (response == 0x03) {
|
||||||
logPrintlnD("power chip found!");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, MODULE_NAME, "power chip found!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
logPrintlnD("power chip NOT found");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, MODULE_NAME, "power chip NOT found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
|
#include <logger.h>
|
||||||
|
|
||||||
enum BoardType
|
enum BoardType
|
||||||
{
|
{
|
||||||
eHELTEC_WIFI_LORA_32_V1,
|
eHELTEC_WIFI_LORA_32_V1,
|
||||||
|
|
@ -49,16 +51,16 @@ class BoardFinder {
|
||||||
public:
|
public:
|
||||||
explicit BoardFinder(const std::list<BoardConfig const *> &boardConfigs);
|
explicit BoardFinder(const std::list<BoardConfig const *> &boardConfigs);
|
||||||
|
|
||||||
BoardConfig const *searchBoardConfig();
|
BoardConfig const *searchBoardConfig(logging::Logger &logger);
|
||||||
|
|
||||||
BoardConfig const *getBoardConfig(String name);
|
BoardConfig const *getBoardConfig(String name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::list<BoardConfig const *> &_boardConfigs;
|
const std::list<BoardConfig const *> &_boardConfigs;
|
||||||
|
|
||||||
bool checkOledConfig(BoardConfig const *boardConfig);
|
bool checkOledConfig(BoardConfig const *boardConfig, logging::Logger &logger);
|
||||||
bool checkModemConfig(BoardConfig const *boardConfig);
|
bool checkModemConfig(BoardConfig const *boardConfig);
|
||||||
bool checkPowerConfig(BoardConfig const *boardConfig);
|
bool checkPowerConfig(BoardConfig const *boardConfig, logging::Logger &logger);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern BoardConfig TTGO_LORA32_V1;
|
extern BoardConfig TTGO_LORA32_V1;
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,14 @@
|
||||||
#include <SPIFFS.h>
|
#include <SPIFFS.h>
|
||||||
#include <logger.h>
|
#include <logger.h>
|
||||||
|
|
||||||
ConfigurationManagement::ConfigurationManagement(String FilePath) : mFilePath(FilePath) {
|
#define MODULE_NAME "ConfigurationManagement"
|
||||||
|
|
||||||
|
ConfigurationManagement::ConfigurationManagement(logging::Logger &logger, String FilePath) : mFilePath(FilePath) {
|
||||||
if (!SPIFFS.begin(true)) {
|
if (!SPIFFS.begin(true)) {
|
||||||
logPrintlnI("Mounting SPIFFS was not possible. Trying to format SPIFFS...");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "Mounting SPIFFS was not possible. Trying to format SPIFFS...");
|
||||||
SPIFFS.format();
|
SPIFFS.format();
|
||||||
if (!SPIFFS.begin()) {
|
if (!SPIFFS.begin()) {
|
||||||
logPrintlnE("Formating SPIFFS was not okay!");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, MODULE_NAME, "Formating SPIFFS was not okay!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,16 +17,16 @@ ConfigurationManagement::ConfigurationManagement(String FilePath) : mFilePath(Fi
|
||||||
ConfigurationManagement::~ConfigurationManagement() {
|
ConfigurationManagement::~ConfigurationManagement() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigurationManagement::readConfiguration(Configuration &conf) {
|
void ConfigurationManagement::readConfiguration(logging::Logger &logger, Configuration &conf) {
|
||||||
File file = SPIFFS.open(mFilePath);
|
File file = SPIFFS.open(mFilePath);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
logPrintlnE("Failed to open file for reading, using default configuration.");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, MODULE_NAME, "Failed to open file for reading, using default configuration.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DynamicJsonDocument data(2048);
|
DynamicJsonDocument data(2048);
|
||||||
DeserializationError error = deserializeJson(data, file);
|
DeserializationError error = deserializeJson(data, file);
|
||||||
if (error) {
|
if (error) {
|
||||||
logPrintlnW("Failed to read file, using default configuration.");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, MODULE_NAME, "Failed to read file, using default configuration.");
|
||||||
}
|
}
|
||||||
// serializeJson(data, Serial);
|
// serializeJson(data, Serial);
|
||||||
// Serial.println();
|
// Serial.println();
|
||||||
|
|
@ -33,13 +35,13 @@ void ConfigurationManagement::readConfiguration(Configuration &conf) {
|
||||||
readProjectConfiguration(data, conf);
|
readProjectConfiguration(data, conf);
|
||||||
|
|
||||||
// update config in memory to get the new fields:
|
// update config in memory to get the new fields:
|
||||||
writeConfiguration(conf);
|
writeConfiguration(logger, conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigurationManagement::writeConfiguration(Configuration &conf) {
|
void ConfigurationManagement::writeConfiguration(logging::Logger &logger, Configuration &conf) {
|
||||||
File file = SPIFFS.open(mFilePath, "w");
|
File file = SPIFFS.open(mFilePath, "w");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
logPrintlnE("Failed to open file for writing...");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, MODULE_NAME, "Failed to open file for writing...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DynamicJsonDocument data(2048);
|
DynamicJsonDocument data(2048);
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,17 @@
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <logger.h>
|
||||||
|
|
||||||
class Configuration;
|
class Configuration;
|
||||||
|
|
||||||
class ConfigurationManagement {
|
class ConfigurationManagement {
|
||||||
public:
|
public:
|
||||||
explicit ConfigurationManagement(String FilePath);
|
explicit ConfigurationManagement(logging::Logger &logger, String FilePath);
|
||||||
virtual ~ConfigurationManagement();
|
virtual ~ConfigurationManagement();
|
||||||
|
|
||||||
void readConfiguration(Configuration &conf);
|
void readConfiguration(logging::Logger &logger, Configuration &conf);
|
||||||
void writeConfiguration(Configuration &conf);
|
void writeConfiguration(logging::Logger &logger, Configuration &conf);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void readProjectConfiguration(DynamicJsonDocument &data, Configuration &conf) = 0;
|
virtual void readProjectConfiguration(DynamicJsonDocument &data, Configuration &conf) = 0;
|
||||||
|
|
|
||||||
|
|
@ -38,3 +38,7 @@ bool System::isWifiEthConnected() const {
|
||||||
void System::connectedViaWifiEth(bool status) {
|
void System::connectedViaWifiEth(bool status) {
|
||||||
_isWifiEthConnected = status;
|
_isWifiEthConnected = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logging::Logger &System::getLogger() {
|
||||||
|
return _logger;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef SYSTEM_H_
|
#ifndef SYSTEM_H_
|
||||||
#define SYSTEM_H_
|
#define SYSTEM_H_
|
||||||
|
|
||||||
|
#include <logger.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "TaskManager.h"
|
#include "TaskManager.h"
|
||||||
|
|
@ -22,6 +23,7 @@ public:
|
||||||
Display & getDisplay();
|
Display & getDisplay();
|
||||||
bool isWifiEthConnected() const;
|
bool isWifiEthConnected() const;
|
||||||
void connectedViaWifiEth(bool status);
|
void connectedViaWifiEth(bool status);
|
||||||
|
logging::Logger & getLogger();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BoardConfig const * _boardConfig;
|
BoardConfig const * _boardConfig;
|
||||||
|
|
@ -29,6 +31,7 @@ private:
|
||||||
TaskManager _taskManager;
|
TaskManager _taskManager;
|
||||||
Display _display;
|
Display _display;
|
||||||
bool _isWifiEthConnected;
|
bool _isWifiEthConnected;
|
||||||
|
logging::Logger _logger;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
#include <FontConfig.h>
|
#include <FontConfig.h>
|
||||||
#include <logger.h>
|
#include <logger.h>
|
||||||
|
|
||||||
|
#define MODULE_NAME "TaskManager"
|
||||||
|
|
||||||
TaskManager::TaskManager() {
|
TaskManager::TaskManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -20,15 +22,13 @@ std::list<Task *> TaskManager::getTasks() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TaskManager::setup(System &system) {
|
bool TaskManager::setup(System &system) {
|
||||||
logPrintlnV("will setup all tasks...");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "will setup all tasks...");
|
||||||
for (Task *elem : _alwaysRunTasks) {
|
for (Task *elem : _alwaysRunTasks) {
|
||||||
logPrintD("call setup from ");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, MODULE_NAME, "call setup for %s", elem->getName().c_str());
|
||||||
logPrintlnD(elem->getName());
|
|
||||||
elem->setup(system);
|
elem->setup(system);
|
||||||
}
|
}
|
||||||
for (Task *elem : _tasks) {
|
for (Task *elem : _tasks) {
|
||||||
logPrintD("call setup from ");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, MODULE_NAME, "call setup for %s", elem->getName().c_str());
|
||||||
logPrintlnD(elem->getName());
|
|
||||||
elem->setup(system);
|
elem->setup(system);
|
||||||
}
|
}
|
||||||
_nextTask = _tasks.begin();
|
_nextTask = _tasks.begin();
|
||||||
|
|
@ -36,10 +36,7 @@ bool TaskManager::setup(System &system) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TaskManager::loop(System &system) {
|
bool TaskManager::loop(System &system) {
|
||||||
// logPrintlnD("will loop all tasks...");
|
|
||||||
for (Task *elem : _alwaysRunTasks) {
|
for (Task *elem : _alwaysRunTasks) {
|
||||||
// logPrintD("call loop from ");
|
|
||||||
// logPrintlnD(elem->getName());
|
|
||||||
elem->loop(system);
|
elem->loop(system);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ lib_deps =
|
||||||
bblanchon/ArduinoJson @ 6.17.0
|
bblanchon/ArduinoJson @ 6.17.0
|
||||||
lewisxhe/AXP202X_Library @ 1.1.2
|
lewisxhe/AXP202X_Library @ 1.1.2
|
||||||
peterus/APRS-Decoder-Lib @ 0.0.6
|
peterus/APRS-Decoder-Lib @ 0.0.6
|
||||||
peterus/esp-logger @ 0.0.1
|
peterus/esp-logger @ 1.0.0
|
||||||
peterus/ESP-FTP-Server-Lib @ 0.9.5
|
peterus/ESP-FTP-Server-Lib @ 0.9.5
|
||||||
knolleary/PubSubClient@^2.8
|
knolleary/PubSubClient@^2.8
|
||||||
check_tool = cppcheck
|
check_tool = cppcheck
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ version = None
|
||||||
with open("src/LoRa_APRS_iGate.cpp") as f:
|
with open("src/LoRa_APRS_iGate.cpp") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
if line.startswith("#define VERSION"):
|
if line.startswith("#define VERSION"):
|
||||||
version = line.strip().split(" ")[2].replace('"', "")
|
version = line.strip().split(" ")[-1].replace('"', "")
|
||||||
|
|
||||||
version_split = version.split(".")
|
version_split = version.split(".")
|
||||||
version_year = int(version_split[0])
|
version_year = int(version_split[0])
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@
|
||||||
#include "TaskWifi.h"
|
#include "TaskWifi.h"
|
||||||
#include "project_configuration.h"
|
#include "project_configuration.h"
|
||||||
|
|
||||||
#define VERSION "22.11.0"
|
#define VERSION "22.11.2"
|
||||||
|
#define MODULE_NAME "Main"
|
||||||
|
|
||||||
String create_lat_aprs(double lat);
|
String create_lat_aprs(double lat);
|
||||||
String create_long_aprs(double lng);
|
String create_long_aprs(double lng);
|
||||||
|
|
@ -47,10 +48,11 @@ BeaconTask beaconTask(toModem, toAprsIs);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Logger::instance().setSerial(&Serial);
|
LoRaSystem.getLogger().setSerial(&Serial);
|
||||||
|
setWiFiLogger(&LoRaSystem.getLogger());
|
||||||
delay(500);
|
delay(500);
|
||||||
logPrintlnI("LoRa APRS iGate by OE5BPA (Peter Buchegger)");
|
LoRaSystem.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "LoRa APRS iGate by OE5BPA (Peter Buchegger)");
|
||||||
logPrintlnI("Version: " VERSION);
|
LoRaSystem.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "Version: %s", VERSION);
|
||||||
|
|
||||||
std::list<BoardConfig const *> boardConfigs;
|
std::list<BoardConfig const *> boardConfigs;
|
||||||
boardConfigs.push_back(&TTGO_LORA32_V1);
|
boardConfigs.push_back(&TTGO_LORA32_V1);
|
||||||
|
|
@ -62,36 +64,34 @@ void setup() {
|
||||||
boardConfigs.push_back(&HELTEC_WIFI_LORA_32_V1);
|
boardConfigs.push_back(&HELTEC_WIFI_LORA_32_V1);
|
||||||
boardConfigs.push_back(&HELTEC_WIFI_LORA_32_V2);
|
boardConfigs.push_back(&HELTEC_WIFI_LORA_32_V2);
|
||||||
|
|
||||||
ProjectConfigurationManagement confmg;
|
ProjectConfigurationManagement confmg(LoRaSystem.getLogger());
|
||||||
confmg.readConfiguration(userConfig);
|
confmg.readConfiguration(LoRaSystem.getLogger(), userConfig);
|
||||||
|
|
||||||
BoardFinder finder(boardConfigs);
|
BoardFinder finder(boardConfigs);
|
||||||
BoardConfig const *boardConfig = finder.getBoardConfig(userConfig.board);
|
BoardConfig const *boardConfig = finder.getBoardConfig(userConfig.board);
|
||||||
if (!boardConfig) {
|
if (!boardConfig) {
|
||||||
boardConfig = finder.searchBoardConfig();
|
boardConfig = finder.searchBoardConfig(LoRaSystem.getLogger());
|
||||||
if (!boardConfig) {
|
if (!boardConfig) {
|
||||||
logPrintlnE("Board config not set and search failed!");
|
LoRaSystem.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, MODULE_NAME, "Board config not set and search failed!");
|
||||||
while (true)
|
while (true)
|
||||||
;
|
;
|
||||||
} else {
|
} else {
|
||||||
userConfig.board = boardConfig->Name;
|
userConfig.board = boardConfig->Name;
|
||||||
confmg.writeConfiguration(userConfig);
|
confmg.writeConfiguration(LoRaSystem.getLogger(), userConfig);
|
||||||
logPrintlnI("will restart board now!");
|
LoRaSystem.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "will restart board now!");
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logPrintI("Board ");
|
LoRaSystem.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "Board %s loaded.", boardConfig->Name.c_str());
|
||||||
logPrintI(boardConfig->Name);
|
|
||||||
logPrintlnI(" loaded.");
|
|
||||||
|
|
||||||
if (boardConfig->Type == eTTGO_T_Beam_V1_0) {
|
if (boardConfig->Type == eTTGO_T_Beam_V1_0) {
|
||||||
Wire.begin(boardConfig->OledSda, boardConfig->OledScl);
|
Wire.begin(boardConfig->OledSda, boardConfig->OledScl);
|
||||||
PowerManagement powerManagement;
|
PowerManagement powerManagement;
|
||||||
if (!powerManagement.begin(Wire)) {
|
if (!powerManagement.begin(Wire)) {
|
||||||
logPrintlnI("AXP192 init done!");
|
LoRaSystem.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "AXP192 init done!");
|
||||||
} else {
|
} else {
|
||||||
logPrintlnE("AXP192 init failed!");
|
LoRaSystem.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, MODULE_NAME, "AXP192 init failed!");
|
||||||
}
|
}
|
||||||
powerManagement.activateLoRa();
|
powerManagement.activateLoRa();
|
||||||
powerManagement.activateOLED();
|
powerManagement.activateOLED();
|
||||||
|
|
@ -133,13 +133,13 @@ void setup() {
|
||||||
LoRaSystem.getDisplay().showSpashScreen("LoRa APRS iGate", VERSION);
|
LoRaSystem.getDisplay().showSpashScreen("LoRa APRS iGate", VERSION);
|
||||||
|
|
||||||
if (userConfig.callsign == "NOCALL-10") {
|
if (userConfig.callsign == "NOCALL-10") {
|
||||||
logPrintlnE("You have to change your settings in 'data/is-cfg.json' and upload it via \"Upload File System image\"!");
|
LoRaSystem.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, MODULE_NAME, "You have to change your settings in 'data/is-cfg.json' and upload it via 'Upload File System image'!");
|
||||||
LoRaSystem.getDisplay().showStatusScreen("ERROR", "You have to change your settings in 'data/is-cfg.json' and upload it via \"Upload File System image\"!");
|
LoRaSystem.getDisplay().showStatusScreen("ERROR", "You have to change your settings in 'data/is-cfg.json' and upload it via \"Upload File System image\"!");
|
||||||
while (true)
|
while (true)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
if ((!userConfig.aprs_is.active) && !(userConfig.digi.active)) {
|
if ((!userConfig.aprs_is.active) && !(userConfig.digi.active)) {
|
||||||
logPrintlnE("No mode selected (iGate or Digi)! You have to activate one of iGate or Digi.");
|
LoRaSystem.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, MODULE_NAME, "No mode selected (iGate or Digi)! You have to activate one of iGate or Digi.");
|
||||||
LoRaSystem.getDisplay().showStatusScreen("ERROR", "No mode selected (iGate or Digi)! You have to activate one of iGate or Digi.");
|
LoRaSystem.getDisplay().showStatusScreen("ERROR", "No mode selected (iGate or Digi)! You have to activate one of iGate or Digi.");
|
||||||
while (true)
|
while (true)
|
||||||
;
|
;
|
||||||
|
|
@ -151,9 +151,16 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(5000);
|
delay(5000);
|
||||||
logPrintlnI("setup done...");
|
LoRaSystem.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "setup done...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
volatile bool syslogSet = false;
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
LoRaSystem.getTaskManager().loop(LoRaSystem);
|
LoRaSystem.getTaskManager().loop(LoRaSystem);
|
||||||
|
if (LoRaSystem.isWifiEthConnected() && LoRaSystem.getUserConfig()->syslog.active && !syslogSet) {
|
||||||
|
LoRaSystem.getLogger().setSyslogServer(LoRaSystem.getUserConfig()->syslog.server, LoRaSystem.getUserConfig()->syslog.port, LoRaSystem.getUserConfig()->callsign);
|
||||||
|
LoRaSystem.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "System connected after a restart to the network, syslog server set");
|
||||||
|
syslogSet = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,15 +40,18 @@ bool AprsIsTask::loop(System &system) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AprsIsTask::connect(const System &system) {
|
bool AprsIsTask::connect(System &system) {
|
||||||
logPrintI("connecting to APRS-IS server: ");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "connecting to APRS-IS server: %s on port: %d", system.getUserConfig()->aprs_is.server.c_str(), system.getUserConfig()->aprs_is.port);
|
||||||
logPrintI(system.getUserConfig()->aprs_is.server);
|
APRS_IS::ConnectionStatus status = _aprs_is.connect(system.getUserConfig()->aprs_is.server, system.getUserConfig()->aprs_is.port);
|
||||||
logPrintI(" on port: ");
|
if (status == APRS_IS::ERROR_CONNECTION) {
|
||||||
logPrintlnI(String(system.getUserConfig()->aprs_is.port));
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "Something went wrong on connecting! Is the server reachable?");
|
||||||
if (!_aprs_is.connect(system.getUserConfig()->aprs_is.server, system.getUserConfig()->aprs_is.port)) {
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "Connection failed.");
|
||||||
logPrintlnE("Connection failed.");
|
return false;
|
||||||
|
} else if (status == APRS_IS::ERROR_PASSCODE) {
|
||||||
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "User can not be verified with passcode!");
|
||||||
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "Connection failed.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
logPrintlnI("Connected to APRS-IS server!");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "Connected to APRS-IS server!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ private:
|
||||||
|
|
||||||
TaskQueue<std::shared_ptr<APRSMessage>> &_toAprsIs;
|
TaskQueue<std::shared_ptr<APRSMessage>> &_toAprsIs;
|
||||||
|
|
||||||
bool connect(const System &system);
|
bool connect(System &system);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,67 +6,62 @@
|
||||||
#include "TaskEth.h"
|
#include "TaskEth.h"
|
||||||
#include "project_configuration.h"
|
#include "project_configuration.h"
|
||||||
|
|
||||||
volatile bool eth_connected = false;
|
#define WIFI_EVENT "WiFiEvent"
|
||||||
|
|
||||||
|
volatile bool eth_connected = false;
|
||||||
|
logging::Logger *_logger;
|
||||||
|
|
||||||
|
void setWiFiLogger(logging::Logger *logger) {
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
void WiFiEvent(WiFiEvent_t event) {
|
void WiFiEvent(WiFiEvent_t event) {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case SYSTEM_EVENT_STA_START:
|
case SYSTEM_EVENT_STA_START:
|
||||||
logPrintlnI("WiFi Started");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "WiFi Started");
|
||||||
break;
|
break;
|
||||||
case SYSTEM_EVENT_STA_CONNECTED:
|
case SYSTEM_EVENT_STA_CONNECTED:
|
||||||
logPrintlnI("WiFi Connected");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "WiFi Connected");
|
||||||
break;
|
break;
|
||||||
case SYSTEM_EVENT_STA_GOT_IP:
|
case SYSTEM_EVENT_STA_GOT_IP:
|
||||||
logPrintI("WiFi MAC: ");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "WiFi MAC: %s", WiFi.macAddress().c_str());
|
||||||
logPrintI(WiFi.macAddress());
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "IPv4: %s", WiFi.localIP().toString().c_str());
|
||||||
logPrintI(", IPv4: ");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "Gateway: %s", WiFi.gatewayIP().toString().c_str());
|
||||||
logPrintI(WiFi.localIP().toString());
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "DNS1: %s", WiFi.dnsIP().toString().c_str());
|
||||||
logPrintI(", Gateway: ");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "DNS2: %s", WiFi.dnsIP(1).toString().c_str());
|
||||||
logPrintI(WiFi.gatewayIP().toString());
|
|
||||||
logPrintI(", DNS1: ");
|
|
||||||
logPrintI(WiFi.dnsIP().toString());
|
|
||||||
logPrintI(", DNS2: ");
|
|
||||||
logPrintlnI(WiFi.dnsIP(1).toString());
|
|
||||||
break;
|
break;
|
||||||
case SYSTEM_EVENT_STA_DISCONNECTED:
|
case SYSTEM_EVENT_STA_DISCONNECTED:
|
||||||
logPrintlnW("WiFi Disconnected");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "WiFi Disconnected");
|
||||||
break;
|
break;
|
||||||
case SYSTEM_EVENT_STA_STOP:
|
case SYSTEM_EVENT_STA_STOP:
|
||||||
logPrintlnW("WiFi Stopped");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "WiFi Stopped");
|
||||||
break;
|
break;
|
||||||
case SYSTEM_EVENT_ETH_START:
|
case SYSTEM_EVENT_ETH_START:
|
||||||
logPrintlnI("ETH Started");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "WiFi Started");
|
||||||
break;
|
break;
|
||||||
case SYSTEM_EVENT_ETH_CONNECTED:
|
case SYSTEM_EVENT_ETH_CONNECTED:
|
||||||
logPrintlnI("ETH Connected");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "ETH Connected");
|
||||||
break;
|
break;
|
||||||
case SYSTEM_EVENT_ETH_GOT_IP:
|
case SYSTEM_EVENT_ETH_GOT_IP:
|
||||||
logPrintI("Hostname: ");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "Hostname: %s", ETH.getHostname());
|
||||||
logPrintI(ETH.getHostname());
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "ETH MAC: %s", ETH.macAddress().c_str());
|
||||||
logPrintI(", ETH MAC: ");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "IPv4: %s", ETH.localIP().toString().c_str());
|
||||||
logPrintI(ETH.macAddress());
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "Gateway: %s", ETH.gatewayIP().toString().c_str());
|
||||||
logPrintI(", IPv4: ");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "DNS1: %s", ETH.dnsIP().toString().c_str());
|
||||||
logPrintI(ETH.localIP().toString());
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "DNS2: %s", ETH.dnsIP(1).toString().c_str());
|
||||||
logPrintI(", Gateway: ");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "Hostname: %s", ETH.getHostname());
|
||||||
logPrintI(ETH.gatewayIP().toString());
|
|
||||||
logPrintI(", DNS1: ");
|
|
||||||
logPrintI(ETH.dnsIP().toString());
|
|
||||||
logPrintI(", DNS2: ");
|
|
||||||
logPrintI(ETH.dnsIP(1).toString());
|
|
||||||
if (ETH.fullDuplex()) {
|
if (ETH.fullDuplex()) {
|
||||||
logPrintI(", FULL_DUPLEX");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "FULL_DUPLEX");
|
||||||
}
|
}
|
||||||
logPrintI(", ");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "%dMbps", ETH.linkSpeed());
|
||||||
logPrintI(String(ETH.linkSpeed()));
|
|
||||||
logPrintlnI("Mbps");
|
|
||||||
eth_connected = true;
|
eth_connected = true;
|
||||||
break;
|
break;
|
||||||
case SYSTEM_EVENT_ETH_DISCONNECTED:
|
case SYSTEM_EVENT_ETH_DISCONNECTED:
|
||||||
logPrintlnW("ETH Disconnected");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_WARN, WIFI_EVENT, "ETH Disconnected");
|
||||||
eth_connected = false;
|
eth_connected = false;
|
||||||
break;
|
break;
|
||||||
case SYSTEM_EVENT_ETH_STOP:
|
case SYSTEM_EVENT_ETH_STOP:
|
||||||
logPrintlnW("ETH Stopped");
|
_logger->log(logging::LoggerLevel::LOGGER_LEVEL_WARN, WIFI_EVENT, "ETH Stopped");
|
||||||
eth_connected = false;
|
eth_connected = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <TaskManager.h>
|
#include <TaskManager.h>
|
||||||
|
|
||||||
|
void setWiFiLogger(logging::Logger *logger);
|
||||||
void WiFiEvent(WiFiEvent_t event);
|
void WiFiEvent(WiFiEvent_t event);
|
||||||
|
|
||||||
class EthTask : public Task {
|
class EthTask : public Task {
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,7 @@ FTPTask::~FTPTask() {
|
||||||
|
|
||||||
bool FTPTask::setup(System &system) {
|
bool FTPTask::setup(System &system) {
|
||||||
for (Configuration::Ftp::User user : system.getUserConfig()->ftp.users) {
|
for (Configuration::Ftp::User user : system.getUserConfig()->ftp.users) {
|
||||||
logPrintD("Adding user to FTP Server: ");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "Adding user to FTP Server: %s", user.name.c_str());
|
||||||
logPrintlnD(user.name);
|
|
||||||
_ftpServer.addUser(user.name, user.password);
|
_ftpServer.addUser(user.name, user.password);
|
||||||
}
|
}
|
||||||
_ftpServer.addFilesystem("SPIFFS", &SPIFFS);
|
_ftpServer.addFilesystem("SPIFFS", &SPIFFS);
|
||||||
|
|
@ -31,8 +30,7 @@ bool FTPTask::loop(System &system) {
|
||||||
_ftpServer.handle();
|
_ftpServer.handle();
|
||||||
static bool configWasOpen = false;
|
static bool configWasOpen = false;
|
||||||
if (configWasOpen && _ftpServer.countConnections() == 0) {
|
if (configWasOpen && _ftpServer.countConnections() == 0) {
|
||||||
logPrintlnW("Maybe the config has been changed via FTP, lets restart now to get the new config...");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_WARN, getName(), "Maybe the config has been changed via FTP, lets restart now to get the new config...");
|
||||||
logPrintlnW("");
|
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
if (_ftpServer.countConnections() > 0) {
|
if (_ftpServer.countConnections() > 0) {
|
||||||
|
|
|
||||||
|
|
@ -46,29 +46,19 @@ bool MQTTTask::loop(System &system) {
|
||||||
topic = topic + "/";
|
topic = topic + "/";
|
||||||
}
|
}
|
||||||
topic = topic + system.getUserConfig()->callsign;
|
topic = topic + system.getUserConfig()->callsign;
|
||||||
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "Send MQTT with topic: '%s', data: %s", topic.c_str(), r.c_str());
|
||||||
logPrintD("Send MQTT with topic: \"");
|
|
||||||
logPrintD(topic);
|
|
||||||
logPrintD("\", data: ");
|
|
||||||
logPrintlnD(r);
|
|
||||||
|
|
||||||
_MQTT.publish(topic.c_str(), r.c_str());
|
_MQTT.publish(topic.c_str(), r.c_str());
|
||||||
}
|
}
|
||||||
_MQTT.loop();
|
_MQTT.loop();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MQTTTask::connect(const System &system) {
|
bool MQTTTask::connect(System &system) {
|
||||||
logPrintI("Connecting to MQTT broker: ");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "Connecting to MQTT broker: %s on port %d", system.getUserConfig()->mqtt.server.c_str(), system.getUserConfig()->mqtt.port);
|
||||||
logPrintI(system.getUserConfig()->mqtt.server);
|
|
||||||
logPrintI(" on port ");
|
|
||||||
logPrintlnI(String(system.getUserConfig()->mqtt.port));
|
|
||||||
|
|
||||||
if (_MQTT.connect(system.getUserConfig()->callsign.c_str(), system.getUserConfig()->mqtt.name.c_str(), system.getUserConfig()->mqtt.password.c_str())) {
|
if (_MQTT.connect(system.getUserConfig()->callsign.c_str(), system.getUserConfig()->mqtt.name.c_str(), system.getUserConfig()->mqtt.password.c_str())) {
|
||||||
logPrintI("Connected to MQTT broker as: ");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "Connected to MQTT broker as: %s", system.getUserConfig()->callsign.c_str());
|
||||||
logPrintlnI(system.getUserConfig()->callsign);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
logPrintlnI("Connecting to MQTT broker faild. Try again later.");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "Connecting to MQTT broker failed. Try again later.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ private:
|
||||||
WiFiClient _client;
|
WiFiClient _client;
|
||||||
PubSubClient _MQTT;
|
PubSubClient _MQTT;
|
||||||
|
|
||||||
bool connect(const System &system);
|
bool connect(System &system);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ bool ModemTask::setup(System &system) {
|
||||||
SPI.begin(system.getBoardConfig()->LoraSck, system.getBoardConfig()->LoraMiso, system.getBoardConfig()->LoraMosi, system.getBoardConfig()->LoraCS);
|
SPI.begin(system.getBoardConfig()->LoraSck, system.getBoardConfig()->LoraMiso, system.getBoardConfig()->LoraMosi, system.getBoardConfig()->LoraCS);
|
||||||
_lora_aprs.setPins(system.getBoardConfig()->LoraCS, system.getBoardConfig()->LoraReset, system.getBoardConfig()->LoraIRQ);
|
_lora_aprs.setPins(system.getBoardConfig()->LoraCS, system.getBoardConfig()->LoraReset, system.getBoardConfig()->LoraIRQ);
|
||||||
if (!_lora_aprs.begin(system.getUserConfig()->lora.frequencyRx)) {
|
if (!_lora_aprs.begin(system.getUserConfig()->lora.frequencyRx)) {
|
||||||
logPrintlnE("Starting LoRa failed!");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "Starting LoRa failed!");
|
||||||
_stateInfo = "LoRa-Modem failed";
|
_stateInfo = "LoRa-Modem failed";
|
||||||
_state = Error;
|
_state = Error;
|
||||||
while (true)
|
while (true)
|
||||||
|
|
@ -39,31 +39,19 @@ bool ModemTask::setup(System &system) {
|
||||||
bool ModemTask::loop(System &system) {
|
bool ModemTask::loop(System &system) {
|
||||||
if (_lora_aprs.checkMessage()) {
|
if (_lora_aprs.checkMessage()) {
|
||||||
std::shared_ptr<APRSMessage> msg = _lora_aprs.getMessage();
|
std::shared_ptr<APRSMessage> msg = _lora_aprs.getMessage();
|
||||||
// msg->getAPRSBody()->setData(msg->getAPRSBody()->getData() + " 123");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Received packet '%s' with RSSI %d and SNR %f", timeString().c_str(), msg->toString().c_str(), _lora_aprs.packetRssi(), _lora_aprs.packetSnr());
|
||||||
logPrintD("[" + timeString() + "] ");
|
|
||||||
logPrintD("Received packet '");
|
|
||||||
logPrintD(msg->toString());
|
|
||||||
logPrintD("' with RSSI ");
|
|
||||||
logPrintD(String(_lora_aprs.packetRssi()));
|
|
||||||
logPrintD(" and SNR ");
|
|
||||||
logPrintlnD(String(_lora_aprs.packetSnr()));
|
|
||||||
|
|
||||||
_fromModem.addElement(msg);
|
_fromModem.addElement(msg);
|
||||||
system.getDisplay().addFrame(std::shared_ptr<DisplayFrame>(new TextFrame("LoRa", msg->toString())));
|
system.getDisplay().addFrame(std::shared_ptr<DisplayFrame>(new TextFrame("LoRa", msg->toString().c_str())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_toModem.empty()) {
|
if (!_toModem.empty()) {
|
||||||
std::shared_ptr<APRSMessage> msg = _toModem.getElement();
|
std::shared_ptr<APRSMessage> msg = _toModem.getElement();
|
||||||
logPrintD("[" + timeString() + "] ");
|
if (system.getUserConfig()->lora.tx_enable) {
|
||||||
if (system.getUserConfig()->lora.txok) {
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Transmitting packet '%s'", timeString().c_str(), msg->toString().c_str());
|
||||||
logPrintD("Transmitting packet '");
|
|
||||||
logPrintD(msg->toString());
|
|
||||||
_lora_aprs.sendMessage(msg);
|
_lora_aprs.sendMessage(msg);
|
||||||
logPrintlnD(String(" TXDone"));
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] TX done", timeString().c_str());
|
||||||
} else {
|
} else {
|
||||||
logPrintD("NOT Transmitting packet '");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] NOT transmitting packet as TX is not enabled '%s'", timeString().c_str(), msg->toString().c_str());
|
||||||
logPrintD(msg->toString());
|
|
||||||
logPrintlnD(String(" TXNG"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,7 @@ bool NTPTask::loop(System &system) {
|
||||||
}
|
}
|
||||||
if (_ntpClient.update()) {
|
if (_ntpClient.update()) {
|
||||||
setTime(_ntpClient.getEpochTime());
|
setTime(_ntpClient.getEpochTime());
|
||||||
logPrintI("Current time: ");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "Current time: %s", _ntpClient.getFormattedTime().c_str());
|
||||||
logPrintlnI(_ntpClient.getFormattedTime());
|
|
||||||
}
|
}
|
||||||
_stateInfo = _ntpClient.getFormattedTime();
|
_stateInfo = _ntpClient.getFormattedTime();
|
||||||
_state = Okay;
|
_state = Okay;
|
||||||
|
|
|
||||||
|
|
@ -13,35 +13,33 @@ OTATask::~OTATask() {
|
||||||
bool OTATask::setup(System &system) {
|
bool OTATask::setup(System &system) {
|
||||||
_ota.onStart([&]() {
|
_ota.onStart([&]() {
|
||||||
String type;
|
String type;
|
||||||
if (_ota.getCommand() == U_FLASH)
|
if (_ota.getCommand() == U_FLASH) {
|
||||||
type = "sketch";
|
type = "sketch";
|
||||||
else // U_SPIFFS
|
} else { // U_SPIFFS
|
||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
logPrintlnI("Start updating " + type);
|
}
|
||||||
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "Start updating %s", type.c_str());
|
||||||
})
|
})
|
||||||
.onEnd([]() {
|
.onEnd([&]() {
|
||||||
logPrintlnI("");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "OTA End");
|
||||||
logPrintlnI("OTA End");
|
|
||||||
})
|
})
|
||||||
.onProgress([](unsigned int progress, unsigned int total) {
|
.onProgress([&](unsigned int progress, unsigned int total) {
|
||||||
logPrintI("Progress: ");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "Progress: %f", (progress / (total / 100)));
|
||||||
logPrintI(String(progress / (total / 100)));
|
|
||||||
logPrintlnI("%");
|
|
||||||
})
|
})
|
||||||
.onError([](ota_error_t error) {
|
.onError([&](ota_error_t error) {
|
||||||
logPrintE("Error[");
|
String error_str;
|
||||||
logPrintE(String(error));
|
if (error == OTA_AUTH_ERROR) {
|
||||||
logPrintE("]: ");
|
error_str = "Auth Failed";
|
||||||
if (error == OTA_AUTH_ERROR)
|
} else if (error == OTA_BEGIN_ERROR) {
|
||||||
logPrintlnE("Auth Failed");
|
error_str = "Begin Failed";
|
||||||
else if (error == OTA_BEGIN_ERROR)
|
} else if (error == OTA_CONNECT_ERROR) {
|
||||||
logPrintlnE("Begin Failed");
|
error_str = "Connect Failed";
|
||||||
else if (error == OTA_CONNECT_ERROR)
|
} else if (error == OTA_RECEIVE_ERROR) {
|
||||||
logPrintlnE("Connect Failed");
|
error_str = "Receive Failed";
|
||||||
else if (error == OTA_RECEIVE_ERROR)
|
} else if (error == OTA_END_ERROR) {
|
||||||
logPrintlnE("Receive Failed");
|
error_str = "End Failed";
|
||||||
else if (error == OTA_END_ERROR)
|
}
|
||||||
logPrintlnE("End Failed");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "Error[%d]: %s", error, error_str.c_str());
|
||||||
});
|
});
|
||||||
if (system.getUserConfig()->network.hostname.overwrite) {
|
if (system.getUserConfig()->network.hostname.overwrite) {
|
||||||
_ota.setHostname(system.getUserConfig()->network.hostname.name.c_str());
|
_ota.setHostname(system.getUserConfig()->network.hostname.name.c_str());
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ bool RouterTask::setup(System &system) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RouterTask::loop(System &system) {
|
bool RouterTask::loop(System &system) {
|
||||||
// do routing
|
|
||||||
if (!_fromModem.empty()) {
|
if (!_fromModem.empty()) {
|
||||||
std::shared_ptr<APRSMessage> modemMsg = _fromModem.getElement();
|
std::shared_ptr<APRSMessage> modemMsg = _fromModem.getElement();
|
||||||
|
|
||||||
|
|
@ -36,18 +35,19 @@ bool RouterTask::loop(System &system) {
|
||||||
|
|
||||||
aprsIsMsg->setPath(path + "qAO," + system.getUserConfig()->callsign);
|
aprsIsMsg->setPath(path + "qAO," + system.getUserConfig()->callsign);
|
||||||
|
|
||||||
logPrintD("APRS-IS: ");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "APRS-IS: %s", aprsIsMsg->toString().c_str());
|
||||||
logPrintlnD(aprsIsMsg->toString());
|
|
||||||
_toAprsIs.addElement(aprsIsMsg);
|
_toAprsIs.addElement(aprsIsMsg);
|
||||||
} else {
|
} else {
|
||||||
logPrintlnD("APRS-IS: no forward => RFonly");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "APRS-IS: no forward => RFonly");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!system.getUserConfig()->aprs_is.active)
|
if (!system.getUserConfig()->aprs_is.active) {
|
||||||
logPrintlnD("APRS-IS: disabled");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "APRS-IS: disabled");
|
||||||
|
}
|
||||||
|
|
||||||
if (modemMsg->getSource() == system.getUserConfig()->callsign)
|
if (modemMsg->getSource() == system.getUserConfig()->callsign) {
|
||||||
logPrintlnD("APRS-IS: no forward => own packet received");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "APRS-IS: no forward => own packet received");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (system.getUserConfig()->digi.active && modemMsg->getSource() != system.getUserConfig()->callsign) {
|
if (system.getUserConfig()->digi.active && modemMsg->getSource() != system.getUserConfig()->callsign) {
|
||||||
|
|
@ -59,8 +59,7 @@ bool RouterTask::loop(System &system) {
|
||||||
// fixme
|
// fixme
|
||||||
digiMsg->setPath(system.getUserConfig()->callsign + "*");
|
digiMsg->setPath(system.getUserConfig()->callsign + "*");
|
||||||
|
|
||||||
logPrintD("DIGI: ");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "DIGI: %s", digiMsg->toString().c_str());
|
||||||
logPrintlnD(digiMsg->toString());
|
|
||||||
|
|
||||||
_toModem.addElement(digiMsg);
|
_toModem.addElement(digiMsg);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,7 @@ bool WifiTask::setup(System &system) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Configuration::Wifi::AP ap : system.getUserConfig()->wifi.APs) {
|
for (Configuration::Wifi::AP ap : system.getUserConfig()->wifi.APs) {
|
||||||
logPrintD("Looking for AP: ");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "Looking for AP: %s", ap.SSID.c_str());
|
||||||
logPrintlnD(ap.SSID);
|
|
||||||
_wiFiMulti.addAP(ap.SSID.c_str(), ap.password.c_str());
|
_wiFiMulti.addAP(ap.SSID.c_str(), ap.password.c_str());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -42,14 +41,13 @@ bool WifiTask::loop(System &system) {
|
||||||
const uint8_t wifi_status = _wiFiMulti.run();
|
const uint8_t wifi_status = _wiFiMulti.run();
|
||||||
if (wifi_status != WL_CONNECTED) {
|
if (wifi_status != WL_CONNECTED) {
|
||||||
system.connectedViaWifiEth(false);
|
system.connectedViaWifiEth(false);
|
||||||
logPrintlnE("WiFi not connected!");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "WiFi not connected!");
|
||||||
_oldWifiStatus = wifi_status;
|
_oldWifiStatus = wifi_status;
|
||||||
_stateInfo = "WiFi not connected";
|
_stateInfo = "WiFi not connected";
|
||||||
_state = Error;
|
_state = Error;
|
||||||
return false;
|
return false;
|
||||||
} else if (wifi_status != _oldWifiStatus) {
|
} else if (wifi_status != _oldWifiStatus) {
|
||||||
logPrintD("IP address: ");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "IP address: %s", WiFi.localIP().toString().c_str());
|
||||||
logPrintlnD(WiFi.localIP().toString());
|
|
||||||
_oldWifiStatus = wifi_status;
|
_oldWifiStatus = wifi_status;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen
|
||||||
conf.lora.spreadingFactor = data["lora"]["spreading_factor"] | 12;
|
conf.lora.spreadingFactor = data["lora"]["spreading_factor"] | 12;
|
||||||
conf.lora.signalBandwidth = data["lora"]["signal_bandwidth"] | 125000;
|
conf.lora.signalBandwidth = data["lora"]["signal_bandwidth"] | 125000;
|
||||||
conf.lora.codingRate4 = data["lora"]["coding_rate4"] | 5;
|
conf.lora.codingRate4 = data["lora"]["coding_rate4"] | 5;
|
||||||
conf.lora.txok = data["lora"]["txok"] | false;
|
conf.lora.tx_enable = data["lora"]["tx_enable"] | true;
|
||||||
conf.display.alwaysOn = data["display"]["always_on"] | true;
|
conf.display.alwaysOn = data["display"]["always_on"] | true;
|
||||||
conf.display.timeout = data["display"]["timeout"] | 10;
|
conf.display.timeout = data["display"]["timeout"] | 10;
|
||||||
conf.display.overwritePin = data["display"]["overwrite_pin"] | 0;
|
conf.display.overwritePin = data["display"]["overwrite_pin"] | 0;
|
||||||
|
|
@ -87,6 +87,11 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen
|
||||||
conf.mqtt.password = data["mqtt"]["password"].as<String>();
|
conf.mqtt.password = data["mqtt"]["password"].as<String>();
|
||||||
conf.mqtt.topic = data["mqtt"]["topic"].as<String>();
|
conf.mqtt.topic = data["mqtt"]["topic"].as<String>();
|
||||||
}
|
}
|
||||||
|
if (data.containsKey("syslog")) {
|
||||||
|
conf.syslog.active = data["syslog"]["active"] | true;
|
||||||
|
conf.syslog.server = data["syslog"]["server"].as<String>();
|
||||||
|
conf.syslog.port = data["syslog"]["port"] | 514;
|
||||||
|
}
|
||||||
if (data.containsKey("ntp_server"))
|
if (data.containsKey("ntp_server"))
|
||||||
conf.ntpServer = data["ntp_server"].as<String>();
|
conf.ntpServer = data["ntp_server"].as<String>();
|
||||||
|
|
||||||
|
|
@ -133,7 +138,7 @@ void ProjectConfigurationManagement::writeProjectConfiguration(Configuration &co
|
||||||
data["lora"]["spreading_factor"] = conf.lora.spreadingFactor;
|
data["lora"]["spreading_factor"] = conf.lora.spreadingFactor;
|
||||||
data["lora"]["signal_bandwidth"] = conf.lora.signalBandwidth;
|
data["lora"]["signal_bandwidth"] = conf.lora.signalBandwidth;
|
||||||
data["lora"]["coding_rate4"] = conf.lora.codingRate4;
|
data["lora"]["coding_rate4"] = conf.lora.codingRate4;
|
||||||
data["lora"]["txok"] = conf.lora.txok;
|
data["lora"]["tx_enable"] = conf.lora.tx_enable;
|
||||||
data["display"]["always_on"] = conf.display.alwaysOn;
|
data["display"]["always_on"] = conf.display.alwaysOn;
|
||||||
data["display"]["timeout"] = conf.display.timeout;
|
data["display"]["timeout"] = conf.display.timeout;
|
||||||
data["display"]["overwrite_pin"] = conf.display.overwritePin;
|
data["display"]["overwrite_pin"] = conf.display.overwritePin;
|
||||||
|
|
@ -151,6 +156,9 @@ void ProjectConfigurationManagement::writeProjectConfiguration(Configuration &co
|
||||||
data["mqtt"]["name"] = conf.mqtt.name;
|
data["mqtt"]["name"] = conf.mqtt.name;
|
||||||
data["mqtt"]["password"] = conf.mqtt.password;
|
data["mqtt"]["password"] = conf.mqtt.password;
|
||||||
data["mqtt"]["topic"] = conf.mqtt.topic;
|
data["mqtt"]["topic"] = conf.mqtt.topic;
|
||||||
|
data["syslog"]["active"] = conf.syslog.active;
|
||||||
|
data["syslog"]["server"] = conf.syslog.server;
|
||||||
|
data["syslog"]["port"] = conf.syslog.port;
|
||||||
data["ntp_server"] = conf.ntpServer;
|
data["ntp_server"] = conf.ntpServer;
|
||||||
|
|
||||||
data["board"] = conf.board;
|
data["board"] = conf.board;
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ public:
|
||||||
|
|
||||||
class LoRa {
|
class LoRa {
|
||||||
public:
|
public:
|
||||||
LoRa() : frequencyRx(433775000), frequencyTx(433775000), power(20), spreadingFactor(12), signalBandwidth(125000), codingRate4(5), txok(false) {
|
LoRa() : frequencyRx(433775000), frequencyTx(433775000), power(20), spreadingFactor(12), signalBandwidth(125000), codingRate4(5), tx_enable(true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
long frequencyRx;
|
long frequencyRx;
|
||||||
|
|
@ -90,7 +90,7 @@ public:
|
||||||
int spreadingFactor;
|
int spreadingFactor;
|
||||||
long signalBandwidth;
|
long signalBandwidth;
|
||||||
int codingRate4;
|
int codingRate4;
|
||||||
bool txok;
|
bool tx_enable;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Display {
|
class Display {
|
||||||
|
|
@ -121,6 +121,9 @@ public:
|
||||||
|
|
||||||
class MQTT {
|
class MQTT {
|
||||||
public:
|
public:
|
||||||
|
MQTT() : active(false), server(""), port(1883), name(""), password(""), topic("LoraAPRS/Data") {
|
||||||
|
}
|
||||||
|
|
||||||
bool active;
|
bool active;
|
||||||
String server;
|
String server;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
|
|
@ -129,7 +132,18 @@ public:
|
||||||
String topic;
|
String topic;
|
||||||
};
|
};
|
||||||
|
|
||||||
Configuration() : callsign("NOCALL-10"), board(""), ntpServer("pool.ntp.org"){};
|
class Syslog {
|
||||||
|
public:
|
||||||
|
Syslog() : active(true), server("syslog.lora-aprs.info"), port(514) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool active;
|
||||||
|
String server;
|
||||||
|
int port;
|
||||||
|
};
|
||||||
|
|
||||||
|
Configuration() : callsign("NOCALL-10"), ntpServer("pool.ntp.org"), board("") {
|
||||||
|
}
|
||||||
|
|
||||||
String callsign;
|
String callsign;
|
||||||
Network network;
|
Network network;
|
||||||
|
|
@ -141,13 +155,14 @@ public:
|
||||||
Display display;
|
Display display;
|
||||||
Ftp ftp;
|
Ftp ftp;
|
||||||
MQTT mqtt;
|
MQTT mqtt;
|
||||||
String board;
|
Syslog syslog;
|
||||||
String ntpServer;
|
String ntpServer;
|
||||||
|
String board;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProjectConfigurationManagement : public ConfigurationManagement {
|
class ProjectConfigurationManagement : public ConfigurationManagement {
|
||||||
public:
|
public:
|
||||||
explicit ProjectConfigurationManagement() : ConfigurationManagement("/is-cfg.json") {
|
explicit ProjectConfigurationManagement(logging::Logger &logger) : ConfigurationManagement(logger, "/is-cfg.json") {
|
||||||
}
|
}
|
||||||
virtual ~ProjectConfigurationManagement() {
|
virtual ~ProjectConfigurationManagement() {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue