mirror of
https://github.com/lora-aprs/LoRa_APRS_iGate.git
synced 2026-03-18 11:14:48 +01:00
Merge branch 'develop' of github.com:lora-aprs/LoRa_APRS_iGate into develop
This commit is contained in:
commit
7d35134949
69
.github/workflows/build_check.yml
vendored
69
.github/workflows/build_check.yml
vendored
|
|
@ -1,56 +1,22 @@
|
|||
name: push pull checks
|
||||
name: Integreation Tests
|
||||
|
||||
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:
|
||||
name: Compile Firmware
|
||||
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: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- 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
|
||||
- uses: actions/upload-artifact@v2
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: firmware
|
||||
path: .pio/build/lora_board/firmware.bin
|
||||
|
|
@ -72,10 +38,29 @@ 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
|
||||
env:
|
||||
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
|
||||
- run: docker pull facthunder/cppcheck:latest
|
||||
- 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:
|
||||
name: Cppcheck Report
|
||||
path: output
|
||||
|
|
|
|||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -3,3 +3,5 @@
|
|||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
report.xml
|
||||
output
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "TaskModem.h"
|
||||
#include "TaskNTP.h"
|
||||
#include "TaskOTA.h"
|
||||
#include "TaskRouter.h"
|
||||
#include "TaskWifi.h"
|
||||
#include "project_configuration.h"
|
||||
|
||||
|
|
@ -25,6 +26,9 @@ String create_long_aprs(double lng);
|
|||
|
||||
std::shared_ptr<System> LoRaSystem;
|
||||
|
||||
TaskQueue<std::shared_ptr<APRSMessage>> toAprsIs;
|
||||
TaskQueue<std::shared_ptr<APRSMessage>> fromModem;
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
|
@ -78,7 +82,7 @@ void setup() {
|
|||
|
||||
LoRaSystem = std::shared_ptr<System>(new System(boardConfig, userConfig));
|
||||
LoRaSystem->getTaskManager().addTask(std::shared_ptr<Task>(new DisplayTask()));
|
||||
LoRaSystem->getTaskManager().addTask(std::shared_ptr<Task>(new ModemTask()));
|
||||
LoRaSystem->getTaskManager().addTask(std::shared_ptr<Task>(new ModemTask(fromModem)));
|
||||
if (boardConfig->Type == eETH_BOARD) {
|
||||
LoRaSystem->getTaskManager().addAlwaysRunTask(std::shared_ptr<Task>(new EthTask()));
|
||||
} else {
|
||||
|
|
@ -89,7 +93,8 @@ void setup() {
|
|||
if (userConfig->ftp.active) {
|
||||
LoRaSystem->getTaskManager().addTask(std::shared_ptr<Task>(new FTPTask()));
|
||||
}
|
||||
LoRaSystem->getTaskManager().addTask(std::shared_ptr<Task>(new AprsIsTask()));
|
||||
LoRaSystem->getTaskManager().addTask(std::shared_ptr<Task>(new AprsIsTask(toAprsIs)));
|
||||
LoRaSystem->getTaskManager().addTask(std::shared_ptr<Task>(new RouterTask(fromModem, toAprsIs)));
|
||||
|
||||
LoRaSystem->getTaskManager().setup(LoRaSystem);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,11 @@ enum TaskNames
|
|||
TaskAprsIs = 1,
|
||||
TaskEth,
|
||||
TaskFtp,
|
||||
TaskLora,
|
||||
TaskModem,
|
||||
TaskNtp,
|
||||
TaskOta,
|
||||
TaskWifi,
|
||||
TaskRouter,
|
||||
TaskSize,
|
||||
};
|
||||
|
||||
|
|
@ -18,9 +19,10 @@ 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"
|
||||
#define TASK_ROUTER "RouterTask"
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -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<std::shared_ptr<APRSMessage>> &toAprsIs) : Task(TASK_APRS_IS, TaskAprsIs), _toAprsIs(toAprsIs) {
|
||||
}
|
||||
|
||||
AprsIsTask::~AprsIsTask() {
|
||||
}
|
||||
|
||||
bool AprsIsTask::setup(std::shared_ptr<System> system) {
|
||||
_beacon_timer.setTimeout(system->getUserConfig()->beacon.timeout * 60 * 1000);
|
||||
_aprs_is = std::shared_ptr<APRS_IS>(new APRS_IS(system->getUserConfig()->callsign, system->getUserConfig()->aprs_is.passcode, "ESP32-APRS-IS", "0.2"));
|
||||
|
||||
_beaconMsg = std::shared_ptr<APRSMessage>(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> system) {
|
|||
|
||||
_aprs_is->getAPRSMessage();
|
||||
|
||||
if (!inputQueue.empty()) {
|
||||
std::shared_ptr<APRSMessage> msg = inputQueue.getElement();
|
||||
if (!_toAprsIs.empty()) {
|
||||
std::shared_ptr<APRSMessage> 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<DisplayFrame>(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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,18 +8,16 @@
|
|||
|
||||
class AprsIsTask : public Task {
|
||||
public:
|
||||
AprsIsTask();
|
||||
explicit AprsIsTask(TaskQueue<std::shared_ptr<APRSMessage>> &toAprsIs);
|
||||
virtual ~AprsIsTask();
|
||||
|
||||
virtual bool setup(std::shared_ptr<System> system) override;
|
||||
virtual bool loop(std::shared_ptr<System> system) override;
|
||||
|
||||
TaskQueue<std::shared_ptr<APRSMessage>> inputQueue;
|
||||
|
||||
private:
|
||||
std::shared_ptr<APRS_IS> _aprs_is;
|
||||
std::shared_ptr<APRSMessage> _beaconMsg;
|
||||
Timer _beacon_timer;
|
||||
std::shared_ptr<APRS_IS> _aprs_is;
|
||||
|
||||
TaskQueue<std::shared_ptr<APRSMessage>> &_toAprsIs;
|
||||
|
||||
bool connect(std::shared_ptr<System> system);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include "TaskModem.h"
|
||||
#include "project_configuration.h"
|
||||
|
||||
ModemTask::ModemTask() : Task(TASK_LORA, TaskLora) {
|
||||
ModemTask::ModemTask(TaskQueue<std::shared_ptr<APRSMessage>> &fromModem) : Task(TASK_MODEM, TaskModem), _fromModem(fromModem) {
|
||||
}
|
||||
|
||||
ModemTask::~ModemTask() {
|
||||
|
|
@ -55,15 +55,9 @@ bool ModemTask::loop(std::shared_ptr<System> system) {
|
|||
}
|
||||
msg->setPath(path + "qAR," + system->getUserConfig()->callsign);
|
||||
|
||||
std::shared_ptr<AprsIsTask> is_thread = std::static_pointer_cast<AprsIsTask>(system->getTaskManager().getTask(TASK_APRS_IS));
|
||||
is_thread->inputQueue.addElement(msg);
|
||||
_fromModem.addElement(msg);
|
||||
system->getDisplay().addFrame(std::shared_ptr<DisplayFrame>(new TextFrame("LoRa", msg->toString())));
|
||||
}
|
||||
|
||||
if (!inputQueue.empty()) {
|
||||
std::shared_ptr<APRSMessage> msg = inputQueue.getElement();
|
||||
_lora_aprs->sendMessage(msg);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,16 +7,15 @@
|
|||
|
||||
class ModemTask : public Task {
|
||||
public:
|
||||
ModemTask();
|
||||
explicit ModemTask(TaskQueue<std::shared_ptr<APRSMessage>> &fromModem);
|
||||
virtual ~ModemTask();
|
||||
|
||||
virtual bool setup(std::shared_ptr<System> system) override;
|
||||
virtual bool loop(std::shared_ptr<System> system) override;
|
||||
|
||||
TaskQueue<std::shared_ptr<APRSMessage>> inputQueue;
|
||||
|
||||
private:
|
||||
std::shared_ptr<LoRa_APRS> _lora_aprs;
|
||||
std::shared_ptr<LoRa_APRS> _lora_aprs;
|
||||
TaskQueue<std::shared_ptr<APRSMessage>> &_fromModem;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
46
src/TaskRouter.cpp
Normal file
46
src/TaskRouter.cpp
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#include <logger.h>
|
||||
|
||||
#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<std::shared_ptr<APRSMessage>> &fromModem, TaskQueue<std::shared_ptr<APRSMessage>> &toAprsIs) : Task(TASK_ROUTER, TaskRouter), _fromModem(fromModem), _toAprsIs(toAprsIs) {
|
||||
}
|
||||
|
||||
RouterTask::~RouterTask() {
|
||||
}
|
||||
|
||||
bool RouterTask::setup(std::shared_ptr<System> system) {
|
||||
// setup beacon
|
||||
_beacon_timer.setTimeout(system->getUserConfig()->beacon.timeout * 60 * 1000);
|
||||
_beaconMsg = std::shared_ptr<APRSMessage>(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> 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<DisplayFrame>(new TextFrame("BEACON", _beaconMsg->toString())));
|
||||
_beacon_timer.start();
|
||||
}
|
||||
time_t diff = _beacon_timer.getTriggerTimeInSec();
|
||||
_stateInfo = "beacon " + String(diff / 60) + ":" + String(diff % 60);
|
||||
return true;
|
||||
}
|
||||
23
src/TaskRouter.h
Normal file
23
src/TaskRouter.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef TASK_ROUTER_H_
|
||||
#define TASK_ROUTER_H_
|
||||
|
||||
#include <APRSMessage.h>
|
||||
#include <TaskManager.h>
|
||||
|
||||
class RouterTask : public Task {
|
||||
public:
|
||||
RouterTask(TaskQueue<std::shared_ptr<APRSMessage>> &fromModem, TaskQueue<std::shared_ptr<APRSMessage>> &toAprsIs);
|
||||
virtual ~RouterTask();
|
||||
|
||||
virtual bool setup(std::shared_ptr<System> system) override;
|
||||
virtual bool loop(std::shared_ptr<System> system) override;
|
||||
|
||||
private:
|
||||
TaskQueue<std::shared_ptr<APRSMessage>> &_fromModem;
|
||||
TaskQueue<std::shared_ptr<APRSMessage>> &_toAprsIs;
|
||||
|
||||
std::shared_ptr<APRSMessage> _beaconMsg;
|
||||
Timer _beacon_timer;
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Reference in a new issue