From fe17aaddb6f2c0a682b3bc7648ca501b871358f6 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sat, 10 Apr 2021 00:43:18 +0200 Subject: [PATCH 01/75] 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 e7f3308..80f60c3 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -18,7 +18,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "21.12.0-dev" +#define VERSION "21.14.0-dev" String create_lat_aprs(double lat); String create_long_aprs(double lng); From ee62a10fa930f60ecb7f68569add88e478e819cb Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sat, 1 May 2021 16:48:45 +0200 Subject: [PATCH 02/75] monitor color fix --- platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio.ini b/platformio.ini index edf1463..9e216b5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -6,6 +6,7 @@ platform = espressif32 @ 3.0.0 framework = arduino lib_ldf_mode = deep+ monitor_speed = 115200 +monitor_flags = --raw lib_deps = bblanchon/ArduinoJson @ 6.17.0 lewisxhe/AXP202X_Library @ 1.1.2 From 2f772b028a9deb4e55efdbbb98558b61d3f7be18 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 9 May 2021 21:19:13 +0200 Subject: [PATCH 03/75] rename TaskLora to TaskModem --- src/LoRa_APRS_iGate.cpp | 4 ++-- src/{TaskLora.cpp => TaskModem.cpp} | 10 +++++----- src/{TaskLora.h => TaskModem.h} | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) rename src/{TaskLora.cpp => TaskModem.cpp} (90%) rename src/{TaskLora.h => TaskModem.h} (83%) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 80f60c3..a9bf9f4 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -12,7 +12,7 @@ #include "TaskDisplay.h" #include "TaskEth.h" #include "TaskFTP.h" -#include "TaskLora.h" +#include "TaskModem.h" #include "TaskNTP.h" #include "TaskOTA.h" #include "TaskWifi.h" @@ -81,7 +81,7 @@ void setup() { LoRaSystem = std::shared_ptr(new System(boardConfig, userConfig)); LoRaSystem->getTaskManager().addTask(std::shared_ptr(new DisplayTask())); - LoRaSystem->getTaskManager().addTask(std::shared_ptr(new LoraTask())); + LoRaSystem->getTaskManager().addTask(std::shared_ptr(new ModemTask())); if (boardConfig->Type == eETH_BOARD) { LoRaSystem->getTaskManager().addAlwaysRunTask(std::shared_ptr(new EthTask())); } else { diff --git a/src/TaskLora.cpp b/src/TaskModem.cpp similarity index 90% rename from src/TaskLora.cpp rename to src/TaskModem.cpp index 04b6f83..6f9a8ba 100644 --- a/src/TaskLora.cpp +++ b/src/TaskModem.cpp @@ -3,16 +3,16 @@ #include "Task.h" #include "TaskAprsIs.h" -#include "TaskLora.h" +#include "TaskModem.h" #include "project_configuration.h" -LoraTask::LoraTask() : Task(TASK_LORA, TaskLora) { +ModemTask::ModemTask() : Task(TASK_LORA, TaskLora) { } -LoraTask::~LoraTask() { +ModemTask::~ModemTask() { } -bool LoraTask::setup(std::shared_ptr system) { +bool ModemTask::setup(std::shared_ptr system) { _lora_aprs = std::shared_ptr(new LoRa_APRS(system->getBoardConfig())); if (!_lora_aprs->begin(_lora_aprs->getRxFrequency())) { logPrintlnE("Starting LoRa failed!"); @@ -33,7 +33,7 @@ bool LoraTask::setup(std::shared_ptr system) { return true; } -bool LoraTask::loop(std::shared_ptr system) { +bool ModemTask::loop(std::shared_ptr system) { if (_lora_aprs->checkMessage()) { std::shared_ptr msg = _lora_aprs->getMessage(); // msg->getAPRSBody()->setData(msg->getAPRSBody()->getData() + " 123"); diff --git a/src/TaskLora.h b/src/TaskModem.h similarity index 83% rename from src/TaskLora.h rename to src/TaskModem.h index b274f5b..84e125c 100644 --- a/src/TaskLora.h +++ b/src/TaskModem.h @@ -5,10 +5,10 @@ #include #include -class LoraTask : public Task { +class ModemTask : public Task { public: - LoraTask(); - virtual ~LoraTask(); + ModemTask(); + virtual ~ModemTask(); virtual bool setup(std::shared_ptr system) override; virtual bool loop(std::shared_ptr system) override; From 86eef28702fb7737db5e7a32a6192353cb2299be Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 9 May 2021 22:58:21 +0200 Subject: [PATCH 04/75] use global instances --- lib/BoardFinder/BoardFinder.cpp | 43 +++++++++++++++------------------ platformio.ini | 4 +-- src/LoRa_APRS_iGate.cpp | 1 - 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/lib/BoardFinder/BoardFinder.cpp b/lib/BoardFinder/BoardFinder.cpp index 57d3d28..e18541c 100644 --- a/lib/BoardFinder/BoardFinder.cpp +++ b/lib/BoardFinder/BoardFinder.cpp @@ -16,9 +16,8 @@ std::shared_ptr BoardFinder::searchBoardConfig() { for (std::shared_ptr boardconf : _boardConfigs) { if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf) == boardconf->powerCheckStatus) { PowerManagement powerManagement; - TwoWire wire(0); - wire.begin(boardconf->OledSda, boardconf->OledScl); - powerManagement.begin(wire); + Wire.begin(boardconf->OledSda, boardconf->OledScl); + powerManagement.begin(Wire); powerManagement.activateOLED(); } else if (boardconf->needCheckPowerChip) { continue; @@ -35,9 +34,8 @@ std::shared_ptr BoardFinder::searchBoardConfig() { for (std::shared_ptr boardconf : _boardConfigs) { if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf) == boardconf->powerCheckStatus) { PowerManagement powerManagement; - TwoWire wire(0); - wire.begin(boardconf->OledSda, boardconf->OledScl); - powerManagement.begin(wire); + Wire.begin(boardconf->OledSda, boardconf->OledScl); + powerManagement.begin(Wire); powerManagement.activateLoRa(); } if (checkModemConfig(boardconf)) { @@ -71,13 +69,12 @@ bool BoardFinder::checkOledConfig(std::shared_ptr boardConfig) { delay(10); digitalWrite(boardConfig->OledReset, HIGH); } - TwoWire wire(0); - if (!wire.begin(boardConfig->OledSda, boardConfig->OledScl)) { + if (!Wire.begin(boardConfig->OledSda, boardConfig->OledScl)) { logPrintlnW("issue with wire"); return false; } - wire.beginTransmission(boardConfig->OledAddr); - if (!wire.endTransmission()) { + Wire.beginTransmission(boardConfig->OledAddr); + if (!Wire.endTransmission()) { return true; } return false; @@ -93,15 +90,14 @@ bool BoardFinder::checkModemConfig(std::shared_ptr boardConfig) { pinMode(boardConfig->LoraCS, OUTPUT); digitalWrite(boardConfig->LoraCS, HIGH); - SPIClass spi; - spi.begin(boardConfig->LoraSck, boardConfig->LoraMiso, boardConfig->LoraMosi, boardConfig->LoraCS); + SPI.begin(boardConfig->LoraSck, boardConfig->LoraMiso, boardConfig->LoraMosi, boardConfig->LoraCS); digitalWrite(boardConfig->LoraCS, LOW); - spi.beginTransaction(SPISettings(8E6, MSBFIRST, SPI_MODE0)); - spi.transfer(0x42); - uint8_t response = spi.transfer(0x00); - spi.endTransaction(); + SPI.beginTransaction(SPISettings(8E6, MSBFIRST, SPI_MODE0)); + SPI.transfer(0x42); + uint8_t response = SPI.transfer(0x00); + SPI.endTransaction(); digitalWrite(boardConfig->LoraCS, HIGH); @@ -112,18 +108,17 @@ bool BoardFinder::checkModemConfig(std::shared_ptr boardConfig) { } bool BoardFinder::checkPowerConfig(std::shared_ptr boardConfig) { - TwoWire wire(0); - if (!wire.begin(boardConfig->OledSda, boardConfig->OledScl)) { + if (!Wire.begin(boardConfig->OledSda, boardConfig->OledScl)) { logPrintlnW("issue with wire"); return false; } - wire.beginTransmission(0x34); - wire.write(0x03); - wire.endTransmission(); + Wire.beginTransmission(0x34); + Wire.write(0x03); + Wire.endTransmission(); - wire.requestFrom(0x34, 1); - int response = wire.read(); - wire.endTransmission(); + Wire.requestFrom(0x34, 1); + int response = Wire.read(); + Wire.endTransmission(); logPrintlnD(String(response)); if (response == 0x03) { diff --git a/platformio.ini b/platformio.ini index 9e216b5..f8d8be4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -25,10 +25,10 @@ check_skip_packages = yes [env:lora_board] board = esp32doit-devkit-v1 -build_flags = -Werror -Wall -DNO_GLOBAL_INSTANCES +build_flags = -Werror -Wall [env:lora_board_debug] board = esp32doit-devkit-v1 -build_flags = -Werror -Wall -DNO_GLOBAL_INSTANCES +build_flags = -Werror -Wall build_type = debug monitor_filters = esp32_exception_decoder diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index a9bf9f4..e3504e8 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -24,7 +24,6 @@ String create_lat_aprs(double lat); String create_long_aprs(double lng); std::shared_ptr LoRaSystem; -HardwareSerial Serial(0); // cppcheck-suppress unusedFunction void setup() { From c5fd0cc46c2283453f768b8f566d14aa8105741d Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 9 May 2021 23:09:07 +0200 Subject: [PATCH 05/75] adjust log levels --- lib/BoardFinder/BoardFinder.cpp | 4 ++-- lib/ConfigurationManagement/configuration.cpp | 2 +- lib/System/TaskManager.cpp | 8 ++++---- src/LoRa_APRS_iGate.cpp | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/BoardFinder/BoardFinder.cpp b/lib/BoardFinder/BoardFinder.cpp index e18541c..66eace0 100644 --- a/lib/BoardFinder/BoardFinder.cpp +++ b/lib/BoardFinder/BoardFinder.cpp @@ -29,7 +29,7 @@ std::shared_ptr BoardFinder::searchBoardConfig() { } } - logPrintlnW("could not find OLED, will search for the modem now..."); + logPrintlnI("could not find OLED, will search for the modem now..."); for (std::shared_ptr boardconf : _boardConfigs) { if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf) == boardconf->powerCheckStatus) { @@ -45,7 +45,7 @@ std::shared_ptr BoardFinder::searchBoardConfig() { } } - logPrintlnW("could not find a board config!"); + logPrintlnE("could not find a board config!"); return 0; } diff --git a/lib/ConfigurationManagement/configuration.cpp b/lib/ConfigurationManagement/configuration.cpp index 7a35fdc..7f75d9e 100644 --- a/lib/ConfigurationManagement/configuration.cpp +++ b/lib/ConfigurationManagement/configuration.cpp @@ -4,7 +4,7 @@ ConfigurationManagement::ConfigurationManagement(String FilePath) : mFilePath(FilePath) { if (!SPIFFS.begin(true)) { - logPrintlnE("Mounting SPIFFS was not possible. Trying to format SPIFFS..."); + logPrintlnI("Mounting SPIFFS was not possible. Trying to format SPIFFS..."); SPIFFS.format(); if (!SPIFFS.begin()) { logPrintlnE("Formating SPIFFS was not okay!"); diff --git a/lib/System/TaskManager.cpp b/lib/System/TaskManager.cpp index ce57033..5c506cb 100644 --- a/lib/System/TaskManager.cpp +++ b/lib/System/TaskManager.cpp @@ -30,13 +30,13 @@ std::list> TaskManager::getTasks() { bool TaskManager::setup(std::shared_ptr system) { logPrintlnV("will setup all tasks..."); for (std::shared_ptr &elem : _alwaysRunTasks) { - logPrintW("call setup from "); - logPrintlnW(elem->getName()); + logPrintD("call setup from "); + logPrintlnD(elem->getName()); elem->setup(system); } for (std::shared_ptr &elem : _tasks) { - logPrintW("call setup from "); - logPrintlnW(elem->getName()); + logPrintD("call setup from "); + logPrintlnD(elem->getName()); elem->setup(system); } _nextTask = _tasks.begin(); diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index e3504e8..cc1ff8e 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -30,8 +30,8 @@ void setup() { Serial.begin(115200); Logger::instance().setSerial(&Serial); delay(500); - logPrintlnW("LoRa APRS iGate by OE5BPA (Peter Buchegger)"); - logPrintlnW("Version: " VERSION); + logPrintlnI("LoRa APRS iGate by OE5BPA (Peter Buchegger)"); + logPrintlnI("Version: " VERSION); std::list> boardConfigs; // clang-format off From f01a3e211ddebf23d55f916a80f5d8bb2cc7e4ce Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Thu, 13 May 2021 13:17:41 +0200 Subject: [PATCH 06/75] fix 2f772b028a9deb4e55efdbbb98558b61d3f7be18 --- src/Task.h | 4 ++-- src/TaskModem.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Task.h b/src/Task.h index 4c881a4..bc74fee 100644 --- a/src/Task.h +++ b/src/Task.h @@ -6,7 +6,7 @@ enum TaskNames TaskAprsIs = 1, TaskEth, TaskFtp, - TaskLora, + TaskModem, TaskNtp, TaskOta, TaskWifi, @@ -18,7 +18,7 @@ enum TaskNames #define TASK_APRS_IS "AprsIsTask" #define TASK_ETH "EthTask" #define TASK_FTP "FTPTask" -#define TASK_LORA "LoraTask" +#define TASK_MODEM "ModemTask" #define TASK_NTP "NTPTask" #define TASK_OTA "OTATask" #define TASK_WIFI "WifiTask" diff --git a/src/TaskModem.cpp b/src/TaskModem.cpp index 6f9a8ba..c02a568 100644 --- a/src/TaskModem.cpp +++ b/src/TaskModem.cpp @@ -6,7 +6,7 @@ #include "TaskModem.h" #include "project_configuration.h" -ModemTask::ModemTask() : Task(TASK_LORA, TaskLora) { +ModemTask::ModemTask() : Task(TASK_MODEM, TaskModem) { } ModemTask::~ModemTask() { From b6f7db49f61878387c622c69c512895e8e10bb31 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sat, 15 May 2021 16:49:51 +0200 Subject: [PATCH 07/75] lets try this cppcheck --- .github/workflows/cppcheck.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/cppcheck.yml diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml new file mode 100644 index 0000000..1e2d257 --- /dev/null +++ b/.github/workflows/cppcheck.yml @@ -0,0 +1,21 @@ +name: cppcheck-action-test +on: [push] + +jobs: + build: + name: cppcheck-test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: cppcheck + uses: deep5050/cppcheck-action@main + with: + github_token: ${{ secrets.GITHUB_TOKEN}} + + + - name: publish report + uses: mikeal/publish-to-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH_NAME: 'develop' # your branch name goes here From 1b5fabfc72fd07408164191979363788e341f3dd Mon Sep 17 00:00:00 2001 From: Automated Publisher Date: Sat, 15 May 2021 14:52:24 +0000 Subject: [PATCH 08/75] Automated publish: Sat May 15 14:52:24 UTC 2021 b6f7db49f61878387c622c69c512895e8e10bb31 --- cppcheck_report.txt | 287 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 287 insertions(+) create mode 100644 cppcheck_report.txt diff --git a/cppcheck_report.txt b/cppcheck_report.txt new file mode 100644 index 0000000..e3d4679 --- /dev/null +++ b/cppcheck_report.txt @@ -0,0 +1,287 @@ +lib/BoardFinder/BoardFinder.h:57:8: performance:inconclusive: Technically the member function 'BoardFinder::checkOledConfig' can be static (but you may consider moving to unnamed namespace). [functionStatic] + bool checkOledConfig(std::shared_ptr boardConfig); + ^ +lib/BoardFinder/BoardFinder.cpp:63:19: note: Technically the member function 'BoardFinder::checkOledConfig' can be static (but you may consider moving to unnamed namespace). +bool BoardFinder::checkOledConfig(std::shared_ptr boardConfig) { + ^ +lib/BoardFinder/BoardFinder.h:57:8: note: Technically the member function 'BoardFinder::checkOledConfig' can be static (but you may consider moving to unnamed namespace). + bool checkOledConfig(std::shared_ptr boardConfig); + ^ +lib/BoardFinder/BoardFinder.h:58:8: performance:inconclusive: Technically the member function 'BoardFinder::checkModemConfig' can be static (but you may consider moving to unnamed namespace). [functionStatic] + bool checkModemConfig(std::shared_ptr boardConfig); + ^ +lib/BoardFinder/BoardFinder.cpp:83:19: note: Technically the member function 'BoardFinder::checkModemConfig' can be static (but you may consider moving to unnamed namespace). +bool BoardFinder::checkModemConfig(std::shared_ptr boardConfig) { + ^ +lib/BoardFinder/BoardFinder.h:58:8: note: Technically the member function 'BoardFinder::checkModemConfig' can be static (but you may consider moving to unnamed namespace). + bool checkModemConfig(std::shared_ptr boardConfig); + ^ +lib/BoardFinder/BoardFinder.h:59:8: performance:inconclusive: Technically the member function 'BoardFinder::checkPowerConfig' can be static (but you may consider moving to unnamed namespace). [functionStatic] + bool checkPowerConfig(std::shared_ptr boardConfig); + ^ +lib/BoardFinder/BoardFinder.cpp:110:19: note: Technically the member function 'BoardFinder::checkPowerConfig' can be static (but you may consider moving to unnamed namespace). +bool BoardFinder::checkPowerConfig(std::shared_ptr boardConfig) { + ^ +lib/BoardFinder/BoardFinder.h:59:8: note: Technically the member function 'BoardFinder::checkPowerConfig' can be static (but you may consider moving to unnamed namespace). + bool checkPowerConfig(std::shared_ptr boardConfig); + ^ +lib/Display/OLEDDisplay.h:119:8: performance:inconclusive: Technically the member function 'OLEDDisplay::clear' can be static (but you may consider moving to unnamed namespace). [functionStatic] + void clear(); + ^ +lib/Display/OLEDDisplay.cpp:127:19: note: Technically the member function 'OLEDDisplay::clear' can be static (but you may consider moving to unnamed namespace). +void OLEDDisplay::clear() { + ^ +lib/Display/OLEDDisplay.h:119:8: note: Technically the member function 'OLEDDisplay::clear' can be static (but you may consider moving to unnamed namespace). + void clear(); + ^ +lib/Display/OLEDDisplay.h:122:8: style:inconclusive: Technically the member function 'OLEDDisplay::getWidth' can be const. [functionConst] + uint getWidth(); + ^ +lib/Display/OLEDDisplay.cpp:131:19: note: Technically the member function 'OLEDDisplay::getWidth' can be const. +uint OLEDDisplay::getWidth() { + ^ +lib/Display/OLEDDisplay.h:122:8: note: Technically the member function 'OLEDDisplay::getWidth' can be const. + uint getWidth(); + ^ +lib/Display/OLEDDisplay.h:123:8: style:inconclusive: Technically the member function 'OLEDDisplay::getHeight' can be const. [functionConst] + uint getHeight(); + ^ +lib/Display/OLEDDisplay.cpp:144:19: note: Technically the member function 'OLEDDisplay::getHeight' can be const. +uint OLEDDisplay::getHeight() { + ^ +lib/Display/OLEDDisplay.h:123:8: note: Technically the member function 'OLEDDisplay::getHeight' can be const. + uint getHeight(); + ^ +lib/System/TaskManager.h:67:36: style:inconclusive: Technically the member function 'TaskManager::getTasks' can be const. [functionConst] + std::list> getTasks(); + ^ +lib/System/TaskManager.cpp:26:47: note: Technically the member function 'TaskManager::getTasks' can be const. +std::list> TaskManager::getTasks() { + ^ +lib/System/TaskManager.h:67:36: note: Technically the member function 'TaskManager::getTasks' can be const. + std::list> getTasks(); + ^ +lib/System/Timer.h:17:8: style:inconclusive: Technically the member function 'Timer::check' can be const. [functionConst] + bool check(); + ^ +lib/System/Timer.cpp:22:13: note: Technically the member function 'Timer::check' can be const. +bool Timer::check() { + ^ +lib/System/Timer.h:17:8: note: Technically the member function 'Timer::check' can be const. + bool check(); + ^ +lib/TimeLib/TimeLib.cpp:159:23: style:inconclusive: Function 'breakTime' argument 1 names different: declaration 'time' definition 'timeInput'. [funcArgNamesDifferent] +void breakTime(time_t timeInput, tmElements_t &tm){ + ^ +lib/TimeLib/TimeLib.h:123:23: note: Function 'breakTime' argument 1 names different: declaration 'time' definition 'timeInput'. +void breakTime(time_t time, tmElements_t &tm); // break time_t into elements + ^ +lib/TimeLib/TimeLib.cpp:159:23: note: Function 'breakTime' argument 1 names different: declaration 'time' definition 'timeInput'. +void breakTime(time_t timeInput, tmElements_t &tm){ + ^ +lib/TimeLib/TimeLib.cpp:294:41: style:inconclusive: Function 'setTime' argument 4 names different: declaration 'day' definition 'dy'. [funcArgNamesDifferent] +void setTime(int hr,int min,int sec,int dy, int mnth, int yr){ + ^ +lib/TimeLib/TimeLib.h:107:44: note: Function 'setTime' argument 4 names different: declaration 'day' definition 'dy'. +void setTime(int hr,int min,int sec,int day, int month, int yr); + ^ +lib/TimeLib/TimeLib.cpp:294:41: note: Function 'setTime' argument 4 names different: declaration 'day' definition 'dy'. +void setTime(int hr,int min,int sec,int dy, int mnth, int yr){ + ^ +lib/TimeLib/TimeLib.cpp:294:49: style:inconclusive: Function 'setTime' argument 5 names different: declaration 'month' definition 'mnth'. [funcArgNamesDifferent] +void setTime(int hr,int min,int sec,int dy, int mnth, int yr){ + ^ +lib/TimeLib/TimeLib.h:107:53: note: Function 'setTime' argument 5 names different: declaration 'month' definition 'mnth'. +void setTime(int hr,int min,int sec,int day, int month, int yr); + ^ +lib/TimeLib/TimeLib.cpp:294:49: note: Function 'setTime' argument 5 names different: declaration 'month' definition 'mnth'. +void setTime(int hr,int min,int sec,int dy, int mnth, int yr){ + ^ +lib/TimeLib/TimeLib.cpp:164:10: style: Local variable 'year' shadows outer function [shadowFunction] + uint8_t year; + ^ +lib/TimeLib/TimeLib.h:99:9: note: Shadowed declaration +int year(); // the full four digit year: (2009, 2010 etc) + ^ +lib/TimeLib/TimeLib.cpp:164:10: note: Shadow variable + uint8_t year; + ^ +lib/TimeLib/TimeLib.cpp:165:10: style: Local variable 'month' shadows outer function [shadowFunction] + uint8_t month, monthLength; + ^ +lib/TimeLib/TimeLib.h:97:9: note: Shadowed declaration +int month(); // the month now (Jan is month 1) + ^ +lib/TimeLib/TimeLib.cpp:165:10: note: Shadow variable + uint8_t month, monthLength; + ^ +lib/TimeLib/TimeLib.cpp:188:6: style: Variable 'days' is assigned a value that is never used. [unreadVariable] + days=0; + ^ +lib/TimeLib/TimeLib.cpp:190:13: style: Variable 'monthLength' is assigned a value that is never used. [unreadVariable] + monthLength=0; + ^ +src/LoRa_APRS_iGate.cpp:59:25: warning: Either the condition 'boardConfig==0' is redundant or there is possible null pointer dereference: boardConfig. [nullPointerRedundantCheck] + userConfig->board = boardConfig->Name; + ^ +src/LoRa_APRS_iGate.cpp:54:21: note: Assuming that condition 'boardConfig==0' is not redundant + if (boardConfig == 0) { + ^ +src/LoRa_APRS_iGate.cpp:59:25: note: Null pointer dereference + userConfig->board = boardConfig->Name; + ^ +src/LoRa_APRS_iGate.cpp:65:13: warning: Either the condition 'boardConfig==0' is redundant or there is possible null pointer dereference: boardConfig. [nullPointerRedundantCheck] + logPrintI(boardConfig->Name); + ^ +src/LoRa_APRS_iGate.cpp:54:21: note: Assuming that condition 'boardConfig==0' is not redundant + if (boardConfig == 0) { + ^ +src/LoRa_APRS_iGate.cpp:65:13: note: Null pointer dereference + logPrintI(boardConfig->Name); + ^ +src/project_configuration.cpp:36:61: style:inconclusive: Boolean expression 'true' is used in bitwise operation. Did you mean '||'? [bitwiseOnBoolean] + conf->display.alwaysOn = data["display"]["always_on"] | true; + ^ +src/project_configuration.cpp:39:59: style:inconclusive: Boolean expression 'true' is used in bitwise operation. Did you mean '||'? [bitwiseOnBoolean] + conf->display.turn180 = data["display"]["turn180"] | true; + ^ +src/project_configuration.cpp:41:44: style:inconclusive: Boolean expression 'false' is used in bitwise operation. Did you mean '||'? [bitwiseOnBoolean] + conf->ftp.active = data["ftp"]["active"] | false; + ^ +lib/PowerManagement/power_management.cpp:28:0: style: The function 'activateGPS' is never used. [unusedFunction] + +^ +lib/TimeLib/TimeLib.cpp:310:0: style: The function 'adjustTime' is never used. [unusedFunction] + +^ +lib/TimeLib/TimeLibString.cpp:53:0: style: The function 'dayShortStr' is never used. [unusedFunction] + +^ +lib/TimeLib/TimeLibString.cpp:42:0: style: The function 'dayStr' is never used. [unusedFunction] + +^ +lib/PowerManagement/power_management.cpp:23:0: style: The function 'deactivateLoRa' is never used. [unusedFunction] + +^ +lib/PowerManagement/power_management.cpp:43:0: style: The function 'decativateOLED' is never used. [unusedFunction] + +^ +lib/LoRa/LoRa.cpp:558:0: style: The function 'disableInvertIQ' is never used. [unusedFunction] + +^ +lib/Display/Bitmap.cpp:123:0: style: The function 'drawCircle' is never used. [unusedFunction] + +^ +lib/Display/Bitmap.cpp:61:0: style: The function 'drawLine' is never used. [unusedFunction] + +^ +lib/Display/Bitmap.cpp:218:0: style: The function 'drawProgressBar' is never used. [unusedFunction] + +^ +lib/Display/Bitmap.cpp:108:0: style: The function 'drawRect' is never used. [unusedFunction] + +^ +lib/Display/Bitmap.cpp:313:0: style: The function 'drawStringLFf' is never used. [unusedFunction] + +^ +lib/Display/Bitmap.cpp:290:0: style: The function 'drawStringf' is never used. [unusedFunction] + +^ +lib/LoRa/LoRa.cpp:625:0: style: The function 'dumpRegisters' is never used. [unusedFunction] + +^ +lib/LoRa/LoRa.cpp:552:0: style: The function 'enableInvertIQ' is never used. [unusedFunction] + +^ +lib/NTPClient/NTPClient.cpp:127:0: style: The function 'getDay' is never used. [unusedFunction] + +^ +lib/NTPClient/NTPClient.cpp:130:0: style: The function 'getHours' is never used. [unusedFunction] + +^ +lib/NTPClient/NTPClient.cpp:133:0: style: The function 'getMinutes' is never used. [unusedFunction] + +^ +lib/Display/Bitmap.cpp:48:0: style: The function 'getPixel' is never used. [unusedFunction] + +^ +lib/NTPClient/NTPClient.cpp:136:0: style: The function 'getSeconds' is never used. [unusedFunction] + +^ +lib/LoRa_APRS/LoRa_APRS.cpp:65:0: style: The function 'getTxFrequency' is never used. [unusedFunction] + +^ +lib/Display/OLEDDisplay.cpp:63:0: style: The function 'invertDisplay' is never used. [unusedFunction] + +^ +lib/TimeLib/TimeLib.cpp:68:0: style: The function 'isAM' is never used. [unusedFunction] + +^ +lib/Display/OLEDDisplay.cpp:114:0: style: The function 'mirrorScreen' is never used. [unusedFunction] + +^ +lib/TimeLib/TimeLibString.cpp:31:0: style: The function 'monthShortStr' is never used. [unusedFunction] + +^ +lib/TimeLib/TimeLibString.cpp:20:0: style: The function 'monthStr' is never used. [unusedFunction] + +^ +lib/Display/OLEDDisplay.cpp:68:0: style: The function 'normalDisplay' is never used. [unusedFunction] + +^ +lib/LoRa/LoRa.cpp:269:0: style: The function 'packetFrequencyError' is never used. [unusedFunction] + +^ +lib/LoRa/LoRa.cpp:334:0: style: The function 'peek' is never used. [unusedFunction] + +^ +lib/LoRa/LoRa.cpp:356:0: style: The function 'receive' is never used. [unusedFunction] + +^ +lib/Display/OLEDDisplay.cpp:102:0: style: The function 'resetOrientation' is never used. [unusedFunction] + +^ +lib/LoRa/LoRa.cpp:288:0: style: The function 'rssi' is never used. [unusedFunction] + +^ +lib/Display/OLEDDisplay.cpp:86:0: style: The function 'setBrightness' is never used. [unusedFunction] + +^ +lib/LoRa/LoRa.cpp:577:0: style: The function 'setGain' is never used. [unusedFunction] + +^ +lib/NTPClient/NTPClient.cpp:168:0: style: The function 'setPoolServerName' is never used. [unusedFunction] + +^ +lib/LoRa/LoRa.cpp:531:0: style: The function 'setPreambleLength' is never used. [unusedFunction] + +^ +lib/NTPClient/NTPClient.cpp:199:0: style: The function 'setRandomPort' is never used. [unusedFunction] + +^ +lib/LoRa/LoRa.cpp:615:0: style: The function 'setSPI' is never used. [unusedFunction] + +^ +lib/LoRa/LoRa.cpp:620:0: style: The function 'setSPIFrequency' is never used. [unusedFunction] + +^ +lib/TimeLib/TimeLib.cpp:326:0: style: The function 'setSyncInterval' is never used. [unusedFunction] + +^ +lib/TimeLib/TimeLib.cpp:320:0: style: The function 'setSyncProvider' is never used. [unusedFunction] + +^ +lib/LoRa/LoRa.cpp:537:0: style: The function 'setSyncWord' is never used. [unusedFunction] + +^ +lib/NTPClient/NTPClient.cpp:160:0: style: The function 'setTimeOffset' is never used. [unusedFunction] + +^ +lib/NTPClient/NTPClient.cpp:164:0: style: The function 'setUpdateInterval' is never used. [unusedFunction] + +^ +lib/TimeLib/TimeLib.cpp:315:0: style: The function 'timeStatus' is never used. [unusedFunction] + +^ +nofile:0:0: information: Cppcheck cannot find all the include files (use --check-config for details) [missingIncludeSystem] + From 74f4c3872cb44d86d9ba3c97406c4bf847966888 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sat, 15 May 2021 17:16:58 +0200 Subject: [PATCH 09/75] cppcheck --- .github/workflows/build_check.yml | 17 +++++++++++++++++ .github/workflows/cppcheck.yml | 21 --------------------- 2 files changed, 17 insertions(+), 21 deletions(-) delete mode 100644 .github/workflows/cppcheck.yml diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 0cbe379..894609f 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -79,3 +79,20 @@ jobs: clang-format-version: '11' check-path: ${{ matrix.path }} + cppcheck: + name: Run Cppcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run Cppcheck + uses: Bedzior/cppcheck-action@v1.0 + with: + enabled checks: all + enable inconclusive: true + generate report: true + - name: Upload report + uses: actions/upload-artifact@v1 + with: + name: report + path: output + diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml deleted file mode 100644 index 1e2d257..0000000 --- a/.github/workflows/cppcheck.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: cppcheck-action-test -on: [push] - -jobs: - build: - name: cppcheck-test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: cppcheck - uses: deep5050/cppcheck-action@main - with: - github_token: ${{ secrets.GITHUB_TOKEN}} - - - - name: publish report - uses: mikeal/publish-to-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH_NAME: 'develop' # your branch name goes here From 0f44b859ef24d37fe3d68c5bcc6785f372aa1c97 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sat, 15 May 2021 17:17:48 +0200 Subject: [PATCH 10/75] remove report --- cppcheck_report.txt | 287 -------------------------------------------- 1 file changed, 287 deletions(-) delete mode 100644 cppcheck_report.txt diff --git a/cppcheck_report.txt b/cppcheck_report.txt deleted file mode 100644 index e3d4679..0000000 --- a/cppcheck_report.txt +++ /dev/null @@ -1,287 +0,0 @@ -lib/BoardFinder/BoardFinder.h:57:8: performance:inconclusive: Technically the member function 'BoardFinder::checkOledConfig' can be static (but you may consider moving to unnamed namespace). [functionStatic] - bool checkOledConfig(std::shared_ptr boardConfig); - ^ -lib/BoardFinder/BoardFinder.cpp:63:19: note: Technically the member function 'BoardFinder::checkOledConfig' can be static (but you may consider moving to unnamed namespace). -bool BoardFinder::checkOledConfig(std::shared_ptr boardConfig) { - ^ -lib/BoardFinder/BoardFinder.h:57:8: note: Technically the member function 'BoardFinder::checkOledConfig' can be static (but you may consider moving to unnamed namespace). - bool checkOledConfig(std::shared_ptr boardConfig); - ^ -lib/BoardFinder/BoardFinder.h:58:8: performance:inconclusive: Technically the member function 'BoardFinder::checkModemConfig' can be static (but you may consider moving to unnamed namespace). [functionStatic] - bool checkModemConfig(std::shared_ptr boardConfig); - ^ -lib/BoardFinder/BoardFinder.cpp:83:19: note: Technically the member function 'BoardFinder::checkModemConfig' can be static (but you may consider moving to unnamed namespace). -bool BoardFinder::checkModemConfig(std::shared_ptr boardConfig) { - ^ -lib/BoardFinder/BoardFinder.h:58:8: note: Technically the member function 'BoardFinder::checkModemConfig' can be static (but you may consider moving to unnamed namespace). - bool checkModemConfig(std::shared_ptr boardConfig); - ^ -lib/BoardFinder/BoardFinder.h:59:8: performance:inconclusive: Technically the member function 'BoardFinder::checkPowerConfig' can be static (but you may consider moving to unnamed namespace). [functionStatic] - bool checkPowerConfig(std::shared_ptr boardConfig); - ^ -lib/BoardFinder/BoardFinder.cpp:110:19: note: Technically the member function 'BoardFinder::checkPowerConfig' can be static (but you may consider moving to unnamed namespace). -bool BoardFinder::checkPowerConfig(std::shared_ptr boardConfig) { - ^ -lib/BoardFinder/BoardFinder.h:59:8: note: Technically the member function 'BoardFinder::checkPowerConfig' can be static (but you may consider moving to unnamed namespace). - bool checkPowerConfig(std::shared_ptr boardConfig); - ^ -lib/Display/OLEDDisplay.h:119:8: performance:inconclusive: Technically the member function 'OLEDDisplay::clear' can be static (but you may consider moving to unnamed namespace). [functionStatic] - void clear(); - ^ -lib/Display/OLEDDisplay.cpp:127:19: note: Technically the member function 'OLEDDisplay::clear' can be static (but you may consider moving to unnamed namespace). -void OLEDDisplay::clear() { - ^ -lib/Display/OLEDDisplay.h:119:8: note: Technically the member function 'OLEDDisplay::clear' can be static (but you may consider moving to unnamed namespace). - void clear(); - ^ -lib/Display/OLEDDisplay.h:122:8: style:inconclusive: Technically the member function 'OLEDDisplay::getWidth' can be const. [functionConst] - uint getWidth(); - ^ -lib/Display/OLEDDisplay.cpp:131:19: note: Technically the member function 'OLEDDisplay::getWidth' can be const. -uint OLEDDisplay::getWidth() { - ^ -lib/Display/OLEDDisplay.h:122:8: note: Technically the member function 'OLEDDisplay::getWidth' can be const. - uint getWidth(); - ^ -lib/Display/OLEDDisplay.h:123:8: style:inconclusive: Technically the member function 'OLEDDisplay::getHeight' can be const. [functionConst] - uint getHeight(); - ^ -lib/Display/OLEDDisplay.cpp:144:19: note: Technically the member function 'OLEDDisplay::getHeight' can be const. -uint OLEDDisplay::getHeight() { - ^ -lib/Display/OLEDDisplay.h:123:8: note: Technically the member function 'OLEDDisplay::getHeight' can be const. - uint getHeight(); - ^ -lib/System/TaskManager.h:67:36: style:inconclusive: Technically the member function 'TaskManager::getTasks' can be const. [functionConst] - std::list> getTasks(); - ^ -lib/System/TaskManager.cpp:26:47: note: Technically the member function 'TaskManager::getTasks' can be const. -std::list> TaskManager::getTasks() { - ^ -lib/System/TaskManager.h:67:36: note: Technically the member function 'TaskManager::getTasks' can be const. - std::list> getTasks(); - ^ -lib/System/Timer.h:17:8: style:inconclusive: Technically the member function 'Timer::check' can be const. [functionConst] - bool check(); - ^ -lib/System/Timer.cpp:22:13: note: Technically the member function 'Timer::check' can be const. -bool Timer::check() { - ^ -lib/System/Timer.h:17:8: note: Technically the member function 'Timer::check' can be const. - bool check(); - ^ -lib/TimeLib/TimeLib.cpp:159:23: style:inconclusive: Function 'breakTime' argument 1 names different: declaration 'time' definition 'timeInput'. [funcArgNamesDifferent] -void breakTime(time_t timeInput, tmElements_t &tm){ - ^ -lib/TimeLib/TimeLib.h:123:23: note: Function 'breakTime' argument 1 names different: declaration 'time' definition 'timeInput'. -void breakTime(time_t time, tmElements_t &tm); // break time_t into elements - ^ -lib/TimeLib/TimeLib.cpp:159:23: note: Function 'breakTime' argument 1 names different: declaration 'time' definition 'timeInput'. -void breakTime(time_t timeInput, tmElements_t &tm){ - ^ -lib/TimeLib/TimeLib.cpp:294:41: style:inconclusive: Function 'setTime' argument 4 names different: declaration 'day' definition 'dy'. [funcArgNamesDifferent] -void setTime(int hr,int min,int sec,int dy, int mnth, int yr){ - ^ -lib/TimeLib/TimeLib.h:107:44: note: Function 'setTime' argument 4 names different: declaration 'day' definition 'dy'. -void setTime(int hr,int min,int sec,int day, int month, int yr); - ^ -lib/TimeLib/TimeLib.cpp:294:41: note: Function 'setTime' argument 4 names different: declaration 'day' definition 'dy'. -void setTime(int hr,int min,int sec,int dy, int mnth, int yr){ - ^ -lib/TimeLib/TimeLib.cpp:294:49: style:inconclusive: Function 'setTime' argument 5 names different: declaration 'month' definition 'mnth'. [funcArgNamesDifferent] -void setTime(int hr,int min,int sec,int dy, int mnth, int yr){ - ^ -lib/TimeLib/TimeLib.h:107:53: note: Function 'setTime' argument 5 names different: declaration 'month' definition 'mnth'. -void setTime(int hr,int min,int sec,int day, int month, int yr); - ^ -lib/TimeLib/TimeLib.cpp:294:49: note: Function 'setTime' argument 5 names different: declaration 'month' definition 'mnth'. -void setTime(int hr,int min,int sec,int dy, int mnth, int yr){ - ^ -lib/TimeLib/TimeLib.cpp:164:10: style: Local variable 'year' shadows outer function [shadowFunction] - uint8_t year; - ^ -lib/TimeLib/TimeLib.h:99:9: note: Shadowed declaration -int year(); // the full four digit year: (2009, 2010 etc) - ^ -lib/TimeLib/TimeLib.cpp:164:10: note: Shadow variable - uint8_t year; - ^ -lib/TimeLib/TimeLib.cpp:165:10: style: Local variable 'month' shadows outer function [shadowFunction] - uint8_t month, monthLength; - ^ -lib/TimeLib/TimeLib.h:97:9: note: Shadowed declaration -int month(); // the month now (Jan is month 1) - ^ -lib/TimeLib/TimeLib.cpp:165:10: note: Shadow variable - uint8_t month, monthLength; - ^ -lib/TimeLib/TimeLib.cpp:188:6: style: Variable 'days' is assigned a value that is never used. [unreadVariable] - days=0; - ^ -lib/TimeLib/TimeLib.cpp:190:13: style: Variable 'monthLength' is assigned a value that is never used. [unreadVariable] - monthLength=0; - ^ -src/LoRa_APRS_iGate.cpp:59:25: warning: Either the condition 'boardConfig==0' is redundant or there is possible null pointer dereference: boardConfig. [nullPointerRedundantCheck] - userConfig->board = boardConfig->Name; - ^ -src/LoRa_APRS_iGate.cpp:54:21: note: Assuming that condition 'boardConfig==0' is not redundant - if (boardConfig == 0) { - ^ -src/LoRa_APRS_iGate.cpp:59:25: note: Null pointer dereference - userConfig->board = boardConfig->Name; - ^ -src/LoRa_APRS_iGate.cpp:65:13: warning: Either the condition 'boardConfig==0' is redundant or there is possible null pointer dereference: boardConfig. [nullPointerRedundantCheck] - logPrintI(boardConfig->Name); - ^ -src/LoRa_APRS_iGate.cpp:54:21: note: Assuming that condition 'boardConfig==0' is not redundant - if (boardConfig == 0) { - ^ -src/LoRa_APRS_iGate.cpp:65:13: note: Null pointer dereference - logPrintI(boardConfig->Name); - ^ -src/project_configuration.cpp:36:61: style:inconclusive: Boolean expression 'true' is used in bitwise operation. Did you mean '||'? [bitwiseOnBoolean] - conf->display.alwaysOn = data["display"]["always_on"] | true; - ^ -src/project_configuration.cpp:39:59: style:inconclusive: Boolean expression 'true' is used in bitwise operation. Did you mean '||'? [bitwiseOnBoolean] - conf->display.turn180 = data["display"]["turn180"] | true; - ^ -src/project_configuration.cpp:41:44: style:inconclusive: Boolean expression 'false' is used in bitwise operation. Did you mean '||'? [bitwiseOnBoolean] - conf->ftp.active = data["ftp"]["active"] | false; - ^ -lib/PowerManagement/power_management.cpp:28:0: style: The function 'activateGPS' is never used. [unusedFunction] - -^ -lib/TimeLib/TimeLib.cpp:310:0: style: The function 'adjustTime' is never used. [unusedFunction] - -^ -lib/TimeLib/TimeLibString.cpp:53:0: style: The function 'dayShortStr' is never used. [unusedFunction] - -^ -lib/TimeLib/TimeLibString.cpp:42:0: style: The function 'dayStr' is never used. [unusedFunction] - -^ -lib/PowerManagement/power_management.cpp:23:0: style: The function 'deactivateLoRa' is never used. [unusedFunction] - -^ -lib/PowerManagement/power_management.cpp:43:0: style: The function 'decativateOLED' is never used. [unusedFunction] - -^ -lib/LoRa/LoRa.cpp:558:0: style: The function 'disableInvertIQ' is never used. [unusedFunction] - -^ -lib/Display/Bitmap.cpp:123:0: style: The function 'drawCircle' is never used. [unusedFunction] - -^ -lib/Display/Bitmap.cpp:61:0: style: The function 'drawLine' is never used. [unusedFunction] - -^ -lib/Display/Bitmap.cpp:218:0: style: The function 'drawProgressBar' is never used. [unusedFunction] - -^ -lib/Display/Bitmap.cpp:108:0: style: The function 'drawRect' is never used. [unusedFunction] - -^ -lib/Display/Bitmap.cpp:313:0: style: The function 'drawStringLFf' is never used. [unusedFunction] - -^ -lib/Display/Bitmap.cpp:290:0: style: The function 'drawStringf' is never used. [unusedFunction] - -^ -lib/LoRa/LoRa.cpp:625:0: style: The function 'dumpRegisters' is never used. [unusedFunction] - -^ -lib/LoRa/LoRa.cpp:552:0: style: The function 'enableInvertIQ' is never used. [unusedFunction] - -^ -lib/NTPClient/NTPClient.cpp:127:0: style: The function 'getDay' is never used. [unusedFunction] - -^ -lib/NTPClient/NTPClient.cpp:130:0: style: The function 'getHours' is never used. [unusedFunction] - -^ -lib/NTPClient/NTPClient.cpp:133:0: style: The function 'getMinutes' is never used. [unusedFunction] - -^ -lib/Display/Bitmap.cpp:48:0: style: The function 'getPixel' is never used. [unusedFunction] - -^ -lib/NTPClient/NTPClient.cpp:136:0: style: The function 'getSeconds' is never used. [unusedFunction] - -^ -lib/LoRa_APRS/LoRa_APRS.cpp:65:0: style: The function 'getTxFrequency' is never used. [unusedFunction] - -^ -lib/Display/OLEDDisplay.cpp:63:0: style: The function 'invertDisplay' is never used. [unusedFunction] - -^ -lib/TimeLib/TimeLib.cpp:68:0: style: The function 'isAM' is never used. [unusedFunction] - -^ -lib/Display/OLEDDisplay.cpp:114:0: style: The function 'mirrorScreen' is never used. [unusedFunction] - -^ -lib/TimeLib/TimeLibString.cpp:31:0: style: The function 'monthShortStr' is never used. [unusedFunction] - -^ -lib/TimeLib/TimeLibString.cpp:20:0: style: The function 'monthStr' is never used. [unusedFunction] - -^ -lib/Display/OLEDDisplay.cpp:68:0: style: The function 'normalDisplay' is never used. [unusedFunction] - -^ -lib/LoRa/LoRa.cpp:269:0: style: The function 'packetFrequencyError' is never used. [unusedFunction] - -^ -lib/LoRa/LoRa.cpp:334:0: style: The function 'peek' is never used. [unusedFunction] - -^ -lib/LoRa/LoRa.cpp:356:0: style: The function 'receive' is never used. [unusedFunction] - -^ -lib/Display/OLEDDisplay.cpp:102:0: style: The function 'resetOrientation' is never used. [unusedFunction] - -^ -lib/LoRa/LoRa.cpp:288:0: style: The function 'rssi' is never used. [unusedFunction] - -^ -lib/Display/OLEDDisplay.cpp:86:0: style: The function 'setBrightness' is never used. [unusedFunction] - -^ -lib/LoRa/LoRa.cpp:577:0: style: The function 'setGain' is never used. [unusedFunction] - -^ -lib/NTPClient/NTPClient.cpp:168:0: style: The function 'setPoolServerName' is never used. [unusedFunction] - -^ -lib/LoRa/LoRa.cpp:531:0: style: The function 'setPreambleLength' is never used. [unusedFunction] - -^ -lib/NTPClient/NTPClient.cpp:199:0: style: The function 'setRandomPort' is never used. [unusedFunction] - -^ -lib/LoRa/LoRa.cpp:615:0: style: The function 'setSPI' is never used. [unusedFunction] - -^ -lib/LoRa/LoRa.cpp:620:0: style: The function 'setSPIFrequency' is never used. [unusedFunction] - -^ -lib/TimeLib/TimeLib.cpp:326:0: style: The function 'setSyncInterval' is never used. [unusedFunction] - -^ -lib/TimeLib/TimeLib.cpp:320:0: style: The function 'setSyncProvider' is never used. [unusedFunction] - -^ -lib/LoRa/LoRa.cpp:537:0: style: The function 'setSyncWord' is never used. [unusedFunction] - -^ -lib/NTPClient/NTPClient.cpp:160:0: style: The function 'setTimeOffset' is never used. [unusedFunction] - -^ -lib/NTPClient/NTPClient.cpp:164:0: style: The function 'setUpdateInterval' is never used. [unusedFunction] - -^ -lib/TimeLib/TimeLib.cpp:315:0: style: The function 'timeStatus' is never used. [unusedFunction] - -^ -nofile:0:0: information: Cppcheck cannot find all the include files (use --check-config for details) [missingIncludeSystem] - From 76ff65e0ef36214fce4ff70fc238beaf9c37f771 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sat, 15 May 2021 17:20:59 +0200 Subject: [PATCH 11/75] Update build_check.yml --- .github/workflows/build_check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 894609f..b1f3609 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -85,7 +85,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Run Cppcheck - uses: Bedzior/cppcheck-action@v1.0 + uses: Bedzior/cppcheck-action with: enabled checks: all enable inconclusive: true From 7baefa51bb36aff3ff63252a26552c28c30dd00f Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sat, 15 May 2021 17:27:25 +0200 Subject: [PATCH 12/75] Update build_check.yml --- .github/workflows/build_check.yml | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index b1f3609..5bd16a3 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -79,20 +79,20 @@ jobs: clang-format-version: '11' check-path: ${{ matrix.path }} - cppcheck: - name: Run Cppcheck - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Run Cppcheck - uses: Bedzior/cppcheck-action - with: - enabled checks: all - enable inconclusive: true - generate report: true - - name: Upload report - uses: actions/upload-artifact@v1 - with: - name: report - path: output +# cppcheck: +# name: Run Cppcheck +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - name: Run Cppcheck +# uses: Bedzior/cppcheck-action +# with: +# enabled checks: all +# enable inconclusive: true +# generate report: true +# - name: Upload report +# uses: actions/upload-artifact@v1 +# with: +# name: report +# path: output From 9ef9aff52a2c00bf0ea0883fb7a8d147e86bdfd8 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sat, 15 May 2021 22:19:17 +0200 Subject: [PATCH 13/75] add cppcheck --- .github/workflows/build_check.yml | 42 ++++++++++++++++--------------- .gitignore | 2 ++ 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 5bd16a3..69e1efa 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -30,7 +30,8 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v2 - name: Cache pip uses: actions/cache@v2 with: @@ -50,7 +51,8 @@ jobs: pip install --upgrade platformio - name: Run PlatformIO CI run: platformio run - - uses: actions/upload-artifact@v2 + - name: Upload artifacts + uses: actions/upload-artifact@v2 with: name: firmware path: .pio/build/lora_board/firmware.bin @@ -72,27 +74,27 @@ jobs: - 'lib/System' #- 'lib/TimeLib' steps: - - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v2 - name: Run clang-format style check for C/C++ programs. uses: jidicula/clang-format-action@v3.2.0 with: clang-format-version: '11' check-path: ${{ matrix.path }} -# cppcheck: -# name: Run Cppcheck -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v2 -# - name: Run Cppcheck -# uses: Bedzior/cppcheck-action -# with: -# enabled checks: all -# enable inconclusive: true -# generate report: true -# - name: Upload report -# uses: actions/upload-artifact@v1 -# with: -# name: report -# path: output - + cppcheck: + name: Run Cppcheck + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v2 + - run: docker pull facthunder/cppcheck:latest + - name: Run Cppcheck + run: docker run --rm -v ${PWD}:/src facthunder/cppcheck:latest cppcheck -v --xml --enable=all . 2> report.xml + - name: Generate HTML report + run: docker run --rm -v ${PWD}:/src facthunder/cppcheck:latest cppcheck-htmlreport --file=report.xml --report-dir=output + - name: Upload report + uses: actions/upload-artifact@v1 + with: + name: Cppcheck Report + path: output diff --git a/.gitignore b/.gitignore index 89cc49c..9f19284 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ .vscode/c_cpp_properties.json .vscode/launch.json .vscode/ipch +report.xml +output From 0cbf0a560c78a6c3eac4544b1f25a187e921ce15 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sat, 15 May 2021 22:58:15 +0200 Subject: [PATCH 14/75] add message router --- src/LoRa_APRS_iGate.cpp | 9 ++++++-- src/Task.h | 2 ++ src/TaskAprsIs.cpp | 27 +++-------------------- src/TaskAprsIs.h | 8 +++---- src/TaskModem.cpp | 10 ++------- src/TaskModem.h | 5 ++--- src/TaskRouter.cpp | 48 +++++++++++++++++++++++++++++++++++++++++ src/TaskRouter.h | 23 ++++++++++++++++++++ 8 files changed, 90 insertions(+), 42 deletions(-) create mode 100644 src/TaskRouter.cpp create mode 100644 src/TaskRouter.h diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index cc1ff8e..b12443a 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -16,6 +16,7 @@ #include "TaskNTP.h" #include "TaskOTA.h" #include "TaskWifi.h" +#include "TaskRouter.h" #include "project_configuration.h" #define VERSION "21.14.0-dev" @@ -25,6 +26,9 @@ String create_long_aprs(double lng); std::shared_ptr LoRaSystem; +TaskQueue> toAprsIs; +TaskQueue> fromModem; + // cppcheck-suppress unusedFunction void setup() { Serial.begin(115200); @@ -80,7 +84,7 @@ void setup() { LoRaSystem = std::shared_ptr(new System(boardConfig, userConfig)); LoRaSystem->getTaskManager().addTask(std::shared_ptr(new DisplayTask())); - LoRaSystem->getTaskManager().addTask(std::shared_ptr(new ModemTask())); + LoRaSystem->getTaskManager().addTask(std::shared_ptr(new ModemTask(&fromModem))); if (boardConfig->Type == eETH_BOARD) { LoRaSystem->getTaskManager().addAlwaysRunTask(std::shared_ptr(new EthTask())); } else { @@ -91,7 +95,8 @@ void setup() { if (userConfig->ftp.active) { LoRaSystem->getTaskManager().addTask(std::shared_ptr(new FTPTask())); } - LoRaSystem->getTaskManager().addTask(std::shared_ptr(new AprsIsTask())); + LoRaSystem->getTaskManager().addTask(std::shared_ptr(new AprsIsTask(&toAprsIs))); + LoRaSystem->getTaskManager().addTask(std::shared_ptr(new RouterTask(&fromModem, &toAprsIs))); LoRaSystem->getTaskManager().setup(LoRaSystem); diff --git a/src/Task.h b/src/Task.h index bc74fee..b9a1f12 100644 --- a/src/Task.h +++ b/src/Task.h @@ -10,6 +10,7 @@ enum TaskNames TaskNtp, TaskOta, TaskWifi, + TaskRouter, TaskSize, }; @@ -22,5 +23,6 @@ enum TaskNames #define TASK_NTP "NTPTask" #define TASK_OTA "OTATask" #define TASK_WIFI "WifiTask" +#define TASK_ROUTER "RouterTask" #endif diff --git a/src/TaskAprsIs.cpp b/src/TaskAprsIs.cpp index d060043..cb79802 100644 --- a/src/TaskAprsIs.cpp +++ b/src/TaskAprsIs.cpp @@ -5,26 +5,15 @@ #include "TaskAprsIs.h" #include "project_configuration.h" -String create_lat_aprs(double lat); -String create_long_aprs(double lng); - -AprsIsTask::AprsIsTask() : Task(TASK_APRS_IS, TaskAprsIs) { +AprsIsTask::AprsIsTask(TaskQueue> * const toAprsIs) : Task(TASK_APRS_IS, TaskAprsIs), _toAprsIs(toAprsIs) { } AprsIsTask::~AprsIsTask() { } bool AprsIsTask::setup(std::shared_ptr system) { - _beacon_timer.setTimeout(system->getUserConfig()->beacon.timeout * 60 * 1000); _aprs_is = std::shared_ptr(new APRS_IS(system->getUserConfig()->callsign, system->getUserConfig()->aprs_is.passcode, "ESP32-APRS-IS", "0.2")); - _beaconMsg = std::shared_ptr(new APRSMessage()); - _beaconMsg->setSource(system->getUserConfig()->callsign); - _beaconMsg->setDestination("APLG01"); - String lat = create_lat_aprs(system->getUserConfig()->beacon.positionLatitude); - String lng = create_long_aprs(system->getUserConfig()->beacon.positionLongitude); - _beaconMsg->getBody()->setData(String("=") + lat + "L" + lng + "&" + system->getUserConfig()->beacon.message); - return true; } @@ -45,21 +34,11 @@ bool AprsIsTask::loop(std::shared_ptr system) { _aprs_is->getAPRSMessage(); - if (!inputQueue.empty()) { - std::shared_ptr msg = inputQueue.getElement(); + if (!_toAprsIs->empty()) { + std::shared_ptr msg = _toAprsIs->getElement(); _aprs_is->sendMessage(msg); } - if (_beacon_timer.check()) { - logPrintD("[" + timeString() + "] "); - logPrintlnD(_beaconMsg->encode()); - _aprs_is->sendMessage(_beaconMsg); - system->getDisplay().addFrame(std::shared_ptr(new TextFrame("BEACON", _beaconMsg->toString()))); - _beacon_timer.start(); - } - time_t diff = _beacon_timer.getTriggerTimeInSec(); - _stateInfo = "beacon " + String(diff / 60) + ":" + String(diff % 60); - _state = Okay; return true; } diff --git a/src/TaskAprsIs.h b/src/TaskAprsIs.h index 67b1d31..4e38615 100644 --- a/src/TaskAprsIs.h +++ b/src/TaskAprsIs.h @@ -8,18 +8,16 @@ class AprsIsTask : public Task { public: - AprsIsTask(); + AprsIsTask(TaskQueue> * const toAprsIs); virtual ~AprsIsTask(); virtual bool setup(std::shared_ptr system) override; virtual bool loop(std::shared_ptr system) override; - TaskQueue> inputQueue; - private: std::shared_ptr _aprs_is; - std::shared_ptr _beaconMsg; - Timer _beacon_timer; + + TaskQueue> * const _toAprsIs; bool connect(std::shared_ptr system); }; diff --git a/src/TaskModem.cpp b/src/TaskModem.cpp index c02a568..6b78738 100644 --- a/src/TaskModem.cpp +++ b/src/TaskModem.cpp @@ -6,7 +6,7 @@ #include "TaskModem.h" #include "project_configuration.h" -ModemTask::ModemTask() : Task(TASK_MODEM, TaskModem) { +ModemTask::ModemTask(TaskQueue> * const fromModem) : Task(TASK_MODEM, TaskModem), _fromModem(fromModem) { } ModemTask::~ModemTask() { @@ -55,15 +55,9 @@ bool ModemTask::loop(std::shared_ptr system) { } msg->setPath(path + "qAR," + system->getUserConfig()->callsign); - std::shared_ptr is_thread = std::static_pointer_cast(system->getTaskManager().getTask(TASK_APRS_IS)); - is_thread->inputQueue.addElement(msg); + _fromModem->addElement(msg); system->getDisplay().addFrame(std::shared_ptr(new TextFrame("LoRa", msg->toString()))); } - if (!inputQueue.empty()) { - std::shared_ptr msg = inputQueue.getElement(); - _lora_aprs->sendMessage(msg); - } - return true; } diff --git a/src/TaskModem.h b/src/TaskModem.h index 84e125c..8be2403 100644 --- a/src/TaskModem.h +++ b/src/TaskModem.h @@ -7,16 +7,15 @@ class ModemTask : public Task { public: - ModemTask(); + ModemTask(TaskQueue> * const fromModem); virtual ~ModemTask(); virtual bool setup(std::shared_ptr system) override; virtual bool loop(std::shared_ptr system) override; - TaskQueue> inputQueue; - private: std::shared_ptr _lora_aprs; + TaskQueue> * const _fromModem; }; #endif diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp new file mode 100644 index 0000000..4b983d9 --- /dev/null +++ b/src/TaskRouter.cpp @@ -0,0 +1,48 @@ +#include + +#include "Task.h" +#include "TaskRouter.h" +#include "project_configuration.h" + +String create_lat_aprs(double lat); +String create_long_aprs(double lng); + +RouterTask::RouterTask(TaskQueue> * const fromModem, TaskQueue> * const toAprsIs) +: Task(TASK_ROUTER, TaskRouter), _fromModem(fromModem), _toAprsIs(toAprsIs) { +} + +RouterTask::~RouterTask() { +} + +bool RouterTask::setup(std::shared_ptr system) { + // setup beacon + _beacon_timer.setTimeout(system->getUserConfig()->beacon.timeout * 60 * 1000); + _beaconMsg = std::shared_ptr(new APRSMessage()); + _beaconMsg->setSource(system->getUserConfig()->callsign); + _beaconMsg->setDestination("APLG01"); + String lat = create_lat_aprs(system->getUserConfig()->beacon.positionLatitude); + String lng = create_long_aprs(system->getUserConfig()->beacon.positionLongitude); + _beaconMsg->getBody()->setData(String("=") + lat + "L" + lng + "&" + system->getUserConfig()->beacon.message); + + return true; +} + +bool RouterTask::loop(std::shared_ptr system) { + // do routing + if(!_fromModem->empty()) + { + _toAprsIs->addElement(_fromModem->getElement()); + } + + // check for beacon + if (_beacon_timer.check()) { + logPrintD("[" + timeString() + "] "); + logPrintlnD(_beaconMsg->encode()); + _toAprsIs->addElement(_beaconMsg); + system->getDisplay().addFrame(std::shared_ptr(new TextFrame("BEACON", _beaconMsg->toString()))); + _beacon_timer.start(); + } + time_t diff = _beacon_timer.getTriggerTimeInSec(); + _stateInfo = "beacon " + String(diff / 60) + ":" + String(diff % 60); + return true; +} diff --git a/src/TaskRouter.h b/src/TaskRouter.h new file mode 100644 index 0000000..1888ea3 --- /dev/null +++ b/src/TaskRouter.h @@ -0,0 +1,23 @@ +#ifndef TASK_ROUTER_H_ +#define TASK_ROUTER_H_ + +#include +#include + +class RouterTask : public Task { +public: + RouterTask(TaskQueue> * const fromModem, TaskQueue> * const toAprsIs); + virtual ~RouterTask(); + + virtual bool setup(std::shared_ptr system) override; + virtual bool loop(std::shared_ptr system) override; + +private: + TaskQueue> * const _fromModem; + TaskQueue> * const _toAprsIs; + + std::shared_ptr _beaconMsg; + Timer _beacon_timer; +}; + +#endif From a5dbb9fd778893f06afaba4427f31f47fe18861d Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sat, 15 May 2021 23:10:24 +0200 Subject: [PATCH 15/75] clang-format --- src/LoRa_APRS_iGate.cpp | 2 +- src/TaskAprsIs.cpp | 2 +- src/TaskAprsIs.h | 6 +++--- src/TaskModem.cpp | 2 +- src/TaskModem.h | 6 +++--- src/TaskRouter.cpp | 6 ++---- src/TaskRouter.h | 10 +++++----- 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index b12443a..18e9d48 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -15,8 +15,8 @@ #include "TaskModem.h" #include "TaskNTP.h" #include "TaskOTA.h" -#include "TaskWifi.h" #include "TaskRouter.h" +#include "TaskWifi.h" #include "project_configuration.h" #define VERSION "21.14.0-dev" diff --git a/src/TaskAprsIs.cpp b/src/TaskAprsIs.cpp index cb79802..c7c0ca3 100644 --- a/src/TaskAprsIs.cpp +++ b/src/TaskAprsIs.cpp @@ -5,7 +5,7 @@ #include "TaskAprsIs.h" #include "project_configuration.h" -AprsIsTask::AprsIsTask(TaskQueue> * const toAprsIs) : Task(TASK_APRS_IS, TaskAprsIs), _toAprsIs(toAprsIs) { +AprsIsTask::AprsIsTask(TaskQueue> *const toAprsIs) : Task(TASK_APRS_IS, TaskAprsIs), _toAprsIs(toAprsIs) { } AprsIsTask::~AprsIsTask() { diff --git a/src/TaskAprsIs.h b/src/TaskAprsIs.h index 4e38615..229e113 100644 --- a/src/TaskAprsIs.h +++ b/src/TaskAprsIs.h @@ -8,16 +8,16 @@ class AprsIsTask : public Task { public: - AprsIsTask(TaskQueue> * const toAprsIs); + AprsIsTask(TaskQueue> *const toAprsIs); virtual ~AprsIsTask(); virtual bool setup(std::shared_ptr system) override; virtual bool loop(std::shared_ptr system) override; private: - std::shared_ptr _aprs_is; + std::shared_ptr _aprs_is; - TaskQueue> * const _toAprsIs; + TaskQueue> *const _toAprsIs; bool connect(std::shared_ptr system); }; diff --git a/src/TaskModem.cpp b/src/TaskModem.cpp index 6b78738..17dafe9 100644 --- a/src/TaskModem.cpp +++ b/src/TaskModem.cpp @@ -6,7 +6,7 @@ #include "TaskModem.h" #include "project_configuration.h" -ModemTask::ModemTask(TaskQueue> * const fromModem) : Task(TASK_MODEM, TaskModem), _fromModem(fromModem) { +ModemTask::ModemTask(TaskQueue> *const fromModem) : Task(TASK_MODEM, TaskModem), _fromModem(fromModem) { } ModemTask::~ModemTask() { diff --git a/src/TaskModem.h b/src/TaskModem.h index 8be2403..ebedcbb 100644 --- a/src/TaskModem.h +++ b/src/TaskModem.h @@ -7,15 +7,15 @@ class ModemTask : public Task { public: - ModemTask(TaskQueue> * const fromModem); + ModemTask(TaskQueue> *const fromModem); virtual ~ModemTask(); virtual bool setup(std::shared_ptr system) override; virtual bool loop(std::shared_ptr system) override; private: - std::shared_ptr _lora_aprs; - TaskQueue> * const _fromModem; + std::shared_ptr _lora_aprs; + TaskQueue> *const _fromModem; }; #endif diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index 4b983d9..59fcb63 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -7,8 +7,7 @@ String create_lat_aprs(double lat); String create_long_aprs(double lng); -RouterTask::RouterTask(TaskQueue> * const fromModem, TaskQueue> * const toAprsIs) -: Task(TASK_ROUTER, TaskRouter), _fromModem(fromModem), _toAprsIs(toAprsIs) { +RouterTask::RouterTask(TaskQueue> *const fromModem, TaskQueue> *const toAprsIs) : Task(TASK_ROUTER, TaskRouter), _fromModem(fromModem), _toAprsIs(toAprsIs) { } RouterTask::~RouterTask() { @@ -29,8 +28,7 @@ bool RouterTask::setup(std::shared_ptr system) { bool RouterTask::loop(std::shared_ptr system) { // do routing - if(!_fromModem->empty()) - { + if (!_fromModem->empty()) { _toAprsIs->addElement(_fromModem->getElement()); } diff --git a/src/TaskRouter.h b/src/TaskRouter.h index 1888ea3..e673be6 100644 --- a/src/TaskRouter.h +++ b/src/TaskRouter.h @@ -1,21 +1,21 @@ #ifndef TASK_ROUTER_H_ #define TASK_ROUTER_H_ -#include #include +#include class RouterTask : public Task { public: - RouterTask(TaskQueue> * const fromModem, TaskQueue> * const toAprsIs); + RouterTask(TaskQueue> *const fromModem, TaskQueue> *const toAprsIs); virtual ~RouterTask(); virtual bool setup(std::shared_ptr system) override; virtual bool loop(std::shared_ptr system) override; private: - TaskQueue> * const _fromModem; - TaskQueue> * const _toAprsIs; - + TaskQueue> *const _fromModem; + TaskQueue> *const _toAprsIs; + std::shared_ptr _beaconMsg; Timer _beacon_timer; }; From 0396db7d951b2d300178de536e8ac93ee1af8901 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 16 May 2021 03:52:28 +0200 Subject: [PATCH 16/75] change pointers to references --- src/LoRa_APRS_iGate.cpp | 6 +++--- src/TaskAprsIs.cpp | 6 +++--- src/TaskAprsIs.h | 4 ++-- src/TaskModem.cpp | 4 ++-- src/TaskModem.h | 4 ++-- src/TaskRouter.cpp | 9 +++++---- src/TaskRouter.h | 6 +++--- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 18e9d48..354dab9 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -84,7 +84,7 @@ void setup() { LoRaSystem = std::shared_ptr(new System(boardConfig, userConfig)); LoRaSystem->getTaskManager().addTask(std::shared_ptr(new DisplayTask())); - LoRaSystem->getTaskManager().addTask(std::shared_ptr(new ModemTask(&fromModem))); + LoRaSystem->getTaskManager().addTask(std::shared_ptr(new ModemTask(fromModem))); if (boardConfig->Type == eETH_BOARD) { LoRaSystem->getTaskManager().addAlwaysRunTask(std::shared_ptr(new EthTask())); } else { @@ -95,8 +95,8 @@ void setup() { if (userConfig->ftp.active) { LoRaSystem->getTaskManager().addTask(std::shared_ptr(new FTPTask())); } - LoRaSystem->getTaskManager().addTask(std::shared_ptr(new AprsIsTask(&toAprsIs))); - LoRaSystem->getTaskManager().addTask(std::shared_ptr(new RouterTask(&fromModem, &toAprsIs))); + LoRaSystem->getTaskManager().addTask(std::shared_ptr(new AprsIsTask(toAprsIs))); + LoRaSystem->getTaskManager().addTask(std::shared_ptr(new RouterTask(fromModem, toAprsIs))); LoRaSystem->getTaskManager().setup(LoRaSystem); diff --git a/src/TaskAprsIs.cpp b/src/TaskAprsIs.cpp index c7c0ca3..67051f8 100644 --- a/src/TaskAprsIs.cpp +++ b/src/TaskAprsIs.cpp @@ -5,7 +5,7 @@ #include "TaskAprsIs.h" #include "project_configuration.h" -AprsIsTask::AprsIsTask(TaskQueue> *const toAprsIs) : Task(TASK_APRS_IS, TaskAprsIs), _toAprsIs(toAprsIs) { +AprsIsTask::AprsIsTask(TaskQueue> & toAprsIs) : Task(TASK_APRS_IS, TaskAprsIs), _toAprsIs(toAprsIs) { } AprsIsTask::~AprsIsTask() { @@ -34,8 +34,8 @@ bool AprsIsTask::loop(std::shared_ptr system) { _aprs_is->getAPRSMessage(); - if (!_toAprsIs->empty()) { - std::shared_ptr msg = _toAprsIs->getElement(); + if (!_toAprsIs.empty()) { + std::shared_ptr msg = _toAprsIs.getElement(); _aprs_is->sendMessage(msg); } diff --git a/src/TaskAprsIs.h b/src/TaskAprsIs.h index 229e113..43dcc07 100644 --- a/src/TaskAprsIs.h +++ b/src/TaskAprsIs.h @@ -8,7 +8,7 @@ class AprsIsTask : public Task { public: - AprsIsTask(TaskQueue> *const toAprsIs); + AprsIsTask(TaskQueue> & toAprsIs); virtual ~AprsIsTask(); virtual bool setup(std::shared_ptr system) override; @@ -17,7 +17,7 @@ public: private: std::shared_ptr _aprs_is; - TaskQueue> *const _toAprsIs; + TaskQueue> & _toAprsIs; bool connect(std::shared_ptr system); }; diff --git a/src/TaskModem.cpp b/src/TaskModem.cpp index 17dafe9..4504e53 100644 --- a/src/TaskModem.cpp +++ b/src/TaskModem.cpp @@ -6,7 +6,7 @@ #include "TaskModem.h" #include "project_configuration.h" -ModemTask::ModemTask(TaskQueue> *const fromModem) : Task(TASK_MODEM, TaskModem), _fromModem(fromModem) { +ModemTask::ModemTask(TaskQueue> & fromModem) : Task(TASK_MODEM, TaskModem), _fromModem(fromModem) { } ModemTask::~ModemTask() { @@ -55,7 +55,7 @@ bool ModemTask::loop(std::shared_ptr system) { } msg->setPath(path + "qAR," + system->getUserConfig()->callsign); - _fromModem->addElement(msg); + _fromModem.addElement(msg); system->getDisplay().addFrame(std::shared_ptr(new TextFrame("LoRa", msg->toString()))); } diff --git a/src/TaskModem.h b/src/TaskModem.h index ebedcbb..6e6e97b 100644 --- a/src/TaskModem.h +++ b/src/TaskModem.h @@ -7,7 +7,7 @@ class ModemTask : public Task { public: - ModemTask(TaskQueue> *const fromModem); + ModemTask(TaskQueue> & fromModem); virtual ~ModemTask(); virtual bool setup(std::shared_ptr system) override; @@ -15,7 +15,7 @@ public: private: std::shared_ptr _lora_aprs; - TaskQueue> *const _fromModem; + TaskQueue> & _fromModem; }; #endif diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index 59fcb63..0703aa1 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -7,7 +7,8 @@ String create_lat_aprs(double lat); String create_long_aprs(double lng); -RouterTask::RouterTask(TaskQueue> *const fromModem, TaskQueue> *const toAprsIs) : Task(TASK_ROUTER, TaskRouter), _fromModem(fromModem), _toAprsIs(toAprsIs) { +RouterTask::RouterTask(TaskQueue> & fromModem, TaskQueue> * +& toAprsIs) : Task(TASK_ROUTER, TaskRouter), _fromModem(fromModem), _toAprsIs(toAprsIs) { } RouterTask::~RouterTask() { @@ -28,15 +29,15 @@ bool RouterTask::setup(std::shared_ptr system) { bool RouterTask::loop(std::shared_ptr system) { // do routing - if (!_fromModem->empty()) { - _toAprsIs->addElement(_fromModem->getElement()); + if (!_fromModem.empty()) { + _toAprsIs.addElement(_fromModem->getElement()); } // check for beacon if (_beacon_timer.check()) { logPrintD("[" + timeString() + "] "); logPrintlnD(_beaconMsg->encode()); - _toAprsIs->addElement(_beaconMsg); + _toAprsIs.addElement(_beaconMsg); system->getDisplay().addFrame(std::shared_ptr(new TextFrame("BEACON", _beaconMsg->toString()))); _beacon_timer.start(); } diff --git a/src/TaskRouter.h b/src/TaskRouter.h index e673be6..e42d8f0 100644 --- a/src/TaskRouter.h +++ b/src/TaskRouter.h @@ -6,15 +6,15 @@ class RouterTask : public Task { public: - RouterTask(TaskQueue> *const fromModem, TaskQueue> *const toAprsIs); + RouterTask(TaskQueue> & fromModem, TaskQueue> & toAprsIs); virtual ~RouterTask(); virtual bool setup(std::shared_ptr system) override; virtual bool loop(std::shared_ptr system) override; private: - TaskQueue> *const _fromModem; - TaskQueue> *const _toAprsIs; + TaskQueue> & _fromModem; + TaskQueue> & _toAprsIs; std::shared_ptr _beaconMsg; Timer _beacon_timer; From 2c326337557a909105aef344eccddf6a23a5e927 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 16 May 2021 03:56:53 +0200 Subject: [PATCH 17/75] fix --- src/TaskRouter.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index 0703aa1..c232c9d 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -7,8 +7,7 @@ String create_lat_aprs(double lat); String create_long_aprs(double lng); -RouterTask::RouterTask(TaskQueue> & fromModem, TaskQueue> * -& toAprsIs) : Task(TASK_ROUTER, TaskRouter), _fromModem(fromModem), _toAprsIs(toAprsIs) { +RouterTask::RouterTask(TaskQueue> & fromModem, TaskQueue> & toAprsIs) : Task(TASK_ROUTER, TaskRouter), _fromModem(fromModem), _toAprsIs(toAprsIs) { } RouterTask::~RouterTask() { From f745e5f710509ea2070f64b0965e1672e654e2c6 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 16 May 2021 03:59:28 +0200 Subject: [PATCH 18/75] fix --- src/TaskRouter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index c232c9d..7bf5207 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -29,7 +29,7 @@ bool RouterTask::setup(std::shared_ptr system) { bool RouterTask::loop(std::shared_ptr system) { // do routing if (!_fromModem.empty()) { - _toAprsIs.addElement(_fromModem->getElement()); + _toAprsIs.addElement(_fromModem.getElement()); } // check for beacon From 4c0200c05e89fe12425a0a12fd53792d7c347b0f Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 16 May 2021 08:40:44 +0200 Subject: [PATCH 19/75] fixing the linter --- src/TaskAprsIs.cpp | 2 +- src/TaskAprsIs.h | 4 ++-- src/TaskModem.cpp | 2 +- src/TaskModem.h | 6 +++--- src/TaskRouter.cpp | 2 +- src/TaskRouter.h | 6 +++--- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/TaskAprsIs.cpp b/src/TaskAprsIs.cpp index 67051f8..b03c2e0 100644 --- a/src/TaskAprsIs.cpp +++ b/src/TaskAprsIs.cpp @@ -5,7 +5,7 @@ #include "TaskAprsIs.h" #include "project_configuration.h" -AprsIsTask::AprsIsTask(TaskQueue> & toAprsIs) : Task(TASK_APRS_IS, TaskAprsIs), _toAprsIs(toAprsIs) { +AprsIsTask::AprsIsTask(TaskQueue> &toAprsIs) : Task(TASK_APRS_IS, TaskAprsIs), _toAprsIs(toAprsIs) { } AprsIsTask::~AprsIsTask() { diff --git a/src/TaskAprsIs.h b/src/TaskAprsIs.h index 43dcc07..2466996 100644 --- a/src/TaskAprsIs.h +++ b/src/TaskAprsIs.h @@ -8,7 +8,7 @@ class AprsIsTask : public Task { public: - AprsIsTask(TaskQueue> & toAprsIs); + AprsIsTask(TaskQueue> &toAprsIs); virtual ~AprsIsTask(); virtual bool setup(std::shared_ptr system) override; @@ -17,7 +17,7 @@ public: private: std::shared_ptr _aprs_is; - TaskQueue> & _toAprsIs; + TaskQueue> &_toAprsIs; bool connect(std::shared_ptr system); }; diff --git a/src/TaskModem.cpp b/src/TaskModem.cpp index 4504e53..a7590a2 100644 --- a/src/TaskModem.cpp +++ b/src/TaskModem.cpp @@ -6,7 +6,7 @@ #include "TaskModem.h" #include "project_configuration.h" -ModemTask::ModemTask(TaskQueue> & fromModem) : Task(TASK_MODEM, TaskModem), _fromModem(fromModem) { +ModemTask::ModemTask(TaskQueue> &fromModem) : Task(TASK_MODEM, TaskModem), _fromModem(fromModem) { } ModemTask::~ModemTask() { diff --git a/src/TaskModem.h b/src/TaskModem.h index 6e6e97b..95010b0 100644 --- a/src/TaskModem.h +++ b/src/TaskModem.h @@ -7,15 +7,15 @@ class ModemTask : public Task { public: - ModemTask(TaskQueue> & fromModem); + ModemTask(TaskQueue> &fromModem); virtual ~ModemTask(); virtual bool setup(std::shared_ptr system) override; virtual bool loop(std::shared_ptr system) override; private: - std::shared_ptr _lora_aprs; - TaskQueue> & _fromModem; + std::shared_ptr _lora_aprs; + TaskQueue> &_fromModem; }; #endif diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index 7bf5207..1bcf7b8 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -7,7 +7,7 @@ String create_lat_aprs(double lat); String create_long_aprs(double lng); -RouterTask::RouterTask(TaskQueue> & fromModem, TaskQueue> & toAprsIs) : Task(TASK_ROUTER, TaskRouter), _fromModem(fromModem), _toAprsIs(toAprsIs) { +RouterTask::RouterTask(TaskQueue> &fromModem, TaskQueue> &toAprsIs) : Task(TASK_ROUTER, TaskRouter), _fromModem(fromModem), _toAprsIs(toAprsIs) { } RouterTask::~RouterTask() { diff --git a/src/TaskRouter.h b/src/TaskRouter.h index e42d8f0..0ed8092 100644 --- a/src/TaskRouter.h +++ b/src/TaskRouter.h @@ -6,15 +6,15 @@ class RouterTask : public Task { public: - RouterTask(TaskQueue> & fromModem, TaskQueue> & toAprsIs); + RouterTask(TaskQueue> &fromModem, TaskQueue> &toAprsIs); virtual ~RouterTask(); virtual bool setup(std::shared_ptr system) override; virtual bool loop(std::shared_ptr system) override; private: - TaskQueue> & _fromModem; - TaskQueue> & _toAprsIs; + TaskQueue> &_fromModem; + TaskQueue> &_toAprsIs; std::shared_ptr _beaconMsg; Timer _beacon_timer; From b88bc534a7614dd24e605bc6506f96397769b402 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Mon, 17 May 2021 10:02:22 +0200 Subject: [PATCH 20/75] remove cache --- .github/workflows/build_check.yml | 35 ------------------------------- 1 file changed, 35 deletions(-) diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 69e1efa..0785dee 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -3,46 +3,11 @@ name: push pull checks on: [push, pull_request] jobs: - #check: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v2 - # - name: Cache pip - # uses: actions/cache@v2 - # with: - # path: ~/.cache/pip - # key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - # restore-keys: ${{ runner.os }}-pip- - # - name: Cache PlatformIO - # uses: actions/cache@v2 - # with: - # path: ~/.platformio - # key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} - # - name: Set up Python - # uses: actions/setup-python@v2 - # - name: Install PlatformIO - # run: | - # python -m pip install --upgrade pip - # pip install --upgrade platformio - # - name: Run PlatformIO Check - # run: platformio check --fail-on-defect low --fail-on-defect medium --fail-on-defect high - build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - - name: Cache pip - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: ${{ runner.os }}-pip- - - name: Cache PlatformIO - uses: actions/cache@v2 - with: - path: ~/.platformio - key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} - name: Set up Python uses: actions/setup-python@v2 - name: Install PlatformIO From 445f7cc9d95f4f2636b98d301a0c3598f306c8d1 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Mon, 17 May 2021 10:02:36 +0200 Subject: [PATCH 21/75] simplify platformio install --- .github/workflows/build_check.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 0785dee..06a6057 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -11,9 +11,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 - name: Install PlatformIO - run: | - python -m pip install --upgrade pip - pip install --upgrade platformio + run: python -m pip install --upgrade pip platformio - name: Run PlatformIO CI run: platformio run - name: Upload artifacts From 55d13549c623f2f4c13287c034c2c7411ac3054e Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Mon, 17 May 2021 10:04:05 +0200 Subject: [PATCH 22/75] rename tests --- .github/workflows/build_check.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 06a6057..2938001 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -1,9 +1,10 @@ -name: push pull checks +name: Integreation Tests on: [push, pull_request] jobs: build: + name: Compile Firmware runs-on: ubuntu-latest steps: - name: Checkout code From f8038eb4f34a6d1192daac1f33b6abaea7f6cf01 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Mon, 17 May 2021 10:28:27 +0200 Subject: [PATCH 23/75] cppcheck update --- .github/workflows/build_check.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 2938001..6bd8d93 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -47,16 +47,18 @@ jobs: check-path: ${{ matrix.path }} cppcheck: - name: Run Cppcheck + name: Run cppcheck runs-on: ubuntu-latest + env: + CPPCHECK_ARGS: -v --enable=all . steps: - name: checkout code uses: actions/checkout@v2 - run: docker pull facthunder/cppcheck:latest - - name: Run Cppcheck - run: docker run --rm -v ${PWD}:/src facthunder/cppcheck:latest cppcheck -v --xml --enable=all . 2> report.xml - - name: Generate HTML report - run: docker run --rm -v ${PWD}:/src facthunder/cppcheck:latest cppcheck-htmlreport --file=report.xml --report-dir=output + - name: Run cppcheck and print result + run: docker run --rm -v ${PWD}:/src facthunder/cppcheck:latest /bin/bash -c "cppcheck $CPPCHECK_ARGS" + - name: Run cppcheck and create html + run: docker run --rm -v ${PWD}:/src facthunder/cppcheck:latest /bin/bash -c "cppcheck --xml $CPPCHECK_ARGS 2> report.xml && cppcheck-htmlreport --file=report.xml --report-dir=output" - name: Upload report uses: actions/upload-artifact@v1 with: From 9c21cda3c556569908072006d7e18efefaa400f9 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 19 May 2021 00:12:34 +0200 Subject: [PATCH 24/75] update cppcheck arguments --- .github/workflows/build_check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 6bd8d93..98b7038 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -50,7 +50,7 @@ jobs: name: Run cppcheck runs-on: ubuntu-latest env: - CPPCHECK_ARGS: -v --enable=all . + CPPCHECK_ARGS: --enable=all --std=c++14 -I lib/BoardFinder -I lib/ConfigurationManagement -I lib/Display -I lib/LoRa -I lib/LoRa_APRS -I lib/NTPClient -I lib/PowerManagement -I lib/System -I lib/TimeLib -i lib/Display -i lib/LoRa -i lib/NTPClient -i lib/TimeLib src lib steps: - name: checkout code uses: actions/checkout@v2 From c6d73c33b271676fecad05247781944ca34fa43c Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 19 May 2021 00:27:27 +0200 Subject: [PATCH 25/75] cppcheck fix --- .github/workflows/build_check.yml | 2 +- src/TaskAprsIs.h | 2 +- src/TaskModem.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 98b7038..542fe65 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -50,7 +50,7 @@ jobs: name: Run cppcheck runs-on: ubuntu-latest env: - CPPCHECK_ARGS: --enable=all --std=c++14 -I lib/BoardFinder -I lib/ConfigurationManagement -I lib/Display -I lib/LoRa -I lib/LoRa_APRS -I lib/NTPClient -I lib/PowerManagement -I lib/System -I lib/TimeLib -i lib/Display -i lib/LoRa -i lib/NTPClient -i lib/TimeLib src lib + CPPCHECK_ARGS: --enable=all --std=c++14 --inline-suppr -I lib/BoardFinder -I lib/ConfigurationManagement -I lib/Display -I lib/LoRa -I lib/LoRa_APRS -I lib/NTPClient -I lib/PowerManagement -I lib/System -I lib/TimeLib -i lib/Display -i lib/LoRa -i lib/NTPClient -i lib/TimeLib src lib steps: - name: checkout code uses: actions/checkout@v2 diff --git a/src/TaskAprsIs.h b/src/TaskAprsIs.h index 2466996..69fd66d 100644 --- a/src/TaskAprsIs.h +++ b/src/TaskAprsIs.h @@ -8,7 +8,7 @@ class AprsIsTask : public Task { public: - AprsIsTask(TaskQueue> &toAprsIs); + explicit AprsIsTask(TaskQueue> &toAprsIs); virtual ~AprsIsTask(); virtual bool setup(std::shared_ptr system) override; diff --git a/src/TaskModem.h b/src/TaskModem.h index 95010b0..7d324fd 100644 --- a/src/TaskModem.h +++ b/src/TaskModem.h @@ -7,7 +7,7 @@ class ModemTask : public Task { public: - ModemTask(TaskQueue> &fromModem); + explicit ModemTask(TaskQueue> &fromModem); virtual ~ModemTask(); virtual bool setup(std::shared_ptr system) override; From 16fea99b9b865d0178d2fc51cb063fb6a9db39e7 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 19 May 2021 00:43:59 +0200 Subject: [PATCH 26/75] remove smart pointer of board config --- lib/BoardFinder/BoardFinder.cpp | 29 ++++++++++++++++++++--------- lib/BoardFinder/BoardFinder.h | 23 ++++++++++++++++------- lib/Display/Display.cpp | 2 +- lib/Display/Display.h | 2 +- lib/LoRa_APRS/LoRa_APRS.cpp | 2 +- lib/LoRa_APRS/LoRa_APRS.h | 2 +- lib/System/System.cpp | 4 ++-- lib/System/System.h | 6 +++--- src/LoRa_APRS_iGate.cpp | 22 ++++++++++------------ 9 files changed, 55 insertions(+), 37 deletions(-) diff --git a/lib/BoardFinder/BoardFinder.cpp b/lib/BoardFinder/BoardFinder.cpp index 66eace0..c8eb972 100644 --- a/lib/BoardFinder/BoardFinder.cpp +++ b/lib/BoardFinder/BoardFinder.cpp @@ -6,14 +6,14 @@ BoardConfig::BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t o : Name(name), Type(type), OledSda(oledsda), OledScl(oledscl), OledAddr(oledaddr), OledReset(oledreset), LoraSck(lorasck), LoraMiso(loramiso), LoraMosi(loramosi), LoraCS(loracs), LoraReset(lorareset), LoraIRQ(lorairq), needCheckPowerChip(needcheckpowerchip), powerCheckStatus(powercheckstatus) { } -BoardFinder::BoardFinder(std::list> &boardConfigs) : _boardConfigs(boardConfigs) { +BoardFinder::BoardFinder(std::list boardConfigs) : _boardConfigs(boardConfigs) { } -std::shared_ptr BoardFinder::searchBoardConfig() { +BoardConfig const *BoardFinder::searchBoardConfig() { logPrintlnI("looking for a board config."); logPrintlnI("searching for OLED..."); - for (std::shared_ptr boardconf : _boardConfigs) { + for (BoardConfig const *boardconf : _boardConfigs) { if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf) == boardconf->powerCheckStatus) { PowerManagement powerManagement; Wire.begin(boardconf->OledSda, boardconf->OledScl); @@ -31,7 +31,7 @@ std::shared_ptr BoardFinder::searchBoardConfig() { logPrintlnI("could not find OLED, will search for the modem now..."); - for (std::shared_ptr boardconf : _boardConfigs) { + for (BoardConfig const *boardconf : _boardConfigs) { if (boardconf->needCheckPowerChip && checkPowerConfig(boardconf) == boardconf->powerCheckStatus) { PowerManagement powerManagement; Wire.begin(boardconf->OledSda, boardconf->OledScl); @@ -50,8 +50,8 @@ std::shared_ptr BoardFinder::searchBoardConfig() { return 0; } -std::shared_ptr BoardFinder::getBoardConfig(String name) { - std::_List_iterator> elem = std::find_if(_boardConfigs.begin(), _boardConfigs.end(), [&](std::shared_ptr conf) { +BoardConfig const *BoardFinder::getBoardConfig(String name) { + std::_List_iterator elem = std::find_if(_boardConfigs.begin(), _boardConfigs.end(), [&](BoardConfig const *conf) { return conf->Name == name; }); if (elem == _boardConfigs.end()) { @@ -60,7 +60,7 @@ std::shared_ptr BoardFinder::getBoardConfig(String name) { return *elem; } -bool BoardFinder::checkOledConfig(std::shared_ptr boardConfig) { +bool BoardFinder::checkOledConfig(BoardConfig const *boardConfig) { if (boardConfig->OledReset > 0) { pinMode(boardConfig->OledReset, OUTPUT); digitalWrite(boardConfig->OledReset, HIGH); @@ -80,7 +80,7 @@ bool BoardFinder::checkOledConfig(std::shared_ptr boardConfig) { return false; } -bool BoardFinder::checkModemConfig(std::shared_ptr boardConfig) { +bool BoardFinder::checkModemConfig(BoardConfig const *boardConfig) { pinMode(boardConfig->LoraReset, OUTPUT); digitalWrite(boardConfig->LoraReset, LOW); delay(10); @@ -107,7 +107,7 @@ bool BoardFinder::checkModemConfig(std::shared_ptr boardConfig) { return false; } -bool BoardFinder::checkPowerConfig(std::shared_ptr boardConfig) { +bool BoardFinder::checkPowerConfig(BoardConfig const *boardConfig) { if (!Wire.begin(boardConfig->OledSda, boardConfig->OledScl)) { logPrintlnW("issue with wire"); return false; @@ -128,3 +128,14 @@ bool BoardFinder::checkPowerConfig(std::shared_ptr boardConfig) { logPrintlnD("power chip NOT found"); return false; } + +// clang-format off +BoardConfig TTGO_LORA32_V1 ("TTGO_LORA32_V1", eTTGO_LORA32_V1, 4, 15, 0x3C, 0, 5, 19, 27, 18, 14, 26); +BoardConfig TTGO_LORA32_V2 ("TTGO_LORA32_V2", eTTGO_LORA32_V2, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, true); +BoardConfig TTGO_T_Beam_V0_7 ("TTGO_T_Beam_V0_7", eTTGO_T_Beam_V0_7, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, true); +BoardConfig TTGO_T_Beam_V1_0 ("TTGO_T_Beam_V1_0", eTTGO_T_Beam_V1_0, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, true, true); +BoardConfig ETH_BOARD ("ETH_BOARD", eETH_BOARD, 33, 32, 0x3C, 0, 14, 2, 15, 12, 4, 36); +BoardConfig TRACKERD ("TRACKERD", eTRACKERD, 5, 4, 0x3C, 0, 18, 19, 23, 16, 14, 26); +BoardConfig HELTEC_WIFI_LORA_32_V1("HELTEC_WIFI_LORA_32_V1", eHELTEC_WIFI_LORA_32_V1, 4, 15, 0x3C, 16, 5, 19, 27, 18, 14, 26); +BoardConfig HELTEC_WIFI_LORA_32_V2("HELTEC_WIFI_LORA_32_V2", eHELTEC_WIFI_LORA_32_V2, 4, 15, 0x3C, 16, 5, 19, 27, 18, 14, 26); +// clang-format on diff --git a/lib/BoardFinder/BoardFinder.h b/lib/BoardFinder/BoardFinder.h index 04dc8a4..a18f674 100644 --- a/lib/BoardFinder/BoardFinder.h +++ b/lib/BoardFinder/BoardFinder.h @@ -45,18 +45,27 @@ public: class BoardFinder { public: - explicit BoardFinder(std::list> &boardConfigs); + explicit BoardFinder(std::list boardConfigs); - std::shared_ptr searchBoardConfig(); + BoardConfig const *searchBoardConfig(); - std::shared_ptr getBoardConfig(String name); + BoardConfig const *getBoardConfig(String name); private: - std::list> _boardConfigs; + std::list _boardConfigs; - bool checkOledConfig(std::shared_ptr boardConfig); - bool checkModemConfig(std::shared_ptr boardConfig); - bool checkPowerConfig(std::shared_ptr boardConfig); + bool checkOledConfig(BoardConfig const *boardConfig); + bool checkModemConfig(BoardConfig const *boardConfig); + bool checkPowerConfig(BoardConfig const *boardConfig); }; +extern BoardConfig TTGO_LORA32_V1; +extern BoardConfig TTGO_LORA32_V2; +extern BoardConfig TTGO_T_Beam_V0_7; +extern BoardConfig TTGO_T_Beam_V1_0; +extern BoardConfig ETH_BOARD; +extern BoardConfig TRACKERD; +extern BoardConfig HELTEC_WIFI_LORA_32_V1; +extern BoardConfig HELTEC_WIFI_LORA_32_V2; + #endif diff --git a/lib/Display/Display.cpp b/lib/Display/Display.cpp index b62074e..865eb34 100644 --- a/lib/Display/Display.cpp +++ b/lib/Display/Display.cpp @@ -8,7 +8,7 @@ Display::Display() : _disp(0), _statusFrame(0), _displaySaveMode(false) { Display::~Display() { } -void Display::setup(std::shared_ptr boardConfig) { +void Display::setup(BoardConfig const *const boardConfig) { if (boardConfig->OledReset != 0) { pinMode(boardConfig->OledReset, OUTPUT); digitalWrite(boardConfig->OledReset, HIGH); diff --git a/lib/Display/Display.h b/lib/Display/Display.h index 2259291..4ff69ff 100644 --- a/lib/Display/Display.h +++ b/lib/Display/Display.h @@ -28,7 +28,7 @@ public: Display(); ~Display(); - void setup(std::shared_ptr boardConfig); + void setup(BoardConfig const *const boardConfig); // setup functions void showSpashScreen(String firmwareTitle, String version); void setStatusFrame(std::shared_ptr frame); diff --git a/lib/LoRa_APRS/LoRa_APRS.cpp b/lib/LoRa_APRS/LoRa_APRS.cpp index d3279b2..6221f2b 100644 --- a/lib/LoRa_APRS/LoRa_APRS.cpp +++ b/lib/LoRa_APRS/LoRa_APRS.cpp @@ -1,6 +1,6 @@ #include "LoRa_APRS.h" -LoRa_APRS::LoRa_APRS(std::shared_ptr boardConfig) : _LastReceivedMsg(0), _RxFrequency(LORA_RX_FREQUENCY), _TxFrequency(LORA_TX_FREQUENCY) { +LoRa_APRS::LoRa_APRS(BoardConfig const *const boardConfig) : _LastReceivedMsg(0), _RxFrequency(LORA_RX_FREQUENCY), _TxFrequency(LORA_TX_FREQUENCY) { SPI.begin(boardConfig->LoraSck, boardConfig->LoraMiso, boardConfig->LoraMosi, boardConfig->LoraCS); setPins(boardConfig->LoraCS, boardConfig->LoraReset, boardConfig->LoraIRQ); } diff --git a/lib/LoRa_APRS/LoRa_APRS.h b/lib/LoRa_APRS/LoRa_APRS.h index 1c29b41..e0b9b87 100644 --- a/lib/LoRa_APRS/LoRa_APRS.h +++ b/lib/LoRa_APRS/LoRa_APRS.h @@ -16,7 +16,7 @@ class LoRa_APRS : public LoRaClass { public: - explicit LoRa_APRS(std::shared_ptr boardConfig); + explicit LoRa_APRS(BoardConfig const *const boardConfig); bool checkMessage(); std::shared_ptr getMessage(); diff --git a/lib/System/System.cpp b/lib/System/System.cpp index 6c77c3f..774d43a 100644 --- a/lib/System/System.cpp +++ b/lib/System/System.cpp @@ -1,13 +1,13 @@ #include "System.h" -System::System(std::shared_ptr boardConfig, std::shared_ptr userConfig) : _boardConfig(boardConfig), _userConfig(userConfig), _isWifiEthConnected(false) { +System::System(BoardConfig const *const boardConfig, std::shared_ptr userConfig) : _boardConfig(boardConfig), _userConfig(userConfig), _isWifiEthConnected(false) { } System::~System() { } -std::shared_ptr System::getBoardConfig() const { +BoardConfig const *const System::getBoardConfig() const { return _boardConfig; } diff --git a/lib/System/System.h b/lib/System/System.h index ab3d655..dd16674 100644 --- a/lib/System/System.h +++ b/lib/System/System.h @@ -10,10 +10,10 @@ class System { public: - System(std::shared_ptr boardConfig, std::shared_ptr userConfig); + System(BoardConfig const *const boardConfig, std::shared_ptr userConfig); ~System(); - std::shared_ptr getBoardConfig() const; + BoardConfig const *const getBoardConfig() const; std::shared_ptr getUserConfig() const; TaskManager & getTaskManager(); Display & getDisplay(); @@ -21,7 +21,7 @@ public: void connectedViaWifiEth(bool status); private: - std::shared_ptr _boardConfig; + BoardConfig const *const _boardConfig; std::shared_ptr _userConfig; TaskManager _taskManager; Display _display; diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index cc1ff8e..fe70d13 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -33,22 +33,20 @@ void setup() { logPrintlnI("LoRa APRS iGate by OE5BPA (Peter Buchegger)"); logPrintlnI("Version: " VERSION); - std::list> boardConfigs; - // clang-format off - boardConfigs.push_back(std::shared_ptr(new BoardConfig("TTGO_LORA32_V1", eTTGO_LORA32_V1, 4, 15, 0x3C, 0, 5, 19, 27, 18, 14, 26))); - boardConfigs.push_back(std::shared_ptr(new BoardConfig("TTGO_LORA32_V2", eTTGO_LORA32_V2, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, true))); - boardConfigs.push_back(std::shared_ptr(new BoardConfig("TTGO_T_Beam_V0_7", eTTGO_T_Beam_V0_7, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, true))); - boardConfigs.push_back(std::shared_ptr(new BoardConfig("TTGO_T_Beam_V1_0", eTTGO_T_Beam_V1_0, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, true, true))); - boardConfigs.push_back(std::shared_ptr(new BoardConfig("ETH_BOARD", eETH_BOARD, 33, 32, 0x3C, 0, 14, 2, 15, 12, 4, 36))); - boardConfigs.push_back(std::shared_ptr(new BoardConfig("TRACKERD", eTRACKERD, 5, 4, 0x3C, 0, 18, 19, 23, 16, 14, 26))); - boardConfigs.push_back(std::shared_ptr(new BoardConfig("HELTEC_WIFI_LORA_32_V1", eHELTEC_WIFI_LORA_32_V1, 4, 15, 0x3C, 16, 5, 19, 27, 18, 14, 26))); - boardConfigs.push_back(std::shared_ptr(new BoardConfig("HELTEC_WIFI_LORA_32_V2", eHELTEC_WIFI_LORA_32_V2, 4, 15, 0x3C, 16, 5, 19, 27, 18, 14, 26))); - // clang-format on + std::list boardConfigs; + boardConfigs.push_back(&TTGO_LORA32_V1); + boardConfigs.push_back(&TTGO_LORA32_V2); + boardConfigs.push_back(&TTGO_T_Beam_V0_7); + boardConfigs.push_back(&TTGO_T_Beam_V1_0); + boardConfigs.push_back(Ð_BOARD); + boardConfigs.push_back(&TRACKERD); + boardConfigs.push_back(&HELTEC_WIFI_LORA_32_V1); + boardConfigs.push_back(&HELTEC_WIFI_LORA_32_V2); ProjectConfigurationManagement confmg; std::shared_ptr userConfig = confmg.readConfiguration(); BoardFinder finder(boardConfigs); - std::shared_ptr boardConfig = finder.getBoardConfig(userConfig->board); + BoardConfig const * boardConfig = finder.getBoardConfig(userConfig->board); if (boardConfig == 0) { boardConfig = finder.searchBoardConfig(); if (boardConfig == 0) { From c1fd41a3557d7a70ba8733bd789d6d48a8160304 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 19 May 2021 00:44:37 +0200 Subject: [PATCH 27/75] remove of smart pointers --- lib/ConfigurationManagement/configuration.cpp | 12 +- lib/ConfigurationManagement/configuration.h | 8 +- lib/Display/Display.cpp | 2 +- lib/Display/Display.h | 2 +- lib/LoRa_APRS/LoRa_APRS.cpp | 2 +- lib/LoRa_APRS/LoRa_APRS.h | 2 +- lib/System/System.cpp | 14 ++- lib/System/System.h | 27 +++-- lib/System/TaskManager.cpp | 4 +- lib/System/TaskManager.h | 8 +- src/LoRa_APRS_iGate.cpp | 51 +++++---- src/TaskAprsIs.cpp | 16 +-- src/TaskAprsIs.h | 6 +- src/TaskDisplay.cpp | 24 ++-- src/TaskDisplay.h | 4 +- src/TaskEth.cpp | 8 +- src/TaskEth.h | 4 +- src/TaskFTP.cpp | 6 +- src/TaskFTP.h | 4 +- src/TaskModem.cpp | 22 ++-- src/TaskModem.h | 4 +- src/TaskNTP.cpp | 8 +- src/TaskNTP.h | 4 +- src/TaskOTA.cpp | 6 +- src/TaskOTA.h | 4 +- src/TaskRouter.cpp | 16 +-- src/TaskRouter.h | 4 +- src/TaskWifi.cpp | 12 +- src/TaskWifi.h | 4 +- src/project_configuration.cpp | 105 +++++++++--------- src/project_configuration.h | 4 +- 31 files changed, 203 insertions(+), 194 deletions(-) diff --git a/lib/ConfigurationManagement/configuration.cpp b/lib/ConfigurationManagement/configuration.cpp index 7f75d9e..5f50550 100644 --- a/lib/ConfigurationManagement/configuration.cpp +++ b/lib/ConfigurationManagement/configuration.cpp @@ -15,11 +15,11 @@ ConfigurationManagement::ConfigurationManagement(String FilePath) : mFilePath(Fi ConfigurationManagement::~ConfigurationManagement() { } -std::shared_ptr ConfigurationManagement::readConfiguration() { +void ConfigurationManagement::readConfiguration(Configuration &conf) { File file = SPIFFS.open(mFilePath); if (!file) { - logPrintlnE("Failed to open file for reading..."); - return 0; + logPrintlnE("Failed to open file for reading, using default configuration."); + return; } DynamicJsonDocument data(2048); DeserializationError error = deserializeJson(data, file); @@ -30,15 +30,13 @@ std::shared_ptr ConfigurationManagement::readConfiguration() { // Serial.println(); file.close(); - std::shared_ptr conf = readProjectConfiguration(data); + readProjectConfiguration(data, conf); // update config in memory to get the new fields: writeConfiguration(conf); - - return conf; } -void ConfigurationManagement::writeConfiguration(std::shared_ptr conf) { +void ConfigurationManagement::writeConfiguration(Configuration &conf) { File file = SPIFFS.open(mFilePath, "w"); if (!file) { logPrintlnE("Failed to open file for writing..."); diff --git a/lib/ConfigurationManagement/configuration.h b/lib/ConfigurationManagement/configuration.h index cb7b6d3..6ebcf75 100644 --- a/lib/ConfigurationManagement/configuration.h +++ b/lib/ConfigurationManagement/configuration.h @@ -16,12 +16,12 @@ public: explicit ConfigurationManagement(String FilePath); virtual ~ConfigurationManagement(); - std::shared_ptr readConfiguration(); - void writeConfiguration(std::shared_ptr conf); + void readConfiguration(Configuration &conf); + void writeConfiguration(Configuration &conf); private: - virtual std::shared_ptr readProjectConfiguration(DynamicJsonDocument &data) = 0; - virtual void writeProjectConfiguration(std::shared_ptr conf, DynamicJsonDocument &data) = 0; + virtual void readProjectConfiguration(DynamicJsonDocument &data, Configuration &conf) = 0; + virtual void writeProjectConfiguration(Configuration &conf, DynamicJsonDocument &data) = 0; const String mFilePath; }; diff --git a/lib/Display/Display.cpp b/lib/Display/Display.cpp index b62074e..865eb34 100644 --- a/lib/Display/Display.cpp +++ b/lib/Display/Display.cpp @@ -8,7 +8,7 @@ Display::Display() : _disp(0), _statusFrame(0), _displaySaveMode(false) { Display::~Display() { } -void Display::setup(std::shared_ptr boardConfig) { +void Display::setup(BoardConfig const *const boardConfig) { if (boardConfig->OledReset != 0) { pinMode(boardConfig->OledReset, OUTPUT); digitalWrite(boardConfig->OledReset, HIGH); diff --git a/lib/Display/Display.h b/lib/Display/Display.h index 2259291..4ff69ff 100644 --- a/lib/Display/Display.h +++ b/lib/Display/Display.h @@ -28,7 +28,7 @@ public: Display(); ~Display(); - void setup(std::shared_ptr boardConfig); + void setup(BoardConfig const *const boardConfig); // setup functions void showSpashScreen(String firmwareTitle, String version); void setStatusFrame(std::shared_ptr frame); diff --git a/lib/LoRa_APRS/LoRa_APRS.cpp b/lib/LoRa_APRS/LoRa_APRS.cpp index d3279b2..6221f2b 100644 --- a/lib/LoRa_APRS/LoRa_APRS.cpp +++ b/lib/LoRa_APRS/LoRa_APRS.cpp @@ -1,6 +1,6 @@ #include "LoRa_APRS.h" -LoRa_APRS::LoRa_APRS(std::shared_ptr boardConfig) : _LastReceivedMsg(0), _RxFrequency(LORA_RX_FREQUENCY), _TxFrequency(LORA_TX_FREQUENCY) { +LoRa_APRS::LoRa_APRS(BoardConfig const *const boardConfig) : _LastReceivedMsg(0), _RxFrequency(LORA_RX_FREQUENCY), _TxFrequency(LORA_TX_FREQUENCY) { SPI.begin(boardConfig->LoraSck, boardConfig->LoraMiso, boardConfig->LoraMosi, boardConfig->LoraCS); setPins(boardConfig->LoraCS, boardConfig->LoraReset, boardConfig->LoraIRQ); } diff --git a/lib/LoRa_APRS/LoRa_APRS.h b/lib/LoRa_APRS/LoRa_APRS.h index 1c29b41..e0b9b87 100644 --- a/lib/LoRa_APRS/LoRa_APRS.h +++ b/lib/LoRa_APRS/LoRa_APRS.h @@ -16,7 +16,7 @@ class LoRa_APRS : public LoRaClass { public: - explicit LoRa_APRS(std::shared_ptr boardConfig); + explicit LoRa_APRS(BoardConfig const *const boardConfig); bool checkMessage(); std::shared_ptr getMessage(); diff --git a/lib/System/System.cpp b/lib/System/System.cpp index 6c77c3f..e074745 100644 --- a/lib/System/System.cpp +++ b/lib/System/System.cpp @@ -1,17 +1,25 @@ #include "System.h" -System::System(std::shared_ptr boardConfig, std::shared_ptr userConfig) : _boardConfig(boardConfig), _userConfig(userConfig), _isWifiEthConnected(false) { +System::System() : _boardConfig(0), _userConfig(0), _isWifiEthConnected(false) { } System::~System() { } -std::shared_ptr System::getBoardConfig() const { +void System::setBoardConfig(BoardConfig const *const boardConfig) { + _boardConfig = boardConfig; +} + +void System::setUserConfig(Configuration const *const userConfig) { + _userConfig = userConfig; +} + +BoardConfig const *const System::getBoardConfig() const { return _boardConfig; } -std::shared_ptr System::getUserConfig() const { +Configuration const *const System::getUserConfig() const { return _userConfig; } diff --git a/lib/System/System.h b/lib/System/System.h index ab3d655..376741b 100644 --- a/lib/System/System.h +++ b/lib/System/System.h @@ -10,22 +10,25 @@ class System { public: - System(std::shared_ptr boardConfig, std::shared_ptr userConfig); + System(); ~System(); - std::shared_ptr getBoardConfig() const; - std::shared_ptr getUserConfig() const; - TaskManager & getTaskManager(); - Display & getDisplay(); - bool isWifiEthConnected() const; - void connectedViaWifiEth(bool status); + void setBoardConfig(BoardConfig const *const boardConfig); + void setUserConfig(Configuration const *const userConfig); + + BoardConfig const *const getBoardConfig() const; + Configuration const *const getUserConfig() const; + TaskManager & getTaskManager(); + Display & getDisplay(); + bool isWifiEthConnected() const; + void connectedViaWifiEth(bool status); private: - std::shared_ptr _boardConfig; - std::shared_ptr _userConfig; - TaskManager _taskManager; - Display _display; - bool _isWifiEthConnected; + BoardConfig const * _boardConfig; + Configuration const *_userConfig; + TaskManager _taskManager; + Display _display; + bool _isWifiEthConnected; }; #endif diff --git a/lib/System/TaskManager.cpp b/lib/System/TaskManager.cpp index 5c506cb..e2741c2 100644 --- a/lib/System/TaskManager.cpp +++ b/lib/System/TaskManager.cpp @@ -27,7 +27,7 @@ std::list> TaskManager::getTasks() { return _tasks; } -bool TaskManager::setup(std::shared_ptr system) { +bool TaskManager::setup(System &system) { logPrintlnV("will setup all tasks..."); for (std::shared_ptr &elem : _alwaysRunTasks) { logPrintD("call setup from "); @@ -43,7 +43,7 @@ bool TaskManager::setup(std::shared_ptr system) { return true; } -bool TaskManager::loop(std::shared_ptr system) { +bool TaskManager::loop(System &system) { // logPrintlnD("will loop all tasks..."); for (std::shared_ptr &elem : _alwaysRunTasks) { // logPrintD("call loop from "); diff --git a/lib/System/TaskManager.h b/lib/System/TaskManager.h index edb8f14..ffb7ff6 100644 --- a/lib/System/TaskManager.h +++ b/lib/System/TaskManager.h @@ -43,8 +43,8 @@ public: return _stateInfo; } - virtual bool setup(std::shared_ptr system) = 0; - virtual bool loop(std::shared_ptr system) = 0; + virtual bool setup(System &system) = 0; + virtual bool loop(System &system) = 0; protected: TaskDisplayState _state; @@ -66,8 +66,8 @@ public: std::shared_ptr getTask(const char *name); std::list> getTasks(); - bool setup(std::shared_ptr system); - bool loop(std::shared_ptr system); + bool setup(System &system); + bool loop(System &system); private: std::list> _tasks; diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 354dab9..e02448e 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -24,7 +24,7 @@ String create_lat_aprs(double lat); String create_long_aprs(double lng); -std::shared_ptr LoRaSystem; +System LoRaSystem; TaskQueue> toAprsIs; TaskQueue> fromModem; @@ -50,9 +50,11 @@ void setup() { // clang-format on ProjectConfigurationManagement confmg; - std::shared_ptr userConfig = confmg.readConfiguration(); - BoardFinder finder(boardConfigs); - std::shared_ptr boardConfig = finder.getBoardConfig(userConfig->board); + Configuration userConfig; + confmg.readConfiguration(userConfig); + + BoardFinder finder(boardConfigs); + std::shared_ptr boardConfig = finder.getBoardConfig(userConfig.board); if (boardConfig == 0) { boardConfig = finder.searchBoardConfig(); if (boardConfig == 0) { @@ -60,7 +62,7 @@ void setup() { while (true) { } } - userConfig->board = boardConfig->Name; + userConfig.board = boardConfig->Name; confmg.writeConfiguration(userConfig); logPrintlnI("will restart board now!"); ESP.restart(); @@ -82,36 +84,37 @@ void setup() { powerManagement->deactivateGPS(); } - LoRaSystem = std::shared_ptr(new System(boardConfig, userConfig)); - LoRaSystem->getTaskManager().addTask(std::shared_ptr(new DisplayTask())); - LoRaSystem->getTaskManager().addTask(std::shared_ptr(new ModemTask(fromModem))); + LoRaSystem.setBoardConfig(boardConfig.get()); + LoRaSystem.setUserConfig(&userConfig); + LoRaSystem.getTaskManager().addTask(std::shared_ptr(new DisplayTask())); + LoRaSystem.getTaskManager().addTask(std::shared_ptr(new ModemTask(fromModem))); if (boardConfig->Type == eETH_BOARD) { - LoRaSystem->getTaskManager().addAlwaysRunTask(std::shared_ptr(new EthTask())); + LoRaSystem.getTaskManager().addAlwaysRunTask(std::shared_ptr(new EthTask())); } else { - LoRaSystem->getTaskManager().addAlwaysRunTask(std::shared_ptr(new WifiTask())); + LoRaSystem.getTaskManager().addAlwaysRunTask(std::shared_ptr(new WifiTask())); } - LoRaSystem->getTaskManager().addTask(std::shared_ptr(new OTATask())); - LoRaSystem->getTaskManager().addTask(std::shared_ptr(new NTPTask())); - if (userConfig->ftp.active) { - LoRaSystem->getTaskManager().addTask(std::shared_ptr(new FTPTask())); + LoRaSystem.getTaskManager().addTask(std::shared_ptr(new OTATask())); + LoRaSystem.getTaskManager().addTask(std::shared_ptr(new NTPTask())); + if (userConfig.ftp.active) { + LoRaSystem.getTaskManager().addTask(std::shared_ptr(new FTPTask())); } - LoRaSystem->getTaskManager().addTask(std::shared_ptr(new AprsIsTask(toAprsIs))); - LoRaSystem->getTaskManager().addTask(std::shared_ptr(new RouterTask(fromModem, toAprsIs))); + LoRaSystem.getTaskManager().addTask(std::shared_ptr(new AprsIsTask(toAprsIs))); + LoRaSystem.getTaskManager().addTask(std::shared_ptr(new RouterTask(fromModem, toAprsIs))); - LoRaSystem->getTaskManager().setup(LoRaSystem); + LoRaSystem.getTaskManager().setup(LoRaSystem); - 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->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) ; } - if (userConfig->display.overwritePin != 0) { - pinMode(userConfig->display.overwritePin, INPUT); - pinMode(userConfig->display.overwritePin, INPUT_PULLUP); + if (userConfig.display.overwritePin != 0) { + pinMode(userConfig.display.overwritePin, INPUT); + pinMode(userConfig.display.overwritePin, INPUT_PULLUP); } delay(5000); @@ -120,7 +123,7 @@ void setup() { // cppcheck-suppress unusedFunction void loop() { - LoRaSystem->getTaskManager().loop(LoRaSystem); + LoRaSystem.getTaskManager().loop(LoRaSystem); } String create_lat_aprs(double lat) { diff --git a/src/TaskAprsIs.cpp b/src/TaskAprsIs.cpp index b03c2e0..af69735 100644 --- a/src/TaskAprsIs.cpp +++ b/src/TaskAprsIs.cpp @@ -11,14 +11,14 @@ AprsIsTask::AprsIsTask(TaskQueue> &toAprsIs) : Task AprsIsTask::~AprsIsTask() { } -bool AprsIsTask::setup(std::shared_ptr system) { - _aprs_is = std::shared_ptr(new APRS_IS(system->getUserConfig()->callsign, system->getUserConfig()->aprs_is.passcode, "ESP32-APRS-IS", "0.2")); +bool AprsIsTask::setup(System &system) { + _aprs_is = std::shared_ptr(new APRS_IS(system.getUserConfig()->callsign, system.getUserConfig()->aprs_is.passcode, "ESP32-APRS-IS", "0.2")); return true; } -bool AprsIsTask::loop(std::shared_ptr system) { - if (!system->isWifiEthConnected()) { +bool AprsIsTask::loop(System &system) { + if (!system.isWifiEthConnected()) { return false; } if (!_aprs_is->connected()) { @@ -42,12 +42,12 @@ bool AprsIsTask::loop(std::shared_ptr system) { return true; } -bool AprsIsTask::connect(std::shared_ptr system) { +bool AprsIsTask::connect(System &system) { logPrintI("connecting to APRS-IS server: "); - logPrintI(system->getUserConfig()->aprs_is.server); + logPrintI(system.getUserConfig()->aprs_is.server); logPrintI(" on port: "); - logPrintlnI(String(system->getUserConfig()->aprs_is.port)); - if (!_aprs_is->connect(system->getUserConfig()->aprs_is.server, system->getUserConfig()->aprs_is.port)) { + logPrintlnI(String(system.getUserConfig()->aprs_is.port)); + if (!_aprs_is->connect(system.getUserConfig()->aprs_is.server, system.getUserConfig()->aprs_is.port)) { logPrintlnE("Connection failed."); return false; } diff --git a/src/TaskAprsIs.h b/src/TaskAprsIs.h index 69fd66d..2b1955a 100644 --- a/src/TaskAprsIs.h +++ b/src/TaskAprsIs.h @@ -11,15 +11,15 @@ public: explicit AprsIsTask(TaskQueue> &toAprsIs); virtual ~AprsIsTask(); - virtual bool setup(std::shared_ptr system) override; - virtual bool loop(std::shared_ptr system) override; + virtual bool setup(System &system) override; + virtual bool loop(System &system) override; private: std::shared_ptr _aprs_is; TaskQueue> &_toAprsIs; - bool connect(std::shared_ptr system); + bool connect(System &system); }; #endif diff --git a/src/TaskDisplay.cpp b/src/TaskDisplay.cpp index 06d74ec..1f5fc00 100644 --- a/src/TaskDisplay.cpp +++ b/src/TaskDisplay.cpp @@ -10,22 +10,22 @@ DisplayTask::DisplayTask() : Task("DisplayTask", 0) { DisplayTask::~DisplayTask() { } -bool DisplayTask::setup(std::shared_ptr system) { - system->getDisplay().setup(system->getBoardConfig()); - if (system->getUserConfig()->display.turn180) { - system->getDisplay().turn180(); +bool DisplayTask::setup(System &system) { + system.getDisplay().setup(system.getBoardConfig()); + if (system.getUserConfig()->display.turn180) { + system.getDisplay().turn180(); } - std::shared_ptr statusFrame = std::shared_ptr(new StatusFrame(system->getTaskManager().getTasks())); - system->getDisplay().setStatusFrame(statusFrame); - if (!system->getUserConfig()->display.alwaysOn) { - system->getDisplay().activateDisplaySaveMode(); - system->getDisplay().setDisplaySaveTimeout(system->getUserConfig()->display.timeout); + std::shared_ptr statusFrame = std::shared_ptr(new StatusFrame(system.getTaskManager().getTasks())); + system.getDisplay().setStatusFrame(statusFrame); + if (!system.getUserConfig()->display.alwaysOn) { + system.getDisplay().activateDisplaySaveMode(); + system.getDisplay().setDisplaySaveTimeout(system.getUserConfig()->display.timeout); } - _stateInfo = system->getUserConfig()->callsign; + _stateInfo = system.getUserConfig()->callsign; return true; } -bool DisplayTask::loop(std::shared_ptr system) { - system->getDisplay().update(); +bool DisplayTask::loop(System &system) { + system.getDisplay().update(); return true; } diff --git a/src/TaskDisplay.h b/src/TaskDisplay.h index 80cb98e..95dff61 100644 --- a/src/TaskDisplay.h +++ b/src/TaskDisplay.h @@ -9,8 +9,8 @@ public: DisplayTask(); virtual ~DisplayTask(); - virtual bool setup(std::shared_ptr system) override; - virtual bool loop(std::shared_ptr system) override; + virtual bool setup(System &system) override; + virtual bool loop(System &system) override; }; #endif diff --git a/src/TaskEth.cpp b/src/TaskEth.cpp index 77ef9c6..bfbab2e 100644 --- a/src/TaskEth.cpp +++ b/src/TaskEth.cpp @@ -48,7 +48,7 @@ EthTask::EthTask() : Task(TASK_ETH, TaskEth) { EthTask::~EthTask() { } -bool EthTask::setup(std::shared_ptr system) { +bool EthTask::setup(System &system) { WiFi.onEvent(WiFiEvent); constexpr uint8_t ETH_NRST = 5; @@ -73,14 +73,14 @@ bool EthTask::setup(std::shared_ptr system) { return true; } -bool EthTask::loop(std::shared_ptr system) { +bool EthTask::loop(System &system) { if (!eth_connected) { - system->connectedViaWifiEth(false); + system.connectedViaWifiEth(false); _stateInfo = "Ethernet not connected"; _state = Error; return false; } - system->connectedViaWifiEth(true); + system.connectedViaWifiEth(true); _stateInfo = ETH.localIP().toString(); _state = Okay; return true; diff --git a/src/TaskEth.h b/src/TaskEth.h index 8597369..e4baefe 100644 --- a/src/TaskEth.h +++ b/src/TaskEth.h @@ -8,8 +8,8 @@ public: EthTask(); virtual ~EthTask(); - virtual bool setup(std::shared_ptr system) override; - virtual bool loop(std::shared_ptr system) override; + virtual bool setup(System &system) override; + virtual bool loop(System &system) override; private: }; diff --git a/src/TaskFTP.cpp b/src/TaskFTP.cpp index b2e67fb..0f4a05d 100644 --- a/src/TaskFTP.cpp +++ b/src/TaskFTP.cpp @@ -12,9 +12,9 @@ FTPTask::FTPTask() : Task(TASK_FTP, TaskFtp), _beginCalled(false) { FTPTask::~FTPTask() { } -bool FTPTask::setup(std::shared_ptr system) { +bool FTPTask::setup(System &system) { _ftpServer = std::shared_ptr(new FTPServer()); - for (Configuration::Ftp::User user : system->getUserConfig()->ftp.users) { + for (Configuration::Ftp::User user : system.getUserConfig()->ftp.users) { logPrintD("Adding user to FTP Server: "); logPrintlnD(user.name); _ftpServer->addUser(user.name, user.password); @@ -24,7 +24,7 @@ bool FTPTask::setup(std::shared_ptr system) { return true; } -bool FTPTask::loop(std::shared_ptr system) { +bool FTPTask::loop(System &system) { if (!_beginCalled) { _ftpServer->begin(); _beginCalled = true; diff --git a/src/TaskFTP.h b/src/TaskFTP.h index 46d27cf..6d5bf2b 100644 --- a/src/TaskFTP.h +++ b/src/TaskFTP.h @@ -9,8 +9,8 @@ public: FTPTask(); virtual ~FTPTask(); - virtual bool setup(std::shared_ptr system) override; - virtual bool loop(std::shared_ptr system) override; + virtual bool setup(System &system) override; + virtual bool loop(System &system) override; private: std::shared_ptr _ftpServer; diff --git a/src/TaskModem.cpp b/src/TaskModem.cpp index a7590a2..deac31c 100644 --- a/src/TaskModem.cpp +++ b/src/TaskModem.cpp @@ -12,8 +12,8 @@ ModemTask::ModemTask(TaskQueue> &fromModem) : Task( ModemTask::~ModemTask() { } -bool ModemTask::setup(std::shared_ptr system) { - _lora_aprs = std::shared_ptr(new LoRa_APRS(system->getBoardConfig())); +bool ModemTask::setup(System &system) { + _lora_aprs = std::shared_ptr(new LoRa_APRS(system.getBoardConfig())); if (!_lora_aprs->begin(_lora_aprs->getRxFrequency())) { logPrintlnE("Starting LoRa failed!"); _stateInfo = "LoRa-Modem failed"; @@ -21,19 +21,19 @@ bool ModemTask::setup(std::shared_ptr system) { while (true) ; } - _lora_aprs->setRxFrequency(system->getUserConfig()->lora.frequencyRx); - _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->setRxFrequency(system.getUserConfig()->lora.frequencyRx); + _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(std::shared_ptr system) { +bool ModemTask::loop(System &system) { if (_lora_aprs->checkMessage()) { std::shared_ptr msg = _lora_aprs->getMessage(); // msg->getAPRSBody()->setData(msg->getAPRSBody()->getData() + " 123"); @@ -53,10 +53,10 @@ bool ModemTask::loop(std::shared_ptr system) { if (!path.isEmpty()) { path += ","; } - msg->setPath(path + "qAR," + system->getUserConfig()->callsign); + msg->setPath(path + "qAR," + system.getUserConfig()->callsign); _fromModem.addElement(msg); - system->getDisplay().addFrame(std::shared_ptr(new TextFrame("LoRa", msg->toString()))); + system.getDisplay().addFrame(std::shared_ptr(new TextFrame("LoRa", msg->toString()))); } return true; diff --git a/src/TaskModem.h b/src/TaskModem.h index 7d324fd..890b3c7 100644 --- a/src/TaskModem.h +++ b/src/TaskModem.h @@ -10,8 +10,8 @@ public: explicit ModemTask(TaskQueue> &fromModem); virtual ~ModemTask(); - virtual bool setup(std::shared_ptr system) override; - virtual bool loop(std::shared_ptr system) override; + virtual bool setup(System &system) override; + virtual bool loop(System &system) override; private: std::shared_ptr _lora_aprs; diff --git a/src/TaskNTP.cpp b/src/TaskNTP.cpp index 8bac58f..ada8c02 100644 --- a/src/TaskNTP.cpp +++ b/src/TaskNTP.cpp @@ -11,13 +11,13 @@ NTPTask::NTPTask() : Task(TASK_NTP, TaskNtp), _beginCalled(false) { NTPTask::~NTPTask() { } -bool NTPTask::setup(std::shared_ptr system) { - _ntpClient = std::shared_ptr(new NTPClient(system->getUserConfig()->ntpServer.c_str())); +bool NTPTask::setup(System &system) { + _ntpClient = std::shared_ptr(new NTPClient(system.getUserConfig()->ntpServer.c_str())); return true; } -bool NTPTask::loop(std::shared_ptr system) { - if (!system->isWifiEthConnected()) { +bool NTPTask::loop(System &system) { + if (!system.isWifiEthConnected()) { return false; } if (!_beginCalled) { diff --git a/src/TaskNTP.h b/src/TaskNTP.h index a18103e..d7e53bc 100644 --- a/src/TaskNTP.h +++ b/src/TaskNTP.h @@ -9,8 +9,8 @@ public: NTPTask(); virtual ~NTPTask(); - virtual bool setup(std::shared_ptr system) override; - virtual bool loop(std::shared_ptr system) override; + virtual bool setup(System &system) override; + virtual bool loop(System &system) override; private: std::shared_ptr _ntpClient; diff --git a/src/TaskOTA.cpp b/src/TaskOTA.cpp index 45ba900..86b0365 100644 --- a/src/TaskOTA.cpp +++ b/src/TaskOTA.cpp @@ -10,7 +10,7 @@ OTATask::OTATask() : Task(TASK_OTA, TaskOta), _beginCalled(false) { OTATask::~OTATask() { } -bool OTATask::setup(std::shared_ptr system) { +bool OTATask::setup(System &system) { _ota = std::shared_ptr(new ArduinoOTAClass()); _ota->onStart([&]() { String type; @@ -44,12 +44,12 @@ bool OTATask::setup(std::shared_ptr system) { else if (error == OTA_END_ERROR) logPrintlnE("End Failed"); }); - _ota->setHostname(system->getUserConfig()->callsign.c_str()); + _ota->setHostname(system.getUserConfig()->callsign.c_str()); _stateInfo = ""; return true; } -bool OTATask::loop(std::shared_ptr system) { +bool OTATask::loop(System &system) { if (!_beginCalled) { _ota->begin(); _beginCalled = true; diff --git a/src/TaskOTA.h b/src/TaskOTA.h index ab781d8..546b4eb 100644 --- a/src/TaskOTA.h +++ b/src/TaskOTA.h @@ -9,8 +9,8 @@ public: OTATask(); virtual ~OTATask(); - virtual bool setup(std::shared_ptr system) override; - virtual bool loop(std::shared_ptr system) override; + virtual bool setup(System &system) override; + virtual bool loop(System &system) override; private: std::shared_ptr _ota; diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index 1bcf7b8..68a2b8a 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -13,20 +13,20 @@ RouterTask::RouterTask(TaskQueue> &fromModem, TaskQ RouterTask::~RouterTask() { } -bool RouterTask::setup(std::shared_ptr system) { +bool RouterTask::setup(System &system) { // setup beacon - _beacon_timer.setTimeout(system->getUserConfig()->beacon.timeout * 60 * 1000); + _beacon_timer.setTimeout(system.getUserConfig()->beacon.timeout * 60 * 1000); _beaconMsg = std::shared_ptr(new APRSMessage()); - _beaconMsg->setSource(system->getUserConfig()->callsign); + _beaconMsg->setSource(system.getUserConfig()->callsign); _beaconMsg->setDestination("APLG01"); - String lat = create_lat_aprs(system->getUserConfig()->beacon.positionLatitude); - String lng = create_long_aprs(system->getUserConfig()->beacon.positionLongitude); - _beaconMsg->getBody()->setData(String("=") + lat + "L" + lng + "&" + system->getUserConfig()->beacon.message); + String lat = create_lat_aprs(system.getUserConfig()->beacon.positionLatitude); + String lng = create_long_aprs(system.getUserConfig()->beacon.positionLongitude); + _beaconMsg->getBody()->setData(String("=") + lat + "L" + lng + "&" + system.getUserConfig()->beacon.message); return true; } -bool RouterTask::loop(std::shared_ptr system) { +bool RouterTask::loop(System &system) { // do routing if (!_fromModem.empty()) { _toAprsIs.addElement(_fromModem.getElement()); @@ -37,7 +37,7 @@ bool RouterTask::loop(std::shared_ptr system) { logPrintD("[" + timeString() + "] "); logPrintlnD(_beaconMsg->encode()); _toAprsIs.addElement(_beaconMsg); - system->getDisplay().addFrame(std::shared_ptr(new TextFrame("BEACON", _beaconMsg->toString()))); + system.getDisplay().addFrame(std::shared_ptr(new TextFrame("BEACON", _beaconMsg->toString()))); _beacon_timer.start(); } time_t diff = _beacon_timer.getTriggerTimeInSec(); diff --git a/src/TaskRouter.h b/src/TaskRouter.h index 0ed8092..b6e4289 100644 --- a/src/TaskRouter.h +++ b/src/TaskRouter.h @@ -9,8 +9,8 @@ public: RouterTask(TaskQueue> &fromModem, TaskQueue> &toAprsIs); virtual ~RouterTask(); - virtual bool setup(std::shared_ptr system) override; - virtual bool loop(std::shared_ptr system) override; + virtual bool setup(System &system) override; + virtual bool loop(System &system) override; private: TaskQueue> &_fromModem; diff --git a/src/TaskWifi.cpp b/src/TaskWifi.cpp index db0cce9..8fa528e 100644 --- a/src/TaskWifi.cpp +++ b/src/TaskWifi.cpp @@ -11,12 +11,12 @@ WifiTask::WifiTask() : Task(TASK_WIFI, TaskWifi), _oldWifiStatus(WL_IDLE_STATUS) WifiTask::~WifiTask() { } -bool WifiTask::setup(std::shared_ptr system) { +bool WifiTask::setup(System &system) { // WiFi.onEvent(WiFiEvent); - WiFi.setHostname(system->getUserConfig()->callsign.c_str()); + WiFi.setHostname(system.getUserConfig()->callsign.c_str()); _wiFiMulti = std::shared_ptr(new WiFiMulti()); ; - for (Configuration::Wifi::AP ap : system->getUserConfig()->wifi.APs) { + for (Configuration::Wifi::AP ap : system.getUserConfig()->wifi.APs) { logPrintD("Looking for AP: "); logPrintlnD(ap.SSID); _wiFiMulti->addAP(ap.SSID.c_str(), ap.password.c_str()); @@ -24,10 +24,10 @@ bool WifiTask::setup(std::shared_ptr system) { return true; } -bool WifiTask::loop(std::shared_ptr system) { +bool WifiTask::loop(System &system) { const uint8_t wifi_status = _wiFiMulti->run(); if (wifi_status != WL_CONNECTED) { - system->connectedViaWifiEth(false); + system.connectedViaWifiEth(false); logPrintlnE("WiFi not connected!"); _oldWifiStatus = wifi_status; _stateInfo = "WiFi not connected"; @@ -39,7 +39,7 @@ bool WifiTask::loop(std::shared_ptr system) { _oldWifiStatus = wifi_status; return false; } - system->connectedViaWifiEth(true); + system.connectedViaWifiEth(true); _stateInfo = WiFi.localIP().toString(); _state = Okay; return true; diff --git a/src/TaskWifi.h b/src/TaskWifi.h index b6758e2..8d6d92d 100644 --- a/src/TaskWifi.h +++ b/src/TaskWifi.h @@ -9,8 +9,8 @@ public: WifiTask(); virtual ~WifiTask(); - virtual bool setup(std::shared_ptr system) override; - virtual bool loop(std::shared_ptr system) override; + virtual bool setup(System &system) override; + virtual bool loop(System &system) override; private: std::shared_ptr _wiFiMulti; diff --git a/src/project_configuration.cpp b/src/project_configuration.cpp index 57a23c7..1a68b74 100644 --- a/src/project_configuration.cpp +++ b/src/project_configuration.cpp @@ -4,96 +4,93 @@ #include "project_configuration.h" -std::shared_ptr ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocument &data) { - std::shared_ptr conf = std::shared_ptr(new Configuration); +void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocument &data, Configuration &conf) { if (data.containsKey("callsign")) - conf->callsign = data["callsign"].as(); + conf.callsign = data["callsign"].as(); JsonArray aps = data["wifi"]["AP"].as(); for (JsonVariant v : aps) { Configuration::Wifi::AP ap; ap.SSID = v["SSID"].as(); ap.password = v["password"].as(); - conf->wifi.APs.push_back(ap); + conf.wifi.APs.push_back(ap); } if (data.containsKey("beacon") && data["beacon"].containsKey("message")) - conf->beacon.message = data["beacon"]["message"].as(); - conf->beacon.positionLatitude = data["beacon"]["position"]["latitude"] | 0.0; - conf->beacon.positionLongitude = data["beacon"]["position"]["longitude"] | 0.0; - conf->beacon.timeout = data["beacon"]["timeout"] | 15; + conf.beacon.message = data["beacon"]["message"].as(); + conf.beacon.positionLatitude = data["beacon"]["position"]["latitude"] | 0.0; + conf.beacon.positionLongitude = data["beacon"]["position"]["longitude"] | 0.0; + conf.beacon.timeout = data["beacon"]["timeout"] | 15; if (data.containsKey("aprs_is") && data["aprs_is"].containsKey("passcode")) - conf->aprs_is.passcode = data["aprs_is"]["passcode"].as(); + conf.aprs_is.passcode = data["aprs_is"]["passcode"].as(); if (data.containsKey("aprs_is") && data["aprs_is"].containsKey("server")) - conf->aprs_is.server = data["aprs_is"]["server"].as(); - conf->aprs_is.port = data["aprs_is"]["port"] | 14580; + conf.aprs_is.server = data["aprs_is"]["server"].as(); + conf.aprs_is.port = data["aprs_is"]["port"] | 14580; - conf->lora.frequencyRx = data["lora"]["frequency_rx"] | 433775000; - conf->lora.frequencyTx = data["lora"]["frequency_tx"] | 433775000; - conf->lora.power = data["lora"]["power"] | 20; - conf->lora.spreadingFactor = data["lora"]["spreading_factor"] | 12; - conf->lora.signalBandwidth = data["lora"]["signal_bandwidth"] | 125000; - conf->lora.codingRate4 = data["lora"]["coding_rate4"] | 5; - conf->display.alwaysOn = data["display"]["always_on"] | true; - conf->display.timeout = data["display"]["timeout"] | 10; - conf->display.overwritePin = data["display"]["overwrite_pin"] | 0; - conf->display.turn180 = data["display"]["turn180"] | true; + conf.lora.frequencyRx = data["lora"]["frequency_rx"] | 433775000; + conf.lora.frequencyTx = data["lora"]["frequency_tx"] | 433775000; + conf.lora.power = data["lora"]["power"] | 20; + conf.lora.spreadingFactor = data["lora"]["spreading_factor"] | 12; + conf.lora.signalBandwidth = data["lora"]["signal_bandwidth"] | 125000; + conf.lora.codingRate4 = data["lora"]["coding_rate4"] | 5; + conf.display.alwaysOn = data["display"]["always_on"] | true; + conf.display.timeout = data["display"]["timeout"] | 10; + conf.display.overwritePin = data["display"]["overwrite_pin"] | 0; + conf.display.turn180 = data["display"]["turn180"] | true; - conf->ftp.active = data["ftp"]["active"] | false; - JsonArray users = data["ftp"]["user"].as(); + conf.ftp.active = data["ftp"]["active"] | false; + JsonArray users = data["ftp"]["user"].as(); for (JsonVariant u : users) { Configuration::Ftp::User us; us.name = u["name"].as(); us.password = u["password"].as(); - conf->ftp.users.push_back(us); + conf.ftp.users.push_back(us); } - if (conf->ftp.users.empty()) { + if (conf.ftp.users.empty()) { Configuration::Ftp::User us; us.name = "ftp"; us.password = "ftp"; - conf->ftp.users.push_back(us); + conf.ftp.users.push_back(us); } if (data.containsKey("ntp_server")) - conf->ntpServer = data["ntp_server"].as(); + conf.ntpServer = data["ntp_server"].as(); if (data.containsKey("board")) - conf->board = data["board"].as(); - - return conf; + conf.board = data["board"].as(); } -void ProjectConfigurationManagement::writeProjectConfiguration(std::shared_ptr conf, DynamicJsonDocument &data) { - data["callsign"] = conf->callsign; +void ProjectConfigurationManagement::writeProjectConfiguration(Configuration &conf, DynamicJsonDocument &data) { + data["callsign"] = conf.callsign; JsonArray aps = data["wifi"].createNestedArray("AP"); - for (Configuration::Wifi::AP ap : conf->wifi.APs) { + for (Configuration::Wifi::AP ap : conf.wifi.APs) { JsonObject v = aps.createNestedObject(); v["SSID"] = ap.SSID; v["password"] = ap.password; } - data["beacon"]["message"] = conf->beacon.message; - data["beacon"]["position"]["latitude"] = conf->beacon.positionLatitude; - data["beacon"]["position"]["longitude"] = conf->beacon.positionLongitude; - data["beacon"]["timeout"] = conf->beacon.timeout; - data["aprs_is"]["passcode"] = conf->aprs_is.passcode; - data["aprs_is"]["server"] = conf->aprs_is.server; - data["aprs_is"]["port"] = conf->aprs_is.port; - data["lora"]["frequency_rx"] = conf->lora.frequencyRx; - data["lora"]["frequency_tx"] = conf->lora.frequencyTx; - data["lora"]["power"] = conf->lora.power; - data["lora"]["spreading_factor"] = conf->lora.spreadingFactor; - data["lora"]["signal_bandwidth"] = conf->lora.signalBandwidth; - data["lora"]["coding_rate4"] = conf->lora.codingRate4; - data["display"]["always_on"] = conf->display.alwaysOn; - data["display"]["timeout"] = conf->display.timeout; - data["display"]["overwrite_pin"] = conf->display.overwritePin; - data["display"]["turn180"] = conf->display.turn180; - data["ftp"]["active"] = conf->ftp.active; + data["beacon"]["message"] = conf.beacon.message; + data["beacon"]["position"]["latitude"] = conf.beacon.positionLatitude; + data["beacon"]["position"]["longitude"] = conf.beacon.positionLongitude; + data["beacon"]["timeout"] = conf.beacon.timeout; + data["aprs_is"]["passcode"] = conf.aprs_is.passcode; + data["aprs_is"]["server"] = conf.aprs_is.server; + data["aprs_is"]["port"] = conf.aprs_is.port; + data["lora"]["frequency_rx"] = conf.lora.frequencyRx; + data["lora"]["frequency_tx"] = conf.lora.frequencyTx; + data["lora"]["power"] = conf.lora.power; + data["lora"]["spreading_factor"] = conf.lora.spreadingFactor; + data["lora"]["signal_bandwidth"] = conf.lora.signalBandwidth; + data["lora"]["coding_rate4"] = conf.lora.codingRate4; + data["display"]["always_on"] = conf.display.alwaysOn; + data["display"]["timeout"] = conf.display.timeout; + data["display"]["overwrite_pin"] = conf.display.overwritePin; + data["display"]["turn180"] = conf.display.turn180; + data["ftp"]["active"] = conf.ftp.active; JsonArray users = data["ftp"].createNestedArray("user"); - for (Configuration::Ftp::User u : conf->ftp.users) { + for (Configuration::Ftp::User u : conf.ftp.users) { JsonObject v = users.createNestedObject(); v["name"] = u.name; v["password"] = u.password; } - data["ntp_server"] = conf->ntpServer; + data["ntp_server"] = conf.ntpServer; - data["board"] = conf->board; + data["board"] = conf.board; } diff --git a/src/project_configuration.h b/src/project_configuration.h index 00ebefa..9399386 100644 --- a/src/project_configuration.h +++ b/src/project_configuration.h @@ -101,8 +101,8 @@ public: } private: - virtual std::shared_ptr readProjectConfiguration(DynamicJsonDocument &data) override; - virtual void writeProjectConfiguration(std::shared_ptr conf, DynamicJsonDocument &data) override; + virtual void readProjectConfiguration(DynamicJsonDocument &data, Configuration &conf) override; + virtual void writeProjectConfiguration(Configuration &conf, DynamicJsonDocument &data) override; }; std::shared_ptr load_config(std::shared_ptr boardConfig); From 1d06f340a35422676de23ac4be26c343dbe397e5 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 19 May 2021 00:50:54 +0200 Subject: [PATCH 28/75] remove old function --- src/project_configuration.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/project_configuration.h b/src/project_configuration.h index 9399386..90af324 100644 --- a/src/project_configuration.h +++ b/src/project_configuration.h @@ -105,6 +105,4 @@ private: virtual void writeProjectConfiguration(Configuration &conf, DynamicJsonDocument &data) override; }; -std::shared_ptr load_config(std::shared_ptr boardConfig); - #endif From d45423ae17d222ccf96214ff8289bd9065860851 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 19 May 2021 00:51:05 +0200 Subject: [PATCH 29/75] remove smart pointer --- src/LoRa_APRS_iGate.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 7d73a04..482cf83 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -71,15 +71,15 @@ void setup() { if (boardConfig->Type == eTTGO_T_Beam_V1_0) { Wire.begin(boardConfig->OledSda, boardConfig->OledScl); - std::shared_ptr powerManagement = std::shared_ptr(new PowerManagement); - if (!powerManagement->begin(Wire)) { + PowerManagement powerManagement; + if (!powerManagement.begin(Wire)) { logPrintlnI("AXP192 init done!"); } else { logPrintlnE("AXP192 init failed!"); } - powerManagement->activateLoRa(); - powerManagement->activateOLED(); - powerManagement->deactivateGPS(); + powerManagement.activateLoRa(); + powerManagement.activateOLED(); + powerManagement.deactivateGPS(); } LoRaSystem.setBoardConfig(boardConfig); From 1f7f56ecfae7e32faf7cafb15dcf20c728e412d5 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 19 May 2021 01:01:10 +0200 Subject: [PATCH 30/75] remove smart pointer from Tasks --- lib/System/TaskManager.cpp | 18 +++++++++--------- lib/System/TaskManager.h | 18 +++++++++--------- src/LoRa_APRS_iGate.cpp | 32 +++++++++++++++++++++----------- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/lib/System/TaskManager.cpp b/lib/System/TaskManager.cpp index e2741c2..9cf7e33 100644 --- a/lib/System/TaskManager.cpp +++ b/lib/System/TaskManager.cpp @@ -5,16 +5,16 @@ TaskManager::TaskManager() { } -void TaskManager::addTask(std::shared_ptr task) { +void TaskManager::addTask(Task *task) { _tasks.push_back(task); } -void TaskManager::addAlwaysRunTask(std::shared_ptr task) { +void TaskManager::addAlwaysRunTask(Task *task) { _alwaysRunTasks.push_back(task); } -std::shared_ptr TaskManager::getTask(const char *name) { - std::_List_iterator> elem = std::find_if(_tasks.begin(), _tasks.end(), [&](std::shared_ptr task) { +Task *TaskManager::getTask(const char *name) { + std::_List_iterator elem = std::find_if(_tasks.begin(), _tasks.end(), [&](Task *task) { return task->getName() == name; }); if (elem == _tasks.end()) { @@ -23,18 +23,18 @@ std::shared_ptr TaskManager::getTask(const char *name) { return *elem; } -std::list> TaskManager::getTasks() { +std::list TaskManager::getTasks() { return _tasks; } bool TaskManager::setup(System &system) { logPrintlnV("will setup all tasks..."); - for (std::shared_ptr &elem : _alwaysRunTasks) { + for (Task *elem : _alwaysRunTasks) { logPrintD("call setup from "); logPrintlnD(elem->getName()); elem->setup(system); } - for (std::shared_ptr &elem : _tasks) { + for (Task *elem : _tasks) { logPrintD("call setup from "); logPrintlnD(elem->getName()); elem->setup(system); @@ -45,7 +45,7 @@ bool TaskManager::setup(System &system) { bool TaskManager::loop(System &system) { // logPrintlnD("will loop all tasks..."); - for (std::shared_ptr &elem : _alwaysRunTasks) { + for (Task *elem : _alwaysRunTasks) { // logPrintD("call loop from "); // logPrintlnD(elem->getName()); elem->loop(system); @@ -61,7 +61,7 @@ bool TaskManager::loop(System &system) { void StatusFrame::drawStatusPage(Bitmap &bitmap) { int y = 0; - for (std::shared_ptr task : _tasks) { + for (Task *task : _tasks) { int x = bitmap.drawString(0, y, (task->getName()).substring(0, task->getName().indexOf("Task"))); x = bitmap.drawString(x, y, ": "); if (task->getStateInfo() == "") { diff --git a/lib/System/TaskManager.h b/lib/System/TaskManager.h index ffb7ff6..8a7ad3b 100644 --- a/lib/System/TaskManager.h +++ b/lib/System/TaskManager.h @@ -61,30 +61,30 @@ public: ~TaskManager() { } - void addTask(std::shared_ptr task); - void addAlwaysRunTask(std::shared_ptr task); - std::shared_ptr getTask(const char *name); - std::list> getTasks(); + void addTask(Task *task); + void addAlwaysRunTask(Task *task); + Task * getTask(const char *name); + std::list getTasks(); bool setup(System &system); bool loop(System &system); private: - std::list> _tasks; - std::list>::iterator _nextTask; - std::list> _alwaysRunTasks; + std::list _tasks; + std::list::iterator _nextTask; + std::list _alwaysRunTasks; }; class StatusFrame : public DisplayFrame { public: - explicit StatusFrame(const std::list> &tasks) : _tasks(tasks) { + explicit StatusFrame(const std::list &tasks) : _tasks(tasks) { } virtual ~StatusFrame() { } void drawStatusPage(Bitmap &bitmap) override; private: - std::list> _tasks; + std::list _tasks; }; #include "System.h" diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 482cf83..f1902dc 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -24,11 +24,21 @@ String create_lat_aprs(double lat); String create_long_aprs(double lng); -System LoRaSystem; - TaskQueue> toAprsIs; TaskQueue> fromModem; +System LoRaSystem; + +DisplayTask displayTask; +ModemTask modemTask(fromModem); +EthTask ethTask; +WifiTask wifiTask; +OTATask otaTask; +NTPTask ntpTask; +FTPTask ftpTask; +AprsIsTask aprsIsTask(toAprsIs); +RouterTask routerTask(fromModem, toAprsIs); + // cppcheck-suppress unusedFunction void setup() { Serial.begin(115200); @@ -84,20 +94,20 @@ void setup() { LoRaSystem.setBoardConfig(boardConfig); LoRaSystem.setUserConfig(&userConfig); - LoRaSystem.getTaskManager().addTask(std::shared_ptr(new DisplayTask())); - LoRaSystem.getTaskManager().addTask(std::shared_ptr(new ModemTask(fromModem))); + LoRaSystem.getTaskManager().addTask(&displayTask); + LoRaSystem.getTaskManager().addTask(&modemTask); if (boardConfig->Type == eETH_BOARD) { - LoRaSystem.getTaskManager().addAlwaysRunTask(std::shared_ptr(new EthTask())); + LoRaSystem.getTaskManager().addAlwaysRunTask(ðTask); } else { - LoRaSystem.getTaskManager().addAlwaysRunTask(std::shared_ptr(new WifiTask())); + LoRaSystem.getTaskManager().addAlwaysRunTask(&wifiTask); } - LoRaSystem.getTaskManager().addTask(std::shared_ptr(new OTATask())); - LoRaSystem.getTaskManager().addTask(std::shared_ptr(new NTPTask())); + LoRaSystem.getTaskManager().addTask(&otaTask); + LoRaSystem.getTaskManager().addTask(&ntpTask); if (userConfig.ftp.active) { - LoRaSystem.getTaskManager().addTask(std::shared_ptr(new FTPTask())); + LoRaSystem.getTaskManager().addTask(&ftpTask); } - LoRaSystem.getTaskManager().addTask(std::shared_ptr(new AprsIsTask(toAprsIs))); - LoRaSystem.getTaskManager().addTask(std::shared_ptr(new RouterTask(fromModem, toAprsIs))); + LoRaSystem.getTaskManager().addTask(&aprsIsTask); + LoRaSystem.getTaskManager().addTask(&routerTask); LoRaSystem.getTaskManager().setup(LoRaSystem); From bfa7b5467d8645c11a4f614bdf0c0e5acdea261d Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 19 May 2021 01:03:35 +0200 Subject: [PATCH 31/75] remove smart pointer of ftp server --- src/TaskFTP.cpp | 13 ++++++------- src/TaskFTP.h | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/TaskFTP.cpp b/src/TaskFTP.cpp index 0f4a05d..d9615cf 100644 --- a/src/TaskFTP.cpp +++ b/src/TaskFTP.cpp @@ -13,30 +13,29 @@ FTPTask::~FTPTask() { } bool FTPTask::setup(System &system) { - _ftpServer = std::shared_ptr(new FTPServer()); for (Configuration::Ftp::User user : system.getUserConfig()->ftp.users) { logPrintD("Adding user to FTP Server: "); logPrintlnD(user.name); - _ftpServer->addUser(user.name, user.password); + _ftpServer.addUser(user.name, user.password); } - _ftpServer->addFilesystem("SPIFFS", &SPIFFS); + _ftpServer.addFilesystem("SPIFFS", &SPIFFS); _stateInfo = "waiting"; return true; } bool FTPTask::loop(System &system) { if (!_beginCalled) { - _ftpServer->begin(); + _ftpServer.begin(); _beginCalled = true; } - _ftpServer->handle(); + _ftpServer.handle(); 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..."); logPrintlnW(""); ESP.restart(); } - if (_ftpServer->countConnections() > 0) { + if (_ftpServer.countConnections() > 0) { configWasOpen = true; _stateInfo = "has connection"; } diff --git a/src/TaskFTP.h b/src/TaskFTP.h index 6d5bf2b..83c0ea7 100644 --- a/src/TaskFTP.h +++ b/src/TaskFTP.h @@ -13,8 +13,8 @@ public: virtual bool loop(System &system) override; private: - std::shared_ptr _ftpServer; - bool _beginCalled; + FTPServer _ftpServer; + bool _beginCalled; }; #endif From 7515db41a503d18af6a013f05c25b03873376238 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 19 May 2021 01:05:34 +0200 Subject: [PATCH 32/75] remove smart pointer from wifi --- src/TaskWifi.cpp | 6 ++---- src/TaskWifi.h | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/TaskWifi.cpp b/src/TaskWifi.cpp index 8fa528e..3c9365f 100644 --- a/src/TaskWifi.cpp +++ b/src/TaskWifi.cpp @@ -14,18 +14,16 @@ WifiTask::~WifiTask() { bool WifiTask::setup(System &system) { // WiFi.onEvent(WiFiEvent); WiFi.setHostname(system.getUserConfig()->callsign.c_str()); - _wiFiMulti = std::shared_ptr(new WiFiMulti()); - ; for (Configuration::Wifi::AP ap : system.getUserConfig()->wifi.APs) { logPrintD("Looking for AP: "); 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; } bool WifiTask::loop(System &system) { - const uint8_t wifi_status = _wiFiMulti->run(); + const uint8_t wifi_status = _wiFiMulti.run(); if (wifi_status != WL_CONNECTED) { system.connectedViaWifiEth(false); logPrintlnE("WiFi not connected!"); diff --git a/src/TaskWifi.h b/src/TaskWifi.h index 8d6d92d..8196629 100644 --- a/src/TaskWifi.h +++ b/src/TaskWifi.h @@ -13,8 +13,8 @@ public: virtual bool loop(System &system) override; private: - std::shared_ptr _wiFiMulti; - uint8_t _oldWifiStatus; + WiFiMulti _wiFiMulti; + uint8_t _oldWifiStatus; }; #endif From 1ba1bbc9e38d06763f3c114d123eaa0ec2a9525d Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 19 May 2021 01:08:37 +0200 Subject: [PATCH 33/75] remove smart pointer from NTP --- src/TaskNTP.cpp | 12 ++++++------ src/TaskNTP.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/TaskNTP.cpp b/src/TaskNTP.cpp index ada8c02..3e03f5b 100644 --- a/src/TaskNTP.cpp +++ b/src/TaskNTP.cpp @@ -12,7 +12,7 @@ NTPTask::~NTPTask() { } bool NTPTask::setup(System &system) { - _ntpClient = std::shared_ptr(new NTPClient(system.getUserConfig()->ntpServer.c_str())); + _ntpClient.setPoolServerName(system.getUserConfig()->ntpServer.c_str()); return true; } @@ -21,15 +21,15 @@ bool NTPTask::loop(System &system) { return false; } if (!_beginCalled) { - _ntpClient->begin(); + _ntpClient.begin(); _beginCalled = true; } - if (_ntpClient->update()) { - setTime(_ntpClient->getEpochTime()); + if (_ntpClient.update()) { + setTime(_ntpClient.getEpochTime()); logPrintI("Current time: "); - logPrintlnI(_ntpClient->getFormattedTime()); + logPrintlnI(_ntpClient.getFormattedTime()); } - _stateInfo = _ntpClient->getFormattedTime(); + _stateInfo = _ntpClient.getFormattedTime(); _state = Okay; return true; } diff --git a/src/TaskNTP.h b/src/TaskNTP.h index d7e53bc..3eab8e3 100644 --- a/src/TaskNTP.h +++ b/src/TaskNTP.h @@ -13,8 +13,8 @@ public: virtual bool loop(System &system) override; private: - std::shared_ptr _ntpClient; - bool _beginCalled; + NTPClient _ntpClient; + bool _beginCalled; }; #endif From f4bc68e7105bd66f679fec79b96e1444f88cf9c4 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 19 May 2021 01:17:23 +0200 Subject: [PATCH 34/75] cleanup TimeLib --- lib/Display/Display.h | 1 - lib/System/Timer.cpp | 4 +++- lib/System/Timer.h | 6 ++---- src/LoRa_APRS_iGate.cpp | 1 - src/TaskAprsIs.cpp | 1 - src/TaskDisplay.cpp | 1 - src/TaskModem.cpp | 3 ++- src/TaskNTP.cpp | 3 ++- src/TaskRouter.cpp | 6 ++++-- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/Display/Display.h b/lib/Display/Display.h index 4ff69ff..cda71ac 100644 --- a/lib/Display/Display.h +++ b/lib/Display/Display.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/System/Timer.cpp b/lib/System/Timer.cpp index c22e34a..ebd17f6 100644 --- a/lib/System/Timer.cpp +++ b/lib/System/Timer.cpp @@ -1,3 +1,5 @@ +#include + #include "Timer.h" Timer::Timer() : _timeout_ms(0), _nextTimeout(0) { @@ -7,7 +9,7 @@ void Timer::setTimeout(const uint32_t timeout_ms) { _timeout_ms = timeout_ms; } -time_t Timer::getTriggerTimeInSec() const { +uint32_t Timer::getTriggerTimeInSec() const { return (_nextTimeout - millis()) / 1000; } diff --git a/lib/System/Timer.h b/lib/System/Timer.h index 239f995..4e3eee5 100644 --- a/lib/System/Timer.h +++ b/lib/System/Timer.h @@ -1,14 +1,12 @@ #ifndef TIMER_H_ #define TIMER_H_ -#include - class Timer { public: Timer(); - void setTimeout(const uint32_t timeout_ms); - time_t getTriggerTimeInSec() const; + void setTimeout(const uint32_t timeout_ms); + uint32_t getTriggerTimeInSec() const; bool isActive() const; diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index f1902dc..f17a5b4 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include diff --git a/src/TaskAprsIs.cpp b/src/TaskAprsIs.cpp index af69735..43526fe 100644 --- a/src/TaskAprsIs.cpp +++ b/src/TaskAprsIs.cpp @@ -1,4 +1,3 @@ -#include #include #include "Task.h" diff --git a/src/TaskDisplay.cpp b/src/TaskDisplay.cpp index 1f5fc00..bfe6d0b 100644 --- a/src/TaskDisplay.cpp +++ b/src/TaskDisplay.cpp @@ -1,4 +1,3 @@ -#include #include #include "TaskDisplay.h" diff --git a/src/TaskModem.cpp b/src/TaskModem.cpp index deac31c..3a1d233 100644 --- a/src/TaskModem.cpp +++ b/src/TaskModem.cpp @@ -1,6 +1,7 @@ -#include #include +#include + #include "Task.h" #include "TaskAprsIs.h" #include "TaskModem.h" diff --git a/src/TaskNTP.cpp b/src/TaskNTP.cpp index 3e03f5b..14b3808 100644 --- a/src/TaskNTP.cpp +++ b/src/TaskNTP.cpp @@ -1,6 +1,7 @@ -#include #include +#include + #include "Task.h" #include "TaskNTP.h" #include "project_configuration.h" diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index 68a2b8a..249c5a0 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -1,5 +1,7 @@ #include +#include + #include "Task.h" #include "TaskRouter.h" #include "project_configuration.h" @@ -40,7 +42,7 @@ bool RouterTask::loop(System &system) { system.getDisplay().addFrame(std::shared_ptr(new TextFrame("BEACON", _beaconMsg->toString()))); _beacon_timer.start(); } - time_t diff = _beacon_timer.getTriggerTimeInSec(); - _stateInfo = "beacon " + String(diff / 60) + ":" + String(diff % 60); + uint32_t diff = _beacon_timer.getTriggerTimeInSec(); + _stateInfo = "beacon " + String(uint32_t(diff / 60)) + ":" + String(uint32_t(diff % 60)); return true; } From 6ab6da3a8a018fa6b47aedf2e93a859003f11f8f Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 19 May 2021 01:29:08 +0200 Subject: [PATCH 35/75] fixing possible memory issue --- src/LoRa_APRS_iGate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index f17a5b4..9d99d09 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -26,7 +26,8 @@ String create_long_aprs(double lng); TaskQueue> toAprsIs; TaskQueue> fromModem; -System LoRaSystem; +System LoRaSystem; +Configuration userConfig; DisplayTask displayTask; ModemTask modemTask(fromModem); @@ -57,7 +58,6 @@ void setup() { boardConfigs.push_back(&HELTEC_WIFI_LORA_32_V2); ProjectConfigurationManagement confmg; - Configuration userConfig; confmg.readConfiguration(userConfig); BoardFinder finder(boardConfigs); From d96e6cebc106508ac584a7887cc0ef994212cb17 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Fri, 21 May 2021 22:22:50 +0200 Subject: [PATCH 36/75] remove smart pointer in Display --- lib/Display/Display.cpp | 10 +++++----- lib/Display/Display.h | 2 +- src/LoRa_APRS_iGate.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Display/Display.cpp b/lib/Display/Display.cpp index 865eb34..95766b5 100644 --- a/lib/Display/Display.cpp +++ b/lib/Display/Display.cpp @@ -18,7 +18,7 @@ void Display::setup(BoardConfig const *const boardConfig) { digitalWrite(boardConfig->OledReset, HIGH); } Wire.begin(boardConfig->OledSda, boardConfig->OledScl); - _disp = std::shared_ptr(new SSD1306(&Wire, boardConfig->OledAddr)); + _disp = new SSD1306(&Wire, boardConfig->OledAddr); Bitmap bitmap(_disp->getWidth(), _disp->getHeight()); _disp->display(&bitmap); @@ -47,7 +47,7 @@ void Display::update() { if (_frames.size() > 0) { std::shared_ptr frame = *_frames.begin(); - Bitmap bitmap(_disp.get()); + Bitmap bitmap(_disp); frame->drawStatusPage(bitmap); _disp->display(&bitmap); @@ -60,7 +60,7 @@ void Display::update() { } } else { if (_disp->isDisplayOn()) { - Bitmap bitmap(_disp.get()); + Bitmap bitmap(_disp); _statusFrame->drawStatusPage(bitmap); _disp->display(&bitmap); @@ -88,7 +88,7 @@ void Display::setStatusFrame(std::shared_ptr frame) { } void Display::showSpashScreen(String firmwareTitle, String version) { - Bitmap bitmap(_disp.get()); + Bitmap bitmap(_disp); bitmap.drawString(0, 10, firmwareTitle); bitmap.drawString(0, 20, version); bitmap.drawString(0, 35, "by Peter Buchegger"); @@ -97,7 +97,7 @@ void Display::showSpashScreen(String firmwareTitle, String version) { } void Display::showStatusScreen(String header, String text) { - Bitmap bitmap(_disp.get()); + Bitmap bitmap(_disp); bitmap.drawString(0, 0, header); bitmap.drawStringLF(0, 10, text); _disp->display(&bitmap); diff --git a/lib/Display/Display.h b/lib/Display/Display.h index cda71ac..045e898 100644 --- a/lib/Display/Display.h +++ b/lib/Display/Display.h @@ -42,7 +42,7 @@ public: void addFrame(std::shared_ptr frame); private: - std::shared_ptr _disp; + OLEDDisplay *_disp; Timer _displayFrameRate; std::shared_ptr _statusFrame; diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 9d99d09..e2ffaea 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -66,8 +66,8 @@ void setup() { boardConfig = finder.searchBoardConfig(); if (boardConfig == 0) { logPrintlnE("Board config not set and search failed!"); - while (true) { - } + while (true) + ; } userConfig.board = boardConfig->Name; confmg.writeConfiguration(userConfig); From b24f42d00affeff8f837d4eddf3fe90677458b4f Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Fri, 21 May 2021 22:41:30 +0200 Subject: [PATCH 37/75] remove smart pointer in APRS IS Task --- lib/APRS-IS/APRS-IS.cpp | 88 +++++++++++++++++++++++++++++++++++++++++ lib/APRS-IS/APRS-IS.h | 34 ++++++++++++++++ platformio.ini | 1 - src/TaskAprsIs.cpp | 11 +++--- src/TaskAprsIs.h | 2 +- 5 files changed, 128 insertions(+), 8 deletions(-) create mode 100644 lib/APRS-IS/APRS-IS.cpp create mode 100644 lib/APRS-IS/APRS-IS.h diff --git a/lib/APRS-IS/APRS-IS.cpp b/lib/APRS-IS/APRS-IS.cpp new file mode 100644 index 0000000..6988ac9 --- /dev/null +++ b/lib/APRS-IS/APRS-IS.cpp @@ -0,0 +1,88 @@ +#include "APRS-IS.h" +#include + +void APRS_IS::setup(const String &user, const String &passcode, const String &tool_name, const String &version) { + _user = user; + _passcode = passcode; + _tool_name = tool_name; + _version = version; +} + +bool APRS_IS::connect(const String &server, const int port) { + const String login = "user " + _user + " pass " + _passcode + " vers " + _tool_name + " " + _version + "\n\r"; + return _connect(server, port, login); +} + +bool 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"; + return _connect(server, port, login); +} + +bool APRS_IS::_connect(const String &server, const int port, const String &login_line) { + if (!_client.connect(server.c_str(), port)) { + logPrintlnE("Something went wrong on connecting! Is the server reachable?"); + return false; + } + sendMessage(login_line); + while (true) { + String line = _client.readStringUntil('\n'); + if (line.indexOf("logresp") != -1) { + if (line.indexOf("unverified") == -1) { + return true; + } else { + logPrintlnE("User can not be verified with passcode!"); + return false; + } + } + } + return true; +} + +bool APRS_IS::connected() { + return _client.connected(); +} + +bool APRS_IS::sendMessage(const String &message) { + if (!connected()) { + return false; + } + _client.println(message); + return true; +} + +bool APRS_IS::sendMessage(const std::shared_ptr message) { + if (!connected()) { + return false; + } + _client.println(message->encode() + "\n"); + return true; +} + +int APRS_IS::available() { + return _client.available(); +} + +String APRS_IS::getMessage() { + String line; + if (_client.available() > 0) { + line = _client.readStringUntil('\n'); + } + return line; +} + +std::shared_ptr APRS_IS::getAPRSMessage() { + String line; + if (_client.available() > 0) { + line = _client.readStringUntil('\n'); + } + if (line.startsWith("#")) { + logPrintlnD(line); + return 0; + } + if (line.length() == 0) { + return 0; + } + std::shared_ptr msg = std::shared_ptr(new APRSMessage()); + msg->decode(line); + return msg; +} diff --git a/lib/APRS-IS/APRS-IS.h b/lib/APRS-IS/APRS-IS.h new file mode 100644 index 0000000..00d27ca --- /dev/null +++ b/lib/APRS-IS/APRS-IS.h @@ -0,0 +1,34 @@ + +#ifndef APRS_IS_Lib_h_ +#define APRS_IS_Lib_h_ + +#include +#include + +class APRS_IS { +public: + void setup(const String &user, const String &passcode, const String &tool_name, const String &version); + + bool connect(const String &server, const int port); + bool connect(const String &server, const int port, const String &filter); + bool connected(); + + bool sendMessage(const String &message); + bool sendMessage(const std::shared_ptr message); + + int available(); + + String getMessage(); + std::shared_ptr getAPRSMessage(); + +private: + String _user; + String _passcode; + String _tool_name; + String _version; + WiFiClient _client; + + bool _connect(const String &server, const int port, const String &login_line); +}; + +#endif diff --git a/platformio.ini b/platformio.ini index f8d8be4..d553213 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,6 @@ lib_deps = bblanchon/ArduinoJson @ 6.17.0 lewisxhe/AXP202X_Library @ 1.1.2 peterus/APRS-Decoder-Lib @ 0.0.6 - peterus/APRS-IS-Lib @ 0.0.8 peterus/esp-logger @ 0.0.1 peterus/ESP-FTP-Server-Lib @ 0.9.5 check_tool = cppcheck diff --git a/src/TaskAprsIs.cpp b/src/TaskAprsIs.cpp index 43526fe..d2fe06d 100644 --- a/src/TaskAprsIs.cpp +++ b/src/TaskAprsIs.cpp @@ -11,8 +11,7 @@ AprsIsTask::~AprsIsTask() { } bool AprsIsTask::setup(System &system) { - _aprs_is = std::shared_ptr(new APRS_IS(system.getUserConfig()->callsign, system.getUserConfig()->aprs_is.passcode, "ESP32-APRS-IS", "0.2")); - + _aprs_is.setup(system.getUserConfig()->callsign, system.getUserConfig()->aprs_is.passcode, "ESP32-APRS-IS", "0.2"); return true; } @@ -20,7 +19,7 @@ bool AprsIsTask::loop(System &system) { if (!system.isWifiEthConnected()) { return false; } - if (!_aprs_is->connected()) { + if (!_aprs_is.connected()) { if (!connect(system)) { _stateInfo = "not connected"; _state = Error; @@ -31,11 +30,11 @@ bool AprsIsTask::loop(System &system) { return false; } - _aprs_is->getAPRSMessage(); + _aprs_is.getAPRSMessage(); if (!_toAprsIs.empty()) { std::shared_ptr msg = _toAprsIs.getElement(); - _aprs_is->sendMessage(msg); + _aprs_is.sendMessage(msg); } return true; @@ -46,7 +45,7 @@ bool AprsIsTask::connect(System &system) { logPrintI(system.getUserConfig()->aprs_is.server); logPrintI(" on port: "); logPrintlnI(String(system.getUserConfig()->aprs_is.port)); - if (!_aprs_is->connect(system.getUserConfig()->aprs_is.server, system.getUserConfig()->aprs_is.port)) { + if (!_aprs_is.connect(system.getUserConfig()->aprs_is.server, system.getUserConfig()->aprs_is.port)) { logPrintlnE("Connection failed."); return false; } diff --git a/src/TaskAprsIs.h b/src/TaskAprsIs.h index 2b1955a..30679db 100644 --- a/src/TaskAprsIs.h +++ b/src/TaskAprsIs.h @@ -15,7 +15,7 @@ public: virtual bool loop(System &system) override; private: - std::shared_ptr _aprs_is; + APRS_IS _aprs_is; TaskQueue> &_toAprsIs; From b16ea9dd81a18209d0327e23286d97768ab08dc3 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Fri, 21 May 2021 23:04:10 +0200 Subject: [PATCH 38/75] remove smart pointer from Modem --- lib/LoRa_APRS/LoRa_APRS.cpp | 5 ----- lib/LoRa_APRS/LoRa_APRS.h | 9 --------- src/TaskModem.cpp | 27 ++++++++++++++------------- src/TaskModem.h | 2 +- 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/lib/LoRa_APRS/LoRa_APRS.cpp b/lib/LoRa_APRS/LoRa_APRS.cpp index 6221f2b..1f8493f 100644 --- a/lib/LoRa_APRS/LoRa_APRS.cpp +++ b/lib/LoRa_APRS/LoRa_APRS.cpp @@ -1,10 +1,5 @@ #include "LoRa_APRS.h" -LoRa_APRS::LoRa_APRS(BoardConfig const *const boardConfig) : _LastReceivedMsg(0), _RxFrequency(LORA_RX_FREQUENCY), _TxFrequency(LORA_TX_FREQUENCY) { - SPI.begin(boardConfig->LoraSck, boardConfig->LoraMiso, boardConfig->LoraMosi, boardConfig->LoraCS); - setPins(boardConfig->LoraCS, boardConfig->LoraReset, boardConfig->LoraIRQ); -} - bool LoRa_APRS::checkMessage() { if (!parsePacket()) { return false; diff --git a/lib/LoRa_APRS/LoRa_APRS.h b/lib/LoRa_APRS/LoRa_APRS.h index e0b9b87..d9cb093 100644 --- a/lib/LoRa_APRS/LoRa_APRS.h +++ b/lib/LoRa_APRS/LoRa_APRS.h @@ -4,20 +4,11 @@ #include #include -#include #include #include -#define LORA_RX_FREQUENCY (433775000) -#define LORA_TX_FREQUENCY (433900000) -#define LORA_SPREADING_FACTOR (12) -#define LORA_SIGNAL_BANDWIDTH (125E3) -#define LORA_CODING_RATE4 (5) - class LoRa_APRS : public LoRaClass { public: - explicit LoRa_APRS(BoardConfig const *const boardConfig); - bool checkMessage(); std::shared_ptr getMessage(); diff --git a/src/TaskModem.cpp b/src/TaskModem.cpp index 3a1d233..0414d05 100644 --- a/src/TaskModem.cpp +++ b/src/TaskModem.cpp @@ -14,37 +14,38 @@ ModemTask::~ModemTask() { } bool ModemTask::setup(System &system) { - _lora_aprs = std::shared_ptr(new LoRa_APRS(system.getBoardConfig())); - if (!_lora_aprs->begin(_lora_aprs->getRxFrequency())) { + 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)) { logPrintlnE("Starting LoRa failed!"); _stateInfo = "LoRa-Modem failed"; _state = Error; while (true) ; } - _lora_aprs->setRxFrequency(system.getUserConfig()->lora.frequencyRx); - _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(); + _lora_aprs.setRxFrequency(system.getUserConfig()->lora.frequencyRx); + _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(); + if (_lora_aprs.checkMessage()) { + std::shared_ptr msg = _lora_aprs.getMessage(); // msg->getAPRSBody()->setData(msg->getAPRSBody()->getData() + " 123"); logPrintD("[" + timeString() + "] "); logPrintD("Received packet '"); logPrintD(msg->toString()); logPrintD("' with RSSI "); - logPrintD(String(_lora_aprs->packetRssi())); + logPrintD(String(_lora_aprs.packetRssi())); logPrintD(" and SNR "); - logPrintlnD(String(_lora_aprs->packetSnr())); + logPrintlnD(String(_lora_aprs.packetSnr())); String path = msg->getPath(); if (path.indexOf("RFONLY") != -1 || path.indexOf("NOGATE") != -1 || path.indexOf("TCPIP") != -1) { diff --git a/src/TaskModem.h b/src/TaskModem.h index 890b3c7..a11dfd3 100644 --- a/src/TaskModem.h +++ b/src/TaskModem.h @@ -14,7 +14,7 @@ public: virtual bool loop(System &system) override; private: - std::shared_ptr _lora_aprs; + LoRa_APRS _lora_aprs; TaskQueue> &_fromModem; }; From 7a6473e30e8ad13b6739f53ce48e489d9a704797 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Fri, 21 May 2021 23:06:13 +0200 Subject: [PATCH 39/75] remove smart pointer from ota --- src/TaskOTA.cpp | 11 +++++------ src/TaskOTA.h | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/TaskOTA.cpp b/src/TaskOTA.cpp index 86b0365..6b6348c 100644 --- a/src/TaskOTA.cpp +++ b/src/TaskOTA.cpp @@ -11,10 +11,9 @@ OTATask::~OTATask() { } bool OTATask::setup(System &system) { - _ota = std::shared_ptr(new ArduinoOTAClass()); - _ota->onStart([&]() { + _ota.onStart([&]() { String type; - if (_ota->getCommand() == U_FLASH) + if (_ota.getCommand() == U_FLASH) type = "sketch"; else // U_SPIFFS type = "filesystem"; @@ -44,16 +43,16 @@ bool OTATask::setup(System &system) { else if (error == OTA_END_ERROR) logPrintlnE("End Failed"); }); - _ota->setHostname(system.getUserConfig()->callsign.c_str()); + _ota.setHostname(system.getUserConfig()->callsign.c_str()); _stateInfo = ""; return true; } bool OTATask::loop(System &system) { if (!_beginCalled) { - _ota->begin(); + _ota.begin(); _beginCalled = true; } - _ota->handle(); + _ota.handle(); return true; } diff --git a/src/TaskOTA.h b/src/TaskOTA.h index 546b4eb..1942d69 100644 --- a/src/TaskOTA.h +++ b/src/TaskOTA.h @@ -13,8 +13,8 @@ public: virtual bool loop(System &system) override; private: - std::shared_ptr _ota; - bool _beginCalled; + ArduinoOTAClass _ota; + bool _beginCalled; }; #endif From ed1a5d7ffec02d43b8b3c7ea7b129df5a31fbeb1 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Fri, 21 May 2021 23:28:50 +0200 Subject: [PATCH 40/75] cppcheck fix --- src/TaskAprsIs.cpp | 2 +- src/TaskAprsIs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TaskAprsIs.cpp b/src/TaskAprsIs.cpp index d2fe06d..b96b06e 100644 --- a/src/TaskAprsIs.cpp +++ b/src/TaskAprsIs.cpp @@ -40,7 +40,7 @@ bool AprsIsTask::loop(System &system) { return true; } -bool AprsIsTask::connect(System &system) { +bool AprsIsTask::connect(const System &system) { logPrintI("connecting to APRS-IS server: "); logPrintI(system.getUserConfig()->aprs_is.server); logPrintI(" on port: "); diff --git a/src/TaskAprsIs.h b/src/TaskAprsIs.h index 30679db..de75fec 100644 --- a/src/TaskAprsIs.h +++ b/src/TaskAprsIs.h @@ -19,7 +19,7 @@ private: TaskQueue> &_toAprsIs; - bool connect(System &system); + bool connect(const System &system); }; #endif From 134b566f984e754bff687b991eddcc406cae0c83 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Fri, 21 May 2021 23:44:18 +0200 Subject: [PATCH 41/75] espressif32 version bump --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index d553213..41331b1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -2,7 +2,7 @@ default_envs = lora_board [env] -platform = espressif32 @ 3.0.0 +platform = espressif32 @ 3.1.1 framework = arduino lib_ldf_mode = deep+ monitor_speed = 115200 From 619a1ea5bf1850b3c652230e07eb646ddf1006ee Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 23 May 2021 23:04:10 +0200 Subject: [PATCH 42/75] move some router stuff into the router class --- src/TaskModem.cpp | 10 ---------- src/TaskRouter.cpp | 12 +++++++++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/TaskModem.cpp b/src/TaskModem.cpp index 0414d05..336b06e 100644 --- a/src/TaskModem.cpp +++ b/src/TaskModem.cpp @@ -47,16 +47,6 @@ bool ModemTask::loop(System &system) { logPrintD(" and SNR "); logPrintlnD(String(_lora_aprs.packetSnr())); - String path = msg->getPath(); - if (path.indexOf("RFONLY") != -1 || path.indexOf("NOGATE") != -1 || path.indexOf("TCPIP") != -1) { - return true; - } - - if (!path.isEmpty()) { - path += ","; - } - msg->setPath(path + "qAR," + system.getUserConfig()->callsign); - _fromModem.addElement(msg); system.getDisplay().addFrame(std::shared_ptr(new TextFrame("LoRa", msg->toString()))); } diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index 249c5a0..73f5ba3 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -31,7 +31,17 @@ bool RouterTask::setup(System &system) { bool RouterTask::loop(System &system) { // do routing if (!_fromModem.empty()) { - _toAprsIs.addElement(_fromModem.getElement()); + std::shared_ptr msg = _fromModem.getElement(); + String path = msg->getPath(); + + if (!(path.indexOf("RFONLY") != -1 || path.indexOf("NOGATE") != -1 || path.indexOf("TCPIP") != -1)) { + if (!path.isEmpty()) { + path += ","; + } + msg->setPath(path + "qAR," + system.getUserConfig()->callsign); + + _toAprsIs.addElement(msg); + } } // check for beacon From acb3ec66d5a5efa877bcce396e233cc8d32706b4 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 23 May 2021 23:28:03 +0200 Subject: [PATCH 43/75] more debug for wifi --- src/TaskEth.cpp | 20 +++++++++++++++++++- src/TaskEth.h | 2 ++ src/TaskWifi.cpp | 3 ++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/TaskEth.cpp b/src/TaskEth.cpp index bfbab2e..55ee653 100644 --- a/src/TaskEth.cpp +++ b/src/TaskEth.cpp @@ -7,8 +7,26 @@ volatile bool eth_connected = false; -static void WiFiEvent(WiFiEvent_t event) { +void WiFiEvent(WiFiEvent_t event) { switch (event) { + case SYSTEM_EVENT_STA_START: + logPrintlnI("WiFi Started"); + break; + case SYSTEM_EVENT_STA_CONNECTED: + logPrintlnI("WiFi Connected"); + break; + case SYSTEM_EVENT_STA_GOT_IP: + logPrintI("WiFi MAC: "); + logPrintI(WiFi.macAddress()); + logPrintI(", IPv4: "); + logPrintlnI(WiFi.localIP().toString()); + break; + case SYSTEM_EVENT_STA_DISCONNECTED: + logPrintlnW("WiFi Disconnected"); + break; + case SYSTEM_EVENT_STA_STOP: + logPrintlnW("WiFi Stopped"); + break; case SYSTEM_EVENT_ETH_START: logPrintlnI("ETH Started"); ETH.setHostname("esp32-ethernet"); diff --git a/src/TaskEth.h b/src/TaskEth.h index e4baefe..4a63d3f 100644 --- a/src/TaskEth.h +++ b/src/TaskEth.h @@ -3,6 +3,8 @@ #include +void WiFiEvent(WiFiEvent_t event); + class EthTask : public Task { public: EthTask(); diff --git a/src/TaskWifi.cpp b/src/TaskWifi.cpp index 3c9365f..408a0fd 100644 --- a/src/TaskWifi.cpp +++ b/src/TaskWifi.cpp @@ -2,6 +2,7 @@ #include #include "Task.h" +#include "TaskEth.h" #include "TaskWifi.h" #include "project_configuration.h" @@ -12,7 +13,7 @@ WifiTask::~WifiTask() { } bool WifiTask::setup(System &system) { - // WiFi.onEvent(WiFiEvent); + WiFi.onEvent(WiFiEvent); WiFi.setHostname(system.getUserConfig()->callsign.c_str()); for (Configuration::Wifi::AP ap : system.getUserConfig()->wifi.APs) { logPrintD("Looking for AP: "); From e96c53359cebb274ee3c5c64f412d858fde335fc Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 23 May 2021 23:28:45 +0200 Subject: [PATCH 44/75] set core debug to verbose --- platformio.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 41331b1..d0aa3c4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -24,10 +24,10 @@ check_skip_packages = yes [env:lora_board] board = esp32doit-devkit-v1 -build_flags = -Werror -Wall +build_flags = -Werror -Wall -DCORE_DEBUG_LEVEL=5 [env:lora_board_debug] board = esp32doit-devkit-v1 -build_flags = -Werror -Wall +build_flags = -Werror -Wall -DCORE_DEBUG_LEVEL=5 build_type = debug monitor_filters = esp32_exception_decoder From 945a51ad5a318cb58e47cc2be49054c60c596564 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Mon, 24 May 2021 10:37:39 +0200 Subject: [PATCH 45/75] 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 e2ffaea..01d62ba 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -18,7 +18,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "21.14.0-dev" +#define VERSION "21.21.0-dev" String create_lat_aprs(double lat); String create_long_aprs(double lng); From d6083df1740d0827934075899f444af5a4d95eb3 Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Sun, 9 May 2021 14:21:24 +0200 Subject: [PATCH 46/75] Revert "remove digi" partly This reverts commit ed5e6a6ba9872da8af126d5b642bd6c5245e47cf. --- data/is-cfg.json | 5 +++++ src/project_configuration.cpp | 6 ++++++ src/project_configuration.h | 11 +++++++++++ 3 files changed, 22 insertions(+) diff --git a/data/is-cfg.json b/data/is-cfg.json index c84a3f5..df180eb 100644 --- a/data/is-cfg.json +++ b/data/is-cfg.json @@ -21,6 +21,11 @@ "server": "euro.aprs2.net", "port": 14580 }, + "digi": { + "active": false, + "forward_timeout": 5, + "beacon": true, + }, "lora": { "frequency_rx": 433775000, "frequency_tx": 433775000, diff --git a/src/project_configuration.cpp b/src/project_configuration.cpp index 1a68b74..3514a97 100644 --- a/src/project_configuration.cpp +++ b/src/project_configuration.cpp @@ -26,6 +26,9 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen conf.aprs_is.server = data["aprs_is"]["server"].as(); conf.aprs_is.port = data["aprs_is"]["port"] | 14580; + conf.digi.active = data["digi"]["active"] | false; + conf.digi.forwardTimeout = data["digi"]["forward_timeout"] | 5; + conf.digi.beacon = data["digi"]["beacon"] | true; conf.lora.frequencyRx = data["lora"]["frequency_rx"] | 433775000; conf.lora.frequencyTx = data["lora"]["frequency_tx"] | 433775000; conf.lora.power = data["lora"]["power"] | 20; @@ -73,6 +76,9 @@ void ProjectConfigurationManagement::writeProjectConfiguration(Configuration &co data["aprs_is"]["passcode"] = conf.aprs_is.passcode; data["aprs_is"]["server"] = conf.aprs_is.server; data["aprs_is"]["port"] = conf.aprs_is.port; + data["digi"]["active"] = conf.digi.active; + data["digi"]["forward_timeout"] = conf.digi.forwardTimeout; + data["digi"]["beacon"] = conf.digi.beacon; data["lora"]["frequency_rx"] = conf.lora.frequencyRx; data["lora"]["frequency_tx"] = conf.lora.frequencyTx; data["lora"]["power"] = conf.lora.power; diff --git a/src/project_configuration.h b/src/project_configuration.h index 90af324..e63e1f1 100644 --- a/src/project_configuration.h +++ b/src/project_configuration.h @@ -41,6 +41,16 @@ public: int port; }; + class Digi { + public: + Digi() : active(false), forwardTimeout(5), beacon(true) { + } + + bool active; + int forwardTimeout; + bool beacon; + }; + class LoRa { public: LoRa() : frequencyRx(433775000), frequencyTx(433775000), power(20), spreadingFactor(12), signalBandwidth(125000), codingRate4(5) { @@ -86,6 +96,7 @@ public: Wifi wifi; Beacon beacon; APRS_IS aprs_is; + Digi digi; LoRa lora; Display display; Ftp ftp; From 6eb82b78bf8d1c7ababa9b18e37be61c7e22deec Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Mon, 24 May 2021 14:22:16 +0200 Subject: [PATCH 47/75] make APRS-IS connection optional --- data/is-cfg.json | 1 + src/LoRa_APRS_iGate.cpp | 4 +++- src/TaskRouter.cpp | 11 +++++++++-- src/project_configuration.cpp | 2 ++ src/project_configuration.h | 3 ++- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/data/is-cfg.json b/data/is-cfg.json index df180eb..1a685b0 100644 --- a/data/is-cfg.json +++ b/data/is-cfg.json @@ -17,6 +17,7 @@ "timeout": 15 }, "aprs_is": { + "active": true, "passcode": "", "server": "euro.aprs2.net", "port": 14580 diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 01d62ba..36d254e 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -105,7 +105,9 @@ void setup() { if (userConfig.ftp.active) { LoRaSystem.getTaskManager().addTask(&ftpTask); } - LoRaSystem.getTaskManager().addTask(&aprsIsTask); + if (userConfig.aprs_is.active) { + LoRaSystem.getTaskManager().addTask(&aprsIsTask); + } LoRaSystem.getTaskManager().addTask(&routerTask); LoRaSystem.getTaskManager().setup(LoRaSystem); diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index 73f5ba3..9b4218d 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -40,7 +40,8 @@ bool RouterTask::loop(System &system) { } msg->setPath(path + "qAR," + system.getUserConfig()->callsign); - _toAprsIs.addElement(msg); + if (system.getUserConfig()->aprs_is.active) + _toAprsIs.addElement(msg); } } @@ -48,11 +49,17 @@ bool RouterTask::loop(System &system) { if (_beacon_timer.check()) { logPrintD("[" + timeString() + "] "); logPrintlnD(_beaconMsg->encode()); - _toAprsIs.addElement(_beaconMsg); + + if (system.getUserConfig()->aprs_is.active) + _toAprsIs.addElement(_beaconMsg); + system.getDisplay().addFrame(std::shared_ptr(new TextFrame("BEACON", _beaconMsg->toString()))); + _beacon_timer.start(); } + uint32_t diff = _beacon_timer.getTriggerTimeInSec(); _stateInfo = "beacon " + String(uint32_t(diff / 60)) + ":" + String(uint32_t(diff % 60)); + return true; } diff --git a/src/project_configuration.cpp b/src/project_configuration.cpp index 3514a97..56b3f25 100644 --- a/src/project_configuration.cpp +++ b/src/project_configuration.cpp @@ -20,6 +20,7 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen conf.beacon.positionLatitude = data["beacon"]["position"]["latitude"] | 0.0; conf.beacon.positionLongitude = data["beacon"]["position"]["longitude"] | 0.0; conf.beacon.timeout = data["beacon"]["timeout"] | 15; + conf.aprs_is.active = data["aprs_is"]["active"] | true; if (data.containsKey("aprs_is") && data["aprs_is"].containsKey("passcode")) conf.aprs_is.passcode = data["aprs_is"]["passcode"].as(); if (data.containsKey("aprs_is") && data["aprs_is"].containsKey("server")) @@ -73,6 +74,7 @@ void ProjectConfigurationManagement::writeProjectConfiguration(Configuration &co data["beacon"]["position"]["latitude"] = conf.beacon.positionLatitude; data["beacon"]["position"]["longitude"] = conf.beacon.positionLongitude; data["beacon"]["timeout"] = conf.beacon.timeout; + data["aprs_is"]["active"] = conf.aprs_is.active; data["aprs_is"]["passcode"] = conf.aprs_is.passcode; data["aprs_is"]["server"] = conf.aprs_is.server; data["aprs_is"]["port"] = conf.aprs_is.port; diff --git a/src/project_configuration.h b/src/project_configuration.h index e63e1f1..2bbbe35 100644 --- a/src/project_configuration.h +++ b/src/project_configuration.h @@ -33,9 +33,10 @@ public: class APRS_IS { public: - APRS_IS() : server("euro.aprs2.net"), port(14580) { + APRS_IS() : active(true), server("euro.aprs2.net"), port(14580) { } + bool active; String passcode; String server; int port; From d82db93801018e9b3fad09f35384a8203fffdf19 Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Mon, 24 May 2021 15:12:31 +0200 Subject: [PATCH 48/75] add RF Bake --- src/LoRa_APRS_iGate.cpp | 5 +++-- src/TaskModem.cpp | 8 +++++++- src/TaskModem.h | 4 +++- src/TaskRouter.cpp | 12 +++++++++++- src/TaskRouter.h | 5 ++++- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 36d254e..c8433aa 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -25,19 +25,20 @@ String create_long_aprs(double lng); TaskQueue> toAprsIs; TaskQueue> fromModem; +TaskQueue> toModem; System LoRaSystem; Configuration userConfig; DisplayTask displayTask; -ModemTask modemTask(fromModem); +ModemTask modemTask(fromModem, toModem); EthTask ethTask; WifiTask wifiTask; OTATask otaTask; NTPTask ntpTask; FTPTask ftpTask; AprsIsTask aprsIsTask(toAprsIs); -RouterTask routerTask(fromModem, toAprsIs); +RouterTask routerTask(fromModem, toModem, toAprsIs); // cppcheck-suppress unusedFunction void setup() { diff --git a/src/TaskModem.cpp b/src/TaskModem.cpp index 336b06e..095df1e 100644 --- a/src/TaskModem.cpp +++ b/src/TaskModem.cpp @@ -7,7 +7,8 @@ #include "TaskModem.h" #include "project_configuration.h" -ModemTask::ModemTask(TaskQueue> &fromModem) : Task(TASK_MODEM, TaskModem), _fromModem(fromModem) { +ModemTask::ModemTask(TaskQueue> &fromModem, TaskQueue> &toModem) + : Task(TASK_MODEM, TaskModem), _fromModem(fromModem), _toModem(toModem) { } ModemTask::~ModemTask() { @@ -51,5 +52,10 @@ bool ModemTask::loop(System &system) { system.getDisplay().addFrame(std::shared_ptr(new TextFrame("LoRa", msg->toString()))); } + if (!_toModem.empty()) { + std::shared_ptr msg = _toModem.getElement(); + _lora_aprs.sendMessage(msg); + } + return true; } diff --git a/src/TaskModem.h b/src/TaskModem.h index a11dfd3..a5aad06 100644 --- a/src/TaskModem.h +++ b/src/TaskModem.h @@ -7,7 +7,7 @@ class ModemTask : public Task { public: - explicit ModemTask(TaskQueue> &fromModem); + explicit ModemTask(TaskQueue> &fromModem, TaskQueue> &_toModem); virtual ~ModemTask(); virtual bool setup(System &system) override; @@ -15,7 +15,9 @@ public: private: LoRa_APRS _lora_aprs; + TaskQueue> &_fromModem; + TaskQueue> &_toModem; }; #endif diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index 9b4218d..06fd14d 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -9,7 +9,10 @@ String create_lat_aprs(double lat); String create_long_aprs(double lng); -RouterTask::RouterTask(TaskQueue> &fromModem, TaskQueue> &toAprsIs) : Task(TASK_ROUTER, TaskRouter), _fromModem(fromModem), _toAprsIs(toAprsIs) { +RouterTask::RouterTask(TaskQueue> &fromModem + , TaskQueue> &toModem + , TaskQueue> &toAprsIs) + : Task(TASK_ROUTER, TaskRouter), _fromModem(fromModem), _toModem(toModem), _toAprsIs(toAprsIs) { } RouterTask::~RouterTask() { @@ -53,6 +56,13 @@ bool RouterTask::loop(System &system) { if (system.getUserConfig()->aprs_is.active) _toAprsIs.addElement(_beaconMsg); + if (system.getUserConfig()->digi.beacon) { + std::shared_ptr msg = _beaconMsg; + msg->setPath("WIDE1-1"); + + _toModem.addElement(msg); + } + system.getDisplay().addFrame(std::shared_ptr(new TextFrame("BEACON", _beaconMsg->toString()))); _beacon_timer.start(); diff --git a/src/TaskRouter.h b/src/TaskRouter.h index b6e4289..043104f 100644 --- a/src/TaskRouter.h +++ b/src/TaskRouter.h @@ -6,7 +6,9 @@ class RouterTask : public Task { public: - RouterTask(TaskQueue> &fromModem, TaskQueue> &toAprsIs); + RouterTask(TaskQueue> &fromModem + , TaskQueue> &toModem + , TaskQueue> &toAprsIs); virtual ~RouterTask(); virtual bool setup(System &system) override; @@ -14,6 +16,7 @@ public: private: TaskQueue> &_fromModem; + TaskQueue> &_toModem; TaskQueue> &_toAprsIs; std::shared_ptr _beaconMsg; From 34f794aac2c9f213bd97d1e267a47e1b52ba51b3 Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Mon, 24 May 2021 15:50:01 +0200 Subject: [PATCH 49/75] move setPath(WIDE1-1) global --- src/TaskRouter.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index 06fd14d..db3b811 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -24,6 +24,7 @@ bool RouterTask::setup(System &system) { _beaconMsg = std::shared_ptr(new APRSMessage()); _beaconMsg->setSource(system.getUserConfig()->callsign); _beaconMsg->setDestination("APLG01"); + _beaconMsg->setPath("WIDE1-1"); String lat = create_lat_aprs(system.getUserConfig()->beacon.positionLatitude); String lng = create_long_aprs(system.getUserConfig()->beacon.positionLongitude); _beaconMsg->getBody()->setData(String("=") + lat + "L" + lng + "&" + system.getUserConfig()->beacon.message); @@ -56,12 +57,8 @@ bool RouterTask::loop(System &system) { if (system.getUserConfig()->aprs_is.active) _toAprsIs.addElement(_beaconMsg); - if (system.getUserConfig()->digi.beacon) { - std::shared_ptr msg = _beaconMsg; - msg->setPath("WIDE1-1"); - - _toModem.addElement(msg); - } + if (system.getUserConfig()->digi.beacon) + _toModem.addElement(_beaconMsg); system.getDisplay().addFrame(std::shared_ptr(new TextFrame("BEACON", _beaconMsg->toString()))); From ccfc0ceb120c16f455c8233a5cdec3d736e29019 Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Mon, 24 May 2021 15:50:30 +0100 Subject: [PATCH 50/75] update routing to APRS-IS --- src/TaskRouter.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index db3b811..09afb91 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -35,17 +35,20 @@ bool RouterTask::setup(System &system) { bool RouterTask::loop(System &system) { // do routing if (!_fromModem.empty()) { - std::shared_ptr msg = _fromModem.getElement(); - String path = msg->getPath(); + std::shared_ptr modemMsg = _fromModem.getElement(); - if (!(path.indexOf("RFONLY") != -1 || path.indexOf("NOGATE") != -1 || path.indexOf("TCPIP") != -1)) { - if (!path.isEmpty()) { - path += ","; - } - msg->setPath(path + "qAR," + system.getUserConfig()->callsign); + if (system.getUserConfig()->aprs_is.active && modemMsg->getSource() != system.getUserConfig()->callsign) { + std::shared_ptr msg = std::make_shared(*modemMsg); + String path = msg->getPath(); - if (system.getUserConfig()->aprs_is.active) + if (!(path.indexOf("RFONLY") != -1 || path.indexOf("NOGATE") != -1 || path.indexOf("TCPIP") != -1)) { + if (!path.isEmpty()) { + path += ","; + } + + msg->setPath(path + "qAR," + system.getUserConfig()->callsign); _toAprsIs.addElement(msg); + } } } From 7d2ad244b053081d7f15f05c4c454b00b6c284a5 Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Mon, 24 May 2021 16:10:20 +0100 Subject: [PATCH 51/75] add debug msg into aprs-is routing part --- src/TaskRouter.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index 09afb91..be8a370 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -38,17 +38,28 @@ bool RouterTask::loop(System &system) { std::shared_ptr modemMsg = _fromModem.getElement(); if (system.getUserConfig()->aprs_is.active && modemMsg->getSource() != system.getUserConfig()->callsign) { - std::shared_ptr msg = std::make_shared(*modemMsg); - String path = msg->getPath(); + std::shared_ptr aprsIsMsg = std::make_shared(*modemMsg); + String path = aprsIsMsg->getPath(); if (!(path.indexOf("RFONLY") != -1 || path.indexOf("NOGATE") != -1 || path.indexOf("TCPIP") != -1)) { if (!path.isEmpty()) { path += ","; } - msg->setPath(path + "qAR," + system.getUserConfig()->callsign); - _toAprsIs.addElement(msg); + aprsIsMsg->setPath(path + "qAR," + system.getUserConfig()->callsign); + + logPrintD("APRS-IS: "); + logPrintlnD(aprsIsMsg->toString()); + _toAprsIs.addElement(aprsIsMsg); + } else { + logPrintlnD("APRS-IS: no forward => RFonly"); } + } else { + if (!system.getUserConfig()->aprs_is.active) + logPrintlnD("APRS-IS: disabled"); + + if (modemMsg->getSource() == system.getUserConfig()->callsign) + logPrintlnD("APRS-IS: no forward => own paket erceived"); } } From 61f42f3d9a60e2b3b890569f93996c9f81f86439 Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Mon, 24 May 2021 16:24:50 +0100 Subject: [PATCH 52/75] more debug for wifi --- src/TaskEth.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/TaskEth.cpp b/src/TaskEth.cpp index 55ee653..fdad5a2 100644 --- a/src/TaskEth.cpp +++ b/src/TaskEth.cpp @@ -39,6 +39,8 @@ void WiFiEvent(WiFiEvent_t event) { logPrintI(ETH.macAddress()); logPrintI(", IPv4: "); logPrintI(ETH.localIP().toString()); + logPrintI(", DNS: "); + logPrintI(ETH.dnsIP().toString()); if (ETH.fullDuplex()) { logPrintI(", FULL_DUPLEX"); } From 4e1e818c4dbc51c3f53d36e5980fbf99070a7b53 Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Mon, 24 May 2021 17:48:39 +0100 Subject: [PATCH 53/75] first digi function --- src/TaskRouter.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index be8a370..ebaf38b 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -36,10 +36,11 @@ bool RouterTask::loop(System &system) { // do routing if (!_fromModem.empty()) { std::shared_ptr modemMsg = _fromModem.getElement(); + String path; if (system.getUserConfig()->aprs_is.active && modemMsg->getSource() != system.getUserConfig()->callsign) { std::shared_ptr aprsIsMsg = std::make_shared(*modemMsg); - String path = aprsIsMsg->getPath(); + path = aprsIsMsg->getPath(); if (!(path.indexOf("RFONLY") != -1 || path.indexOf("NOGATE") != -1 || path.indexOf("TCPIP") != -1)) { if (!path.isEmpty()) { @@ -61,6 +62,22 @@ bool RouterTask::loop(System &system) { if (modemMsg->getSource() == system.getUserConfig()->callsign) logPrintlnD("APRS-IS: no forward => own paket erceived"); } + + if (system.getUserConfig()->digi.active && modemMsg->getSource() != system.getUserConfig()->callsign) { + std::shared_ptr digiMsg = std::make_shared(*modemMsg); + path = digiMsg->getPath(); + + // simple loop check + if (path.indexOf("WIDE1-1") >= 0 || path.indexOf(system.getUserConfig()->callsign) == -1) { + // fixme + digiMsg->setPath(system.getUserConfig()->callsign + "*"); + + logPrintD("DIGI: "); + logPrintlnD(digiMsg->toString()); + + _toModem.addElement(digiMsg); + } + } } // check for beacon From 95ee0eca10bd9fd344c8d9f8e7d56f7e4d04c03d Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Mon, 24 May 2021 18:40:35 +0100 Subject: [PATCH 54/75] set RF Bake default off --- 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 1a685b0..e838666 100644 --- a/data/is-cfg.json +++ b/data/is-cfg.json @@ -25,7 +25,7 @@ "digi": { "active": false, "forward_timeout": 5, - "beacon": true, + "beacon": false, }, "lora": { "frequency_rx": 433775000, From 2d6a6453a7ecd8b17a3017df8032540bcdc13d13 Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Mon, 24 May 2021 16:24:50 +0100 Subject: [PATCH 55/75] more debug for wifi --- src/TaskEth.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/TaskEth.cpp b/src/TaskEth.cpp index 55ee653..fdad5a2 100644 --- a/src/TaskEth.cpp +++ b/src/TaskEth.cpp @@ -39,6 +39,8 @@ void WiFiEvent(WiFiEvent_t event) { logPrintI(ETH.macAddress()); logPrintI(", IPv4: "); logPrintI(ETH.localIP().toString()); + logPrintI(", DNS: "); + logPrintI(ETH.dnsIP().toString()); if (ETH.fullDuplex()) { logPrintI(", FULL_DUPLEX"); } From c843084e7193ed36c16d23b3e92be2338657ecb5 Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Mon, 24 May 2021 22:22:07 +0200 Subject: [PATCH 56/75] set RF Bake default off --- src/project_configuration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/project_configuration.cpp b/src/project_configuration.cpp index 56b3f25..67938d1 100644 --- a/src/project_configuration.cpp +++ b/src/project_configuration.cpp @@ -29,7 +29,7 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen conf.digi.active = data["digi"]["active"] | false; conf.digi.forwardTimeout = data["digi"]["forward_timeout"] | 5; - conf.digi.beacon = data["digi"]["beacon"] | true; + conf.digi.beacon = data["digi"]["beacon"] | false; conf.lora.frequencyRx = data["lora"]["frequency_rx"] | 433775000; conf.lora.frequencyTx = data["lora"]["frequency_tx"] | 433775000; conf.lora.power = data["lora"]["power"] | 20; From 63abe791cd2d4f89f566c056609d5dd95322cfac Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Tue, 25 May 2021 11:15:01 +0200 Subject: [PATCH 57/75] move WIDE1-1 Path to Digi Msg --- src/TaskRouter.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index ebaf38b..4e7eee5 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -21,10 +21,10 @@ RouterTask::~RouterTask() { bool RouterTask::setup(System &system) { // setup beacon _beacon_timer.setTimeout(system.getUserConfig()->beacon.timeout * 60 * 1000); + _beaconMsg = std::shared_ptr(new APRSMessage()); _beaconMsg->setSource(system.getUserConfig()->callsign); _beaconMsg->setDestination("APLG01"); - _beaconMsg->setPath("WIDE1-1"); String lat = create_lat_aprs(system.getUserConfig()->beacon.positionLatitude); String lng = create_long_aprs(system.getUserConfig()->beacon.positionLongitude); _beaconMsg->getBody()->setData(String("=") + lat + "L" + lng + "&" + system.getUserConfig()->beacon.message); @@ -88,8 +88,11 @@ bool RouterTask::loop(System &system) { if (system.getUserConfig()->aprs_is.active) _toAprsIs.addElement(_beaconMsg); - if (system.getUserConfig()->digi.beacon) - _toModem.addElement(_beaconMsg); + if (system.getUserConfig()->digi.beacon) { + std::shared_ptr digiBeaconMsg = std::make_shared(*_beaconMsg); + digiBeaconMsg->setPath("WIDE1-1"); + _toModem.addElement(digiBeaconMsg); + } system.getDisplay().addFrame(std::shared_ptr(new TextFrame("BEACON", _beaconMsg->toString()))); From 86c2e46fcd3242b07f5379ac2051846213df6150 Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Tue, 25 May 2021 11:41:15 +0200 Subject: [PATCH 58/75] fix typo --- src/TaskRouter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index 4e7eee5..91eba46 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -60,7 +60,7 @@ bool RouterTask::loop(System &system) { logPrintlnD("APRS-IS: disabled"); if (modemMsg->getSource() == system.getUserConfig()->callsign) - logPrintlnD("APRS-IS: no forward => own paket erceived"); + logPrintlnD("APRS-IS: no forward => own packet received"); } if (system.getUserConfig()->digi.active && modemMsg->getSource() != system.getUserConfig()->callsign) { From da1be0cc6e9d8d7283d997177ed8e67511b621a5 Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Tue, 25 May 2021 13:00:44 +0200 Subject: [PATCH 59/75] clang format --- src/TaskModem.cpp | 3 +-- src/TaskModem.h | 2 +- src/TaskRouter.cpp | 13 +++++-------- src/TaskRouter.h | 4 +--- src/project_configuration.h | 4 ++-- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/TaskModem.cpp b/src/TaskModem.cpp index 095df1e..1056c39 100644 --- a/src/TaskModem.cpp +++ b/src/TaskModem.cpp @@ -7,8 +7,7 @@ #include "TaskModem.h" #include "project_configuration.h" -ModemTask::ModemTask(TaskQueue> &fromModem, TaskQueue> &toModem) - : Task(TASK_MODEM, TaskModem), _fromModem(fromModem), _toModem(toModem) { +ModemTask::ModemTask(TaskQueue> &fromModem, TaskQueue> &toModem) : Task(TASK_MODEM, TaskModem), _fromModem(fromModem), _toModem(toModem) { } ModemTask::~ModemTask() { diff --git a/src/TaskModem.h b/src/TaskModem.h index a5aad06..6087b67 100644 --- a/src/TaskModem.h +++ b/src/TaskModem.h @@ -14,7 +14,7 @@ public: virtual bool loop(System &system) override; private: - LoRa_APRS _lora_aprs; + LoRa_APRS _lora_aprs; TaskQueue> &_fromModem; TaskQueue> &_toModem; diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index 91eba46..df54ec6 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -9,10 +9,7 @@ String create_lat_aprs(double lat); String create_long_aprs(double lng); -RouterTask::RouterTask(TaskQueue> &fromModem - , TaskQueue> &toModem - , TaskQueue> &toAprsIs) - : Task(TASK_ROUTER, TaskRouter), _fromModem(fromModem), _toModem(toModem), _toAprsIs(toAprsIs) { +RouterTask::RouterTask(TaskQueue> &fromModem, TaskQueue> &toModem, TaskQueue> &toAprsIs) : Task(TASK_ROUTER, TaskRouter), _fromModem(fromModem), _toModem(toModem), _toAprsIs(toAprsIs) { } RouterTask::~RouterTask() { @@ -35,12 +32,12 @@ bool RouterTask::setup(System &system) { bool RouterTask::loop(System &system) { // do routing if (!_fromModem.empty()) { - std::shared_ptr modemMsg = _fromModem.getElement(); - String path; + std::shared_ptr modemMsg = _fromModem.getElement(); + String path; if (system.getUserConfig()->aprs_is.active && modemMsg->getSource() != system.getUserConfig()->callsign) { std::shared_ptr aprsIsMsg = std::make_shared(*modemMsg); - path = aprsIsMsg->getPath(); + path = aprsIsMsg->getPath(); if (!(path.indexOf("RFONLY") != -1 || path.indexOf("NOGATE") != -1 || path.indexOf("TCPIP") != -1)) { if (!path.isEmpty()) { @@ -65,7 +62,7 @@ bool RouterTask::loop(System &system) { if (system.getUserConfig()->digi.active && modemMsg->getSource() != system.getUserConfig()->callsign) { std::shared_ptr digiMsg = std::make_shared(*modemMsg); - path = digiMsg->getPath(); + path = digiMsg->getPath(); // simple loop check if (path.indexOf("WIDE1-1") >= 0 || path.indexOf(system.getUserConfig()->callsign) == -1) { diff --git a/src/TaskRouter.h b/src/TaskRouter.h index 043104f..8d8d1ac 100644 --- a/src/TaskRouter.h +++ b/src/TaskRouter.h @@ -6,9 +6,7 @@ class RouterTask : public Task { public: - RouterTask(TaskQueue> &fromModem - , TaskQueue> &toModem - , TaskQueue> &toAprsIs); + RouterTask(TaskQueue> &fromModem, TaskQueue> &toModem, TaskQueue> &toAprsIs); virtual ~RouterTask(); virtual bool setup(System &system) override; diff --git a/src/project_configuration.h b/src/project_configuration.h index 2bbbe35..fbc785c 100644 --- a/src/project_configuration.h +++ b/src/project_configuration.h @@ -36,7 +36,7 @@ public: APRS_IS() : active(true), server("euro.aprs2.net"), port(14580) { } - bool active; + bool active; String passcode; String server; int port; @@ -48,7 +48,7 @@ public: } bool active; - int forwardTimeout; + int forwardTimeout; bool beacon; }; From 0880428184a5a48711d5c38813ca8903c9adea7e Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Tue, 25 May 2021 12:21:55 +0100 Subject: [PATCH 60/75] avoid global vars --- src/TaskRouter.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index df54ec6..a975691 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -33,11 +33,10 @@ bool RouterTask::loop(System &system) { // do routing if (!_fromModem.empty()) { std::shared_ptr modemMsg = _fromModem.getElement(); - String path; if (system.getUserConfig()->aprs_is.active && modemMsg->getSource() != system.getUserConfig()->callsign) { std::shared_ptr aprsIsMsg = std::make_shared(*modemMsg); - path = aprsIsMsg->getPath(); + String path = aprsIsMsg->getPath(); if (!(path.indexOf("RFONLY") != -1 || path.indexOf("NOGATE") != -1 || path.indexOf("TCPIP") != -1)) { if (!path.isEmpty()) { @@ -62,7 +61,7 @@ bool RouterTask::loop(System &system) { if (system.getUserConfig()->digi.active && modemMsg->getSource() != system.getUserConfig()->callsign) { std::shared_ptr digiMsg = std::make_shared(*modemMsg); - path = digiMsg->getPath(); + String path = digiMsg->getPath(); // simple loop check if (path.indexOf("WIDE1-1") >= 0 || path.indexOf(system.getUserConfig()->callsign) == -1) { From ac77bfb3b9f12430d19a63e63247c0c6d879bd8b Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Tue, 25 May 2021 20:10:42 +0200 Subject: [PATCH 61/75] add const ref --- lib/BoardFinder/BoardFinder.cpp | 4 ++-- lib/BoardFinder/BoardFinder.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/BoardFinder/BoardFinder.cpp b/lib/BoardFinder/BoardFinder.cpp index c8eb972..0e076e0 100644 --- a/lib/BoardFinder/BoardFinder.cpp +++ b/lib/BoardFinder/BoardFinder.cpp @@ -6,7 +6,7 @@ BoardConfig::BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t o : Name(name), Type(type), OledSda(oledsda), OledScl(oledscl), OledAddr(oledaddr), OledReset(oledreset), LoraSck(lorasck), LoraMiso(loramiso), LoraMosi(loramosi), LoraCS(loracs), LoraReset(lorareset), LoraIRQ(lorairq), needCheckPowerChip(needcheckpowerchip), powerCheckStatus(powercheckstatus) { } -BoardFinder::BoardFinder(std::list boardConfigs) : _boardConfigs(boardConfigs) { +BoardFinder::BoardFinder(const std::list &boardConfigs) : _boardConfigs(boardConfigs) { } BoardConfig const *BoardFinder::searchBoardConfig() { @@ -51,7 +51,7 @@ BoardConfig const *BoardFinder::searchBoardConfig() { } BoardConfig const *BoardFinder::getBoardConfig(String name) { - std::_List_iterator elem = std::find_if(_boardConfigs.begin(), _boardConfigs.end(), [&](BoardConfig const *conf) { + std::_List_const_iterator elem = std::find_if(_boardConfigs.begin(), _boardConfigs.end(), [&](BoardConfig const *conf) { return conf->Name == name; }); if (elem == _boardConfigs.end()) { diff --git a/lib/BoardFinder/BoardFinder.h b/lib/BoardFinder/BoardFinder.h index a18f674..142de6d 100644 --- a/lib/BoardFinder/BoardFinder.h +++ b/lib/BoardFinder/BoardFinder.h @@ -45,14 +45,14 @@ public: class BoardFinder { public: - explicit BoardFinder(std::list boardConfigs); + explicit BoardFinder(const std::list &boardConfigs); BoardConfig const *searchBoardConfig(); BoardConfig const *getBoardConfig(String name); private: - std::list _boardConfigs; + const std::list &_boardConfigs; bool checkOledConfig(BoardConfig const *boardConfig); bool checkModemConfig(BoardConfig const *boardConfig); From cc0e014d2eb0b7fba68af2fa9ed7110a3de798dc Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Tue, 25 May 2021 20:21:08 +0200 Subject: [PATCH 62/75] remove WIDE1-1 from digi beacon path --- src/TaskRouter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index a975691..22ae2cf 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -86,7 +86,7 @@ bool RouterTask::loop(System &system) { if (system.getUserConfig()->digi.beacon) { std::shared_ptr digiBeaconMsg = std::make_shared(*_beaconMsg); - digiBeaconMsg->setPath("WIDE1-1"); + //digiBeaconMsg->setPath("WIDE1-1"); _toModem.addElement(digiBeaconMsg); } From 32aee92eeb5036fac08100da220cdf5f9d4f0980 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Tue, 25 May 2021 21:26:22 +0200 Subject: [PATCH 63/75] fixing cppcheck in LoRa_APRS class --- lib/LoRa_APRS/LoRa_APRS.cpp | 5 ++++- lib/LoRa_APRS/LoRa_APRS.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/LoRa_APRS/LoRa_APRS.cpp b/lib/LoRa_APRS/LoRa_APRS.cpp index 1f8493f..c53a2ce 100644 --- a/lib/LoRa_APRS/LoRa_APRS.cpp +++ b/lib/LoRa_APRS/LoRa_APRS.cpp @@ -1,5 +1,8 @@ #include "LoRa_APRS.h" +LoRa_APRS::LoRa_APRS() { +} + bool LoRa_APRS::checkMessage() { if (!parsePacket()) { return false; @@ -28,7 +31,6 @@ std::shared_ptr LoRa_APRS::getMessage() { return _LastReceivedMsg; } -// cppcheck-suppress unusedFunction void LoRa_APRS::sendMessage(const std::shared_ptr msg) { setFrequency(_TxFrequency); String data = msg->encode(); @@ -48,6 +50,7 @@ void LoRa_APRS::setRxFrequency(long frequency) { setFrequency(_RxFrequency); } +// cppcheck-suppress unusedFunction long LoRa_APRS::getRxFrequency() const { return _RxFrequency; } diff --git a/lib/LoRa_APRS/LoRa_APRS.h b/lib/LoRa_APRS/LoRa_APRS.h index d9cb093..cacd0fe 100644 --- a/lib/LoRa_APRS/LoRa_APRS.h +++ b/lib/LoRa_APRS/LoRa_APRS.h @@ -9,6 +9,8 @@ class LoRa_APRS : public LoRaClass { public: + LoRa_APRS(); + bool checkMessage(); std::shared_ptr getMessage(); From 493fd3556250732ddff0573de6614ca98269babf Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Tue, 25 May 2021 21:32:07 +0200 Subject: [PATCH 64/75] fixing cppcheck in power_management --- lib/PowerManagement/power_management.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/PowerManagement/power_management.cpp b/lib/PowerManagement/power_management.cpp index 06771a3..779d32b 100644 --- a/lib/PowerManagement/power_management.cpp +++ b/lib/PowerManagement/power_management.cpp @@ -1,11 +1,9 @@ #include "power_management.h" -// cppcheck-suppress uninitMemberVar PowerManagement::PowerManagement() { } -// cppcheck-suppress unusedFunction bool PowerManagement::begin(TwoWire &port) { bool result = axp.begin(port, AXP192_SLAVE_ADDRESS); if (!result) { @@ -14,7 +12,6 @@ bool PowerManagement::begin(TwoWire &port) { return result; } -// cppcheck-suppress unusedFunction void PowerManagement::activateLoRa() { axp.setPowerOutPut(AXP192_LDO2, AXP202_ON); } @@ -29,12 +26,10 @@ void PowerManagement::activateGPS() { axp.setPowerOutPut(AXP192_LDO3, AXP202_ON); } -// cppcheck-suppress unusedFunction void PowerManagement::deactivateGPS() { axp.setPowerOutPut(AXP192_LDO3, AXP202_OFF); } -// cppcheck-suppress unusedFunction void PowerManagement::activateOLED() { axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); } From 088df6dd6a3dfab547d83460d06ccbe9753c058a Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Tue, 25 May 2021 21:32:28 +0200 Subject: [PATCH 65/75] fixing cppcheck in task manager --- lib/System/TaskManager.cpp | 10 ---------- lib/System/TaskManager.h | 1 - 2 files changed, 11 deletions(-) diff --git a/lib/System/TaskManager.cpp b/lib/System/TaskManager.cpp index 9cf7e33..ed31c2b 100644 --- a/lib/System/TaskManager.cpp +++ b/lib/System/TaskManager.cpp @@ -13,16 +13,6 @@ void TaskManager::addAlwaysRunTask(Task *task) { _alwaysRunTasks.push_back(task); } -Task *TaskManager::getTask(const char *name) { - std::_List_iterator elem = std::find_if(_tasks.begin(), _tasks.end(), [&](Task *task) { - return task->getName() == name; - }); - if (elem == _tasks.end()) { - return 0; - } - return *elem; -} - std::list TaskManager::getTasks() { return _tasks; } diff --git a/lib/System/TaskManager.h b/lib/System/TaskManager.h index 8a7ad3b..7b7c4b6 100644 --- a/lib/System/TaskManager.h +++ b/lib/System/TaskManager.h @@ -63,7 +63,6 @@ public: void addTask(Task *task); void addAlwaysRunTask(Task *task); - Task * getTask(const char *name); std::list getTasks(); bool setup(System &system); From f0f2c0b53889fb5040e2c34b6623d4ba944e625d Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Tue, 25 May 2021 21:32:44 +0200 Subject: [PATCH 66/75] fixing cppcheck in timer --- lib/System/Timer.cpp | 2 ++ src/Task.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/System/Timer.cpp b/lib/System/Timer.cpp index ebd17f6..4fb9e9f 100644 --- a/lib/System/Timer.cpp +++ b/lib/System/Timer.cpp @@ -13,10 +13,12 @@ uint32_t Timer::getTriggerTimeInSec() const { return (_nextTimeout - millis()) / 1000; } +// cppcheck-suppress unusedFunction bool Timer::isActive() const { return _nextTimeout != 0; } +// cppcheck-suppress unusedFunction void Timer::reset() { _nextTimeout = 0; } diff --git a/src/Task.h b/src/Task.h index b9a1f12..4c8163b 100644 --- a/src/Task.h +++ b/src/Task.h @@ -14,8 +14,6 @@ enum TaskNames TaskSize, }; -// char const * const getTaskName(TaskNames task); - #define TASK_APRS_IS "AprsIsTask" #define TASK_ETH "EthTask" #define TASK_FTP "FTPTask" From ee2f14bac1568c7510ab11978a1f7173fd05ed66 Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Tue, 25 May 2021 21:33:55 +0200 Subject: [PATCH 67/75] no commented code! --- src/TaskRouter.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index 22ae2cf..210ed7e 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -85,9 +85,7 @@ bool RouterTask::loop(System &system) { _toAprsIs.addElement(_beaconMsg); if (system.getUserConfig()->digi.beacon) { - std::shared_ptr digiBeaconMsg = std::make_shared(*_beaconMsg); - //digiBeaconMsg->setPath("WIDE1-1"); - _toModem.addElement(digiBeaconMsg); + _toModem.addElement(_beaconMsg); } system.getDisplay().addFrame(std::shared_ptr(new TextFrame("BEACON", _beaconMsg->toString()))); From 31933bd2d837bf0a8384e0c72546d4cc1b4cc8ae Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Tue, 25 May 2021 21:33:55 +0200 Subject: [PATCH 68/75] fixing cppcheck in task modem --- src/TaskModem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TaskModem.cpp b/src/TaskModem.cpp index 336b06e..1cf531b 100644 --- a/src/TaskModem.cpp +++ b/src/TaskModem.cpp @@ -7,7 +7,7 @@ #include "TaskModem.h" #include "project_configuration.h" -ModemTask::ModemTask(TaskQueue> &fromModem) : Task(TASK_MODEM, TaskModem), _fromModem(fromModem) { +ModemTask::ModemTask(TaskQueue> &fromModem) : Task(TASK_MODEM, TaskModem), _lora_aprs(), _fromModem(fromModem) { } ModemTask::~ModemTask() { From f5793ae040627f42c36b0e7003f9d3863c17727f Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Tue, 25 May 2021 21:57:18 +0200 Subject: [PATCH 69/75] remove not implemented features --- data/is-cfg.json | 3 +-- src/project_configuration.cpp | 2 -- src/project_configuration.h | 3 +-- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/data/is-cfg.json b/data/is-cfg.json index e838666..3d536bb 100644 --- a/data/is-cfg.json +++ b/data/is-cfg.json @@ -24,8 +24,7 @@ }, "digi": { "active": false, - "forward_timeout": 5, - "beacon": false, + "beacon": false }, "lora": { "frequency_rx": 433775000, diff --git a/src/project_configuration.cpp b/src/project_configuration.cpp index 67938d1..4bce038 100644 --- a/src/project_configuration.cpp +++ b/src/project_configuration.cpp @@ -28,7 +28,6 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen conf.aprs_is.port = data["aprs_is"]["port"] | 14580; conf.digi.active = data["digi"]["active"] | false; - conf.digi.forwardTimeout = data["digi"]["forward_timeout"] | 5; conf.digi.beacon = data["digi"]["beacon"] | false; conf.lora.frequencyRx = data["lora"]["frequency_rx"] | 433775000; conf.lora.frequencyTx = data["lora"]["frequency_tx"] | 433775000; @@ -79,7 +78,6 @@ void ProjectConfigurationManagement::writeProjectConfiguration(Configuration &co data["aprs_is"]["server"] = conf.aprs_is.server; data["aprs_is"]["port"] = conf.aprs_is.port; data["digi"]["active"] = conf.digi.active; - data["digi"]["forward_timeout"] = conf.digi.forwardTimeout; data["digi"]["beacon"] = conf.digi.beacon; data["lora"]["frequency_rx"] = conf.lora.frequencyRx; data["lora"]["frequency_tx"] = conf.lora.frequencyTx; diff --git a/src/project_configuration.h b/src/project_configuration.h index fbc785c..e1e1686 100644 --- a/src/project_configuration.h +++ b/src/project_configuration.h @@ -44,11 +44,10 @@ public: class Digi { public: - Digi() : active(false), forwardTimeout(5), beacon(true) { + Digi() : active(false), beacon(true) { } bool active; - int forwardTimeout; bool beacon; }; From cb8dcac3cc807980dbb7793ac1c5b1e78339c03b Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Tue, 25 May 2021 22:33:00 +0200 Subject: [PATCH 70/75] cppcheck fixes --- src/LoRa_APRS_iGate.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 01d62ba..9bc836a 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -39,7 +39,6 @@ FTPTask ftpTask; AprsIsTask aprsIsTask(toAprsIs); RouterTask routerTask(fromModem, toAprsIs); -// cppcheck-suppress unusedFunction void setup() { Serial.begin(115200); Logger::instance().setSerial(&Serial); @@ -62,18 +61,20 @@ void setup() { BoardFinder finder(boardConfigs); BoardConfig const *boardConfig = finder.getBoardConfig(userConfig.board); - if (boardConfig == 0) { + if (!boardConfig) { boardConfig = finder.searchBoardConfig(); - if (boardConfig == 0) { + if (!boardConfig) { logPrintlnE("Board config not set and search failed!"); while (true) ; + } else { + userConfig.board = boardConfig->Name; + confmg.writeConfiguration(userConfig); + logPrintlnI("will restart board now!"); + ESP.restart(); } - userConfig.board = boardConfig->Name; - confmg.writeConfiguration(userConfig); - logPrintlnI("will restart board now!"); - ESP.restart(); } + logPrintI("Board "); logPrintI(boardConfig->Name); logPrintlnI(" loaded."); From ee6230854c8e672753b63665b9c76000f7c78a62 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Tue, 25 May 2021 22:55:04 +0200 Subject: [PATCH 71/75] cppcheck fix --- lib/LoRa_APRS/LoRa_APRS.cpp | 2 +- lib/System/TaskManager.cpp | 1 + src/LoRa_APRS_iGate.cpp | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/LoRa_APRS/LoRa_APRS.cpp b/lib/LoRa_APRS/LoRa_APRS.cpp index c53a2ce..ea28f8b 100644 --- a/lib/LoRa_APRS/LoRa_APRS.cpp +++ b/lib/LoRa_APRS/LoRa_APRS.cpp @@ -1,6 +1,6 @@ #include "LoRa_APRS.h" -LoRa_APRS::LoRa_APRS() { +LoRa_APRS::LoRa_APRS() : _RxFrequency(433775000), _TxFrequency(433775000) { } bool LoRa_APRS::checkMessage() { diff --git a/lib/System/TaskManager.cpp b/lib/System/TaskManager.cpp index ed31c2b..b53bc1d 100644 --- a/lib/System/TaskManager.cpp +++ b/lib/System/TaskManager.cpp @@ -49,6 +49,7 @@ bool TaskManager::loop(System &system) { return ret; } +// cppcheck-suppress unusedFunction void StatusFrame::drawStatusPage(Bitmap &bitmap) { int y = 0; for (Task *task : _tasks) { diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 08bcf04..dd45b27 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -132,7 +132,6 @@ void setup() { logPrintlnI("setup done..."); } -// cppcheck-suppress unusedFunction void loop() { LoRaSystem.getTaskManager().loop(LoRaSystem); } From 87f09618c5c8ce41669c281bd01190a4effb61bd Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 26 May 2021 22:26:41 +0200 Subject: [PATCH 72/75] activate Wifi or Eth just in iGate mode not in Digi mode --- src/LoRa_APRS_iGate.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index dd45b27..ceb5d96 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -97,10 +97,12 @@ void setup() { LoRaSystem.setUserConfig(&userConfig); LoRaSystem.getTaskManager().addTask(&displayTask); LoRaSystem.getTaskManager().addTask(&modemTask); - if (boardConfig->Type == eETH_BOARD) { - LoRaSystem.getTaskManager().addAlwaysRunTask(ðTask); - } else { - LoRaSystem.getTaskManager().addAlwaysRunTask(&wifiTask); + if (userConfig.aprs_is.active) { + if (boardConfig->Type == eETH_BOARD) { + LoRaSystem.getTaskManager().addAlwaysRunTask(ðTask); + } else { + LoRaSystem.getTaskManager().addAlwaysRunTask(&wifiTask); + } } LoRaSystem.getTaskManager().addTask(&otaTask); LoRaSystem.getTaskManager().addTask(&ntpTask); @@ -122,6 +124,12 @@ void setup() { while (true) ; } + 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.getDisplay().showStatusScreen("ERROR", "No mode selected (iGate or Digi)! You have to activate one of iGate or Digi."); + while (true) + ; + } if (userConfig.display.overwritePin != 0) { pinMode(userConfig.display.overwritePin, INPUT); From e6283e3359e3c012dd9c0a1b3f2c125265835f8d Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 26 May 2021 22:34:09 +0200 Subject: [PATCH 73/75] activate ntp, ota and ftp just if we have iGate mode --- src/LoRa_APRS_iGate.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index ceb5d96..0890b40 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -97,22 +97,21 @@ void setup() { LoRaSystem.setUserConfig(&userConfig); LoRaSystem.getTaskManager().addTask(&displayTask); LoRaSystem.getTaskManager().addTask(&modemTask); + LoRaSystem.getTaskManager().addTask(&routerTask); + if (userConfig.aprs_is.active) { if (boardConfig->Type == eETH_BOARD) { LoRaSystem.getTaskManager().addAlwaysRunTask(ðTask); } else { LoRaSystem.getTaskManager().addAlwaysRunTask(&wifiTask); } - } - LoRaSystem.getTaskManager().addTask(&otaTask); - LoRaSystem.getTaskManager().addTask(&ntpTask); - if (userConfig.ftp.active) { - LoRaSystem.getTaskManager().addTask(&ftpTask); - } - if (userConfig.aprs_is.active) { + LoRaSystem.getTaskManager().addTask(&otaTask); + LoRaSystem.getTaskManager().addTask(&ntpTask); + if (userConfig.ftp.active) { + LoRaSystem.getTaskManager().addTask(&ftpTask); + } LoRaSystem.getTaskManager().addTask(&aprsIsTask); } - LoRaSystem.getTaskManager().addTask(&routerTask); LoRaSystem.getTaskManager().setup(LoRaSystem); From 4f91743d144abd9cb478b599503b58ff6dfdba97 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 23 Jun 2021 22:14:47 +0200 Subject: [PATCH 74/75] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 93c25c1..bc8bd22 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,12 @@ Try it out and be part of the APRS network. ## Blog posts and Youtube videos from other Hams +* [Manuel Lausmann - iGate & Tracker](https://www.youtube.com/watch?v=-KdFQEaNC1k) (youtube - german) 04.06.2021 +* [Manuel Lausmann - Installationsanleitung als PDF](http://mala-one.de/Lora-APRS/) (PDF - german) 04.06.2021 * [OE1ROT](https://www.aronaut.at/2020/11/lora-aprs-gateway-mit-esp32-boards/) (blog post - german) 14.11.2020 * [DL7AG](http://online.dl7ag.de/lora-aprs-dl7ag-10/) (blog post - german) 08.11.2020 -* [Manuel Lausmann - iGate](https://www.youtube.com/watch?v=C7hfVe32pXs) (youtube - german) 06.11.2020 -* [Manuel Lausmann - Tracker](https://www.youtube.com/watch?v=clIlTEFbWLk) (youtube - german) 02.11.2020 +* [Manuel Lausmann - iGate](https://www.youtube.com/watch?v=C7hfVe32pXs) (youtube - german - OLD) 06.11.2020 +* [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. From 438852b4460fb6d6b775814b87a4ba2e9421e2db Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 23 Jun 2021 22:20:05 +0200 Subject: [PATCH 75/75] 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 0890b40..d6ede91 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -18,7 +18,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "21.21.0-dev" +#define VERSION "21.25.0" String create_lat_aprs(double lat); String create_long_aprs(double lng);