From 5ea6a8f0084476574be5a6237235d5608f4f7753 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Sun, 20 Mar 2022 21:39:45 +0900 Subject: [PATCH 01/37] Add GPS function for setting beacon position. --- data/is-cfg.json | 1 + lib/BoardFinder/BoardFinder.cpp | 20 +++--- lib/BoardFinder/BoardFinder.h | 4 +- src/LoRa_APRS_iGate.cpp | 33 +++------- src/Task.h | 2 + src/TaskBeacon.cpp | 113 ++++++++++++++++++++++++++++++++ src/TaskBeacon.h | 31 +++++++++ src/TaskRouter.cpp | 33 +--------- src/TaskRouter.h | 3 - src/project_configuration.cpp | 2 + src/project_configuration.h | 3 +- 11 files changed, 173 insertions(+), 72 deletions(-) create mode 100644 src/TaskBeacon.cpp create mode 100644 src/TaskBeacon.h diff --git a/data/is-cfg.json b/data/is-cfg.json index 04aae81..e9c5f7e 100644 --- a/data/is-cfg.json +++ b/data/is-cfg.json @@ -29,6 +29,7 @@ "latitude": 0.000000, "longitude": 0.000000 }, + "gps": true, "timeout": 15 }, "aprs_is": { diff --git a/lib/BoardFinder/BoardFinder.cpp b/lib/BoardFinder/BoardFinder.cpp index 0e076e0..0990d86 100644 --- a/lib/BoardFinder/BoardFinder.cpp +++ b/lib/BoardFinder/BoardFinder.cpp @@ -2,8 +2,8 @@ #include #include -BoardConfig::BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t oledscl, uint8_t oledaddr, uint8_t oledreset, uint8_t lorasck, uint8_t loramiso, uint8_t loramosi, uint8_t loracs, uint8_t lorareset, uint8_t lorairq, bool needcheckpowerchip, bool powercheckstatus) - : Name(name), Type(type), OledSda(oledsda), OledScl(oledscl), OledAddr(oledaddr), OledReset(oledreset), LoraSck(lorasck), LoraMiso(loramiso), LoraMosi(loramosi), LoraCS(loracs), LoraReset(lorareset), LoraIRQ(lorairq), needCheckPowerChip(needcheckpowerchip), powerCheckStatus(powercheckstatus) { +BoardConfig::BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t oledscl, uint8_t oledaddr, uint8_t oledreset, uint8_t lorasck, uint8_t loramiso, uint8_t loramosi, uint8_t loracs, uint8_t lorareset, uint8_t lorairq, uint8_t gpsrx, uint8_t gpstx, bool needcheckpowerchip, bool powercheckstatus) + : Name(name), Type(type), OledSda(oledsda), OledScl(oledscl), OledAddr(oledaddr), OledReset(oledreset), LoraSck(lorasck), LoraMiso(loramiso), LoraMosi(loramosi), LoraCS(loracs), LoraReset(lorareset), LoraIRQ(lorairq), GpsRx(gpsrx), GpsTx(gpstx), needCheckPowerChip(needcheckpowerchip), powerCheckStatus(powercheckstatus) { } BoardFinder::BoardFinder(const std::list &boardConfigs) : _boardConfigs(boardConfigs) { @@ -130,12 +130,12 @@ bool BoardFinder::checkPowerConfig(BoardConfig const *boardConfig) { } // 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); +BoardConfig TTGO_LORA32_V1 ("TTGO_LORA32_V1", eTTGO_LORA32_V1, 4, 15, 0x3C, 0, 5, 19, 27, 18, 14, 26, 0, 0); +BoardConfig TTGO_LORA32_V2 ("TTGO_LORA32_V2", eTTGO_LORA32_V2, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, 0, 0, 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, 15, 12, 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, 12, 34, true, true); +BoardConfig ETH_BOARD ("ETH_BOARD", eETH_BOARD, 33, 32, 0x3C, 0, 14, 2, 15, 12, 4, 36, 0, 0); +BoardConfig TRACKERD ("TRACKERD", eTRACKERD, 5, 4, 0x3C, 0, 18, 19, 23, 16, 14, 26, 0, 0); +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, 0, 0); +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, 0, 0); // clang-format on diff --git a/lib/BoardFinder/BoardFinder.h b/lib/BoardFinder/BoardFinder.h index 142de6d..fa68451 100644 --- a/lib/BoardFinder/BoardFinder.h +++ b/lib/BoardFinder/BoardFinder.h @@ -22,7 +22,7 @@ enum BoardType class BoardConfig { public: - explicit BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t oledscl, uint8_t oledaddr, uint8_t oledreset, uint8_t lorasck, uint8_t loramiso, uint8_t loramosi, uint8_t loracs, uint8_t lorareset, uint8_t lorairq, bool needcheckpowerchip = false, bool powercheckstatus = false); + explicit BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t oledscl, uint8_t oledaddr, uint8_t oledreset, uint8_t lorasck, uint8_t loramiso, uint8_t loramosi, uint8_t loracs, uint8_t lorareset, uint8_t lorairq, uint8_t gpsrx, uint8_t gpstx, bool needcheckpowerchip = false, bool powercheckstatus = false); String Name; BoardType Type; @@ -38,6 +38,8 @@ public: uint8_t LoraCS; uint8_t LoraReset; uint8_t LoraIRQ; + uint8_t GpsRx; + uint8_t GpsTx; bool needCheckPowerChip; bool powerCheckStatus; diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index afaa3f0..1996af2 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -8,6 +8,7 @@ #include #include "TaskAprsIs.h" +#include "TaskBeacon.h" #include "TaskDisplay.h" #include "TaskEth.h" #include "TaskFTP.h" @@ -42,6 +43,7 @@ FTPTask ftpTask; MQTTTask mqttTask(toMQTT); AprsIsTask aprsIsTask(toAprsIs); RouterTask routerTask(fromModem, toModem, toAprsIs, toMQTT); +BeaconTask beaconTask(toModem, toAprsIs); void setup() { Serial.begin(115200); @@ -93,7 +95,11 @@ void setup() { } powerManagement.activateLoRa(); powerManagement.activateOLED(); - powerManagement.deactivateGPS(); + if (userConfig.beacon.gps) { + powerManagement.activateGPS(); + } else { + powerManagement.deactivateGPS(); + } } LoRaSystem.setBoardConfig(boardConfig); @@ -101,6 +107,7 @@ void setup() { LoRaSystem.getTaskManager().addTask(&displayTask); LoRaSystem.getTaskManager().addTask(&modemTask); LoRaSystem.getTaskManager().addTask(&routerTask); + LoRaSystem.getTaskManager().addTask(&beaconTask); if (userConfig.aprs_is.active) { if (boardConfig->Type == eETH_BOARD && !userConfig.wifi.active) { @@ -150,27 +157,3 @@ void setup() { void loop() { LoRaSystem.getTaskManager().loop(LoRaSystem); } - -String create_lat_aprs(double lat) { - char str[20]; - char n_s = 'N'; - if (lat < 0) { - n_s = 'S'; - } - lat = std::abs(lat); - sprintf(str, "%02d%05.2f%c", (int)lat, (lat - (double)((int)lat)) * 60.0, n_s); - String lat_str(str); - return lat_str; -} - -String create_long_aprs(double lng) { - char str[20]; - char e_w = 'E'; - if (lng < 0) { - e_w = 'W'; - } - lng = std::abs(lng); - sprintf(str, "%03d%05.2f%c", (int)lng, (lng - (double)((int)lng)) * 60.0, e_w); - String lng_str(str); - return lng_str; -} diff --git a/src/Task.h b/src/Task.h index 7dd4e6d..cd4b3da 100644 --- a/src/Task.h +++ b/src/Task.h @@ -12,6 +12,7 @@ enum TaskNames TaskWifi, TaskRouter, TaskMQTT, + TaskBeacon, TaskSize }; @@ -24,5 +25,6 @@ enum TaskNames #define TASK_WIFI "WifiTask" #define TASK_ROUTER "RouterTask" #define TASK_MQTT "MQTTTask" +#define TASK_BEACON "BeaconTask" #endif diff --git a/src/TaskBeacon.cpp b/src/TaskBeacon.cpp new file mode 100644 index 0000000..43ab41c --- /dev/null +++ b/src/TaskBeacon.cpp @@ -0,0 +1,113 @@ +#include + +#include + +#include "Task.h" +#include "TaskBeacon.h" +#include "project_configuration.h" + +BeaconTask::BeaconTask(TaskQueue> &toModem, TaskQueue> &toAprsIs) : Task(TASK_BEACON, TaskBeacon), _toModem(toModem), _toAprsIs(toAprsIs), ss(1), gpsok(false) { +} + +BeaconTask::~BeaconTask() { +} + +bool BeaconTask::setup(System &system) { + gpsok = system.getUserConfig()->beacon.gps; + + // Setup GPS + if (gpsok) { + if (system.getBoardConfig()->GpsRx != 0) { + ss.begin(9600, SERIAL_8N1, system.getBoardConfig()->GpsTx, system.getBoardConfig()->GpsRx); + } else { + logPrintlnD("NO GPS found."); + gpsok = false; + } + } + // 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"); + + return true; +} + +bool BeaconTask::loop(System &system) { + + if (gpsok) { + while (ss.available() > 0) { + char c = ss.read(); + gps.encode(c); + } + } + + setBeacon(system); +} + +uint32_t diff = _beacon_timer.getTriggerTimeInSec(); +_stateInfo = "beacon " + String(uint32_t(diff / 600)) + String(uint32_t(diff / 60) % 10) + ":" + String(uint32_t(diff / 10) % 6) + String(uint32_t(diff % 10)); + +return true; +} + +String create_lat_aprs(double lat) { + char str[20]; + char n_s = 'N'; + if (lat < 0) { + n_s = 'S'; + } + lat = std::abs(lat); + sprintf(str, "%02d%05.2f%c", (int)lat, (lat - (double)((int)lat)) * 60.0, n_s); + String lat_str(str); + return lat_str; +} + +String create_long_aprs(double lng) { + char str[20]; + char e_w = 'E'; + if (lng < 0) { + e_w = 'W'; + } + lng = std::abs(lng); + sprintf(str, "%03d%05.2f%c", (int)lng, (lng - (double)((int)lng)) * 60.0, e_w); + String lng_str(str); + return lng_str; +} + +void BeaconTask::setBeacon(System &system) { + // check for beacon + if (_beacon_timer.check()) { + double lat, lng; + + if (gpsok) { + // bool gps_time_update = gps.time.isUpdated(); + bool gps_loc_update = gps.location.isUpdated(); + + if (!gps_loc_update) { + return; + } + lat = gps.location.lat(); + lng = gps.location.lng(); + } else { + lat = system.getUserConfig()->beacon.positionLatitude; + lng = system.getUserConfig()->beacon.positionLongitude; + } + _beaconMsg->getBody()->setData(String("=") + create_lat_aprs(lat) + "L" + create_long_aprs(lng) + "&" + system.getUserConfig()->beacon.message); + + logPrintD("[" + timeString() + "] "); + logPrintlnD(_beaconMsg->encode()); + + if (system.getUserConfig()->aprs_is.active) + _toAprsIs.addElement(_beaconMsg); + + if (system.getUserConfig()->digi.beacon) { + _toModem.addElement(_beaconMsg); + } + + system.getDisplay().addFrame(std::shared_ptr(new TextFrame("BEACON", _beaconMsg->toString()))); + + _beacon_timer.start(); + } +} diff --git a/src/TaskBeacon.h b/src/TaskBeacon.h new file mode 100644 index 0000000..dfa5e9a --- /dev/null +++ b/src/TaskBeacon.h @@ -0,0 +1,31 @@ +#ifndef TASK_BEACON_H_ +#define TASK_BEACON_H_ + +#include + +#include +#include +#include + +class BeaconTask : public Task { +public: + BeaconTask(TaskQueue> &toModem, TaskQueue> &toAprsIs); + virtual ~BeaconTask(); + + virtual bool setup(System &system) override; + virtual bool loop(System &system) override; + void setBeacon(System &system); + +private: + TaskQueue> &_toModem; + TaskQueue> &_toAprsIs; + + std::shared_ptr _beaconMsg; + Timer _beacon_timer; + + HardwareSerial ss; + TinyGPSPlus gps; + bool gpsok; +}; + +#endif diff --git a/src/TaskRouter.cpp b/src/TaskRouter.cpp index 2ab3cd5..26d23ab 100644 --- a/src/TaskRouter.cpp +++ b/src/TaskRouter.cpp @@ -6,9 +6,6 @@ #include "TaskRouter.h" #include "project_configuration.h" -String create_lat_aprs(double lat); -String create_long_aprs(double lng); - RouterTask::RouterTask(TaskQueue> &fromModem, TaskQueue> &toModem, TaskQueue> &toAprsIs, TaskQueue> &toMQTT) : Task(TASK_ROUTER, TaskRouter), _fromModem(fromModem), _toModem(toModem), _toAprsIs(toAprsIs), _toMQTT(toMQTT) { } @@ -16,16 +13,6 @@ 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"); - 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; } @@ -80,25 +67,7 @@ bool RouterTask::loop(System &system) { } } - // check for beacon - if (_beacon_timer.check()) { - logPrintD("[" + timeString() + "] "); - logPrintlnD(_beaconMsg->encode()); - - if (system.getUserConfig()->aprs_is.active) - _toAprsIs.addElement(_beaconMsg); - - if (system.getUserConfig()->digi.beacon) { - _toModem.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 / 600)) + String(uint32_t(diff / 60) % 10) + ":" + String(uint32_t(diff / 10) % 6) + String(uint32_t(diff % 10)); + _stateInfo = "Router done "; return true; } diff --git a/src/TaskRouter.h b/src/TaskRouter.h index 348cdff..a2e1bbe 100644 --- a/src/TaskRouter.h +++ b/src/TaskRouter.h @@ -18,9 +18,6 @@ private: TaskQueue> &_toModem; TaskQueue> &_toAprsIs; TaskQueue> &_toMQTT; - - std::shared_ptr _beaconMsg; - Timer _beacon_timer; }; #endif diff --git a/src/project_configuration.cpp b/src/project_configuration.cpp index eaf27dd..829fdc0 100644 --- a/src/project_configuration.cpp +++ b/src/project_configuration.cpp @@ -41,6 +41,7 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen 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.gps = data["beacon"]["gps"] | false; 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")) @@ -117,6 +118,7 @@ void ProjectConfigurationManagement::writeProjectConfiguration(Configuration &co data["beacon"]["message"] = conf.beacon.message; data["beacon"]["position"]["latitude"] = conf.beacon.positionLatitude; data["beacon"]["position"]["longitude"] = conf.beacon.positionLongitude; + data["beacon"]["gps"] = conf.beacon.gps; data["beacon"]["timeout"] = conf.beacon.timeout; data["aprs_is"]["active"] = conf.aprs_is.active; data["aprs_is"]["passcode"] = conf.aprs_is.passcode; diff --git a/src/project_configuration.h b/src/project_configuration.h index 854d450..d7c5f28 100644 --- a/src/project_configuration.h +++ b/src/project_configuration.h @@ -48,12 +48,13 @@ public: class Beacon { public: - Beacon() : message("LoRa iGATE & Digi, Info: github.com/peterus/LoRa_APRS_iGate"), positionLatitude(0.0), positionLongitude(0.0), timeout(15) { + Beacon() : message("LoRa iGATE & Digi, Info: github.com/peterus/LoRa_APRS_iGate"), positionLatitude(0.0), positionLongitude(0.0), gps(false), timeout(15) { } String message; double positionLatitude; double positionLongitude; + bool gps; int timeout; }; From 804a0afe05e213018c4962cabba79e3c0d352183 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Sun, 20 Mar 2022 22:00:29 +0900 Subject: [PATCH 02/37] Add TynyGPSPlus library. --- platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio.ini b/platformio.ini index e9d1555..81ddad3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -14,6 +14,7 @@ lib_deps = peterus/esp-logger @ 1.0.0 peterus/ESP-FTP-Server-Lib @ 0.9.5 knolleary/PubSubClient@^2.8 + mikalhart/TinyGPSPlus @ 1.0.2 check_tool = cppcheck check_flags = cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK --force lib -ilib/TimeLib -ilib/LoRa -ilib/NTPClient From d0deb99668e917117fd5642e8a4dff1db85ab46b Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Sun, 20 Mar 2022 22:08:20 +0900 Subject: [PATCH 03/37] Change logger and correct corrupt source. --- src/TaskBeacon.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/TaskBeacon.cpp b/src/TaskBeacon.cpp index 43ab41c..5e48d72 100644 --- a/src/TaskBeacon.cpp +++ b/src/TaskBeacon.cpp @@ -20,7 +20,7 @@ bool BeaconTask::setup(System &system) { if (system.getBoardConfig()->GpsRx != 0) { ss.begin(9600, SERIAL_8N1, system.getBoardConfig()->GpsTx, system.getBoardConfig()->GpsRx); } else { - logPrintlnD("NO GPS found."); + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "NO GPS found."); gpsok = false; } } @@ -44,12 +44,11 @@ bool BeaconTask::loop(System &system) { } setBeacon(system); -} -uint32_t diff = _beacon_timer.getTriggerTimeInSec(); -_stateInfo = "beacon " + String(uint32_t(diff / 600)) + String(uint32_t(diff / 60) % 10) + ":" + String(uint32_t(diff / 10) % 6) + String(uint32_t(diff % 10)); + uint32_t diff = _beacon_timer.getTriggerTimeInSec(); + _stateInfo = "beacon " + String(uint32_t(diff / 600)) + String(uint32_t(diff / 60) % 10) + ":" + String(uint32_t(diff / 10) % 6) + String(uint32_t(diff % 10)); -return true; + return true; } String create_lat_aprs(double lat) { @@ -96,8 +95,7 @@ void BeaconTask::setBeacon(System &system) { } _beaconMsg->getBody()->setData(String("=") + create_lat_aprs(lat) + "L" + create_long_aprs(lng) + "&" + system.getUserConfig()->beacon.message); - logPrintD("[" + timeString() + "] "); - logPrintlnD(_beaconMsg->encode()); + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "[%s]%s", timeString(), _beaconMsg->encode()); if (system.getUserConfig()->aprs_is.active) _toAprsIs.addElement(_beaconMsg); From 2ce81ed3f2fabc490ce662b0f48113b14abd6e98 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Mon, 21 Mar 2022 08:28:06 +0900 Subject: [PATCH 04/37] Debug for using logger. --- src/TaskBeacon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TaskBeacon.cpp b/src/TaskBeacon.cpp index 5e48d72..6f187e9 100644 --- a/src/TaskBeacon.cpp +++ b/src/TaskBeacon.cpp @@ -95,7 +95,7 @@ void BeaconTask::setBeacon(System &system) { } _beaconMsg->getBody()->setData(String("=") + create_lat_aprs(lat) + "L" + create_long_aprs(lng) + "&" + system.getUserConfig()->beacon.message); - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "[%s]%s", timeString(), _beaconMsg->encode()); + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "[%s]%s", timeString().c_str(), _beaconMsg->encode().c_str()); if (system.getUserConfig()->aprs_is.active) _toAprsIs.addElement(_beaconMsg); From bef3062c658a16e95f79c829547ad2e4a661e905 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Mon, 21 Mar 2022 08:39:40 +0900 Subject: [PATCH 05/37] Clean source. --- src/TaskBeacon.cpp | 55 +++++++++++++++++++++++----------------------- src/TaskBeacon.h | 2 +- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/TaskBeacon.cpp b/src/TaskBeacon.cpp index 6f187e9..8f9d3a9 100644 --- a/src/TaskBeacon.cpp +++ b/src/TaskBeacon.cpp @@ -43,7 +43,12 @@ bool BeaconTask::loop(System &system) { } } - setBeacon(system); + // check for beacon + if (_beacon_timer.check()) { + if setBeacon (system) { + _beacon_timer.start(); + } + } uint32_t diff = _beacon_timer.getTriggerTimeInSec(); _stateInfo = "beacon " + String(uint32_t(diff / 600)) + String(uint32_t(diff / 60) % 10) + ":" + String(uint32_t(diff / 10) % 6) + String(uint32_t(diff % 10)); @@ -75,37 +80,33 @@ String create_long_aprs(double lng) { return lng_str; } -void BeaconTask::setBeacon(System &system) { - // check for beacon - if (_beacon_timer.check()) { - double lat, lng; +bool BeaconTask::setBeacon(System &system) { - if (gpsok) { - // bool gps_time_update = gps.time.isUpdated(); - bool gps_loc_update = gps.location.isUpdated(); + double lat, lng; - if (!gps_loc_update) { - return; - } + if (gpsok) { + if (gps.location.isUpdated()) { lat = gps.location.lat(); lng = gps.location.lng(); } else { - lat = system.getUserConfig()->beacon.positionLatitude; - lng = system.getUserConfig()->beacon.positionLongitude; + return false; } - _beaconMsg->getBody()->setData(String("=") + create_lat_aprs(lat) + "L" + create_long_aprs(lng) + "&" + system.getUserConfig()->beacon.message); - - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "[%s]%s", timeString().c_str(), _beaconMsg->encode().c_str()); - - if (system.getUserConfig()->aprs_is.active) - _toAprsIs.addElement(_beaconMsg); - - if (system.getUserConfig()->digi.beacon) { - _toModem.addElement(_beaconMsg); - } - - system.getDisplay().addFrame(std::shared_ptr(new TextFrame("BEACON", _beaconMsg->toString()))); - - _beacon_timer.start(); + } else { + lat = system.getUserConfig()->beacon.positionLatitude; + lng = system.getUserConfig()->beacon.positionLongitude; } + _beaconMsg->getBody()->setData(String("=") + create_lat_aprs(lat) + "L" + create_long_aprs(lng) + "&" + system.getUserConfig()->beacon.message); + + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "[%s]%s", timeString().c_str(), _beaconMsg->encode().c_str()); + + if (system.getUserConfig()->aprs_is.active) + _toAprsIs.addElement(_beaconMsg); + + if (system.getUserConfig()->digi.beacon) { + _toModem.addElement(_beaconMsg); + } + + system.getDisplay().addFrame(std::shared_ptr(new TextFrame("BEACON", _beaconMsg->toString()))); + + return true; } diff --git a/src/TaskBeacon.h b/src/TaskBeacon.h index dfa5e9a..c23ca07 100644 --- a/src/TaskBeacon.h +++ b/src/TaskBeacon.h @@ -14,7 +14,7 @@ public: virtual bool setup(System &system) override; virtual bool loop(System &system) override; - void setBeacon(System &system); + bool setBeacon(System &system); private: TaskQueue> &_toModem; From 2758b2c4be5e2fd679646c7c2a6ebe273310b7a5 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Mon, 21 Mar 2022 14:20:29 +0900 Subject: [PATCH 06/37] Wrong syntax. --- src/TaskBeacon.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/TaskBeacon.cpp b/src/TaskBeacon.cpp index 8f9d3a9..574b299 100644 --- a/src/TaskBeacon.cpp +++ b/src/TaskBeacon.cpp @@ -44,8 +44,7 @@ bool BeaconTask::loop(System &system) { } // check for beacon - if (_beacon_timer.check()) { - if setBeacon (system) { + if (setBeacon(system)) { _beacon_timer.start(); } } From c4496274e726518604b9f88bedb24b3513545d2a Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Mon, 21 Mar 2022 14:22:43 +0900 Subject: [PATCH 07/37] Correct if block. --- src/TaskBeacon.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TaskBeacon.cpp b/src/TaskBeacon.cpp index 574b299..7fdf265 100644 --- a/src/TaskBeacon.cpp +++ b/src/TaskBeacon.cpp @@ -44,6 +44,7 @@ bool BeaconTask::loop(System &system) { } // check for beacon + if (_beacon_timer.check()) { if (setBeacon(system)) { _beacon_timer.start(); } From fb83b79081c22015c269f9ea62fc022f4a155e12 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Mon, 21 Mar 2022 14:26:46 +0900 Subject: [PATCH 08/37] Change version. --- 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 92bd27a..48a7e73 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "22.11.2" +#define VERSION "22.12.0" #define MODULE_NAME "Main" String create_lat_aprs(double lat); From b9ae54de45860829639c6747e5f75b19a3e393d5 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sat, 26 Mar 2022 22:27:43 +0100 Subject: [PATCH 09/37] update gps function --- data/is-cfg.json | 2 +- src/LoRa_APRS_iGate.cpp | 2 +- src/TaskBeacon.cpp | 44 ++++++++++++++++------------------- src/TaskBeacon.h | 8 +++---- src/project_configuration.cpp | 4 ++-- src/project_configuration.h | 4 ++-- 6 files changed, 30 insertions(+), 34 deletions(-) diff --git a/data/is-cfg.json b/data/is-cfg.json index 37e449b..47d6f65 100644 --- a/data/is-cfg.json +++ b/data/is-cfg.json @@ -29,7 +29,7 @@ "latitude": 0.000000, "longitude": 0.000000 }, - "gps": true, + "use_gps": false, "timeout": 15 }, "aprs_is": { diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 48a7e73..2043e7d 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -95,7 +95,7 @@ void setup() { } powerManagement.activateLoRa(); powerManagement.activateOLED(); - if (userConfig.beacon.gps) { + if (userConfig.beacon.use_gps) { powerManagement.activateGPS(); } else { powerManagement.deactivateGPS(); diff --git a/src/TaskBeacon.cpp b/src/TaskBeacon.cpp index 7fdf265..50025e2 100644 --- a/src/TaskBeacon.cpp +++ b/src/TaskBeacon.cpp @@ -6,22 +6,21 @@ #include "TaskBeacon.h" #include "project_configuration.h" -BeaconTask::BeaconTask(TaskQueue> &toModem, TaskQueue> &toAprsIs) : Task(TASK_BEACON, TaskBeacon), _toModem(toModem), _toAprsIs(toAprsIs), ss(1), gpsok(false) { +BeaconTask::BeaconTask(TaskQueue> &toModem, TaskQueue> &toAprsIs) : Task(TASK_BEACON, TaskBeacon), _toModem(toModem), _toAprsIs(toAprsIs), _ss(1), _useGps(false) { } BeaconTask::~BeaconTask() { } bool BeaconTask::setup(System &system) { - gpsok = system.getUserConfig()->beacon.gps; + _useGps = system.getUserConfig()->beacon.use_gps; - // Setup GPS - if (gpsok) { + if (_useGps) { if (system.getBoardConfig()->GpsRx != 0) { - ss.begin(9600, SERIAL_8N1, system.getBoardConfig()->GpsTx, system.getBoardConfig()->GpsRx); + _ss.begin(9600, SERIAL_8N1, system.getBoardConfig()->GpsTx, system.getBoardConfig()->GpsRx); } else { system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "NO GPS found."); - gpsok = false; + _useGps = false; } } // setup beacon @@ -35,17 +34,16 @@ bool BeaconTask::setup(System &system) { } bool BeaconTask::loop(System &system) { - - if (gpsok) { - while (ss.available() > 0) { - char c = ss.read(); - gps.encode(c); + if (_useGps) { + while (_ss.available() > 0) { + char c = _ss.read(); + _gps.encode(c); } } // check for beacon if (_beacon_timer.check()) { - if (setBeacon(system)) { + if (sendBeacon(system)) { _beacon_timer.start(); } } @@ -80,27 +78,25 @@ String create_long_aprs(double lng) { return lng_str; } -bool BeaconTask::setBeacon(System &system) { +bool BeaconTask::sendBeacon(System &system) { + double lat = system.getUserConfig()->beacon.positionLatitude; + double lng = system.getUserConfig()->beacon.positionLongitude; - double lat, lng; - - if (gpsok) { - if (gps.location.isUpdated()) { - lat = gps.location.lat(); - lng = gps.location.lng(); + if (_useGps) { + if (_gps.location.isUpdated()) { + lat = _gps.location.lat(); + lng = _gps.location.lng(); } else { return false; } - } else { - lat = system.getUserConfig()->beacon.positionLatitude; - lng = system.getUserConfig()->beacon.positionLongitude; } _beaconMsg->getBody()->setData(String("=") + create_lat_aprs(lat) + "L" + create_long_aprs(lng) + "&" + system.getUserConfig()->beacon.message); - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "[%s]%s", timeString().c_str(), _beaconMsg->encode().c_str()); + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "[%s] %s", timeString().c_str(), _beaconMsg->encode().c_str()); - if (system.getUserConfig()->aprs_is.active) + if (system.getUserConfig()->aprs_is.active) { _toAprsIs.addElement(_beaconMsg); + } if (system.getUserConfig()->digi.beacon) { _toModem.addElement(_beaconMsg); diff --git a/src/TaskBeacon.h b/src/TaskBeacon.h index c23ca07..9927dd6 100644 --- a/src/TaskBeacon.h +++ b/src/TaskBeacon.h @@ -14,7 +14,7 @@ public: virtual bool setup(System &system) override; virtual bool loop(System &system) override; - bool setBeacon(System &system); + bool sendBeacon(System &system); private: TaskQueue> &_toModem; @@ -23,9 +23,9 @@ private: std::shared_ptr _beaconMsg; Timer _beacon_timer; - HardwareSerial ss; - TinyGPSPlus gps; - bool gpsok; + HardwareSerial _ss; + TinyGPSPlus _gps; + bool _useGps; }; #endif diff --git a/src/project_configuration.cpp b/src/project_configuration.cpp index 231fe03..680f2c0 100644 --- a/src/project_configuration.cpp +++ b/src/project_configuration.cpp @@ -41,7 +41,7 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen 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.gps = data["beacon"]["gps"] | false; + conf.beacon.use_gps = data["beacon"]["use_gps"] | false; 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")) @@ -123,7 +123,7 @@ void ProjectConfigurationManagement::writeProjectConfiguration(Configuration &co data["beacon"]["message"] = conf.beacon.message; data["beacon"]["position"]["latitude"] = conf.beacon.positionLatitude; data["beacon"]["position"]["longitude"] = conf.beacon.positionLongitude; - data["beacon"]["gps"] = conf.beacon.gps; + data["beacon"]["use_gps"] = conf.beacon.use_gps; data["beacon"]["timeout"] = conf.beacon.timeout; data["aprs_is"]["active"] = conf.aprs_is.active; data["aprs_is"]["passcode"] = conf.aprs_is.passcode; diff --git a/src/project_configuration.h b/src/project_configuration.h index f38974e..8a626c6 100644 --- a/src/project_configuration.h +++ b/src/project_configuration.h @@ -48,13 +48,13 @@ public: class Beacon { public: - Beacon() : message("LoRa iGATE & Digi, Info: github.com/peterus/LoRa_APRS_iGate"), positionLatitude(0.0), positionLongitude(0.0), gps(false), timeout(15) { + Beacon() : message("LoRa iGATE & Digi, Info: github.com/peterus/LoRa_APRS_iGate"), positionLatitude(0.0), positionLongitude(0.0), use_gps(false), timeout(15) { } String message; double positionLatitude; double positionLongitude; - bool gps; + bool use_gps; int timeout; }; From bcbd174512ec45acd0b7708862415be24ce1b26b Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sat, 26 Mar 2022 23:26:42 +0100 Subject: [PATCH 10/37] update build action --- .github/workflows/build_check.yml | 6 ++++- .github/workflows/release.yml | 45 +++++++++---------------------- scripts/create_version_tag.py | 21 +++++++++++++++ 3 files changed, 38 insertions(+), 34 deletions(-) create mode 100755 scripts/create_version_tag.py diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 3694829..efa3945 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -1,6 +1,10 @@ name: Integreation Tests -on: [push, pull_request] +on: + push: + branches: + - '*' + - '!master' jobs: version_check: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1ccc28a..a1e50e4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,46 +1,25 @@ +name: Upload Release Assets + on: push: - tags: - - 'v*' - -name: Upload Release Assets + branches: + - 'master' jobs: build: name: Upload Release Assets runs-on: ubuntu-latest steps: + - uses: actions/checkout@v2 - run: sudo apt-get install python3-setuptools python3-wheel - run: pip3 install platformio - run: echo "$HOME/.local/bin" >> $GITHUB_PATH - - uses: actions/checkout@v2 - with: - submodules: 'recursive' - run: platformio run - - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - run: echo "VERSION=$(echo ./scripts/create_version_tag.py)" >> $GITHUB_ENV + - uses: ncipollo/release-action@v1 with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: false - prerelease: false - # upload firmware bin - - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: .pio/build/lora_board/firmware.bin - asset_name: lora_board.bin - asset_content_type: application/bin - # upload json file - - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: data/is-cfg.json - asset_name: is-cfg.json - asset_content_type: application/json \ No newline at end of file + tag: ${{ env.VERSION }} + commit: Release ${{ env.VERSION }} + generateReleaseNotes: true + artifacts: ".pio/build/lora_board/firmware.bin,data/is-cfg.json" + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/create_version_tag.py b/scripts/create_version_tag.py new file mode 100755 index 0000000..5b37c82 --- /dev/null +++ b/scripts/create_version_tag.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +from datetime import date + +today = date.today() + +current_year = int(str(today.isocalendar()[0])[2:]) +current_week = int(today.isocalendar()[1]) + +version = None +with open("src/LoRa_APRS_iGate.cpp") as f: + for line in f: + if line.startswith("#define VERSION"): + version = line.strip().split(" ")[-1].replace('"', "") + +version_split = version.split(".") +version_year = int(version_split[0]) +version_week = int(version_split[1]) +version_vers = int(version_split[2]) + +print(f"v{version_year}.{version_week}.{version_vers}") From bf4055339806431044f020a10ce7a8486d53a3df Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sat, 26 Mar 2022 23:34:01 +0100 Subject: [PATCH 11/37] update relase script --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a1e50e4..6521fcb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Upload Release Assets +name: Create new release on: push: @@ -7,7 +7,7 @@ on: jobs: build: - name: Upload Release Assets + name: Create new release runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -15,7 +15,7 @@ jobs: - run: pip3 install platformio - run: echo "$HOME/.local/bin" >> $GITHUB_PATH - run: platformio run - - run: echo "VERSION=$(echo ./scripts/create_version_tag.py)" >> $GITHUB_ENV + - run: echo "VERSION=$(./scripts/create_version_tag.py)" >> $GITHUB_ENV - uses: ncipollo/release-action@v1 with: tag: ${{ env.VERSION }} From 296a6f1c2cc64bff540a77167211a2f665042b58 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sat, 26 Mar 2022 23:55:35 +0100 Subject: [PATCH 12/37] set commit to master --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6521fcb..5ba6a87 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: - uses: ncipollo/release-action@v1 with: tag: ${{ env.VERSION }} - commit: Release ${{ env.VERSION }} + commit: master generateReleaseNotes: true artifacts: ".pio/build/lora_board/firmware.bin,data/is-cfg.json" token: ${{ secrets.GITHUB_TOKEN }} From fba322a0d53993be71ee27e3ba9567753e3304c7 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Sun, 27 Mar 2022 09:02:14 +0900 Subject: [PATCH 13/37] Push button to send beacon immediately. --- lib/BoardFinder/BoardFinder.cpp | 20 ++++++++++---------- lib/BoardFinder/BoardFinder.h | 3 ++- platformio.ini | 1 + src/TaskBeacon.cpp | 20 +++++++++++++++++++- src/TaskBeacon.h | 6 ++++++ 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/lib/BoardFinder/BoardFinder.cpp b/lib/BoardFinder/BoardFinder.cpp index 8a39ae6..833008e 100644 --- a/lib/BoardFinder/BoardFinder.cpp +++ b/lib/BoardFinder/BoardFinder.cpp @@ -4,8 +4,8 @@ #define MODULE_NAME "BoardFinder" -BoardConfig::BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t oledscl, uint8_t oledaddr, uint8_t oledreset, uint8_t lorasck, uint8_t loramiso, uint8_t loramosi, uint8_t loracs, uint8_t lorareset, uint8_t lorairq, uint8_t gpsrx, uint8_t gpstx, bool needcheckpowerchip, bool powercheckstatus) - : Name(name), Type(type), OledSda(oledsda), OledScl(oledscl), OledAddr(oledaddr), OledReset(oledreset), LoraSck(lorasck), LoraMiso(loramiso), LoraMosi(loramosi), LoraCS(loracs), LoraReset(lorareset), LoraIRQ(lorairq), GpsRx(gpsrx), GpsTx(gpstx), needCheckPowerChip(needcheckpowerchip), powerCheckStatus(powercheckstatus) { +BoardConfig::BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t oledscl, uint8_t oledaddr, uint8_t oledreset, uint8_t lorasck, uint8_t loramiso, uint8_t loramosi, uint8_t loracs, uint8_t lorareset, uint8_t lorairq, uint8_t gpsrx, uint8_t gpstx, uint8_t button, bool needcheckpowerchip, bool powercheckstatus) + : Name(name), Type(type), OledSda(oledsda), OledScl(oledscl), OledAddr(oledaddr), OledReset(oledreset), LoraSck(lorasck), LoraMiso(loramiso), LoraMosi(loramosi), LoraCS(loracs), LoraReset(lorareset), LoraIRQ(lorairq), GpsRx(gpsrx), GpsTx(gpstx), Button(button), needCheckPowerChip(needcheckpowerchip), powerCheckStatus(powercheckstatus) { } BoardFinder::BoardFinder(const std::list &boardConfigs) : _boardConfigs(boardConfigs) { @@ -130,12 +130,12 @@ bool BoardFinder::checkPowerConfig(BoardConfig const *boardConfig, logging::Logg } // clang-format off -BoardConfig TTGO_LORA32_V1 ("TTGO_LORA32_V1", eTTGO_LORA32_V1, 4, 15, 0x3C, 0, 5, 19, 27, 18, 14, 26, 0, 0); -BoardConfig TTGO_LORA32_V2 ("TTGO_LORA32_V2", eTTGO_LORA32_V2, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, 0, 0, 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, 15, 12, 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, 12, 34, true, true); -BoardConfig ETH_BOARD ("ETH_BOARD", eETH_BOARD, 33, 32, 0x3C, 0, 14, 2, 15, 12, 4, 36, 0, 0); -BoardConfig TRACKERD ("TRACKERD", eTRACKERD, 5, 4, 0x3C, 0, 18, 19, 23, 16, 14, 26, 0, 0); -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, 0, 0); -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, 0, 0); +BoardConfig TTGO_LORA32_V1 ("TTGO_LORA32_V1", eTTGO_LORA32_V1, 4, 15, 0x3C, 0, 5, 19, 27, 18, 14, 26, 0, 0, 0); +BoardConfig TTGO_LORA32_V2 ("TTGO_LORA32_V2", eTTGO_LORA32_V2, 21, 22, 0x3C, 0, 5, 19, 27, 18, 14, 26, 0, 0, 0, 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, 15, 12, 38, 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, 12, 34, 38, true, true); +BoardConfig ETH_BOARD ("ETH_BOARD", eETH_BOARD, 33, 32, 0x3C, 0, 14, 2, 15, 12, 4, 36, 0, 0, 0); +BoardConfig TRACKERD ("TRACKERD", eTRACKERD, 5, 4, 0x3C, 0, 18, 19, 23, 16, 14, 26, 0, 0, 0); +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, 0, 0, 0); +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, 0, 0, 0); // clang-format on diff --git a/lib/BoardFinder/BoardFinder.h b/lib/BoardFinder/BoardFinder.h index c833fab..73b5ff9 100644 --- a/lib/BoardFinder/BoardFinder.h +++ b/lib/BoardFinder/BoardFinder.h @@ -24,7 +24,7 @@ enum BoardType class BoardConfig { public: - explicit BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t oledscl, uint8_t oledaddr, uint8_t oledreset, uint8_t lorasck, uint8_t loramiso, uint8_t loramosi, uint8_t loracs, uint8_t lorareset, uint8_t lorairq, uint8_t gpsrx, uint8_t gpstx, bool needcheckpowerchip = false, bool powercheckstatus = false); + explicit BoardConfig(String name, BoardType type, uint8_t oledsda, uint8_t oledscl, uint8_t oledaddr, uint8_t oledreset, uint8_t lorasck, uint8_t loramiso, uint8_t loramosi, uint8_t loracs, uint8_t lorareset, uint8_t lorairq, uint8_t gpsrx, uint8_t gpstx, uint8_t button, bool needcheckpowerchip = false, bool powercheckstatus = false); String Name; BoardType Type; @@ -42,6 +42,7 @@ public: uint8_t LoraIRQ; uint8_t GpsRx; uint8_t GpsTx; + uint8_t Button; bool needCheckPowerChip; bool powerCheckStatus; diff --git a/platformio.ini b/platformio.ini index 81ddad3..a2f5cb3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,6 +15,7 @@ lib_deps = peterus/ESP-FTP-Server-Lib @ 0.9.5 knolleary/PubSubClient@^2.8 mikalhart/TinyGPSPlus @ 1.0.2 + shaggydog/OneButton @ 1.5.0 check_tool = cppcheck check_flags = cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK --force lib -ilib/TimeLib -ilib/LoRa -ilib/NTPClient diff --git a/src/TaskBeacon.cpp b/src/TaskBeacon.cpp index 50025e2..e356920 100644 --- a/src/TaskBeacon.cpp +++ b/src/TaskBeacon.cpp @@ -1,5 +1,6 @@ #include +#include #include #include "Task.h" @@ -12,7 +13,21 @@ BeaconTask::BeaconTask(TaskQueue> &toModem, TaskQue BeaconTask::~BeaconTask() { } +OneButton BeaconTask::_userButton; +bool BeaconTask::_send_update; +uint BeaconTask::_instances; + +void BeaconTask::pushButton() { + _send_update = true; +} + bool BeaconTask::setup(System &system) { + if (_instances++ == 0 && system.getBoardConfig()->Button > 0) { + _userButton = OneButton(system.getBoardConfig()->Button, true, true); + _userButton.attachClick(pushButton); + _send_update = false; + } + _useGps = system.getUserConfig()->beacon.use_gps; if (_useGps) { @@ -41,9 +56,12 @@ bool BeaconTask::loop(System &system) { } } + _userButton.tick(); + // check for beacon - if (_beacon_timer.check()) { + if (_beacon_timer.check() || _send_update) { if (sendBeacon(system)) { + _send_update = false; _beacon_timer.start(); } } diff --git a/src/TaskBeacon.h b/src/TaskBeacon.h index 9927dd6..ba0ff22 100644 --- a/src/TaskBeacon.h +++ b/src/TaskBeacon.h @@ -1,6 +1,7 @@ #ifndef TASK_BEACON_H_ #define TASK_BEACON_H_ +#include #include #include @@ -26,6 +27,11 @@ private: HardwareSerial _ss; TinyGPSPlus _gps; bool _useGps; + + static uint _instances; + static OneButton _userButton; + static bool _send_update; + static void pushButton(); }; #endif From 21d3ba67e4a1d2c76aba777017c390cdc04bd466 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 27 Mar 2022 01:14:22 +0100 Subject: [PATCH 14/37] version check update --- .github/workflows/build_check.yml | 1 + scripts/check_version.py | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index efa3945..1c8b2b6 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -15,6 +15,7 @@ jobs: uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 + - run: pip install GitPython - name: check version run: ./scripts/check_version.py diff --git a/scripts/check_version.py b/scripts/check_version.py index df9914f..5fc3f93 100755 --- a/scripts/check_version.py +++ b/scripts/check_version.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import git from datetime import date today = date.today() @@ -16,20 +17,32 @@ with open("src/LoRa_APRS_iGate.cpp") as f: version_split = version.split(".") version_year = int(version_split[0]) version_week = int(version_split[1]) +version_vers = int(version_split[2]) -print(f"firmware version year: {version_year}") -print(f"firmware version week: {version_week}") +print(f"[INFO] firmware version year: {version_year}") +print(f"[INFO] firmware version week: {version_week}") +print(f"[INFO] firmware version version: {version_vers}") +print(f"[INFO] -> {version}") -print(f"current year: {current_year}") -print(f"current week: {current_week}") +print(f"[INFO] current year: {current_year}") +print(f"[INFO] current week: {current_week}") +print(f"[INFO] -> {current_year}.{current_week}.x") error = False if version_year != current_year: - print("firmware version is not current year!") + print("[ERROR] firmware version is not current year!") error = True if version_week != current_week: - print("firmware version is not current week!") + print("[ERROR] firmware version is not current week!") error = True +repo = git.Repo('.') +if f"v{version}" in repo.tags: + print("[ERROR] tag with this version is already existing") + error = True + +if error: + print("[ERROR] check/update VERSION define in src/LoRa_APRS_iGate.cpp to fix this issue") + exit(error) From 30f69bd0392e052f98b37f8e9a97dd0ac4f5a3cb Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 27 Mar 2022 01:20:04 +0100 Subject: [PATCH 15/37] version check update --- scripts/check_version.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/check_version.py b/scripts/check_version.py index 5fc3f93..57f87ea 100755 --- a/scripts/check_version.py +++ b/scripts/check_version.py @@ -38,6 +38,7 @@ if version_week != current_week: error = True repo = git.Repo('.') +print(f"[INFO] found {len(repo.tags)} tags in repo") if f"v{version}" in repo.tags: print("[ERROR] tag with this version is already existing") error = True From 6c052d71363da52038aefead780139fdacc5943d Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 27 Mar 2022 01:24:28 +0100 Subject: [PATCH 16/37] get all tags --- .github/workflows/build_check.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 1c8b2b6..65b055c 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -13,6 +13,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v2 - run: pip install GitPython From 44e4f8ec4119c3c0cef85c268362d12eb961c724 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 27 Mar 2022 01:28:33 +0100 Subject: [PATCH 17/37] 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 2043e7d..de4cc71 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "22.12.0" +#define VERSION "22.12.1" #define MODULE_NAME "Main" String create_lat_aprs(double lat); From 593703b57aeb1e6d7320aa825adbae8a407af357 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 27 Mar 2022 01:47:54 +0100 Subject: [PATCH 18/37] fix github action (jobs not running) --- .github/workflows/build_check.yml | 3 +++ src/LoRa_APRS_iGate.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 65b055c..7686833 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -5,6 +5,9 @@ on: branches: - '*' - '!master' + pull_request: + branches: + - master jobs: version_check: diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index de4cc71..62355c9 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "22.12.1" +#define VERSION "22.12.2" #define MODULE_NAME "Main" String create_lat_aprs(double lat); From d8d0a0a2827b908d5ea72ccb35a13f437f171d20 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Sun, 27 Mar 2022 10:02:37 +0900 Subject: [PATCH 19/37] syslog doesn't work properly if aprs_is is false. --- src/LoRa_APRS_iGate.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 62355c9..b3cbeef 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -109,23 +109,30 @@ void setup() { LoRaSystem.getTaskManager().addTask(&routerTask); LoRaSystem.getTaskManager().addTask(&beaconTask); - if (userConfig.aprs_is.active) { - if (boardConfig->Type == eETH_BOARD && !userConfig.wifi.active) { - LoRaSystem.getTaskManager().addAlwaysRunTask(ðTask); - } - if (userConfig.wifi.active) { - LoRaSystem.getTaskManager().addAlwaysRunTask(&wifiTask); - } + bool tcpip = false; + + if (userConfig.wifi.active) { + LoRaSystem.getTaskManager().addAlwaysRunTask(&wifiTask); LoRaSystem.getTaskManager().addTask(&otaTask); + tcpip = true; + } else if (boardConfig->Type == eETH_BOARD) { + LoRaSystem.getTaskManager().addAlwaysRunTask(ðTask); + tcpip = true; + } + + if (tcpip) { LoRaSystem.getTaskManager().addTask(&ntpTask); if (userConfig.ftp.active) { LoRaSystem.getTaskManager().addTask(&ftpTask); } - LoRaSystem.getTaskManager().addTask(&aprsIsTask); - } - if (userConfig.mqtt.active) { - LoRaSystem.getTaskManager().addTask(&mqttTask); + if (userConfig.aprs_is.active) { + LoRaSystem.getTaskManager().addTask(&aprsIsTask); + } + + if (userConfig.mqtt.active) { + LoRaSystem.getTaskManager().addTask(&mqttTask); + } } LoRaSystem.getTaskManager().setup(LoRaSystem); From 8277fd228e2bd12a22ddc6e9ee7172ad09979537 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Sun, 27 Mar 2022 10:05:25 +0900 Subject: [PATCH 20/37] Change VERSION. --- 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 b3cbeef..b839e47 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "22.12.2" +#define VERSION "22.12.3" #define MODULE_NAME "Main" String create_lat_aprs(double lat); From 8652ecc0dec6a4188c44058374723e43e2544631 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 27 Mar 2022 12:56:51 +0200 Subject: [PATCH 21/37] tweet release --- .github/workflows/tweet_release.yml | 19 +++++++++++++++++++ src/LoRa_APRS_iGate.cpp | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tweet_release.yml diff --git a/.github/workflows/tweet_release.yml b/.github/workflows/tweet_release.yml new file mode 100644 index 0000000..462b2bc --- /dev/null +++ b/.github/workflows/tweet_release.yml @@ -0,0 +1,19 @@ +name: tweet-release + +on: + release: + types: [published] + +jobs: + tweet: + runs-on: ubuntu-latest + steps: + - uses: Eomm/why-don-t-you-tweet@v1 + if: ${{ !github.event.repository.private }} + with: + tweet-message: "New ${{ github.event.repository.name }} release ${{ github.event.release.tag_name }}! ${{ github.event.release.html_url }} #LoRa #APRS #HAM #hamradio #iGate" + env: + TWITTER_CONSUMER_API_KEY: ${{ secrets.TWITTER_CONSUMER_API_KEY }} + TWITTER_CONSUMER_API_SECRET: ${{ secrets.TWITTER_CONSUMER_API_SECRET }} + TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} + TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index b839e47..14637e2 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "22.12.3" +#define VERSION "22.12.4" #define MODULE_NAME "Main" String create_lat_aprs(double lat); From f31781cf751d2fb075b36f39aa319e8d0a73adf7 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Mon, 28 Mar 2022 10:15:37 +0900 Subject: [PATCH 22/37] Collision avoidance. --- lib/LoRa/LoRa.cpp | 5 +++++ lib/LoRa/LoRa.h | 1 + src/TaskModem.cpp | 17 +++++++++++------ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/LoRa/LoRa.cpp b/lib/LoRa/LoRa.cpp index 35dfacd..2422ca8 100644 --- a/lib/LoRa/LoRa.cpp +++ b/lib/LoRa/LoRa.cpp @@ -18,6 +18,7 @@ #define REG_FIFO_RX_CURRENT_ADDR 0x10 #define REG_IRQ_FLAGS 0x12 #define REG_RX_NB_BYTES 0x13 +#define REG_MODEM_STAT 0x18 #define REG_PKT_SNR_VALUE 0x19 #define REG_PKT_RSSI_VALUE 0x1a #define REG_RSSI_VALUE 0x1b @@ -251,6 +252,10 @@ float LoRaClass::packetSnr() { return ((int8_t)readRegister(REG_PKT_SNR_VALUE)) * 0.25; } +bool LoRaClass::rxSignalDetected() { + return (readRegister(REG_MODEM_STAT) & 0x01) == 0x01; +} + long LoRaClass::packetFrequencyError() { int32_t freqError = 0; freqError = static_cast(readRegister(REG_FREQ_ERROR_MSB) & B111); diff --git a/lib/LoRa/LoRa.h b/lib/LoRa/LoRa.h index 51e089a..45c92bd 100644 --- a/lib/LoRa/LoRa.h +++ b/lib/LoRa/LoRa.h @@ -44,6 +44,7 @@ public: int packetRssi(); float packetSnr(); long packetFrequencyError(); + bool rxSignalDetected(); int rssi(); diff --git a/src/TaskModem.cpp b/src/TaskModem.cpp index ca0784d..017b2b2 100644 --- a/src/TaskModem.cpp +++ b/src/TaskModem.cpp @@ -45,13 +45,18 @@ bool ModemTask::loop(System &system) { } if (!_toModem.empty()) { - std::shared_ptr msg = _toModem.getElement(); - if (system.getUserConfig()->lora.tx_enable) { - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Transmitting packet '%s'", timeString().c_str(), msg->toString().c_str()); - _lora_aprs.sendMessage(msg); - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] TX done", timeString().c_str()); + if (_lora_aprs.rxSignalDetected()) { + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] RX signal detected. Waiting TX", timeString().c_str()); + delay(1000); } else { - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] NOT transmitting packet as TX is not enabled '%s'", timeString().c_str(), msg->toString().c_str()); + std::shared_ptr msg = _toModem.getElement(); + if (system.getUserConfig()->lora.tx_enable) { + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Transmitting packet '%s'", timeString().c_str(), msg->toString().c_str()); + _lora_aprs.sendMessage(msg); + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] TX done", timeString().c_str()); + } else { + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] NOT transmitting packet as TX is not enabled '%s'", timeString().c_str(), msg->toString().c_str()); + } } } From c48636757f22a17f8d8f74f1618e56d63ec3e9ab Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Mon, 28 Mar 2022 11:09:19 +0900 Subject: [PATCH 23/37] Update version. --- 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 14637e2..30040e6 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "22.12.4" +#define VERSION "22.12.5" #define MODULE_NAME "Main" String create_lat_aprs(double lat); From 6c43f70c4e691434cb70f06fc67a5c1327a1a6aa Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Mon, 28 Mar 2022 11:21:00 +0900 Subject: [PATCH 24/37] Change next week version. --- 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 30040e6..77f0dcc 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "22.12.5" +#define VERSION "22.13.0" #define MODULE_NAME "Main" String create_lat_aprs(double lat); From aeef66a3388f87a4541317aee195040bad4d6808 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Mon, 28 Mar 2022 20:16:06 +0200 Subject: [PATCH 25/37] fixing missing string in config --- src/project_configuration.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/project_configuration.cpp b/src/project_configuration.cpp index 680f2c0..80aaa11 100644 --- a/src/project_configuration.cpp +++ b/src/project_configuration.cpp @@ -89,8 +89,10 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen } if (data.containsKey("syslog")) { conf.syslog.active = data["syslog"]["active"] | true; - conf.syslog.server = data["syslog"]["server"].as(); - conf.syslog.port = data["syslog"]["port"] | 514; + if (data["syslog"].containsKey("server")) { + conf.syslog.server = data["syslog"]["server"].as(); + } + conf.syslog.port = data["syslog"]["port"] | 514; } if (data.containsKey("ntp_server")) conf.ntpServer = data["ntp_server"].as(); From 8e86f868cd737c21d5d7e933e053d677463b7c3a Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Mon, 28 Mar 2022 20:26:42 +0200 Subject: [PATCH 26/37] release update --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5ba6a87..fd4ec4e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,4 +22,5 @@ jobs: commit: master generateReleaseNotes: true artifacts: ".pio/build/lora_board/firmware.bin,data/is-cfg.json" - token: ${{ secrets.GITHUB_TOKEN }} + owner: ${{ secrets.OWNER }} + token: ${{ secrets.PAT }} From 58400bd38bcc114599562d577bb7e4a38d063fef Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Mon, 28 Mar 2022 20:30:10 +0200 Subject: [PATCH 27/37] 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 77f0dcc..b90f582 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "22.13.0" +#define VERSION "22.13.1" #define MODULE_NAME "Main" String create_lat_aprs(double lat); From 414b85d47f79efc3a8117bdaab2f16761183b63a Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Mon, 28 Mar 2022 22:21:50 +0200 Subject: [PATCH 28/37] update project config --- src/project_configuration.cpp | 49 +++++++++++++++++++++-------------- src/project_configuration.h | 12 ++++----- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/project_configuration.cpp b/src/project_configuration.cpp index 80aaa11..02e5acb 100644 --- a/src/project_configuration.cpp +++ b/src/project_configuration.cpp @@ -33,8 +33,10 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen JsonArray aps = data["wifi"]["AP"].as(); for (JsonVariant v : aps) { Configuration::Wifi::AP ap; - ap.SSID = v["SSID"].as(); - ap.password = v["password"].as(); + if (v.containsKey("SSID")) + ap.SSID = v["SSID"].as(); + if (v.containsKey("password")) + ap.password = v["password"].as(); conf.wifi.APs.push_back(ap); } if (data.containsKey("beacon") && data["beacon"].containsKey("message")) @@ -44,14 +46,16 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen conf.beacon.use_gps = data["beacon"]["use_gps"] | false; 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")) 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.beacon = data["digi"]["beacon"] | false; + conf.digi.active = data["digi"]["active"] | false; + conf.digi.beacon = data["digi"]["beacon"] | false; + conf.lora.frequencyRx = data["lora"]["frequency_rx"] | 433775000; conf.lora.gainRx = data["lora"]["gain_rx"] | 0; conf.lora.frequencyTx = data["lora"]["frequency_tx"] | 433775000; @@ -60,6 +64,7 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen conf.lora.signalBandwidth = data["lora"]["signal_bandwidth"] | 125000; conf.lora.codingRate4 = data["lora"]["coding_rate4"] | 5; conf.lora.tx_enable = data["lora"]["tx_enable"] | true; + conf.display.alwaysOn = data["display"]["always_on"] | true; conf.display.timeout = data["display"]["timeout"] | 10; conf.display.overwritePin = data["display"]["overwrite_pin"] | 0; @@ -69,8 +74,10 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen JsonArray users = data["ftp"]["user"].as(); for (JsonVariant u : users) { Configuration::Ftp::User us; - us.name = u["name"].as(); - us.password = u["password"].as(); + if (u.containsKey("name")) + us.name = u["name"].as(); + if (u.containsKey("password")) + us.password = u["password"].as(); conf.ftp.users.push_back(us); } if (conf.ftp.users.empty()) { @@ -79,21 +86,23 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen us.password = "ftp"; conf.ftp.users.push_back(us); } - if (data.containsKey("mqtt")) { - conf.mqtt.active = data["mqtt"]["active"] | false; - conf.mqtt.server = data["mqtt"]["server"].as(); - conf.mqtt.port = data["mqtt"]["port"].as(); - conf.mqtt.name = data["mqtt"]["name"].as(); + + conf.mqtt.active = data["mqtt"]["active"] | false; + if (data["mqtt"].containsKey("server")) + conf.mqtt.server = data["mqtt"]["server"].as(); + conf.mqtt.port = data["mqtt"]["port"] | 1883; + if (data["mqtt"].containsKey("name")) + conf.mqtt.name = data["mqtt"]["name"].as(); + if (data["mqtt"].containsKey("password")) conf.mqtt.password = data["mqtt"]["password"].as(); - conf.mqtt.topic = data["mqtt"]["topic"].as(); - } - if (data.containsKey("syslog")) { - conf.syslog.active = data["syslog"]["active"] | true; - if (data["syslog"].containsKey("server")) { - conf.syslog.server = data["syslog"]["server"].as(); - } - conf.syslog.port = data["syslog"]["port"] | 514; - } + if (data["mqtt"].containsKey("topic")) + conf.mqtt.topic = data["mqtt"]["topic"].as(); + + conf.syslog.active = data["syslog"]["active"] | true; + if (data["syslog"].containsKey("server")) + conf.syslog.server = data["syslog"]["server"].as(); + conf.syslog.port = data["syslog"]["port"] | 514; + if (data.containsKey("ntp_server")) conf.ntpServer = data["ntp_server"].as(); diff --git a/src/project_configuration.h b/src/project_configuration.h index 8a626c6..e32a17a 100644 --- a/src/project_configuration.h +++ b/src/project_configuration.h @@ -124,12 +124,12 @@ public: MQTT() : active(false), server(""), port(1883), name(""), password(""), topic("LoraAPRS/Data") { } - bool active; - String server; - uint16_t port; - String name; - String password; - String topic; + bool active; + String server; + int port; + String name; + String password; + String topic; }; class Syslog { From 8029c7f51fa76ab7b5bacef054701d38ed9b8b7e Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Mon, 28 Mar 2022 22:22:36 +0200 Subject: [PATCH 29/37] 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 b90f582..4dbc9cd 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "22.13.1" +#define VERSION "22.13.2" #define MODULE_NAME "Main" String create_lat_aprs(double lat); From e26023302dcad9220f5551219692ea2ce8860046 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Thu, 31 Mar 2022 10:34:34 +0900 Subject: [PATCH 30/37] Add log to RX Frequency error. --- src/TaskModem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TaskModem.cpp b/src/TaskModem.cpp index 017b2b2..05e4fcd 100644 --- a/src/TaskModem.cpp +++ b/src/TaskModem.cpp @@ -39,7 +39,7 @@ bool ModemTask::setup(System &system) { bool ModemTask::loop(System &system) { if (_lora_aprs.checkMessage()) { std::shared_ptr msg = _lora_aprs.getMessage(); - system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Received packet '%s' with RSSI %d and SNR %f", timeString().c_str(), msg->toString().c_str(), _lora_aprs.packetRssi(), _lora_aprs.packetSnr()); + system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, getName(), "[%s] Received packet '%s' with RSSI %ddBm, SNR %.2fdB and FreqErr %dHz", timeString().c_str(), msg->toString().c_str(), _lora_aprs.packetRssi(), _lora_aprs.packetSnr(), -_lora_aprs.packetFrequencyError()); _fromModem.addElement(msg); system.getDisplay().addFrame(std::shared_ptr(new TextFrame("LoRa", msg->toString().c_str()))); } From 61c27b838d61ccd1b9e591cef7daab31a8d133f2 Mon Sep 17 00:00:00 2001 From: FUJIURA Toyonori Date: Thu, 31 Mar 2022 10:36:34 +0900 Subject: [PATCH 31/37] version number update. --- 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 4dbc9cd..f2a2e35 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "22.13.2" +#define VERSION "22.13.3" #define MODULE_NAME "Main" String create_lat_aprs(double lat); From 1257d9dca0f41dff99d676914830a049a1cec42f Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Wed, 6 Apr 2022 23:50:55 +0200 Subject: [PATCH 32/37] do kot creare a new version with every push request --- .github/workflows/release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fd4ec4e..076e9f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,7 @@ name: Create new release on: - push: - branches: - - 'master' + workflow_dispatch: jobs: build: From b28d6ea3f45dee17c76d210482f99949a1d745a7 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Thu, 7 Apr 2022 11:01:15 +0200 Subject: [PATCH 33/37] remove version check from build --- .github/workflows/build_check.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 7686833..a5655db 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -10,20 +10,6 @@ on: - master jobs: - version_check: - name: Version Check - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v2 - - run: pip install GitPython - - name: check version - run: ./scripts/check_version.py - build: name: Compile Firmware runs-on: ubuntu-latest From b31709bf27931b882066e4e34871422765823188 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Thu, 7 Apr 2022 11:01:31 +0200 Subject: [PATCH 34/37] add version check on relaese --- .github/workflows/release.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 076e9f9..71a9939 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,22 @@ on: workflow_dispatch: jobs: - build: + version_check: + name: Version Check + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v2 + - run: pip install GitPython + - name: check version + run: ./scripts/check_version.py + + create_release: + needs: version_check name: Create new release runs-on: ubuntu-latest steps: From 7ddaf8f23c87f00adc71c15dc13ceb69cc6bd40b Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Thu, 7 Apr 2022 11:12:45 +0200 Subject: [PATCH 35/37] fix ota and wifi bug with ethernet --- src/LoRa_APRS_iGate.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index f2a2e35..554aad7 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -113,14 +113,15 @@ void setup() { if (userConfig.wifi.active) { LoRaSystem.getTaskManager().addAlwaysRunTask(&wifiTask); - LoRaSystem.getTaskManager().addTask(&otaTask); tcpip = true; - } else if (boardConfig->Type == eETH_BOARD) { + } + if (boardConfig->Type == eETH_BOARD) { LoRaSystem.getTaskManager().addAlwaysRunTask(ðTask); tcpip = true; } if (tcpip) { + LoRaSystem.getTaskManager().addTask(&otaTask); LoRaSystem.getTaskManager().addTask(&ntpTask); if (userConfig.ftp.active) { LoRaSystem.getTaskManager().addTask(&ftpTask); From bf6951c850f39b60a95745840a04c2d9904d32fe Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Thu, 7 Apr 2022 11:13:24 +0200 Subject: [PATCH 36/37] 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 554aad7..3793970 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "22.13.3" +#define VERSION "22.14.1" #define MODULE_NAME "Main" String create_lat_aprs(double lat); From 42cd9a34f3cb83bdfc2d3d2f311a0531d115a893 Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Thu, 7 Apr 2022 11:15:46 +0200 Subject: [PATCH 37/37] use correct version --- 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 3793970..9ec796b 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -20,7 +20,7 @@ #include "TaskWifi.h" #include "project_configuration.h" -#define VERSION "22.14.1" +#define VERSION "22.14.0" #define MODULE_NAME "Main" String create_lat_aprs(double lat);