From 3516fbeeb5841e5bcbd10ea678aaeba7f320c9c9 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Sat, 2 Apr 2022 10:20:16 +0900 Subject: [PATCH 01/36] Add TaskRadiolib. --- platformio.ini | 1 + src/LoRa_APRS_iGate.cpp | 24 ++--- src/Task.h | 22 +++-- src/TaskRadiolib.cpp | 201 ++++++++++++++++++++++++++++++++++++++++ src/TaskRadiolib.h | 38 ++++++++ 5 files changed, 265 insertions(+), 21 deletions(-) create mode 100644 src/TaskRadiolib.cpp create mode 100644 src/TaskRadiolib.h diff --git a/platformio.ini b/platformio.ini index a2f5cb3..750984e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -16,6 +16,7 @@ lib_deps = knolleary/PubSubClient@^2.8 mikalhart/TinyGPSPlus @ 1.0.2 shaggydog/OneButton @ 1.5.0 + jgromes/RadioLib@^5.1.2 check_tool = cppcheck check_flags = cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK --force lib -ilib/TimeLib -ilib/LoRa -ilib/NTPClient diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index f2a2e35..179372e 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -13,9 +13,10 @@ #include "TaskEth.h" #include "TaskFTP.h" #include "TaskMQTT.h" -#include "TaskModem.h" +//#include "TaskModem.h" #include "TaskNTP.h" #include "TaskOTA.h" +#include "TaskRadioLib.h" #include "TaskRouter.h" #include "TaskWifi.h" #include "project_configuration.h" @@ -35,16 +36,17 @@ System LoRaSystem; Configuration userConfig; DisplayTask displayTask; -ModemTask modemTask(fromModem, toModem); -EthTask ethTask; -WifiTask wifiTask; -OTATask otaTask; -NTPTask ntpTask; -FTPTask ftpTask; -MQTTTask mqttTask(toMQTT); -AprsIsTask aprsIsTask(toAprsIs); -RouterTask routerTask(fromModem, toModem, toAprsIs, toMQTT); -BeaconTask beaconTask(toModem, toAprsIs); +// ModemTask modemTask(fromModem, toModem); +RadiolibTask modemTask(fromModem, toModem); +EthTask ethTask; +WifiTask wifiTask; +OTATask otaTask; +NTPTask ntpTask; +FTPTask ftpTask; +MQTTTask mqttTask(toMQTT); +AprsIsTask aprsIsTask(toAprsIs); +RouterTask routerTask(fromModem, toModem, toAprsIs, toMQTT); +BeaconTask beaconTask(toModem, toAprsIs); void setup() { Serial.begin(115200); diff --git a/src/Task.h b/src/Task.h index cd4b3da..a3b3fb9 100644 --- a/src/Task.h +++ b/src/Task.h @@ -7,6 +7,7 @@ enum TaskNames TaskEth, TaskFtp, TaskModem, + TaskRadiolib, TaskNtp, TaskOta, TaskWifi, @@ -16,15 +17,16 @@ enum TaskNames TaskSize }; -#define TASK_APRS_IS "AprsIsTask" -#define TASK_ETH "EthTask" -#define TASK_FTP "FTPTask" -#define TASK_MODEM "ModemTask" -#define TASK_NTP "NTPTask" -#define TASK_OTA "OTATask" -#define TASK_WIFI "WifiTask" -#define TASK_ROUTER "RouterTask" -#define TASK_MQTT "MQTTTask" -#define TASK_BEACON "BeaconTask" +#define TASK_APRS_IS "AprsIsTask" +#define TASK_ETH "EthTask" +#define TASK_FTP "FTPTask" +#define TASK_MODEM "ModemTask" +#define TASK_RADIOLIB "RadiolibTask" +#define TASK_NTP "NTPTask" +#define TASK_OTA "OTATask" +#define TASK_WIFI "WifiTask" +#define TASK_ROUTER "RouterTask" +#define TASK_MQTT "MQTTTask" +#define TASK_BEACON "BeaconTask" #endif diff --git a/src/TaskRadiolib.cpp b/src/TaskRadiolib.cpp new file mode 100644 index 0000000..1a032f8 --- /dev/null +++ b/src/TaskRadiolib.cpp @@ -0,0 +1,201 @@ +#include + +#include +#include + +#include "Task.h" +#include "TaskAprsIs.h" +#include "TaskRadioLib.h" + +RadiolibTask::RadiolibTask(TaskQueue> &fromModem, TaskQueue> &toModem) : Task(TASK_RADIOLIB, TaskModem), _fromModem(fromModem), _toModem(toModem) { +} + +RadiolibTask::~RadiolibTask() { +} + +volatile bool RadiolibTask::enableInterrupt = true; // Need to catch interrupt or not. +volatile bool RadiolibTask::operationDone = false; // Caught IRQ or not. + +void RadiolibTask::setFlag(void) { + if (!enableInterrupt) { + return; + } + + operationDone = true; +} + +bool RadiolibTask::setup(System &system) { + SPI.begin(system.getBoardConfig()->LoraSck, system.getBoardConfig()->LoraMiso, system.getBoardConfig()->LoraMosi, system.getBoardConfig()->LoraCS); + module = new Module(system.getBoardConfig()->LoraCS, system.getBoardConfig()->LoraIRQ, system.getBoardConfig()->LoraReset); + radio = new SX1278(module); + + config = system.getUserConfig()->lora; + + rxEnable = true; + txEnable = config.tx_enable; + + float freqMHz = (float)config.frequencyRx / 1000000; + float BWkHz = (float)config.signalBandwidth / 1000; + + int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); + + int state = radio->begin(freqMHz, BWkHz, config.spreadingFactor, config.codingRate4, RADIOLIB_SX127X_SYNC_WORD, config.power /* 2-17 */, 8, config.gainRx); + if (state != RADIOLIB_ERR_NONE) { + switch (state) { + case RADIOLIB_ERR_INVALID_FREQUENCY: + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] SX1278 init failed, The supplied frequency value (%fMHz) is invalid for this module.", timeString().c_str(), freqMHz); + rxEnable = false; + txEnable = false; + break; + case RADIOLIB_ERR_INVALID_BANDWIDTH: + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] SX1278 init failed, The supplied bandwidth value (%fkHz) is invalid for this module. Should be 7800, 10400, 15600, 20800, 31250, 41700 ,62500, 125000, 250000, 500000.", timeString().c_str(), BWkHz); + rxEnable = false; + txEnable = false; + break; + case RADIOLIB_ERR_INVALID_SPREADING_FACTOR: + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] SX1278 init failed, The supplied spreading factor value (%d) is invalid for this module.", timeString().c_str(), config.spreadingFactor); + rxEnable = false; + txEnable = false; + break; + case RADIOLIB_ERR_INVALID_CODING_RATE: + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] SX1278 init failed, The supplied coding rate value (%d) is invalid for this module.", timeString().c_str(), config.codingRate4); + rxEnable = false; + txEnable = false; + break; + case RADIOLIB_ERR_INVALID_OUTPUT_POWER: + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] SX1278 init failed, The supplied output power value (%d) is invalid for this module.", timeString().c_str(), config.power); + txEnable = false; + break; + case RADIOLIB_ERR_INVALID_PREAMBLE_LENGTH: + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] SX1278 init failed, The supplied preamble length is invalid.", timeString().c_str()); + txEnable = false; + break; + case RADIOLIB_ERR_INVALID_GAIN: + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] SX1278 init failed, The supplied gain value (%d) is invalid.", timeString().c_str(), config.gainRx); + rxEnable = false; + break; + default: + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] SX1278 init failed, code %d", timeString().c_str(), state); + rxEnable = false; + txEnable = false; + } + } + + state = radio->setCRC(true); + if (state != RADIOLIB_ERR_NONE) { + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] setCRC failed, code %d", timeString().c_str(), state); + while (true) + ; + } + + radio->setDio0Action(setFlag); + + if (rxEnable) { + int state = startRX(RADIOLIB_SX127X_RXCONTINUOUS); + if (state != RADIOLIB_ERR_NONE) { + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] startRX failed, code %d", timeString().c_str(), state); + rxEnable = false; + } + } + + return true; +} + +int transmissionState = RADIOLIB_ERR_NONE; +bool transmitFlag = false; // Transmitting or not. + +bool RadiolibTask::loop(System &system) { + if (operationDone) { // occurs interrupt. + enableInterrupt = false; + + if (transmitFlag) { // transmitted. + if (transmissionState == RADIOLIB_ERR_NONE) { + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] TX done", timeString().c_str()); + + } else { + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] transmitFlag failed, code %d", timeString().c_str(), transmissionState); + } + operationDone = false; + transmitFlag = false; + + } else { // received. + String str; + int state = radio->readData(str); + + if (state != RADIOLIB_ERR_NONE) { + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] readData failed, code %d", timeString().c_str(), state); + } else { + if (str.substring(0, 3) != "<\xff\x01") { + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Unknown packet '%s' with RSSI %.0fdBm, SNR %.2fdB and FreqErr %dHz", timeString().c_str(), radio->getRSSI(), radio->getSNR(), -radio->getFrequencyError()); + } else { + std::shared_ptr msg = std::shared_ptr(new APRSMessage()); + msg->decode(str.substring(3)); + _fromModem.addElement(msg); + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Received packet '%s' with RSSI %.0fdBm, SNR %.2fdB and FreqErr %fHz", timeString().c_str(), msg->toString().c_str(), radio->getRSSI(), radio->getSNR(), -radio->getFrequencyError()); + system.getDisplay().addFrame(std::shared_ptr(new TextFrame("LoRa", msg->toString().c_str()))); + } + } + operationDone = false; + } + + if (rxEnable) { + int state = startRX(RADIOLIB_SX127X_RXCONTINUOUS); + if (state != RADIOLIB_ERR_NONE) { + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] startRX failed, code %d", timeString().c_str(), state); + rxEnable = false; + } + } + + enableInterrupt = true; + } else { // not interrupt. + if (!txEnable) { + // system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] TX is not enabled", timeString().c_str()); + } else { + if (transmitFlag) { + // system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] TX signal detected. Waiting TX", timeString().c_str()); + } else { + if (!_toModem.empty()) { + if (config.frequencyRx == config.frequencyTx && (radio->getModemStatus() & 0x01) == 0x01) { + // system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] RX signal detected. Waiting TX", timeString().c_str()); + } else { + std::shared_ptr msg = _toModem.getElement(); + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Transmitting packet '%s'", timeString().c_str(), msg->toString().c_str()); + + int16_t state = startTX("<\xff\x01" + msg->encode()); + if (state != RADIOLIB_ERR_NONE) { + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] startTX failed, code %d", timeString().c_str(), state); + txEnable = false; + return true; + } + } + } + } + } + } + + return true; +} + +int16_t RadiolibTask::startRX(uint8_t mode) { + if (config.frequencyTx != config.frequencyRx) { + int16_t state = radio->setFrequency((float)config.frequencyRx / 1000000); + if (state != RADIOLIB_ERR_NONE) { + return state; + } + } + + return radio->startReceive(0, mode); +} + +int16_t RadiolibTask::startTX(String &str) { + if (config.frequencyTx != config.frequencyRx) { + int16_t state = radio->setFrequency((float)config.frequencyTx / 1000000); + if (state != RADIOLIB_ERR_NONE) { + return state; + } + } + + transmissionState = radio->startTransmit(str); + transmitFlag = true; + return RADIOLIB_ERR_NONE; +} diff --git a/src/TaskRadiolib.h b/src/TaskRadiolib.h new file mode 100644 index 0000000..a53cb6d --- /dev/null +++ b/src/TaskRadiolib.h @@ -0,0 +1,38 @@ +#ifndef TASK_LORA_H_ +#define TASK_LORA_H_ + +#include "project_configuration.h" +#include +#include +#include +#include + +class RadiolibTask : public Task { +public: + explicit RadiolibTask(TaskQueue> &fromModem, TaskQueue> &_toModem); + virtual ~RadiolibTask(); + + virtual bool setup(System &system) override; + virtual bool loop(System &system) override; + +private: + Module *module; + SX1278 *radio; + + Configuration::LoRa config; + + bool rxEnable, txEnable; + + TaskQueue> &_fromModem; + TaskQueue> &_toModem; + + static volatile bool enableInterrupt; // Need to catch interrupt or not. + static volatile bool operationDone; // Caught IRQ or not. + + static void setFlag(void); + + int16_t startRX(uint8_t mode); + int16_t startTX(String &str); +}; + +#endif From 3b7f0ffc6c0048fb10cd88432ee9ad0fe3c91ba5 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Sat, 2 Apr 2022 10:27:27 +0900 Subject: [PATCH 02/36] Bump up. --- src/LoRa_APRS_iGate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 179372e..237af8f 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -21,7 +21,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "22.13.3" +#define VERSION "22.13.4" #define MODULE_NAME "Main" String create_lat_aprs(double lat); From 6cb20361d608ee3b15b075d0363137dd8aa7e560 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Sat, 2 Apr 2022 10:36:06 +0900 Subject: [PATCH 03/36] typo --- src/TaskRadiolib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TaskRadiolib.cpp b/src/TaskRadiolib.cpp index 1a032f8..fb9f6b4 100644 --- a/src/TaskRadiolib.cpp +++ b/src/TaskRadiolib.cpp @@ -5,7 +5,7 @@ #include "Task.h" #include "TaskAprsIs.h" -#include "TaskRadioLib.h" +#include "TaskRadiolib.h" RadiolibTask::RadiolibTask(TaskQueue> &fromModem, TaskQueue> &toModem) : Task(TASK_RADIOLIB, TaskModem), _fromModem(fromModem), _toModem(toModem) { } From ba45d3e5518ec5284980a5c5030bedfcfcf18148 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Sat, 2 Apr 2022 10:38:51 +0900 Subject: [PATCH 04/36] sorry more typo. --- src/LoRa_APRS_iGate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 237af8f..49abcf4 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -16,7 +16,7 @@ //#include "TaskModem.h" #include "TaskNTP.h" #include "TaskOTA.h" -#include "TaskRadioLib.h" +#include "TaskRadiolib.h" #include "TaskRouter.h" #include "TaskWifi.h" #include "project_configuration.h" From 2a1475ec723c750e26bb8329d90082a27a93a788 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Sat, 2 Apr 2022 13:16:24 +0900 Subject: [PATCH 05/36] clear intr func when deconstuctor called, and delete no need definition. --- src/TaskRadiolib.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/TaskRadiolib.cpp b/src/TaskRadiolib.cpp index fb9f6b4..964f23f 100644 --- a/src/TaskRadiolib.cpp +++ b/src/TaskRadiolib.cpp @@ -11,6 +11,7 @@ RadiolibTask::RadiolibTask(TaskQueue> &fromModem, T } RadiolibTask::~RadiolibTask() { + radio->clearDio0Action(); } volatile bool RadiolibTask::enableInterrupt = true; // Need to catch interrupt or not. @@ -37,9 +38,7 @@ bool RadiolibTask::setup(System &system) { float freqMHz = (float)config.frequencyRx / 1000000; float BWkHz = (float)config.signalBandwidth / 1000; - int16_t begin(float freq = 434.0, float bw = 125.0, uint8_t sf = 9, uint8_t cr = 7, uint8_t syncWord = RADIOLIB_SX127X_SYNC_WORD, int8_t power = 10, uint16_t preambleLength = 8, uint8_t gain = 0); - - int state = radio->begin(freqMHz, BWkHz, config.spreadingFactor, config.codingRate4, RADIOLIB_SX127X_SYNC_WORD, config.power /* 2-17 */, 8, config.gainRx); + int16_t state = radio->begin(freqMHz, BWkHz, config.spreadingFactor, config.codingRate4, RADIOLIB_SX127X_SYNC_WORD, config.power /* 2-17 */, 8, config.gainRx); if (state != RADIOLIB_ERR_NONE) { switch (state) { case RADIOLIB_ERR_INVALID_FREQUENCY: From ebe78ceaadda189d9abcbec4e5bf800808747abb Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Sat, 2 Apr 2022 18:50:54 +0900 Subject: [PATCH 06/36] Avoid collision after TX is done. --- src/TaskRadiolib.cpp | 42 ++++++++++++++++++++++++++---------------- src/TaskRadiolib.h | 3 +++ 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/TaskRadiolib.cpp b/src/TaskRadiolib.cpp index 964f23f..a35ffbd 100644 --- a/src/TaskRadiolib.cpp +++ b/src/TaskRadiolib.cpp @@ -38,7 +38,9 @@ bool RadiolibTask::setup(System &system) { float freqMHz = (float)config.frequencyRx / 1000000; float BWkHz = (float)config.signalBandwidth / 1000; - int16_t state = radio->begin(freqMHz, BWkHz, config.spreadingFactor, config.codingRate4, RADIOLIB_SX127X_SYNC_WORD, config.power /* 2-17 */, 8, config.gainRx); + const uint16_t preambleLength = 8; + + int16_t state = radio->begin(freqMHz, BWkHz, config.spreadingFactor, config.codingRate4, RADIOLIB_SX127X_SYNC_WORD, config.power, preambleLength, config.gainRx); if (state != RADIOLIB_ERR_NONE) { switch (state) { case RADIOLIB_ERR_INVALID_FREQUENCY: @@ -97,6 +99,8 @@ bool RadiolibTask::setup(System &system) { } } + preambleDurationMilliSec = ((uint64_t)(preambleLength + 4) << (config.spreadingFactor + 10 /* to milli-sec */)) / config.signalBandwidth; + return true; } @@ -117,6 +121,9 @@ bool RadiolibTask::loop(System &system) { operationDone = false; transmitFlag = false; + txWaitTimer.setTimeout(preambleDurationMilliSec * 2); + txWaitTimer.start(); + } else { // received. String str; int state = radio->readData(str); @@ -147,24 +154,27 @@ bool RadiolibTask::loop(System &system) { enableInterrupt = true; } else { // not interrupt. - if (!txEnable) { - // system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] TX is not enabled", timeString().c_str()); + if (!txWaitTimer.check()) { } else { - if (transmitFlag) { - // system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] TX signal detected. Waiting TX", timeString().c_str()); + if (!txEnable) { + // system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] TX is not enabled", timeString().c_str()); } else { - if (!_toModem.empty()) { - if (config.frequencyRx == config.frequencyTx && (radio->getModemStatus() & 0x01) == 0x01) { - // system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] RX signal detected. Waiting TX", timeString().c_str()); - } else { - std::shared_ptr msg = _toModem.getElement(); - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Transmitting packet '%s'", timeString().c_str(), msg->toString().c_str()); + if (transmitFlag) { + // system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] TX signal detected. Waiting TX", timeString().c_str()); + } else { + if (!_toModem.empty()) { + if (config.frequencyRx == config.frequencyTx && (radio->getModemStatus() & 0x01) == 0x01) { + // system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] RX signal detected. Waiting TX", timeString().c_str()); + } else { + std::shared_ptr msg = _toModem.getElement(); + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Transmitting packet '%s'", timeString().c_str(), msg->toString().c_str()); - int16_t state = startTX("<\xff\x01" + msg->encode()); - if (state != RADIOLIB_ERR_NONE) { - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] startTX failed, code %d", timeString().c_str(), state); - txEnable = false; - return true; + int16_t state = startTX("<\xff\x01" + msg->encode()); + if (state != RADIOLIB_ERR_NONE) { + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] startTX failed, code %d", timeString().c_str(), state); + txEnable = false; + return true; + } } } } diff --git a/src/TaskRadiolib.h b/src/TaskRadiolib.h index a53cb6d..2f9cc85 100644 --- a/src/TaskRadiolib.h +++ b/src/TaskRadiolib.h @@ -33,6 +33,9 @@ private: int16_t startRX(uint8_t mode); int16_t startTX(String &str); + + uint32_t preambleDurationMilliSec; + Timer txWaitTimer; }; #endif From 3f7d972958782f3f0b049d99672809dedc09e662 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Sun, 3 Apr 2022 08:39:56 +0900 Subject: [PATCH 07/36] debug. --- src/TaskRadiolib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TaskRadiolib.cpp b/src/TaskRadiolib.cpp index a35ffbd..34f05b9 100644 --- a/src/TaskRadiolib.cpp +++ b/src/TaskRadiolib.cpp @@ -7,7 +7,7 @@ #include "TaskAprsIs.h" #include "TaskRadiolib.h" -RadiolibTask::RadiolibTask(TaskQueue> &fromModem, TaskQueue> &toModem) : Task(TASK_RADIOLIB, TaskModem), _fromModem(fromModem), _toModem(toModem) { +RadiolibTask::RadiolibTask(TaskQueue> &fromModem, TaskQueue> &toModem) : Task(TASK_RADIOLIB, TaskRadiolib), _fromModem(fromModem), _toModem(toModem) { } RadiolibTask::~RadiolibTask() { From b5623a58706265627d1da8dd0f5437389ad549d0 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Fri, 20 May 2022 22:45:58 +0200 Subject: [PATCH 08/36] delete not needed files --- lib/LoRa/LoRa.cpp | 636 ------------------------------------ lib/LoRa/LoRa.h | 120 ------- lib/LoRa_APRS/LoRa_APRS.cpp | 69 ---- lib/LoRa_APRS/LoRa_APRS.h | 33 -- src/TaskModem.cpp | 64 ---- src/TaskModem.h | 23 -- 6 files changed, 945 deletions(-) delete mode 100644 lib/LoRa/LoRa.cpp delete mode 100644 lib/LoRa/LoRa.h delete mode 100644 lib/LoRa_APRS/LoRa_APRS.cpp delete mode 100644 lib/LoRa_APRS/LoRa_APRS.h delete mode 100644 src/TaskModem.cpp delete mode 100644 src/TaskModem.h diff --git a/lib/LoRa/LoRa.cpp b/lib/LoRa/LoRa.cpp deleted file mode 100644 index 2422ca8..0000000 --- a/lib/LoRa/LoRa.cpp +++ /dev/null @@ -1,636 +0,0 @@ -// Copyright (c) Sandeep Mistry. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -#include - -// registers -#define REG_FIFO 0x00 -#define REG_OP_MODE 0x01 -#define REG_FRF_MSB 0x06 -#define REG_FRF_MID 0x07 -#define REG_FRF_LSB 0x08 -#define REG_PA_CONFIG 0x09 -#define REG_OCP 0x0b -#define REG_LNA 0x0c -#define REG_FIFO_ADDR_PTR 0x0d -#define REG_FIFO_TX_BASE_ADDR 0x0e -#define REG_FIFO_RX_BASE_ADDR 0x0f -#define REG_FIFO_RX_CURRENT_ADDR 0x10 -#define REG_IRQ_FLAGS 0x12 -#define REG_RX_NB_BYTES 0x13 -#define REG_MODEM_STAT 0x18 -#define REG_PKT_SNR_VALUE 0x19 -#define REG_PKT_RSSI_VALUE 0x1a -#define REG_RSSI_VALUE 0x1b -#define REG_MODEM_CONFIG_1 0x1d -#define REG_MODEM_CONFIG_2 0x1e -#define REG_PREAMBLE_MSB 0x20 -#define REG_PREAMBLE_LSB 0x21 -#define REG_PAYLOAD_LENGTH 0x22 -#define REG_MODEM_CONFIG_3 0x26 -#define REG_FREQ_ERROR_MSB 0x28 -#define REG_FREQ_ERROR_MID 0x29 -#define REG_FREQ_ERROR_LSB 0x2a -#define REG_RSSI_WIDEBAND 0x2c -#define REG_DETECTION_OPTIMIZE 0x31 -#define REG_INVERTIQ 0x33 -#define REG_DETECTION_THRESHOLD 0x37 -#define REG_SYNC_WORD 0x39 -#define REG_INVERTIQ2 0x3b -#define REG_DIO_MAPPING_1 0x40 -#define REG_VERSION 0x42 -#define REG_PA_DAC 0x4d - -// modes -#define MODE_LONG_RANGE_MODE 0x80 -#define MODE_SLEEP 0x00 -#define MODE_STDBY 0x01 -#define MODE_TX 0x03 -#define MODE_RX_CONTINUOUS 0x05 -#define MODE_RX_SINGLE 0x06 - -// PA config -#define PA_BOOST 0x80 - -// IRQ masks -#define IRQ_TX_DONE_MASK 0x08 -#define IRQ_PAYLOAD_CRC_ERROR_MASK 0x20 -#define IRQ_RX_DONE_MASK 0x40 - -#define RF_MID_BAND_THRESHOLD 525E6 -#define RSSI_OFFSET_HF_PORT 157 -#define RSSI_OFFSET_LF_PORT 164 - -#define MAX_PKT_LENGTH 255 - -#if (ESP8266 || ESP32) -#define ISR_PREFIX ICACHE_RAM_ATTR -#else -#define ISR_PREFIX -#endif - -LoRaClass::LoRaClass() : _spiSettings(LORA_DEFAULT_SPI_FREQUENCY, MSBFIRST, SPI_MODE0), _spi(&LORA_DEFAULT_SPI), _ss(LORA_DEFAULT_SS_PIN), _reset(LORA_DEFAULT_RESET_PIN), _dio0(LORA_DEFAULT_DIO0_PIN), _frequency(0), _packetIndex(0), _implicitHeaderMode(0) { - // overide Stream timeout value - setTimeout(0); -} - -int LoRaClass::begin(long frequency) { -#if defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) - pinMode(LORA_IRQ_DUMB, OUTPUT); - digitalWrite(LORA_IRQ_DUMB, LOW); - - // Hardware reset - pinMode(LORA_BOOT0, OUTPUT); - digitalWrite(LORA_BOOT0, LOW); - - pinMode(LORA_RESET, OUTPUT); - digitalWrite(LORA_RESET, HIGH); - delay(200); - digitalWrite(LORA_RESET, LOW); - delay(200); - digitalWrite(LORA_RESET, HIGH); - delay(50); -#endif - - // setup pins - pinMode(_ss, OUTPUT); - // set SS high - digitalWrite(_ss, HIGH); - - if (_reset != -1) { - pinMode(_reset, OUTPUT); - - // perform reset - digitalWrite(_reset, LOW); - delay(10); - digitalWrite(_reset, HIGH); - delay(10); - } - - // start SPI - _spi->begin(); - - // check version - uint8_t version = readRegister(REG_VERSION); - if (version != 0x12) { - return 0; - } - - // put in sleep mode - sleep(); - - // set frequency - setFrequency(frequency); - - // set base addresses - writeRegister(REG_FIFO_TX_BASE_ADDR, 0); - writeRegister(REG_FIFO_RX_BASE_ADDR, 0); - - // set LNA boost - writeRegister(REG_LNA, readRegister(REG_LNA) | 0x01); - - // set auto AGC - writeRegister(REG_MODEM_CONFIG_3, 0x04); - - // set output power to 17 dBm - setTxPower(17); - - // put in standby mode - idle(); - - return 1; -} - -void LoRaClass::end() { - // put in sleep mode - sleep(); - - // stop SPI - _spi->end(); -} - -int LoRaClass::beginPacket(int implicitHeader) { - if (isTransmitting()) { - return 0; - } - - // put in standby mode - idle(); - - if (implicitHeader) { - implicitHeaderMode(); - } else { - explicitHeaderMode(); - } - - // reset FIFO address and paload length - writeRegister(REG_FIFO_ADDR_PTR, 0); - writeRegister(REG_PAYLOAD_LENGTH, 0); - - return 1; -} - -int LoRaClass::endPacket(bool async) { - - // put in TX mode - writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_TX); - - if (!async) { - // wait for TX done - while ((readRegister(REG_IRQ_FLAGS) & IRQ_TX_DONE_MASK) == 0) { - yield(); - } - // clear IRQ's - writeRegister(REG_IRQ_FLAGS, IRQ_TX_DONE_MASK); - } - - return 1; -} - -bool LoRaClass::isTransmitting() { - if ((readRegister(REG_OP_MODE) & MODE_TX) == MODE_TX) { - return true; - } - - if (readRegister(REG_IRQ_FLAGS) & IRQ_TX_DONE_MASK) { - // clear IRQ's - writeRegister(REG_IRQ_FLAGS, IRQ_TX_DONE_MASK); - } - - return false; -} - -int LoRaClass::parsePacket(int size) { - int packetLength = 0; - int irqFlags = readRegister(REG_IRQ_FLAGS); - - if (size > 0) { - implicitHeaderMode(); - - writeRegister(REG_PAYLOAD_LENGTH, size & 0xff); - } else { - explicitHeaderMode(); - } - - // clear IRQ's - writeRegister(REG_IRQ_FLAGS, irqFlags); - - if ((irqFlags & IRQ_RX_DONE_MASK) && (irqFlags & IRQ_PAYLOAD_CRC_ERROR_MASK) == 0) { - // received a packet - _packetIndex = 0; - - // read packet length - if (_implicitHeaderMode) { - packetLength = readRegister(REG_PAYLOAD_LENGTH); - } else { - packetLength = readRegister(REG_RX_NB_BYTES); - } - - // set FIFO address to current RX address - writeRegister(REG_FIFO_ADDR_PTR, readRegister(REG_FIFO_RX_CURRENT_ADDR)); - - // put in standby mode - idle(); - } else if (readRegister(REG_OP_MODE) != (MODE_LONG_RANGE_MODE | MODE_RX_SINGLE)) { - // not currently in RX mode - - // reset FIFO address - writeRegister(REG_FIFO_ADDR_PTR, 0); - - // put in single RX mode - writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_RX_SINGLE); - } - - return packetLength; -} - -int LoRaClass::packetRssi() { - return (readRegister(REG_PKT_RSSI_VALUE) - (_frequency < RF_MID_BAND_THRESHOLD ? RSSI_OFFSET_LF_PORT : RSSI_OFFSET_HF_PORT)); -} - -float LoRaClass::packetSnr() { - return ((int8_t)readRegister(REG_PKT_SNR_VALUE)) * 0.25; -} - -bool LoRaClass::rxSignalDetected() { - return (readRegister(REG_MODEM_STAT) & 0x01) == 0x01; -} - -long LoRaClass::packetFrequencyError() { - int32_t freqError = 0; - freqError = static_cast(readRegister(REG_FREQ_ERROR_MSB) & B111); - freqError <<= 8L; - freqError += static_cast(readRegister(REG_FREQ_ERROR_MID)); - freqError <<= 8L; - freqError += static_cast(readRegister(REG_FREQ_ERROR_LSB)); - - if (readRegister(REG_FREQ_ERROR_MSB) & B1000) { // Sign bit is on - freqError -= 524288; // B1000'0000'0000'0000'0000 - } - - const float fXtal = 32E6; // FXOSC: crystal oscillator (XTAL) frequency (2.5. Chip Specification, p. 14) - const float fError = ((static_cast(freqError) * (1L << 24)) / fXtal) * (getSignalBandwidth() / 500000.0f); // p. 37 - - return static_cast(fError); -} - -int LoRaClass::rssi() { - return (readRegister(REG_RSSI_VALUE) - (_frequency < RF_MID_BAND_THRESHOLD ? RSSI_OFFSET_LF_PORT : RSSI_OFFSET_HF_PORT)); -} - -size_t LoRaClass::write(uint8_t byte) { - return write(&byte, sizeof(byte)); -} - -size_t LoRaClass::write(const uint8_t *buffer, size_t size) { - int currentLength = readRegister(REG_PAYLOAD_LENGTH); - - // check size - if ((currentLength + size) > MAX_PKT_LENGTH) { - size = MAX_PKT_LENGTH - currentLength; - } - - // write data - for (size_t i = 0; i < size; i++) { - writeRegister(REG_FIFO, buffer[i]); - } - - // update length - writeRegister(REG_PAYLOAD_LENGTH, currentLength + size); - - return size; -} - -int LoRaClass::available() { - return (readRegister(REG_RX_NB_BYTES) - _packetIndex); -} - -int LoRaClass::read() { - if (!available()) { - return -1; - } - - _packetIndex++; - - return readRegister(REG_FIFO); -} - -int LoRaClass::peek() { - if (!available()) { - return -1; - } - - // store current FIFO address - int currentAddress = readRegister(REG_FIFO_ADDR_PTR); - - // read - uint8_t b = readRegister(REG_FIFO); - - // restore FIFO address - writeRegister(REG_FIFO_ADDR_PTR, currentAddress); - - return b; -} - -void LoRaClass::flush() { -} - -void LoRaClass::receive(int size) { - - writeRegister(REG_DIO_MAPPING_1, 0x00); // DIO0 => RXDONE - - if (size > 0) { - implicitHeaderMode(); - - writeRegister(REG_PAYLOAD_LENGTH, size & 0xff); - } else { - explicitHeaderMode(); - } - - writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_RX_CONTINUOUS); -} - -void LoRaClass::idle() { - writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_STDBY); -} - -void LoRaClass::sleep() { - writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_SLEEP); -} - -void LoRaClass::setTxPower(int level, int outputPin) { - if (PA_OUTPUT_RFO_PIN == outputPin) { - // RFO - if (level < 0) { - level = 0; - } else if (level > 14) { - level = 14; - } - - writeRegister(REG_PA_CONFIG, 0x70 | level); - } else { - // PA BOOST - if (level > 17) { - if (level > 20) { - level = 20; - } - - // subtract 3 from level, so 18 - 20 maps to 15 - 17 - level -= 3; - - // High Power +20 dBm Operation (Semtech SX1276/77/78/79 5.4.3.) - writeRegister(REG_PA_DAC, 0x87); - setOCP(140); - } else { - if (level < 2) { - level = 2; - } - // Default value PA_HF/LF or +17dBm - writeRegister(REG_PA_DAC, 0x84); - setOCP(100); - } - - writeRegister(REG_PA_CONFIG, PA_BOOST | (level - 2)); - } -} - -void LoRaClass::setFrequency(long frequency) { - _frequency = frequency; - - uint64_t frf = ((uint64_t)frequency << 19) / 32000000; - - writeRegister(REG_FRF_MSB, (uint8_t)(frf >> 16)); - writeRegister(REG_FRF_MID, (uint8_t)(frf >> 8)); - writeRegister(REG_FRF_LSB, (uint8_t)(frf >> 0)); -} - -int LoRaClass::getSpreadingFactor() { - return readRegister(REG_MODEM_CONFIG_2) >> 4; -} - -void LoRaClass::setSpreadingFactor(int sf) { - if (sf < 6) { - sf = 6; - } else if (sf > 12) { - sf = 12; - } - - if (sf == 6) { - writeRegister(REG_DETECTION_OPTIMIZE, 0xc5); - writeRegister(REG_DETECTION_THRESHOLD, 0x0c); - } else { - writeRegister(REG_DETECTION_OPTIMIZE, 0xc3); - writeRegister(REG_DETECTION_THRESHOLD, 0x0a); - } - - writeRegister(REG_MODEM_CONFIG_2, (readRegister(REG_MODEM_CONFIG_2) & 0x0f) | ((sf << 4) & 0xf0)); - setLdoFlag(); -} - -long LoRaClass::getSignalBandwidth() { - byte bw = (readRegister(REG_MODEM_CONFIG_1) >> 4); - - switch (bw) { - case 0: - return 7.8E3; - case 1: - return 10.4E3; - case 2: - return 15.6E3; - case 3: - return 20.8E3; - case 4: - return 31.25E3; - case 5: - return 41.7E3; - case 6: - return 62.5E3; - case 7: - return 125E3; - case 8: - return 250E3; - case 9: - return 500E3; - } - - return -1; -} - -void LoRaClass::setSignalBandwidth(long sbw) { - int bw; - - if (sbw <= 7.8E3) { - bw = 0; - } else if (sbw <= 10.4E3) { - bw = 1; - } else if (sbw <= 15.6E3) { - bw = 2; - } else if (sbw <= 20.8E3) { - bw = 3; - } else if (sbw <= 31.25E3) { - bw = 4; - } else if (sbw <= 41.7E3) { - bw = 5; - } else if (sbw <= 62.5E3) { - bw = 6; - } else if (sbw <= 125E3) { - bw = 7; - } else if (sbw <= 250E3) { - bw = 8; - } else /*if (sbw <= 250E3)*/ { - bw = 9; - } - - writeRegister(REG_MODEM_CONFIG_1, (readRegister(REG_MODEM_CONFIG_1) & 0x0f) | (bw << 4)); - setLdoFlag(); -} - -void LoRaClass::setLdoFlag() { - // Section 4.1.1.5 - long symbolDuration = 1000 / (getSignalBandwidth() / (1L << getSpreadingFactor())); - - // Section 4.1.1.6 - boolean ldoOn = symbolDuration > 16; - - uint8_t config3 = readRegister(REG_MODEM_CONFIG_3); - bitWrite(config3, 3, ldoOn); - writeRegister(REG_MODEM_CONFIG_3, config3); -} - -void LoRaClass::setCodingRate4(int denominator) { - if (denominator < 5) { - denominator = 5; - } else if (denominator > 8) { - denominator = 8; - } - - int cr = denominator - 4; - - writeRegister(REG_MODEM_CONFIG_1, (readRegister(REG_MODEM_CONFIG_1) & 0xf1) | (cr << 1)); -} - -void LoRaClass::setPreambleLength(long length) { - writeRegister(REG_PREAMBLE_MSB, (uint8_t)(length >> 8)); - writeRegister(REG_PREAMBLE_LSB, (uint8_t)(length >> 0)); -} - -void LoRaClass::setSyncWord(int sw) { - writeRegister(REG_SYNC_WORD, sw); -} - -void LoRaClass::enableCrc() { - writeRegister(REG_MODEM_CONFIG_2, readRegister(REG_MODEM_CONFIG_2) | 0x04); -} - -void LoRaClass::disableCrc() { - writeRegister(REG_MODEM_CONFIG_2, readRegister(REG_MODEM_CONFIG_2) & 0xfb); -} - -void LoRaClass::enableInvertIQ() { - writeRegister(REG_INVERTIQ, 0x66); - writeRegister(REG_INVERTIQ2, 0x19); -} - -void LoRaClass::disableInvertIQ() { - writeRegister(REG_INVERTIQ, 0x27); - writeRegister(REG_INVERTIQ2, 0x1d); -} - -void LoRaClass::setOCP(uint8_t mA) { - uint8_t ocpTrim = 27; - - if (mA <= 120) { - ocpTrim = (mA - 45) / 5; - } else if (mA <= 240) { - ocpTrim = (mA + 30) / 10; - } - - writeRegister(REG_OCP, 0x20 | (0x1F & ocpTrim)); -} - -void LoRaClass::setGain(uint8_t gain) { - // check allowed range - if (gain > 6) { - gain = 6; - } - - // set to standby - idle(); - - // set gain - if (gain == 0) { - // if gain = 0, enable AGC - writeRegister(REG_MODEM_CONFIG_3, 0x04); - } else { - // disable AGC - writeRegister(REG_MODEM_CONFIG_3, 0x00); - - // clear Gain and set LNA boost - writeRegister(REG_LNA, 0x01); - - // set gain - writeRegister(REG_LNA, readRegister(REG_LNA) | (gain << 5)); - } -} - -byte LoRaClass::random() { - return readRegister(REG_RSSI_WIDEBAND); -} - -void LoRaClass::setPins(int ss, int reset, int dio0) { - _ss = ss; - _reset = reset; - _dio0 = dio0; -} - -void LoRaClass::setSPI(SPIClass &spi) { - _spi = &spi; -} - -void LoRaClass::setSPIFrequency(uint32_t frequency) { - _spiSettings = SPISettings(frequency, MSBFIRST, SPI_MODE0); -} - -void LoRaClass::dumpRegisters(Stream &out) { - for (int i = 0; i < 128; i++) { - out.print("0x"); - out.print(i, HEX); - out.print(": 0x"); - out.println(readRegister(i), HEX); - } -} - -void LoRaClass::explicitHeaderMode() { - _implicitHeaderMode = 0; - - writeRegister(REG_MODEM_CONFIG_1, readRegister(REG_MODEM_CONFIG_1) & 0xfe); -} - -void LoRaClass::implicitHeaderMode() { - _implicitHeaderMode = 1; - - writeRegister(REG_MODEM_CONFIG_1, readRegister(REG_MODEM_CONFIG_1) | 0x01); -} - -uint8_t LoRaClass::readRegister(uint8_t address) { - return singleTransfer(address & 0x7f, 0x00); -} - -void LoRaClass::writeRegister(uint8_t address, uint8_t value) { - singleTransfer(address | 0x80, value); -} - -uint8_t LoRaClass::singleTransfer(uint8_t address, uint8_t value) { - uint8_t response; - - digitalWrite(_ss, LOW); - - _spi->beginTransaction(_spiSettings); - _spi->transfer(address); - response = _spi->transfer(value); - _spi->endTransaction(); - - digitalWrite(_ss, HIGH); - - return response; -} diff --git a/lib/LoRa/LoRa.h b/lib/LoRa/LoRa.h deleted file mode 100644 index 45c92bd..0000000 --- a/lib/LoRa/LoRa.h +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) Sandeep Mistry. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -#ifndef LORA_H -#define LORA_H - -#include -#include - -#if defined(ARDUINO_SAMD_MKRWAN1300) -#define LORA_DEFAULT_SPI SPI1 -#define LORA_DEFAULT_SPI_FREQUENCY 200000 -#define LORA_DEFAULT_SS_PIN LORA_IRQ_DUMB -#define LORA_DEFAULT_RESET_PIN -1 -#define LORA_DEFAULT_DIO0_PIN -1 -#elif defined(ARDUINO_SAMD_MKRWAN1310) -#define LORA_DEFAULT_SPI SPI1 -#define LORA_DEFAULT_SPI_FREQUENCY 200000 -#define LORA_DEFAULT_SS_PIN LORA_IRQ_DUMB -#define LORA_DEFAULT_RESET_PIN -1 -#define LORA_DEFAULT_DIO0_PIN LORA_IRQ -#else -#define LORA_DEFAULT_SPI SPI -#define LORA_DEFAULT_SPI_FREQUENCY 8E6 -#define LORA_DEFAULT_SS_PIN 10 -#define LORA_DEFAULT_RESET_PIN 9 -#define LORA_DEFAULT_DIO0_PIN 2 -#endif - -#define PA_OUTPUT_RFO_PIN 0 -#define PA_OUTPUT_PA_BOOST_PIN 1 - -class LoRaClass : public Stream { -public: - LoRaClass(); - - int begin(long frequency); - void end(); - - int beginPacket(int implicitHeader = false); - int endPacket(bool async = false); - - int parsePacket(int size = 0); - int packetRssi(); - float packetSnr(); - long packetFrequencyError(); - bool rxSignalDetected(); - - int rssi(); - - // from Print - virtual size_t write(uint8_t byte); - virtual size_t write(const uint8_t *buffer, size_t size); - - // from Stream - virtual int available(); - virtual int read(); - virtual int peek(); - virtual void flush(); - - void receive(int size = 0); - - void idle(); - void sleep(); - - void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN); - void setFrequency(long frequency); - void setSpreadingFactor(int sf); - void setSignalBandwidth(long sbw); - void setCodingRate4(int denominator); - void setPreambleLength(long length); - void setSyncWord(int sw); - void enableCrc(); - void disableCrc(); - void enableInvertIQ(); - void disableInvertIQ(); - - void setOCP(uint8_t mA); // Over Current Protection control - - void setGain(uint8_t gain); // Set LNA gain - - // deprecated - void crc() { enableCrc(); } - void noCrc() { disableCrc(); } - - byte random(); - - void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN); - void setSPI(SPIClass& spi); - void setSPIFrequency(uint32_t frequency); - - void dumpRegisters(Stream& out); - -private: - void explicitHeaderMode(); - void implicitHeaderMode(); - - bool isTransmitting(); - - int getSpreadingFactor(); - long getSignalBandwidth(); - - void setLdoFlag(); - - uint8_t readRegister(uint8_t address); - void writeRegister(uint8_t address, uint8_t value); - uint8_t singleTransfer(uint8_t address, uint8_t value); - -private: - SPISettings _spiSettings; - SPIClass* _spi; - int _ss; - int _reset; - int _dio0; - long _frequency; - int _packetIndex; - int _implicitHeaderMode; -}; - -#endif diff --git a/lib/LoRa_APRS/LoRa_APRS.cpp b/lib/LoRa_APRS/LoRa_APRS.cpp deleted file mode 100644 index 48d2dfa..0000000 --- a/lib/LoRa_APRS/LoRa_APRS.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "LoRa_APRS.h" - -LoRa_APRS::LoRa_APRS() : _RxFrequency(433775000), _TxFrequency(433775000) { -} - -bool LoRa_APRS::checkMessage() { - if (!parsePacket()) { - return false; - } - // read header: - char dummy[4]; - readBytes(dummy, 3); - if (dummy[0] != '<') { - // is no APRS message, ignore message - while (available()) { - read(); - } - return false; - } - // read APRS data: - String str; - while (available()) { - str += (char)read(); - } - _LastReceivedMsg = std::shared_ptr(new APRSMessage()); - _LastReceivedMsg->decode(str); - return true; -} - -std::shared_ptr LoRa_APRS::getMessage() { - return _LastReceivedMsg; -} - -void LoRa_APRS::sendMessage(const std::shared_ptr msg) { - setFrequency(_TxFrequency); - String data = msg->encode(); - beginPacket(); - // Header: - write('<'); - write(0xFF); - write(0x01); - // APRS Data: - write((const uint8_t *)data.c_str(), data.length()); - endPacket(); - setFrequency(_RxFrequency); -} - -void LoRa_APRS::setRxFrequency(long frequency) { - _RxFrequency = frequency; - setFrequency(_RxFrequency); -} - -void LoRa_APRS::setRxGain(uint8_t gain) { - setGain(gain); -} - -// cppcheck-suppress unusedFunction -long LoRa_APRS::getRxFrequency() const { - return _RxFrequency; -} - -void LoRa_APRS::setTxFrequency(long frequency) { - _TxFrequency = frequency; -} - -// cppcheck-suppress unusedFunction -long LoRa_APRS::getTxFrequency() const { - return _TxFrequency; -} diff --git a/lib/LoRa_APRS/LoRa_APRS.h b/lib/LoRa_APRS/LoRa_APRS.h deleted file mode 100644 index 3d6eff4..0000000 --- a/lib/LoRa_APRS/LoRa_APRS.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef LORA_H_ -#define LORA_H_ - -#include - -#include -#include -#include - -class LoRa_APRS : public LoRaClass { -public: - LoRa_APRS(); - - bool checkMessage(); - std::shared_ptr getMessage(); - - void sendMessage(const std::shared_ptr msg); - - void setRxFrequency(long frequency); - long getRxFrequency() const; - - void setRxGain(uint8_t gain); - - void setTxFrequency(long frequency); - long getTxFrequency() const; - -private: - std::shared_ptr _LastReceivedMsg; - long _RxFrequency; - long _TxFrequency; -}; - -#endif diff --git a/src/TaskModem.cpp b/src/TaskModem.cpp deleted file mode 100644 index 05e4fcd..0000000 --- a/src/TaskModem.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include - -#include - -#include "Task.h" -#include "TaskAprsIs.h" -#include "TaskModem.h" -#include "project_configuration.h" - -ModemTask::ModemTask(TaskQueue> &fromModem, TaskQueue> &toModem) : Task(TASK_MODEM, TaskModem), _lora_aprs(), _fromModem(fromModem), _toModem(toModem) { -} - -ModemTask::~ModemTask() { -} - -bool ModemTask::setup(System &system) { - 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); - if (!_lora_aprs.begin(system.getUserConfig()->lora.frequencyRx)) { - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "Starting LoRa failed!"); - _stateInfo = "LoRa-Modem failed"; - _state = Error; - while (true) - ; - } - _lora_aprs.setRxFrequency(system.getUserConfig()->lora.frequencyRx); - _lora_aprs.setRxGain(system.getUserConfig()->lora.gainRx); - _lora_aprs.setTxFrequency(system.getUserConfig()->lora.frequencyTx); - _lora_aprs.setTxPower(system.getUserConfig()->lora.power); - _lora_aprs.setSpreadingFactor(system.getUserConfig()->lora.spreadingFactor); - _lora_aprs.setSignalBandwidth(system.getUserConfig()->lora.signalBandwidth); - _lora_aprs.setCodingRate4(system.getUserConfig()->lora.codingRate4); - _lora_aprs.enableCrc(); - - _stateInfo = ""; - return true; -} - -bool ModemTask::loop(System &system) { - if (_lora_aprs.checkMessage()) { - std::shared_ptr msg = _lora_aprs.getMessage(); - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Received packet '%s' with RSSI %ddBm, SNR %.2fdB and FreqErr %dHz", timeString().c_str(), msg->toString().c_str(), _lora_aprs.packetRssi(), _lora_aprs.packetSnr(), -_lora_aprs.packetFrequencyError()); - _fromModem.addElement(msg); - system.getDisplay().addFrame(std::shared_ptr(new TextFrame("LoRa", msg->toString().c_str()))); - } - - if (!_toModem.empty()) { - if (_lora_aprs.rxSignalDetected()) { - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] RX signal detected. Waiting TX", timeString().c_str()); - delay(1000); - } else { - std::shared_ptr msg = _toModem.getElement(); - if (system.getUserConfig()->lora.tx_enable) { - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Transmitting packet '%s'", timeString().c_str(), msg->toString().c_str()); - _lora_aprs.sendMessage(msg); - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] TX done", timeString().c_str()); - } else { - 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()); - } - } - } - - return true; -} diff --git a/src/TaskModem.h b/src/TaskModem.h deleted file mode 100644 index 6087b67..0000000 --- a/src/TaskModem.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef TASK_LORA_H_ -#define TASK_LORA_H_ - -#include -#include -#include - -class ModemTask : public Task { -public: - explicit ModemTask(TaskQueue> &fromModem, TaskQueue> &_toModem); - virtual ~ModemTask(); - - virtual bool setup(System &system) override; - virtual bool loop(System &system) override; - -private: - LoRa_APRS _lora_aprs; - - TaskQueue> &_fromModem; - TaskQueue> &_toModem; -}; - -#endif From 6ec0ea292e99e328efd782e6cab2484fc0eaa801 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Fri, 20 May 2022 22:46:27 +0200 Subject: [PATCH 09/36] adjust header and some status variables --- src/LoRa_APRS_iGate.cpp | 1 - src/TaskRadiolib.cpp | 18 ++++++++++-------- src/TaskRadiolib.h | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index af97d49..1dfea9a 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -13,7 +13,6 @@ #include "TaskEth.h" #include "TaskFTP.h" #include "TaskMQTT.h" -//#include "TaskModem.h" #include "TaskNTP.h" #include "TaskOTA.h" #include "TaskRadiolib.h" diff --git a/src/TaskRadiolib.cpp b/src/TaskRadiolib.cpp index 34f05b9..afc7ac2 100644 --- a/src/TaskRadiolib.cpp +++ b/src/TaskRadiolib.cpp @@ -1,10 +1,7 @@ +#include +#include #include -#include -#include - -#include "Task.h" -#include "TaskAprsIs.h" #include "TaskRadiolib.h" RadiolibTask::RadiolibTask(TaskQueue> &fromModem, TaskQueue> &toModem) : Task(TASK_RADIOLIB, TaskRadiolib), _fromModem(fromModem), _toModem(toModem) { @@ -80,13 +77,15 @@ bool RadiolibTask::setup(System &system) { rxEnable = false; txEnable = false; } + _stateInfo = "LoRa-Modem failed"; + _state = Error; } state = radio->setCRC(true); if (state != RADIOLIB_ERR_NONE) { system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] setCRC failed, code %d", timeString().c_str(), state); - while (true) - ; + _stateInfo = "LoRa-Modem failed"; + _state = Error; } radio->setDio0Action(setFlag); @@ -95,12 +94,15 @@ bool RadiolibTask::setup(System &system) { int state = startRX(RADIOLIB_SX127X_RXCONTINUOUS); if (state != RADIOLIB_ERR_NONE) { system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] startRX failed, code %d", timeString().c_str(), state); - rxEnable = false; + rxEnable = false; + _stateInfo = "LoRa-Modem failed"; + _state = Error; } } preambleDurationMilliSec = ((uint64_t)(preambleLength + 4) << (config.spreadingFactor + 10 /* to milli-sec */)) / config.signalBandwidth; + _stateInfo = ""; return true; } diff --git a/src/TaskRadiolib.h b/src/TaskRadiolib.h index 2f9cc85..11e59da 100644 --- a/src/TaskRadiolib.h +++ b/src/TaskRadiolib.h @@ -2,8 +2,8 @@ #define TASK_LORA_H_ #include "project_configuration.h" +#include #include -#include #include #include From 2f748621dc2ef5db441097e8ea9e3e31b020e1a3 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Fri, 20 May 2022 22:46:44 +0200 Subject: [PATCH 10/36] update version in platformio --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 750984e..7c1aa1c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -16,7 +16,7 @@ lib_deps = knolleary/PubSubClient@^2.8 mikalhart/TinyGPSPlus @ 1.0.2 shaggydog/OneButton @ 1.5.0 - jgromes/RadioLib@^5.1.2 + jgromes/RadioLib @ 5.1.2 check_tool = cppcheck check_flags = cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK --force lib -ilib/TimeLib -ilib/LoRa -ilib/NTPClient From 312c1ab70a776abd208609246e5c967bcb2b05c1 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Fri, 20 May 2022 22:47:29 +0200 Subject: [PATCH 11/36] version bump --- src/LoRa_APRS_iGate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 1dfea9a..11adfdf 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "22.14.0" +#define VERSION "22.20.0" #define MODULE_NAME "Main" String create_lat_aprs(double lat); From faa22606618ddd1c0e860bff88de48ad2a4d3faf Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Fri, 20 May 2022 22:50:24 +0200 Subject: [PATCH 12/36] remove old check --- .github/workflows/build_check.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index a5655db..ef7e68f 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -38,8 +38,6 @@ jobs: - 'lib/BoardFinder' - 'lib/ConfigurationManagement' #- 'lib/Display' - #- 'lib/LoRa' - - 'lib/LoRa_APRS' #- 'lib/NTPClient' - 'lib/PowerManagement' - 'lib/System' From e8aec31c1790b0ef16c22a7a9cbdac76fd385d5e Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Fri, 20 May 2022 23:09:26 +0200 Subject: [PATCH 13/36] comment write on read --- lib/ConfigurationManagement/configuration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ConfigurationManagement/configuration.cpp b/lib/ConfigurationManagement/configuration.cpp index 6734608..451fee4 100644 --- a/lib/ConfigurationManagement/configuration.cpp +++ b/lib/ConfigurationManagement/configuration.cpp @@ -35,7 +35,7 @@ void ConfigurationManagement::readConfiguration(logging::Logger &logger, Configu readProjectConfiguration(data, conf); // update config in memory to get the new fields: - writeConfiguration(logger, conf); + // writeConfiguration(logger, conf); } void ConfigurationManagement::writeConfiguration(logging::Logger &logger, Configuration &conf) { From e2a544f1c0b7eb0e45bcd440529a951f192b18cf Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Mon, 23 May 2022 21:12:30 +0000 Subject: [PATCH 14/36] add devcontainer --- .devcontainer/Dockerfile | 4 ++++ .devcontainer/devcontainer.json | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..b129666 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,4 @@ +ARG VARIANT="3.10-bullseye" +FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} + +RUN pip3 --disable-pip-version-check --no-cache-dir install platformio diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..d4b6ff2 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,31 @@ +{ + "name": "Python 3", + "build": { + "dockerfile": "Dockerfile", + "context": "..", + "args": { + "VARIANT": "3.10-bullseye" + } + }, + "settings": { + "python.defaultInterpreterPath": "/usr/local/bin/python", + "python.linting.enabled": true, + "python.linting.pylintEnabled": true, + "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", + "python.formatting.blackPath": "/usr/local/py-utils/bin/black", + "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", + "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", + "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", + "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", + "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", + "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", + "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" + }, + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance", + "platformio.platformio-ide" + ], + "postCreateCommand": "pip3 install --user platformio", + "remoteUser": "vscode" +} From 0835d45f3c1eae4becae5ec892b7250aaeadd4ad Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Mon, 23 May 2022 21:16:57 +0000 Subject: [PATCH 15/36] update --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d4b6ff2..4ce1cec 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -27,5 +27,5 @@ "platformio.platformio-ide" ], "postCreateCommand": "pip3 install --user platformio", - "remoteUser": "vscode" + //"remoteUser": "vscode" } From fc053ebf97d6f29dad9328eb8d59cb6162c62f30 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Thu, 26 May 2022 06:08:47 +0000 Subject: [PATCH 16/36] add clang-format-11 support --- .devcontainer/Dockerfile | 2 ++ .devcontainer/devcontainer.json | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index b129666..eb3135b 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,6 @@ ARG VARIANT="3.10-bullseye" FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} +RUN apt-get update && apt-get install -y clang-format-11 + RUN pip3 --disable-pip-version-check --no-cache-dir install platformio diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4ce1cec..dc7411a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -19,12 +19,14 @@ "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", - "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" + "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint", + "clang-format.executable": "clang-format-11" }, "extensions": [ "ms-python.python", "ms-python.vscode-pylance", - "platformio.platformio-ide" + "platformio.platformio-ide", + "xaver.clang-format" ], "postCreateCommand": "pip3 install --user platformio", //"remoteUser": "vscode" From 7d91f0ec8c113966761f7a7ee664ccd7d3bf2906 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Mon, 6 Jun 2022 23:53:36 +0200 Subject: [PATCH 17/36] change ntp sync to 1h --- lib/NTPClient/NTPClient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/NTPClient/NTPClient.h b/lib/NTPClient/NTPClient.h index b528023..1c6c9c2 100644 --- a/lib/NTPClient/NTPClient.h +++ b/lib/NTPClient/NTPClient.h @@ -17,7 +17,7 @@ class NTPClient { unsigned int _port = NTP_DEFAULT_LOCAL_PORT; long _timeOffset = 0; - unsigned long _updateInterval = 60000; // In ms + unsigned long _updateInterval = 3600000; // In ms unsigned long _currentEpoc = 0; // In s unsigned long _lastUpdate = 0; // In ms From 468cda5d57dad9d44f20c8e2f098ad248eb9a5e9 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Mon, 6 Jun 2022 23:56:26 +0200 Subject: [PATCH 18/36] Update TaskOTA.cpp --- src/TaskOTA.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/TaskOTA.cpp b/src/TaskOTA.cpp index 89cbf7f..08f90fa 100644 --- a/src/TaskOTA.cpp +++ b/src/TaskOTA.cpp @@ -18,14 +18,11 @@ bool OTATask::setup(System &system) { } else { // U_SPIFFS type = "filesystem"; } - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "Start updating %s", type.c_str()); + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "Start updating %s. please wait, this prozess is taking some time!", type.c_str()); }) .onEnd([&]() { system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "OTA End"); }) - .onProgress([&](unsigned int progress, unsigned int total) { - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "Progress: %f", (progress / (total / 100))); - }) .onError([&](ota_error_t error) { String error_str; if (error == OTA_AUTH_ERROR) { From 0d0f0d922fdfcf11c458429e6103ab61c8d5559e Mon Sep 17 00:00:00 2001 From: dahuafschmied <3955019+dahuafschmied@users.noreply.github.com> Date: Tue, 28 Jun 2022 21:26:53 +0200 Subject: [PATCH 19/36] fix for NTP booting on ETH Board eht and wifi status has been mutually overwritten --- lib/System/System.cpp | 14 +++++++++----- lib/System/System.h | 7 ++++--- src/LoRa_APRS_iGate.cpp | 2 +- src/TaskAprsIs.cpp | 2 +- src/TaskEth.cpp | 4 ++-- src/TaskMQTT.cpp | 2 +- src/TaskNTP.cpp | 2 +- src/TaskWifi.cpp | 4 ++-- 8 files changed, 21 insertions(+), 16 deletions(-) diff --git a/lib/System/System.cpp b/lib/System/System.cpp index 18b89d4..008e3a4 100644 --- a/lib/System/System.cpp +++ b/lib/System/System.cpp @@ -1,7 +1,7 @@ #include "System.h" -System::System() : _boardConfig(0), _userConfig(0), _isWifiEthConnected(false) { +System::System() : _boardConfig(0), _userConfig(0), _isEthConnected(false), _isWifiConnected(false) { } System::~System() { @@ -31,12 +31,16 @@ Display &System::getDisplay() { return _display; } -bool System::isWifiEthConnected() const { - return _isWifiEthConnected; +bool System::isWifiOrEthConnected() const { + return _isEthConnected || _isWifiConnected; } -void System::connectedViaWifiEth(bool status) { - _isWifiEthConnected = status; +void System::connectedViaEth(bool status) { + _isEthConnected = status; +} + +void System::connectedViaWifi(bool status) { + _isWifiConnected = status; } logging::Logger &System::getLogger() { diff --git a/lib/System/System.h b/lib/System/System.h index 6c7e9d4..6e7daa2 100644 --- a/lib/System/System.h +++ b/lib/System/System.h @@ -21,8 +21,9 @@ public: Configuration const *const getUserConfig() const; TaskManager & getTaskManager(); Display & getDisplay(); - bool isWifiEthConnected() const; - void connectedViaWifiEth(bool status); + bool isWifiOrEthConnected() const; + void connectedViaEth(bool status); + void connectedViaWifi(bool status); logging::Logger & getLogger(); private: @@ -30,7 +31,7 @@ private: Configuration const *_userConfig; TaskManager _taskManager; Display _display; - bool _isWifiEthConnected; + bool _isEthConnected, _isWifiConnected; logging::Logger _logger; }; diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 11adfdf..da05b99 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -167,7 +167,7 @@ volatile bool syslogSet = false; void loop() { LoRaSystem.getTaskManager().loop(LoRaSystem); - if (LoRaSystem.isWifiEthConnected() && LoRaSystem.getUserConfig()->syslog.active && !syslogSet) { + if (LoRaSystem.isWifiOrEthConnected() && 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; diff --git a/src/TaskAprsIs.cpp b/src/TaskAprsIs.cpp index 680a2c4..3fa3da6 100644 --- a/src/TaskAprsIs.cpp +++ b/src/TaskAprsIs.cpp @@ -16,7 +16,7 @@ bool AprsIsTask::setup(System &system) { } bool AprsIsTask::loop(System &system) { - if (!system.isWifiEthConnected()) { + if (!system.isWifiOrEthConnected()) { return false; } if (!_aprs_is.connected()) { diff --git a/src/TaskEth.cpp b/src/TaskEth.cpp index 03f211f..1efdad9 100644 --- a/src/TaskEth.cpp +++ b/src/TaskEth.cpp @@ -111,12 +111,12 @@ bool EthTask::setup(System &system) { bool EthTask::loop(System &system) { if (!eth_connected) { - system.connectedViaWifiEth(false); + system.connectedViaEth(false); _stateInfo = "Ethernet not connected"; _state = Error; return false; } - system.connectedViaWifiEth(true); + system.connectedViaEth(true); _stateInfo = ETH.localIP().toString(); _state = Okay; return true; diff --git a/src/TaskMQTT.cpp b/src/TaskMQTT.cpp index fe6ee3f..e065a1d 100644 --- a/src/TaskMQTT.cpp +++ b/src/TaskMQTT.cpp @@ -18,7 +18,7 @@ bool MQTTTask::setup(System &system) { } bool MQTTTask::loop(System &system) { - if (!system.isWifiEthConnected()) { + if (!system.isWifiOrEthConnected()) { return false; } diff --git a/src/TaskNTP.cpp b/src/TaskNTP.cpp index 569eecc..7622032 100644 --- a/src/TaskNTP.cpp +++ b/src/TaskNTP.cpp @@ -18,7 +18,7 @@ bool NTPTask::setup(System &system) { } bool NTPTask::loop(System &system) { - if (!system.isWifiEthConnected()) { + if (!system.isWifiOrEthConnected()) { return false; } if (!_beginCalled) { diff --git a/src/TaskWifi.cpp b/src/TaskWifi.cpp index d7e1868..2756cd7 100644 --- a/src/TaskWifi.cpp +++ b/src/TaskWifi.cpp @@ -40,7 +40,7 @@ bool WifiTask::setup(System &system) { bool WifiTask::loop(System &system) { const uint8_t wifi_status = _wiFiMulti.run(); if (wifi_status != WL_CONNECTED) { - system.connectedViaWifiEth(false); + system.connectedViaWifi(false); system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "WiFi not connected!"); _oldWifiStatus = wifi_status; _stateInfo = "WiFi not connected"; @@ -51,7 +51,7 @@ bool WifiTask::loop(System &system) { _oldWifiStatus = wifi_status; return false; } - system.connectedViaWifiEth(true); + system.connectedViaWifi(true); _stateInfo = WiFi.localIP().toString(); _state = Okay; return true; From f093167bf7ba2db7481795e2dfc44ad467a35d08 Mon Sep 17 00:00:00 2001 From: dahuafschmied <3955019+dahuafschmied@users.noreply.github.com> Date: Tue, 28 Jun 2022 22:00:48 +0200 Subject: [PATCH 20/36] one line for one variable --- lib/System/System.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/System/System.h b/lib/System/System.h index 6e7daa2..a2788e9 100644 --- a/lib/System/System.h +++ b/lib/System/System.h @@ -31,7 +31,8 @@ private: Configuration const *_userConfig; TaskManager _taskManager; Display _display; - bool _isEthConnected, _isWifiConnected; + bool _isEthConnected; + bool _isWifiConnected; logging::Logger _logger; }; From 2f53d44a09f717ae0cf2e9b248fe0752624fd65c Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Tue, 28 Jun 2022 22:41:11 +0200 Subject: [PATCH 21/36] remove whitespace --- lib/System/System.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/System/System.h b/lib/System/System.h index a2788e9..a6a0d97 100644 --- a/lib/System/System.h +++ b/lib/System/System.h @@ -31,7 +31,7 @@ private: Configuration const *_userConfig; TaskManager _taskManager; Display _display; - bool _isEthConnected; + bool _isEthConnected; bool _isWifiConnected; logging::Logger _logger; }; From 183b23af584aa39bc2e8cffbe98370ccee114c8e Mon Sep 17 00:00:00 2001 From: dahuafschmied <3955019+dahuafschmied@users.noreply.github.com> Date: Wed, 29 Jun 2022 08:28:16 +0200 Subject: [PATCH 22/36] Copy Paste Typo Fix --- src/TaskEth.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TaskEth.cpp b/src/TaskEth.cpp index 1efdad9..e1843c9 100644 --- a/src/TaskEth.cpp +++ b/src/TaskEth.cpp @@ -37,7 +37,7 @@ void WiFiEvent(WiFiEvent_t event) { _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "WiFi Stopped"); break; case SYSTEM_EVENT_ETH_START: - _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "WiFi Started"); + _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "ETH Started"); break; case SYSTEM_EVENT_ETH_CONNECTED: _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "ETH Connected"); From 8ca68d492da7c817a4ab3325c88eec162dde6f45 Mon Sep 17 00:00:00 2001 From: dahuafschmied <3955019+dahuafschmied@users.noreply.github.com> Date: Wed, 29 Jun 2022 08:56:55 +0200 Subject: [PATCH 23/36] better differentiation in debug output ETH/WiFi --- src/TaskEth.cpp | 25 +++++++++++++------------ src/TaskWifi.cpp | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/TaskEth.cpp b/src/TaskEth.cpp index e1843c9..59d4149 100644 --- a/src/TaskEth.cpp +++ b/src/TaskEth.cpp @@ -25,10 +25,11 @@ void WiFiEvent(WiFiEvent_t event) { break; case SYSTEM_EVENT_STA_GOT_IP: _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "WiFi MAC: %s", WiFi.macAddress().c_str()); - _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "IPv4: %s", WiFi.localIP().toString().c_str()); - _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "Gateway: %s", WiFi.gatewayIP().toString().c_str()); - _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "DNS1: %s", WiFi.dnsIP().toString().c_str()); - _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "DNS2: %s", WiFi.dnsIP(1).toString().c_str()); + _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "WiFi IPv4: %s", WiFi.localIP().toString().c_str()); + _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "WiFi Gateway: %s", WiFi.gatewayIP().toString().c_str()); + _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "WiFi DNS1: %s", WiFi.dnsIP().toString().c_str()); + _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "WiFi DNS2: %s", WiFi.dnsIP(1).toString().c_str()); + _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "WiFi Hostname: %s", WiFi.getHostname()); break; case SYSTEM_EVENT_STA_DISCONNECTED: _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "WiFi Disconnected"); @@ -43,17 +44,16 @@ void WiFiEvent(WiFiEvent_t event) { _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "ETH Connected"); break; case SYSTEM_EVENT_ETH_GOT_IP: - _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "Hostname: %s", ETH.getHostname()); _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "ETH MAC: %s", ETH.macAddress().c_str()); - _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "IPv4: %s", ETH.localIP().toString().c_str()); - _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "Gateway: %s", ETH.gatewayIP().toString().c_str()); - _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "DNS1: %s", ETH.dnsIP().toString().c_str()); - _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "DNS2: %s", ETH.dnsIP(1).toString().c_str()); - _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "Hostname: %s", ETH.getHostname()); + _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "ETH IPv4: %s", ETH.localIP().toString().c_str()); + _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "ETH Gateway: %s", ETH.gatewayIP().toString().c_str()); + _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "ETH DNS1: %s", ETH.dnsIP().toString().c_str()); + _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "ETH DNS2: %s", ETH.dnsIP(1).toString().c_str()); + _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "ETH Hostname: %s", ETH.getHostname()); if (ETH.fullDuplex()) { - _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "FULL_DUPLEX"); + _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "ETH FULL_DUPLEX"); } - _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "%dMbps", ETH.linkSpeed()); + _logger->log(logging::LoggerLevel::LOGGER_LEVEL_INFO, WIFI_EVENT, "ETH Speed: %dMbps", ETH.linkSpeed()); eth_connected = true; break; case SYSTEM_EVENT_ETH_DISCONNECTED: @@ -106,6 +106,7 @@ bool EthTask::setup(System &system) { } else { ETH.setHostname(system.getUserConfig()->callsign.c_str()); } + return true; } diff --git a/src/TaskWifi.cpp b/src/TaskWifi.cpp index 2756cd7..03cf95d 100644 --- a/src/TaskWifi.cpp +++ b/src/TaskWifi.cpp @@ -47,7 +47,7 @@ bool WifiTask::loop(System &system) { _state = Error; return false; } else if (wifi_status != _oldWifiStatus) { - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "IP address: %s", WiFi.localIP().toString().c_str()); + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "WiFi IP address: %s", WiFi.localIP().toString().c_str()); _oldWifiStatus = wifi_status; return false; } From 3fdac573257569783dca424d51c4d7175132e20a Mon Sep 17 00:00:00 2001 From: dahuafschmied <3955019+dahuafschmied@users.noreply.github.com> Date: Thu, 30 Jun 2022 14:00:24 +0200 Subject: [PATCH 24/36] last octet of ip address and signal stength for WiFi status --- src/TaskWifi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TaskWifi.cpp b/src/TaskWifi.cpp index 03cf95d..1377ba7 100644 --- a/src/TaskWifi.cpp +++ b/src/TaskWifi.cpp @@ -52,7 +52,7 @@ bool WifiTask::loop(System &system) { return false; } system.connectedViaWifi(true); - _stateInfo = WiFi.localIP().toString(); + _stateInfo = String("IP .") + String(WiFi.localIP()[3]) + String(" @ ") + String(WiFi.RSSI()) + String("dBm"); _state = Okay; return true; } From be8a006394876f4a25656158e4a9b03fa9d3bc03 Mon Sep 17 00:00:00 2001 From: Konrad Roeder Date: Sun, 14 Aug 2022 01:55:58 +0000 Subject: [PATCH 25/36] Update README.md Spelling corrections, added link to LoRa APRS Traker WiKi - Displays --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1adfc06..6766f7e 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,11 @@ Try it out and be part of the APRS network. * [Manuel Lausmann - Tracker](https://www.youtube.com/watch?v=clIlTEFbWLk) (youtube - german - OLD) 02.11.2020 * [OE1ROT](https://www.aronaut.at/2019/12/lora-aprs-tracker-mit-ttgo-t-beam-433mhz/) (blog post - german) 09.12.2019 -feel free to add yours or create a ticket if you want to be added. +Feel free to add yours or create a ticket if you want to be added. ## Supported boards -You can use one of the Lora32 boards without changings: +You can use one of the Lora32 boards without changes: * Heltec WiFi LoRa 32 V1 (433MHz SX1278) * Heltec WiFi LoRa 32 V2 (433MHz SX1278) @@ -42,7 +42,7 @@ Here are some amazon-de links for some example boards: * [T-Beam V1.0](https://www.amazon.de/dp/B07RT9FKPL) This boards cost around 20 Euros, they are very cheap and perfect for an LoRa iGate. -Keep in minde: you need a 433MHz version! +Keep in mind: you need a 433MHz version! ## Compiling and configuration @@ -63,7 +63,7 @@ The best success is to use PlatformIO (and it is the only platform where I can s * You can find all nessesary settings to change for your configuration in **data/is-cfg.json**. * To upload it to your board you have to do this via **Upload File System image** in PlatformIO! -* To find the 'Upload File System image' click the PlatformIO symbol (the little alien) on the left side, choos your configuration, click on 'Platform' and search for 'Upload File System image'. +* To find the 'Upload File System image' click the PlatformIO symbol (the little alien) on the left side, choose your configuration, click on 'Platform' and search for 'Upload File System image'. ## Branches in this repository and version system @@ -106,13 +106,15 @@ Look at my other project: a [LoRa Tracker](https://github.com/peterus/LoRa_APRS_ ### Here are some peculiarities of the different boards -* TTGO T-Beam V1 +* TTGO T-Beam V1.0 and V1.1 and SSD1306 OLED display -When adding a 0,96" OLED display direct to the board you have to be careful, there are two different pinout +When adding an SSD1306 0,96" OLED display direct to the board you have to be careful, there are two different pinout versions on the market. For direct mount you need a display with this Pinout -> [VCC - GND - SCL - SDA](pics/display-right.jpg). A direct mount of the [other display](pics/display-wrong.jpg) is not possible without damage the display! The 'wrong' display works too but you have to change VCC and GND by wire ! -feel free to add hints! +The [LoRa APRS WiKi Displays](https://github.com/lora-aprs/LoRa_APRS_Tracker/wiki/Displays) page has more details. + +Feel free to add hints! From 31d807fac766a09a7e7807d6d8f9259d67889776 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sun, 21 Aug 2022 09:34:04 +0200 Subject: [PATCH 26/36] Fix for incorrect formatting string --- src/TaskRadiolib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TaskRadiolib.cpp b/src/TaskRadiolib.cpp index afc7ac2..435c18a 100644 --- a/src/TaskRadiolib.cpp +++ b/src/TaskRadiolib.cpp @@ -134,7 +134,7 @@ bool RadiolibTask::loop(System &system) { system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] readData failed, code %d", timeString().c_str(), state); } else { if (str.substring(0, 3) != "<\xff\x01") { - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Unknown packet '%s' with RSSI %.0fdBm, SNR %.2fdB and FreqErr %dHz", timeString().c_str(), radio->getRSSI(), radio->getSNR(), -radio->getFrequencyError()); + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Unknown packet '%s' with RSSI %.0fdBm, SNR %.2fdB and FreqErr %fHz", timeString().c_str(), radio->getRSSI(), radio->getSNR(), -radio->getFrequencyError()); } else { std::shared_ptr msg = std::shared_ptr(new APRSMessage()); msg->decode(str.substring(3)); From 7f2155336afcf8e86a089d1e791d1441158c7949 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sun, 21 Aug 2022 10:16:07 +0200 Subject: [PATCH 27/36] An other "unknown packet"-fix --- src/TaskRadiolib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TaskRadiolib.cpp b/src/TaskRadiolib.cpp index 435c18a..295753a 100644 --- a/src/TaskRadiolib.cpp +++ b/src/TaskRadiolib.cpp @@ -134,7 +134,7 @@ bool RadiolibTask::loop(System &system) { system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] readData failed, code %d", timeString().c_str(), state); } else { if (str.substring(0, 3) != "<\xff\x01") { - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Unknown packet '%s' with RSSI %.0fdBm, SNR %.2fdB and FreqErr %fHz", timeString().c_str(), radio->getRSSI(), radio->getSNR(), -radio->getFrequencyError()); + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Unknown packet '%s' with RSSI %.0fdBm, SNR %.2fdB and FreqErr %fHz%s", timeString().c_str(), str.c_str(), radio->getRSSI(), radio->getSNR(), -radio->getFrequencyError()); } else { std::shared_ptr msg = std::shared_ptr(new APRSMessage()); msg->decode(str.substring(3)); From 2563e66b57f22ffea97e9fc1e1f60752589e289e Mon Sep 17 00:00:00 2001 From: Morgan Diepart Date: Mon, 24 Oct 2022 19:00:27 +0200 Subject: [PATCH 28/36] Disabled default syslog Why was it even enabled at this unknown address? --- data/is-cfg.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/is-cfg.json b/data/is-cfg.json index 47d6f65..9047a3b 100644 --- a/data/is-cfg.json +++ b/data/is-cfg.json @@ -76,8 +76,8 @@ "topic": "LoraAPRS/Data" }, "syslog": { - "active": true, - "server": "syslog.lora-aprs.info", + "active": false, + "server": "", "port": 514 }, "ntp_server": "pool.ntp.org" From d984dadb5dd8939ae402a60aae6ba549effcd92a Mon Sep 17 00:00:00 2001 From: Morgan Diepart Date: Tue, 25 Oct 2022 19:13:21 +0200 Subject: [PATCH 29/36] Fixed monitor flags --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 7c1aa1c..75d41b9 100644 --- a/platformio.ini +++ b/platformio.ini @@ -6,7 +6,7 @@ platform = espressif32 @ 3.1.1 framework = arduino lib_ldf_mode = deep+ monitor_speed = 115200 -monitor_flags = --raw +monitor_raw = yes lib_deps = bblanchon/ArduinoJson @ 6.17.0 lewisxhe/AXP202X_Library @ 1.1.2 From 1547d5b8b132672a6588a367b0c335f2d53cacd9 Mon Sep 17 00:00:00 2001 From: Morgan Diepart Date: Wed, 26 Oct 2022 00:43:57 +0200 Subject: [PATCH 30/36] Added watchdog timer Allows to automatically reboot the device if crashed. --- src/LoRa_APRS_iGate.cpp | 5 +++++ src/TaskOTA.cpp | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index da05b99..4654d46 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "TaskAprsIs.h" #include "TaskBeacon.h" @@ -48,6 +49,8 @@ RouterTask routerTask(fromModem, toModem, toAprsIs, toMQTT); BeaconTask beaconTask(toModem, toAprsIs); void setup() { + esp_task_wdt_init(10, true); + esp_task_wdt_add(NULL); Serial.begin(115200); LoRaSystem.getLogger().setSerial(&Serial); setWiFiLogger(&LoRaSystem.getLogger()); @@ -137,6 +140,7 @@ void setup() { } } + esp_task_wdt_reset(); LoRaSystem.getTaskManager().setup(LoRaSystem); LoRaSystem.getDisplay().showSpashScreen("LoRa APRS iGate", VERSION); @@ -166,6 +170,7 @@ void setup() { volatile bool syslogSet = false; void loop() { + esp_task_wdt_reset(); LoRaSystem.getTaskManager().loop(LoRaSystem); if (LoRaSystem.isWifiOrEthConnected() && LoRaSystem.getUserConfig()->syslog.active && !syslogSet) { LoRaSystem.getLogger().setSyslogServer(LoRaSystem.getUserConfig()->syslog.server, LoRaSystem.getUserConfig()->syslog.port, LoRaSystem.getUserConfig()->callsign); diff --git a/src/TaskOTA.cpp b/src/TaskOTA.cpp index 08f90fa..7f2d2cd 100644 --- a/src/TaskOTA.cpp +++ b/src/TaskOTA.cpp @@ -1,4 +1,5 @@ #include +#include #include "Task.h" #include "TaskOTA.h" @@ -37,6 +38,9 @@ bool OTATask::setup(System &system) { error_str = "End Failed"; } system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "Error[%d]: %s", error, error_str.c_str()); + }) + .onProgress([&](unsigned int received, unsigned int total_size){ + esp_task_wdt_reset(); }); if (system.getUserConfig()->network.hostname.overwrite) { _ota.setHostname(system.getUserConfig()->network.hostname.name.c_str()); From 13e95ac4d2cb9f0f5137f86f810415a7dc78e6ad Mon Sep 17 00:00:00 2001 From: Morgan Diepart Date: Sun, 13 Nov 2022 22:27:42 +0100 Subject: [PATCH 31/36] Removed extra "%s" --- src/TaskRadiolib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TaskRadiolib.cpp b/src/TaskRadiolib.cpp index 295753a..f71dbb7 100644 --- a/src/TaskRadiolib.cpp +++ b/src/TaskRadiolib.cpp @@ -134,7 +134,7 @@ bool RadiolibTask::loop(System &system) { system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "[%s] readData failed, code %d", timeString().c_str(), state); } else { if (str.substring(0, 3) != "<\xff\x01") { - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Unknown packet '%s' with RSSI %.0fdBm, SNR %.2fdB and FreqErr %fHz%s", timeString().c_str(), str.c_str(), radio->getRSSI(), radio->getSNR(), -radio->getFrequencyError()); + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Unknown packet '%s' with RSSI %.0fdBm, SNR %.2fdB and FreqErr %fHz", timeString().c_str(), str.c_str(), radio->getRSSI(), radio->getSNR(), -radio->getFrequencyError()); } else { std::shared_ptr msg = std::shared_ptr(new APRSMessage()); msg->decode(str.substring(3)); From c8ae26c9cfbee8ce94c8689d6c26dc9fe7136c9c Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 16 Nov 2022 20:14:48 +0100 Subject: [PATCH 32/36] Update is-cfg.json --- data/is-cfg.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/is-cfg.json b/data/is-cfg.json index 9047a3b..63becf5 100644 --- a/data/is-cfg.json +++ b/data/is-cfg.json @@ -77,7 +77,7 @@ }, "syslog": { "active": false, - "server": "", + "server": "syslog.lora-aprs.info", "port": 514 }, "ntp_server": "pool.ntp.org" From 3ab673ceaa7bf8176636b8f7e67f5f5893a920a8 Mon Sep 17 00:00:00 2001 From: Morgan Diepart Date: Wed, 16 Nov 2022 20:22:03 +0100 Subject: [PATCH 33/36] clang format --- src/TaskOTA.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TaskOTA.cpp b/src/TaskOTA.cpp index 7f2d2cd..b8da848 100644 --- a/src/TaskOTA.cpp +++ b/src/TaskOTA.cpp @@ -39,7 +39,7 @@ bool OTATask::setup(System &system) { } system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "Error[%d]: %s", error, error_str.c_str()); }) - .onProgress([&](unsigned int received, unsigned int total_size){ + .onProgress([&](unsigned int received, unsigned int total_size) { esp_task_wdt_reset(); }); if (system.getUserConfig()->network.hostname.overwrite) { From 251a2c623ba670fc6971f5ed1a63a563bf611df6 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 16 Nov 2022 21:41:50 +0100 Subject: [PATCH 34/36] Update TaskOTA.cpp --- src/TaskOTA.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TaskOTA.cpp b/src/TaskOTA.cpp index b8da848..8be9330 100644 --- a/src/TaskOTA.cpp +++ b/src/TaskOTA.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include "Task.h" #include "TaskOTA.h" From b10a7fbabbe3f0b5202beba369d509842b4c6c83 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 16 Nov 2022 21:42:21 +0100 Subject: [PATCH 35/36] Update LoRa_APRS_iGate.cpp --- src/LoRa_APRS_iGate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 4654d46..49e6822 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -2,11 +2,11 @@ #include #include +#include #include #include #include #include -#include #include "TaskAprsIs.h" #include "TaskBeacon.h" From c88cdb63e10e508b0114a6638adb16a3bef69808 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 16 Nov 2022 21:45:48 +0100 Subject: [PATCH 36/36] Update LoRa_APRS_iGate.cpp --- src/LoRa_APRS_iGate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 49e6822..1665a6d 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -2,9 +2,9 @@ #include #include -#include #include #include +#include #include #include