mirror of
https://github.com/lora-aprs/LoRa_APRS_iGate.git
synced 2025-12-06 07:42:00 +01:00
Merge branch 'develop' into patch-1
This commit is contained in:
commit
ab1bc73104
35
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
35
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: bug
|
||||||
|
assignees: peterus
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1. Go to '...'
|
||||||
|
2. Click on '....'
|
||||||
|
3. Scroll down to '....'
|
||||||
|
4. See error
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Desktop (please complete the following information):**
|
||||||
|
- OS:
|
||||||
|
- PlatformIO Version:
|
||||||
|
- Firmware Version:
|
||||||
|
|
||||||
|
**Board name:**
|
||||||
|
-
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
||||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: enhancement
|
||||||
|
assignees: peterus
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
9
.github/auto_assign.yml
vendored
Normal file
9
.github/auto_assign.yml
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Set to true to add reviewers to pull requests
|
||||||
|
addReviewers: true
|
||||||
|
|
||||||
|
# Set to true to add assignees to pull requests
|
||||||
|
addAssignees: true
|
||||||
|
|
||||||
|
# A list of reviewers to be added to pull requests (GitHub user name)
|
||||||
|
reviewers:
|
||||||
|
- peterus
|
||||||
6
.github/workflows/build_check.yml
vendored
6
.github/workflows/build_check.yml
vendored
|
|
@ -16,7 +16,9 @@ jobs:
|
||||||
- run: pip3 install platformio
|
- run: pip3 install platformio
|
||||||
- run: echo "$HOME/.local/bin" >> $GITHUB_PATH
|
- run: echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- run: platformio check --fail-on-defect low --fail-on-defect medium --fail-on-defect high --skip-packages --flags "--suppress=*:*.pio\* --inline-suppr" -v
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
|
- run: platformio check --fail-on-defect low --fail-on-defect medium --fail-on-defect high --skip-packages --flags "--suppress=*:*.pio\* --inline-suppr lib/common/src" -v
|
||||||
|
|
||||||
PlatformIO-Build:
|
PlatformIO-Build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
@ -25,6 +27,8 @@ jobs:
|
||||||
- run: pip3 install platformio
|
- run: pip3 install platformio
|
||||||
- run: echo "$HOME/.local/bin" >> $GITHUB_PATH
|
- run: echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
- run: platformio run
|
- run: platformio run
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
|
@ -14,6 +14,8 @@ jobs:
|
||||||
- run: pip3 install platformio
|
- run: pip3 install platformio
|
||||||
- run: echo "$HOME/.local/bin" >> $GITHUB_PATH
|
- run: echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: 'recursive'
|
||||||
- run: platformio run
|
- run: platformio run
|
||||||
- id: create_release
|
- id: create_release
|
||||||
uses: actions/create-release@v1
|
uses: actions/create-release@v1
|
||||||
|
|
|
||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "lib"]
|
||||||
|
path = lib/common
|
||||||
|
url = ../LoRa_APRS_Common
|
||||||
1
lib/common
Submodule
1
lib/common
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 87d7cb9c81d691acb3a22a0b26ca071be56d1816
|
||||||
|
|
@ -16,7 +16,7 @@ lib_deps =
|
||||||
peterus/LoRa-APRS-Lib @ 0.0.5
|
peterus/LoRa-APRS-Lib @ 0.0.5
|
||||||
check_tool = cppcheck
|
check_tool = cppcheck
|
||||||
check_flags =
|
check_flags =
|
||||||
cppcheck: --suppress=*:*.pio\* --inline-suppr
|
cppcheck: --suppress=*:*.pio\* --inline-suppr lib/common/src
|
||||||
monitor_flags = --raw
|
monitor_flags = --raw
|
||||||
# activate for OTA Update, use the CALLSIGN from is-cfg.json as upload_port:
|
# activate for OTA Update, use the CALLSIGN from is-cfg.json as upload_port:
|
||||||
#upload_protocol = espota
|
#upload_protocol = espota
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "pins.h"
|
#include "pins.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "configuration.h"
|
#include "project_configuration.h"
|
||||||
|
|
||||||
#if defined(ARDUINO_T_Beam) && !defined(ARDUINO_T_Beam_V0_7)
|
#if defined(ARDUINO_T_Beam) && !defined(ARDUINO_T_Beam_V0_7)
|
||||||
#include "power_management.h"
|
#include "power_management.h"
|
||||||
|
|
@ -35,7 +35,7 @@ WiFiMulti WiFiMulti;
|
||||||
WiFiUDP ntpUDP;
|
WiFiUDP ntpUDP;
|
||||||
NTPClient timeClient(ntpUDP, 60*60);
|
NTPClient timeClient(ntpUDP, 60*60);
|
||||||
FTPServer ftpServer;
|
FTPServer ftpServer;
|
||||||
Configuration Config;
|
Configuration * Config;
|
||||||
APRS_IS * aprs_is = 0;
|
APRS_IS * aprs_is = 0;
|
||||||
LoRa_APRS lora_aprs;
|
LoRa_APRS lora_aprs;
|
||||||
std::shared_ptr<APRSMessage> BeaconMsg;
|
std::shared_ptr<APRSMessage> BeaconMsg;
|
||||||
|
|
@ -84,9 +84,9 @@ void setup()
|
||||||
|
|
||||||
delay(500);
|
delay(500);
|
||||||
logPrintlnA("LoRa APRS iGate & Digi by OE5BPA (Peter Buchegger)");
|
logPrintlnA("LoRa APRS iGate & Digi by OE5BPA (Peter Buchegger)");
|
||||||
logPrintlnA("Version: 20.49.0");
|
logPrintlnA("Version: 20.49.0-dev");
|
||||||
setup_display();
|
setup_display();
|
||||||
show_display("OE5BPA", "LoRa APRS iGate & Digi", "by Peter Buchegger", "20.49.0", 3000);
|
show_display("OE5BPA", "LoRa APRS iGate & Digi", "by Peter Buchegger", "20.49.0-dev", 3000);
|
||||||
|
|
||||||
load_config();
|
load_config();
|
||||||
setup_lora();
|
setup_lora();
|
||||||
|
|
@ -97,7 +97,7 @@ void setup()
|
||||||
setup_ftp();
|
setup_ftp();
|
||||||
setup_aprs_is();
|
setup_aprs_is();
|
||||||
#else
|
#else
|
||||||
if(Config.wifi.active)
|
if(Config->wifi.active)
|
||||||
{
|
{
|
||||||
setup_wifi();
|
setup_wifi();
|
||||||
setup_ota();
|
setup_ota();
|
||||||
|
|
@ -110,14 +110,14 @@ void setup()
|
||||||
WiFi.mode(WIFI_OFF);
|
WiFi.mode(WIFI_OFF);
|
||||||
btStop();
|
btStop();
|
||||||
}
|
}
|
||||||
if(Config.aprs_is.active) setup_aprs_is();
|
if(Config->aprs_is.active) setup_aprs_is();
|
||||||
#endif
|
#endif
|
||||||
setup_timer();
|
setup_timer();
|
||||||
|
|
||||||
if(Config.display.overwritePin != 0)
|
if(Config->display.overwritePin != 0)
|
||||||
{
|
{
|
||||||
pinMode(Config.display.overwritePin, INPUT);
|
pinMode(Config->display.overwritePin, INPUT);
|
||||||
pinMode(Config.display.overwritePin, INPUT_PULLUP);
|
pinMode(Config->display.overwritePin, INPUT_PULLUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
@ -129,37 +129,37 @@ void setup()
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
static bool display_is_on = true;
|
static bool display_is_on = true;
|
||||||
if(Config.display.overwritePin != 0 && !digitalRead(Config.display.overwritePin))
|
if(Config->display.overwritePin != 0 && !digitalRead(Config->display.overwritePin))
|
||||||
{
|
{
|
||||||
secondsSinceDisplay = 0;
|
secondsSinceDisplay = 0;
|
||||||
display_is_on = true;
|
display_is_on = true;
|
||||||
setup_display();
|
setup_display();
|
||||||
} else
|
} else
|
||||||
if(!Config.display.alwaysOn && secondsSinceDisplay > Config.display.timeout && display_is_on)
|
if(!Config->display.alwaysOn && secondsSinceDisplay > Config->display.timeout && display_is_on)
|
||||||
{
|
{
|
||||||
turn_off_display();
|
turn_off_display();
|
||||||
display_is_on = false;
|
display_is_on = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool beacon_aprs_is = Config.aprs_is.active && Config.aprs_is.beacon;
|
static bool beacon_aprs_is = Config->aprs_is.active && Config->aprs_is.beacon;
|
||||||
static bool beacon_digi = Config.digi.active && Config.digi.beacon;
|
static bool beacon_digi = Config->digi.active && Config->digi.beacon;
|
||||||
|
|
||||||
if(Config.aprs_is.active && Config.aprs_is.beacon && secondsSinceLastAPRSISBeacon >= (Config.aprs_is.beaconTimeout*60))
|
if(Config->aprs_is.active && Config->aprs_is.beacon && secondsSinceLastAPRSISBeacon >= (Config->aprs_is.beaconTimeout*60))
|
||||||
{
|
{
|
||||||
portENTER_CRITICAL(&timerMux);
|
portENTER_CRITICAL(&timerMux);
|
||||||
secondsSinceLastAPRSISBeacon -= (Config.aprs_is.beaconTimeout*60);
|
secondsSinceLastAPRSISBeacon -= (Config->aprs_is.beaconTimeout*60);
|
||||||
portEXIT_CRITICAL(&timerMux);
|
portEXIT_CRITICAL(&timerMux);
|
||||||
beacon_aprs_is = true;
|
beacon_aprs_is = true;
|
||||||
}
|
}
|
||||||
if(Config.digi.active && Config.digi.beacon && secondsSinceLastDigiBeacon >= (Config.digi.beaconTimeout*60))
|
if(Config->digi.active && Config->digi.beacon && secondsSinceLastDigiBeacon >= (Config->digi.beaconTimeout*60))
|
||||||
{
|
{
|
||||||
portENTER_CRITICAL(&timerMux);
|
portENTER_CRITICAL(&timerMux);
|
||||||
secondsSinceLastDigiBeacon -= (Config.digi.beaconTimeout*60);
|
secondsSinceLastDigiBeacon -= (Config->digi.beaconTimeout*60);
|
||||||
portEXIT_CRITICAL(&timerMux);
|
portEXIT_CRITICAL(&timerMux);
|
||||||
beacon_digi = true;
|
beacon_digi = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.ftp.active)
|
if(Config->ftp.active)
|
||||||
{
|
{
|
||||||
ftpServer.handle();
|
ftpServer.handle();
|
||||||
static bool configWasOpen = false;
|
static bool configWasOpen = false;
|
||||||
|
|
@ -175,8 +175,8 @@ void loop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.wifi.active || eth_connected) ArduinoOTA.handle();
|
if(Config->wifi.active || eth_connected) ArduinoOTA.handle();
|
||||||
if(Config.wifi.active && WiFiMulti.run() != WL_CONNECTED)
|
if(Config->wifi.active && WiFiMulti.run() != WL_CONNECTED)
|
||||||
{
|
{
|
||||||
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
||||||
logPrintlnE("WiFi not connected!");
|
logPrintlnE("WiFi not connected!");
|
||||||
|
|
@ -184,15 +184,15 @@ void loop()
|
||||||
delay(1000);
|
delay(1000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if((eth_connected && !aprs_is->connected()) || (Config.aprs_is.active && !aprs_is->connected()))
|
if((eth_connected && !aprs_is->connected()) || (Config->aprs_is.active && !aprs_is->connected()))
|
||||||
{
|
{
|
||||||
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
||||||
logPrintI("connecting to APRS-IS server: ");
|
logPrintI("connecting to APRS-IS server: ");
|
||||||
logPrintI(Config.aprs_is.server);
|
logPrintI(Config->aprs_is.server);
|
||||||
logPrintI(" on port: ");
|
logPrintI(" on port: ");
|
||||||
logPrintlnI(String(Config.aprs_is.port));
|
logPrintlnI(String(Config->aprs_is.port));
|
||||||
show_display("INFO", "Connecting to APRS-IS server");
|
show_display("INFO", "Connecting to APRS-IS server");
|
||||||
if(!aprs_is->connect(Config.aprs_is.server, Config.aprs_is.port))
|
if(!aprs_is->connect(Config->aprs_is.server, Config->aprs_is.port))
|
||||||
{
|
{
|
||||||
logPrintlnE("Connection failed.");
|
logPrintlnE("Connection failed.");
|
||||||
logPrintlnI("Waiting 5 seconds before retrying...");
|
logPrintlnI("Waiting 5 seconds before retrying...");
|
||||||
|
|
@ -202,7 +202,7 @@ void loop()
|
||||||
}
|
}
|
||||||
logPrintlnI("Connected to APRS-IS server!");
|
logPrintlnI("Connected to APRS-IS server!");
|
||||||
}
|
}
|
||||||
if(Config.aprs_is.active && aprs_is->available() > 0)
|
if(Config->aprs_is.active && aprs_is->available() > 0)
|
||||||
{
|
{
|
||||||
String str = aprs_is->getMessage();
|
String str = aprs_is->getMessage();
|
||||||
logPrintD("[" + timeClient.getFormattedTime() + "] ");
|
logPrintD("[" + timeClient.getFormattedTime() + "] ");
|
||||||
|
|
@ -213,7 +213,7 @@ void loop()
|
||||||
std::shared_ptr<APRSMessage> msg = lora_aprs.getMessage();
|
std::shared_ptr<APRSMessage> msg = lora_aprs.getMessage();
|
||||||
|
|
||||||
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
||||||
show_display(Config.callsign, timeClient.getFormattedTime() + " LoRa", "RSSI: " + String(lora_aprs.packetRssi()) + ", SNR: " + String(lora_aprs.packetSnr()), msg->toString());
|
show_display(Config->callsign, timeClient.getFormattedTime() + " LoRa", "RSSI: " + String(lora_aprs.packetRssi()) + ", SNR: " + String(lora_aprs.packetSnr()), msg->toString());
|
||||||
logPrintD("[" + timeClient.getFormattedTime() + "] ");
|
logPrintD("[" + timeClient.getFormattedTime() + "] ");
|
||||||
logPrintD(" Received packet '");
|
logPrintD(" Received packet '");
|
||||||
logPrintD(msg->toString());
|
logPrintD(msg->toString());
|
||||||
|
|
@ -222,13 +222,13 @@ void loop()
|
||||||
logPrintD(" and SNR ");
|
logPrintD(" and SNR ");
|
||||||
logPrintlnD(String(lora_aprs.packetSnr()));
|
logPrintlnD(String(lora_aprs.packetSnr()));
|
||||||
|
|
||||||
if(Config.aprs_is.active)
|
if(Config->aprs_is.active)
|
||||||
{
|
{
|
||||||
aprs_is->sendMessage(msg->encode());
|
aprs_is->sendMessage(msg->encode());
|
||||||
}
|
}
|
||||||
if(Config.digi.active)
|
if(Config->digi.active)
|
||||||
{
|
{
|
||||||
if(msg->getSource().indexOf(Config.callsign) != -1)
|
if(msg->getSource().indexOf(Config->callsign) != -1)
|
||||||
{
|
{
|
||||||
logPrintD("Message already received as repeater: '");
|
logPrintD("Message already received as repeater: '");
|
||||||
logPrintD(msg->toString());
|
logPrintD(msg->toString());
|
||||||
|
|
@ -254,14 +254,14 @@ void loop()
|
||||||
if(foundMsg == lastMessages.end())
|
if(foundMsg == lastMessages.end())
|
||||||
{
|
{
|
||||||
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
||||||
show_display(Config.callsign, "RSSI: " + String(lora_aprs.packetRssi()) + ", SNR: " + String(lora_aprs.packetSnr()), msg->toString(), 0);
|
show_display(Config->callsign, "RSSI: " + String(lora_aprs.packetRssi()) + ", SNR: " + String(lora_aprs.packetSnr()), msg->toString(), 0);
|
||||||
logPrintD("Received packet '");
|
logPrintD("Received packet '");
|
||||||
logPrintD(msg->toString());
|
logPrintD(msg->toString());
|
||||||
logPrintD("' with RSSI ");
|
logPrintD("' with RSSI ");
|
||||||
logPrintD(String(lora_aprs.packetRssi()));
|
logPrintD(String(lora_aprs.packetRssi()));
|
||||||
logPrintD(" and SNR ");
|
logPrintD(" and SNR ");
|
||||||
logPrintlnD(String(lora_aprs.packetSnr()));
|
logPrintlnD(String(lora_aprs.packetSnr()));
|
||||||
msg->setPath(String(Config.callsign) + "*");
|
msg->setPath(String(Config->callsign) + "*");
|
||||||
lora_aprs.sendMessage(msg);
|
lora_aprs.sendMessage(msg);
|
||||||
lastMessages.insert({secondsSinceStartup, msg});
|
lastMessages.insert({secondsSinceStartup, msg});
|
||||||
}
|
}
|
||||||
|
|
@ -277,11 +277,11 @@ void loop()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(Config.digi.active)
|
if(Config->digi.active)
|
||||||
{
|
{
|
||||||
for(std::map<uint, std::shared_ptr<APRSMessage>>::iterator iter = lastMessages.begin(); iter != lastMessages.end(); )
|
for(std::map<uint, std::shared_ptr<APRSMessage>>::iterator iter = lastMessages.begin(); iter != lastMessages.end(); )
|
||||||
{
|
{
|
||||||
if(secondsSinceStartup >= iter->first + Config.digi.forwardTimeout*60)
|
if(secondsSinceStartup >= iter->first + Config->digi.forwardTimeout*60)
|
||||||
{
|
{
|
||||||
iter = lastMessages.erase(iter);
|
iter = lastMessages.erase(iter);
|
||||||
}
|
}
|
||||||
|
|
@ -295,30 +295,30 @@ void loop()
|
||||||
{
|
{
|
||||||
beacon_digi = false;
|
beacon_digi = false;
|
||||||
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
||||||
show_display(Config.callsign, "Beacon to HF...");
|
show_display(Config->callsign, "Beacon to HF...");
|
||||||
logPrintD("[" + timeClient.getFormattedTime() + "] ");
|
logPrintD("[" + timeClient.getFormattedTime() + "] ");
|
||||||
logPrintlnD(BeaconMsg->encode());
|
logPrintlnD(BeaconMsg->encode());
|
||||||
lora_aprs.sendMessage(BeaconMsg);
|
lora_aprs.sendMessage(BeaconMsg);
|
||||||
logPrintlnD("finished TXing...");
|
logPrintlnD("finished TXing...");
|
||||||
show_display(Config.callsign, "Standby...");
|
show_display(Config->callsign, "Standby...");
|
||||||
}
|
}
|
||||||
if(beacon_aprs_is)
|
if(beacon_aprs_is)
|
||||||
{
|
{
|
||||||
beacon_aprs_is = false;
|
beacon_aprs_is = false;
|
||||||
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
||||||
show_display(Config.callsign, "Beacon to APRS-IS Server...");
|
show_display(Config->callsign, "Beacon to APRS-IS Server...");
|
||||||
logPrintD("[" + timeClient.getFormattedTime() + "] ");
|
logPrintD("[" + timeClient.getFormattedTime() + "] ");
|
||||||
logPrintlnD(BeaconMsg->encode());
|
logPrintlnD(BeaconMsg->encode());
|
||||||
aprs_is->sendMessage(BeaconMsg);
|
aprs_is->sendMessage(BeaconMsg);
|
||||||
show_display(Config.callsign, "Standby...");
|
show_display(Config->callsign, "Standby...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_config()
|
void load_config()
|
||||||
{
|
{
|
||||||
ConfigurationManagement confmg("/is-cfg.json");
|
ProjectConfigurationManagement confmg;
|
||||||
Config = confmg.readConfiguration();
|
Config = confmg.readConfiguration();
|
||||||
if(Config.callsign == "NOCALL-10")
|
if(Config->callsign == "NOCALL-10")
|
||||||
{
|
{
|
||||||
logPrintlnE("You have to change your settings in 'data/is-cfg.json' and upload it via \"Upload File System image\"!");
|
logPrintlnE("You have to change your settings in 'data/is-cfg.json' and upload it via \"Upload File System image\"!");
|
||||||
show_display("ERROR", "You have to change your settings in 'data/is-cfg.json' and upload it via \"Upload File System image\"!");
|
show_display("ERROR", "You have to change your settings in 'data/is-cfg.json' and upload it via \"Upload File System image\"!");
|
||||||
|
|
@ -327,7 +327,7 @@ void load_config()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef ETH_BOARD
|
#ifndef ETH_BOARD
|
||||||
if(Config.aprs_is.active && !Config.wifi.active)
|
if(Config->aprs_is.active && !Config->wifi.active)
|
||||||
{
|
{
|
||||||
logPrintlnE("You have to activate Wifi for APRS IS to work, please check your settings!");
|
logPrintlnE("You have to activate Wifi for APRS IS to work, please check your settings!");
|
||||||
show_display("ERROR", "You have to activate Wifi for APRS IS to work, please check your settings!");
|
show_display("ERROR", "You have to activate Wifi for APRS IS to work, please check your settings!");
|
||||||
|
|
@ -336,9 +336,9 @@ void load_config()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(KEY_BUILTIN != 0 && Config.display.overwritePin == 0)
|
if(KEY_BUILTIN != 0 && Config->display.overwritePin == 0)
|
||||||
{
|
{
|
||||||
Config.display.overwritePin = KEY_BUILTIN;
|
Config->display.overwritePin = KEY_BUILTIN;
|
||||||
}
|
}
|
||||||
logPrintlnI("Configuration loaded!");
|
logPrintlnI("Configuration loaded!");
|
||||||
}
|
}
|
||||||
|
|
@ -403,8 +403,8 @@ void setup_eth()
|
||||||
void setup_wifi()
|
void setup_wifi()
|
||||||
{
|
{
|
||||||
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE);
|
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE);
|
||||||
WiFi.setHostname(Config.callsign.c_str());
|
WiFi.setHostname(Config->callsign.c_str());
|
||||||
for(Configuration::Wifi::AP ap : Config.wifi.APs)
|
for(Configuration::Wifi::AP ap : Config->wifi.APs)
|
||||||
{
|
{
|
||||||
logPrintD("Looking for AP: ");
|
logPrintD("Looking for AP: ");
|
||||||
logPrintlnD(ap.SSID);
|
logPrintlnD(ap.SSID);
|
||||||
|
|
@ -459,34 +459,34 @@ void setup_ota()
|
||||||
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
|
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
|
||||||
else if (error == OTA_END_ERROR) Serial.println("End Failed");
|
else if (error == OTA_END_ERROR) Serial.println("End Failed");
|
||||||
});
|
});
|
||||||
ArduinoOTA.setHostname(Config.callsign.c_str());
|
ArduinoOTA.setHostname(Config->callsign.c_str());
|
||||||
ArduinoOTA.begin();
|
ArduinoOTA.begin();
|
||||||
logPrintlnI("OTA init done!");
|
logPrintlnI("OTA init done!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup_lora()
|
void setup_lora()
|
||||||
{
|
{
|
||||||
lora_aprs.setRxFrequency(Config.lora.frequencyRx);
|
lora_aprs.setRxFrequency(Config->lora.frequencyRx);
|
||||||
lora_aprs.setTxFrequency(Config.lora.frequencyTx);
|
lora_aprs.setTxFrequency(Config->lora.frequencyTx);
|
||||||
if (!lora_aprs.begin(lora_aprs.getRxFrequency()))
|
if (!lora_aprs.begin(lora_aprs.getRxFrequency()))
|
||||||
{
|
{
|
||||||
logPrintlnE("Starting LoRa failed!");
|
logPrintlnE("Starting LoRa failed!");
|
||||||
show_display("ERROR", "Starting LoRa failed!");
|
show_display("ERROR", "Starting LoRa failed!");
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
lora_aprs.setTxPower(Config.lora.power);
|
lora_aprs.setTxPower(Config->lora.power);
|
||||||
lora_aprs.setSpreadingFactor(Config.lora.spreadingFactor);
|
lora_aprs.setSpreadingFactor(Config->lora.spreadingFactor);
|
||||||
lora_aprs.setSignalBandwidth(Config.lora.signalBandwidth);
|
lora_aprs.setSignalBandwidth(Config->lora.signalBandwidth);
|
||||||
lora_aprs.setCodingRate4(Config.lora.codingRate4);
|
lora_aprs.setCodingRate4(Config->lora.codingRate4);
|
||||||
logPrintlnI("LoRa init done!");
|
logPrintlnI("LoRa init done!");
|
||||||
show_display("INFO", "LoRa init done!", 2000);
|
show_display("INFO", "LoRa init done!", 2000);
|
||||||
|
|
||||||
BeaconMsg = std::shared_ptr<APRSMessage>(new APRSMessage());
|
BeaconMsg = std::shared_ptr<APRSMessage>(new APRSMessage());
|
||||||
BeaconMsg->setSource(Config.callsign);
|
BeaconMsg->setSource(Config->callsign);
|
||||||
BeaconMsg->setDestination("APLG0");
|
BeaconMsg->setDestination("APLG0");
|
||||||
String lat = create_lat_aprs(Config.beacon.positionLatitude);
|
String lat = create_lat_aprs(Config->beacon.positionLatitude);
|
||||||
String lng = create_long_aprs(Config.beacon.positionLongitude);
|
String lng = create_long_aprs(Config->beacon.positionLongitude);
|
||||||
BeaconMsg->getAPRSBody()->setData(String("=") + lat + "I" + lng + "&" + Config.beacon.message);
|
BeaconMsg->getAPRSBody()->setData(String("=") + lat + "I" + lng + "&" + Config->beacon.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup_ntp()
|
void setup_ntp()
|
||||||
|
|
@ -503,7 +503,7 @@ void setup_ntp()
|
||||||
|
|
||||||
void setup_aprs_is()
|
void setup_aprs_is()
|
||||||
{
|
{
|
||||||
aprs_is = new APRS_IS(Config.callsign, Config.aprs_is.password , "ESP32-APRS-IS", "0.1");
|
aprs_is = new APRS_IS(Config->callsign, Config->aprs_is.password , "ESP32-APRS-IS", "0.1");
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR onTimer()
|
void IRAM_ATTR onTimer()
|
||||||
|
|
@ -526,11 +526,11 @@ void setup_timer()
|
||||||
|
|
||||||
void setup_ftp()
|
void setup_ftp()
|
||||||
{
|
{
|
||||||
if(!Config.ftp.active)
|
if(!Config->ftp.active)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(Configuration::Ftp::User user : Config.ftp.users)
|
for(Configuration::Ftp::User user : Config->ftp.users)
|
||||||
{
|
{
|
||||||
logPrintD("Adding user to FTP Server: ");
|
logPrintD("Adding user to FTP Server: ");
|
||||||
logPrintlnD(user.name);
|
logPrintlnD(user.name);
|
||||||
|
|
|
||||||
|
|
@ -1,155 +0,0 @@
|
||||||
#include <SPIFFS.h>
|
|
||||||
|
|
||||||
#include "configuration.h"
|
|
||||||
#include "logger.h"
|
|
||||||
|
|
||||||
ConfigurationManagement::ConfigurationManagement(String FilePath)
|
|
||||||
: mFilePath(FilePath)
|
|
||||||
{
|
|
||||||
if(!SPIFFS.begin(true))
|
|
||||||
{
|
|
||||||
logPrintlnE("Mounting SPIFFS was not possible. Trying to format SPIFFS...");
|
|
||||||
SPIFFS.format();
|
|
||||||
if(!SPIFFS.begin())
|
|
||||||
{
|
|
||||||
logPrintlnE("Formating SPIFFS was not okay!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Configuration ConfigurationManagement::readConfiguration()
|
|
||||||
{
|
|
||||||
File file = SPIFFS.open(mFilePath);
|
|
||||||
if(!file)
|
|
||||||
{
|
|
||||||
logPrintlnE("Failed to open file for reading...");
|
|
||||||
return Configuration();
|
|
||||||
}
|
|
||||||
DynamicJsonDocument data(2048);
|
|
||||||
DeserializationError error = deserializeJson(data, file);
|
|
||||||
if(error)
|
|
||||||
{
|
|
||||||
logPrintlnW("Failed to read file, using default configuration.");
|
|
||||||
}
|
|
||||||
//serializeJson(data, Serial);
|
|
||||||
//Serial.println();
|
|
||||||
file.close();
|
|
||||||
|
|
||||||
Configuration conf;
|
|
||||||
if(data.containsKey("callsign"))
|
|
||||||
conf.callsign = data["callsign"].as<String>();
|
|
||||||
|
|
||||||
conf.wifi.active = data["wifi"]["active"] | false;
|
|
||||||
JsonArray aps = data["wifi"]["AP"].as<JsonArray>();
|
|
||||||
for(JsonVariant v : aps)
|
|
||||||
{
|
|
||||||
Configuration::Wifi::AP ap;
|
|
||||||
ap.SSID = v["SSID"].as<String>();
|
|
||||||
ap.password = v["password"].as<String>();
|
|
||||||
conf.wifi.APs.push_back(ap);
|
|
||||||
}
|
|
||||||
if(data.containsKey("beacon") && data["beacon"].containsKey("message"))
|
|
||||||
conf.beacon.message = data["beacon"]["message"].as<String>();
|
|
||||||
conf.beacon.positionLatitude = data["beacon"]["position"]["latitude"] | 0.0;
|
|
||||||
conf.beacon.positionLongitude = data["beacon"]["position"]["longitude"] | 0.0;
|
|
||||||
conf.aprs_is.active = data["aprs_is"]["active"] | false;
|
|
||||||
if(data.containsKey("aprs_is") && data["aprs_is"].containsKey("password"))
|
|
||||||
conf.aprs_is.password = data["aprs_is"]["password"].as<String>();
|
|
||||||
if(data.containsKey("aprs_is") && data["aprs_is"].containsKey("server"))
|
|
||||||
conf.aprs_is.server = data["aprs_is"]["server"].as<String>();
|
|
||||||
conf.aprs_is.port = data["aprs_is"]["port"] | 14580;
|
|
||||||
conf.aprs_is.beacon = data["aprs_is"]["beacon"] | true;
|
|
||||||
conf.aprs_is.beaconTimeout = data["aprs_is"]["beacon_timeout"] | 15;
|
|
||||||
conf.digi.active = data["digi"]["active"] | false;
|
|
||||||
conf.digi.forwardTimeout = data["digi"]["forward_timeout"] | 5;
|
|
||||||
conf.digi.beacon = data["digi"]["beacon"] | true;
|
|
||||||
conf.digi.beaconTimeout = data["digi"]["beacon_timeout"] | 30;
|
|
||||||
|
|
||||||
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.ftp.active = data["ftp"]["active"] | false;
|
|
||||||
JsonArray users = data["ftp"]["user"].as<JsonArray>();
|
|
||||||
for(JsonVariant u : users)
|
|
||||||
{
|
|
||||||
Configuration::Ftp::User us;
|
|
||||||
us.name = u["name"].as<String>();
|
|
||||||
us.password = u["password"].as<String>();
|
|
||||||
conf.ftp.users.push_back(us);
|
|
||||||
}
|
|
||||||
if(conf.ftp.users.empty())
|
|
||||||
{
|
|
||||||
Configuration::Ftp::User us;
|
|
||||||
us.name = "ftp";
|
|
||||||
us.password = "ftp";
|
|
||||||
conf.ftp.users.push_back(us);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update config in memory to get the new fields:
|
|
||||||
writeConfiguration(conf);
|
|
||||||
|
|
||||||
return conf;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigurationManagement::writeConfiguration(Configuration conf)
|
|
||||||
{
|
|
||||||
File file = SPIFFS.open(mFilePath, "w");
|
|
||||||
if(!file)
|
|
||||||
{
|
|
||||||
logPrintlnE("Failed to open file for writing...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DynamicJsonDocument data(2048);
|
|
||||||
|
|
||||||
data["callsign"] = conf.callsign;
|
|
||||||
data["wifi"]["active"] = conf.wifi.active;
|
|
||||||
JsonArray aps = data["wifi"].createNestedArray("AP");
|
|
||||||
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["aprs_is"]["active"] = conf.aprs_is.active;
|
|
||||||
data["aprs_is"]["password"] = conf.aprs_is.password;
|
|
||||||
data["aprs_is"]["server"] = conf.aprs_is.server;
|
|
||||||
data["aprs_is"]["port"] = conf.aprs_is.port;
|
|
||||||
data["aprs_is"]["beacon"] = conf.aprs_is.beacon;
|
|
||||||
data["aprs_is"]["beacon_timeout"] = conf.aprs_is.beaconTimeout;
|
|
||||||
data["digi"]["active"] = conf.digi.active;
|
|
||||||
data["digi"]["forward_timeout"] = conf.digi.forwardTimeout;
|
|
||||||
data["digi"]["beacon"] = conf.digi.beacon;
|
|
||||||
data["digi"]["beacon_timeout"] = conf.digi.beaconTimeout;
|
|
||||||
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["ftp"]["active"] = conf.ftp.active;
|
|
||||||
JsonArray users = data["ftp"].createNestedArray("user");
|
|
||||||
for(Configuration::Ftp::User u : conf.ftp.users)
|
|
||||||
{
|
|
||||||
JsonObject v = users.createNestedObject();
|
|
||||||
v["name"] = u.name;
|
|
||||||
v["password"] = u.password;
|
|
||||||
}
|
|
||||||
|
|
||||||
serializeJson(data, file);
|
|
||||||
//serializeJson(data, Serial);
|
|
||||||
//Serial.println();
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
127
src/display.cpp
127
src/display.cpp
|
|
@ -1,127 +0,0 @@
|
||||||
|
|
||||||
#include <Wire.h>
|
|
||||||
#include <Adafruit_GFX.h>
|
|
||||||
#include <Adafruit_SSD1306.h>
|
|
||||||
|
|
||||||
#include "display.h"
|
|
||||||
#include "pins.h"
|
|
||||||
#include "logger.h"
|
|
||||||
|
|
||||||
Adafruit_SSD1306 display(128, 64, &Wire);
|
|
||||||
|
|
||||||
void setup_display()
|
|
||||||
{
|
|
||||||
Wire.begin(OLED_SDA, OLED_SCL);
|
|
||||||
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false))
|
|
||||||
{
|
|
||||||
logPrintlnE("SSD1306 allocation failed");
|
|
||||||
while (1);
|
|
||||||
}
|
|
||||||
logPrintlnI("Display init done!");
|
|
||||||
}
|
|
||||||
|
|
||||||
void turn_off_display()
|
|
||||||
{
|
|
||||||
display.ssd1306_command(SSD1306_DISPLAYOFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
void show_display(String header, int wait)
|
|
||||||
{
|
|
||||||
display.clearDisplay();
|
|
||||||
display.setTextColor(WHITE);
|
|
||||||
display.setTextSize(2);
|
|
||||||
display.setCursor(0,0);
|
|
||||||
display.println(header);
|
|
||||||
display.display();
|
|
||||||
delay(wait);
|
|
||||||
}
|
|
||||||
|
|
||||||
void show_display(String header, String line1, int wait)
|
|
||||||
{
|
|
||||||
display.clearDisplay();
|
|
||||||
display.setTextColor(WHITE);
|
|
||||||
display.setTextSize(2);
|
|
||||||
display.setCursor(0,0);
|
|
||||||
display.println(header);
|
|
||||||
display.setTextSize(1);
|
|
||||||
display.setCursor(0,16);
|
|
||||||
display.println(line1);
|
|
||||||
display.display();
|
|
||||||
delay(wait);
|
|
||||||
}
|
|
||||||
|
|
||||||
void show_display(String header, String line1, String line2, int wait)
|
|
||||||
{
|
|
||||||
display.clearDisplay();
|
|
||||||
display.setTextColor(WHITE);
|
|
||||||
display.setTextSize(2);
|
|
||||||
display.setCursor(0,0);
|
|
||||||
display.println(header);
|
|
||||||
display.setTextSize(1);
|
|
||||||
display.setCursor(0,16);
|
|
||||||
display.println(line1);
|
|
||||||
display.setCursor(0,26);
|
|
||||||
display.println(line2);
|
|
||||||
display.display();
|
|
||||||
delay(wait);
|
|
||||||
}
|
|
||||||
|
|
||||||
void show_display(String header, String line1, String line2, String line3, int wait)
|
|
||||||
{
|
|
||||||
display.clearDisplay();
|
|
||||||
display.setTextColor(WHITE);
|
|
||||||
display.setTextSize(2);
|
|
||||||
display.setCursor(0,0);
|
|
||||||
display.println(header);
|
|
||||||
display.setTextSize(1);
|
|
||||||
display.setCursor(0,16);
|
|
||||||
display.println(line1);
|
|
||||||
display.setCursor(0,26);
|
|
||||||
display.println(line2);
|
|
||||||
display.setCursor(0,36);
|
|
||||||
display.println(line3);
|
|
||||||
display.display();
|
|
||||||
delay(wait);
|
|
||||||
}
|
|
||||||
|
|
||||||
void show_display(String header, String line1, String line2, String line3, String line4, int wait)
|
|
||||||
{
|
|
||||||
display.clearDisplay();
|
|
||||||
display.setTextColor(WHITE);
|
|
||||||
display.setTextSize(2);
|
|
||||||
display.setCursor(0,0);
|
|
||||||
display.println(header);
|
|
||||||
display.setTextSize(1);
|
|
||||||
display.setCursor(0,16);
|
|
||||||
display.println(line1);
|
|
||||||
display.setCursor(0,26);
|
|
||||||
display.println(line2);
|
|
||||||
display.setCursor(0,36);
|
|
||||||
display.println(line3);
|
|
||||||
display.setCursor(0,46);
|
|
||||||
display.println(line4);
|
|
||||||
display.display();
|
|
||||||
delay(wait);
|
|
||||||
}
|
|
||||||
|
|
||||||
void show_display(String header, String line1, String line2, String line3, String line4, String line5, int wait)
|
|
||||||
{
|
|
||||||
display.clearDisplay();
|
|
||||||
display.setTextColor(WHITE);
|
|
||||||
display.setTextSize(2);
|
|
||||||
display.setCursor(0,0);
|
|
||||||
display.println(header);
|
|
||||||
display.setTextSize(1);
|
|
||||||
display.setCursor(0,16);
|
|
||||||
display.println(line1);
|
|
||||||
display.setCursor(0,26);
|
|
||||||
display.println(line2);
|
|
||||||
display.setCursor(0,36);
|
|
||||||
display.println(line3);
|
|
||||||
display.setCursor(0,46);
|
|
||||||
display.println(line4);
|
|
||||||
display.setCursor(0,56);
|
|
||||||
display.println(line5);
|
|
||||||
display.display();
|
|
||||||
delay(wait);
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
|
|
||||||
#ifndef DISPLAY_H_
|
|
||||||
#define DISPLAY_H_
|
|
||||||
|
|
||||||
void setup_display();
|
|
||||||
void turn_off_display();
|
|
||||||
|
|
||||||
void show_display(String header, int wait = 0);
|
|
||||||
void show_display(String header, String line1, int wait = 0);
|
|
||||||
void show_display(String header, String line1, String line2, int wait = 0);
|
|
||||||
void show_display(String header, String line1, String line2, String line3, int wait = 0);
|
|
||||||
void show_display(String header, String line1, String line2, String line3, String line4, int wait = 0);
|
|
||||||
void show_display(String header, String line1, String line2, String line3, String line4, String line5, int wait = 0);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
248
src/logger.cpp
248
src/logger.cpp
|
|
@ -1,248 +0,0 @@
|
||||||
#include "logger.h"
|
|
||||||
|
|
||||||
#undef LOG_RESET_COLOR
|
|
||||||
#undef LOG_COLOR_E
|
|
||||||
#undef LOG_COLOR_W
|
|
||||||
#undef LOG_COLOR_I
|
|
||||||
#undef LOG_COLOR_D
|
|
||||||
#undef LOG_COLOR_V
|
|
||||||
|
|
||||||
#define LOG_COLOR_BLACK "30"
|
|
||||||
#define LOG_COLOR_RED "31"
|
|
||||||
#define LOG_COLOR_GREEN "32"
|
|
||||||
#define LOG_COLOR_BROWN "33"
|
|
||||||
#define LOG_COLOR_BLUE "34"
|
|
||||||
#define LOG_COLOR_PURPLE "35"
|
|
||||||
#define LOG_COLOR_CYAN "36"
|
|
||||||
#define LOG_COLOR(COLOR) "\033[0;" COLOR "m"
|
|
||||||
#define LOG_BOLD(COLOR) "\033[1;" COLOR "m"
|
|
||||||
#define LOG_RESET_COLOR "\033[0m"
|
|
||||||
#define LOG_COLOR_E LOG_COLOR(LOG_COLOR_RED)
|
|
||||||
#define LOG_COLOR_W LOG_COLOR(LOG_COLOR_BROWN)
|
|
||||||
#define LOG_COLOR_I LOG_COLOR(LOG_COLOR_GREEN)
|
|
||||||
#define LOG_COLOR_D LOG_COLOR(LOG_COLOR_BLUE)
|
|
||||||
#define LOG_COLOR_V LOG_COLOR(LOG_COLOR_CYAN)
|
|
||||||
|
|
||||||
Logger::Logger()
|
|
||||||
: _serial(Serial), _level(DEBUG_LEVEL_DEBUG), _printIsNewline(true)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void Logger::setSerial(const HardwareSerial & serial)
|
|
||||||
{
|
|
||||||
_serial = serial;
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void Logger::setDebugLevel(debug_level_t level)
|
|
||||||
{
|
|
||||||
_level = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void Logger::printA(const String & text, const char * file, uint32_t line)
|
|
||||||
{
|
|
||||||
printStartColor(DEBUG_LEVEL_NONE);
|
|
||||||
printHeader(DEBUG_LEVEL_NONE, file, line, false);
|
|
||||||
_serial.print(text);
|
|
||||||
printEndColor(DEBUG_LEVEL_NONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void Logger::printE(const String & text, const char * file, uint32_t line)
|
|
||||||
{
|
|
||||||
printStartColor(DEBUG_LEVEL_ERROR);
|
|
||||||
printHeader(DEBUG_LEVEL_ERROR, file, line, false);
|
|
||||||
_serial.print(text);
|
|
||||||
printEndColor(DEBUG_LEVEL_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void Logger::printlnA(const String & text, const char * file, uint32_t line)
|
|
||||||
{
|
|
||||||
printStartColor(DEBUG_LEVEL_NONE);
|
|
||||||
printHeader(DEBUG_LEVEL_NONE, file, line, true);
|
|
||||||
_serial.println(text);
|
|
||||||
printEndColor(DEBUG_LEVEL_NONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void Logger::printlnE(const String & text, const char * file, uint32_t line)
|
|
||||||
{
|
|
||||||
printStartColor(DEBUG_LEVEL_ERROR);
|
|
||||||
printHeader(DEBUG_LEVEL_ERROR, file, line, true);
|
|
||||||
_serial.println(text);
|
|
||||||
printEndColor(DEBUG_LEVEL_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void Logger::printV(const String & text, const char * file, uint32_t line)
|
|
||||||
{
|
|
||||||
if (_level >= DEBUG_LEVEL_VERBOSE)
|
|
||||||
{
|
|
||||||
printStartColor(DEBUG_LEVEL_VERBOSE);
|
|
||||||
printHeader(DEBUG_LEVEL_VERBOSE, file, line, false);
|
|
||||||
_serial.print(text);
|
|
||||||
printEndColor(DEBUG_LEVEL_VERBOSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void Logger::printD(const String & text, const char * file, uint32_t line)
|
|
||||||
{
|
|
||||||
if (_level >= DEBUG_LEVEL_DEBUG)
|
|
||||||
{
|
|
||||||
printStartColor(DEBUG_LEVEL_DEBUG);
|
|
||||||
printHeader(DEBUG_LEVEL_DEBUG, file, line, false);
|
|
||||||
_serial.print(text);
|
|
||||||
printEndColor(DEBUG_LEVEL_DEBUG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void Logger::printI(const String & text, const char * file, uint32_t line)
|
|
||||||
{
|
|
||||||
if (_level >= DEBUG_LEVEL_INFO)
|
|
||||||
{
|
|
||||||
printStartColor(DEBUG_LEVEL_INFO);
|
|
||||||
printHeader(DEBUG_LEVEL_INFO, file, line, false);
|
|
||||||
_serial.print(text);
|
|
||||||
printEndColor(DEBUG_LEVEL_INFO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void Logger::printW(const String & text, const char * file, uint32_t line)
|
|
||||||
{
|
|
||||||
if (_level >= DEBUG_LEVEL_WARN)
|
|
||||||
{
|
|
||||||
printStartColor(DEBUG_LEVEL_WARN);
|
|
||||||
printHeader(DEBUG_LEVEL_WARN, file, line, false);
|
|
||||||
_serial.print(text);
|
|
||||||
printEndColor(DEBUG_LEVEL_WARN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void Logger::printlnV(const String & text, const char * file, uint32_t line)
|
|
||||||
{
|
|
||||||
if (_level >= DEBUG_LEVEL_VERBOSE)
|
|
||||||
{
|
|
||||||
printStartColor(DEBUG_LEVEL_VERBOSE);
|
|
||||||
printHeader(DEBUG_LEVEL_VERBOSE, file, line, true);
|
|
||||||
_serial.println(text);
|
|
||||||
printEndColor(DEBUG_LEVEL_VERBOSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void Logger::printlnD(const String & text, const char * file, uint32_t line)
|
|
||||||
{
|
|
||||||
if (_level >= DEBUG_LEVEL_DEBUG)
|
|
||||||
{
|
|
||||||
printStartColor(DEBUG_LEVEL_DEBUG);
|
|
||||||
printHeader(DEBUG_LEVEL_DEBUG, file, line, true);
|
|
||||||
_serial.println(text);
|
|
||||||
printEndColor(DEBUG_LEVEL_DEBUG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void Logger::printlnI(const String & text, const char * file, uint32_t line)
|
|
||||||
{
|
|
||||||
if (_level >= DEBUG_LEVEL_INFO)
|
|
||||||
{
|
|
||||||
printStartColor(DEBUG_LEVEL_INFO);
|
|
||||||
printHeader(DEBUG_LEVEL_INFO, file, line, true);
|
|
||||||
_serial.println(text);
|
|
||||||
printEndColor(DEBUG_LEVEL_INFO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void Logger::printlnW(const String & text, const char * file, uint32_t line)
|
|
||||||
{
|
|
||||||
if (_level >= DEBUG_LEVEL_WARN)
|
|
||||||
{
|
|
||||||
printStartColor(DEBUG_LEVEL_WARN);
|
|
||||||
printHeader(DEBUG_LEVEL_WARN, file, line, true);
|
|
||||||
_serial.println(text);
|
|
||||||
printEndColor(DEBUG_LEVEL_WARN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Logger::printStartColor(debug_level_t level)
|
|
||||||
{
|
|
||||||
switch (level)
|
|
||||||
{
|
|
||||||
case DEBUG_LEVEL_ERROR:
|
|
||||||
_serial.print(LOG_COLOR_E);
|
|
||||||
break;
|
|
||||||
case DEBUG_LEVEL_WARN:
|
|
||||||
_serial.print(LOG_COLOR_W);
|
|
||||||
break;
|
|
||||||
case DEBUG_LEVEL_INFO:
|
|
||||||
_serial.print(LOG_COLOR_I);
|
|
||||||
break;
|
|
||||||
case DEBUG_LEVEL_DEBUG:
|
|
||||||
_serial.print(LOG_COLOR_D);
|
|
||||||
break;
|
|
||||||
case DEBUG_LEVEL_VERBOSE:
|
|
||||||
_serial.print(LOG_COLOR_V);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Logger::printHeader(debug_level_t level, const char * file, uint32_t line, bool isln)
|
|
||||||
{
|
|
||||||
if (_printIsNewline)
|
|
||||||
{
|
|
||||||
Serial.printf("%c %25s %4d : ", levelToChar(level), file, line);
|
|
||||||
if(!isln)
|
|
||||||
{
|
|
||||||
_printIsNewline = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_printIsNewline = isln;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Logger::printEndColor(debug_level_t level)
|
|
||||||
{
|
|
||||||
switch (level)
|
|
||||||
{
|
|
||||||
case DEBUG_LEVEL_ERROR:
|
|
||||||
case DEBUG_LEVEL_WARN:
|
|
||||||
case DEBUG_LEVEL_INFO:
|
|
||||||
case DEBUG_LEVEL_DEBUG:
|
|
||||||
case DEBUG_LEVEL_VERBOSE:
|
|
||||||
_serial.print(LOG_RESET_COLOR);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
char Logger::levelToChar(debug_level_t level)
|
|
||||||
{
|
|
||||||
switch (level)
|
|
||||||
{
|
|
||||||
case DEBUG_LEVEL_ERROR:
|
|
||||||
return 'E';
|
|
||||||
case DEBUG_LEVEL_WARN:
|
|
||||||
return 'W';
|
|
||||||
case DEBUG_LEVEL_INFO:
|
|
||||||
return 'I';
|
|
||||||
case DEBUG_LEVEL_DEBUG:
|
|
||||||
return 'D';
|
|
||||||
case DEBUG_LEVEL_VERBOSE:
|
|
||||||
return 'V';
|
|
||||||
default:
|
|
||||||
return ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
75
src/logger.h
75
src/logger.h
|
|
@ -1,75 +0,0 @@
|
||||||
#ifndef _LOGGER_H_
|
|
||||||
#define _LOGGER_H_
|
|
||||||
|
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
class Logger
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum debug_level_t {
|
|
||||||
DEBUG_LEVEL_NONE, // No debug output
|
|
||||||
DEBUG_LEVEL_ERROR, // Critical errors
|
|
||||||
DEBUG_LEVEL_WARN, // Error conditions but not critical
|
|
||||||
DEBUG_LEVEL_INFO, // Information messages
|
|
||||||
DEBUG_LEVEL_DEBUG, // Extra information - default level (if not changed)
|
|
||||||
DEBUG_LEVEL_VERBOSE, // More information than the usual
|
|
||||||
DEBUG_LEVELS_SIZE
|
|
||||||
};
|
|
||||||
|
|
||||||
static Logger & instance()
|
|
||||||
{
|
|
||||||
static Logger _instance;
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
~Logger() {}
|
|
||||||
|
|
||||||
void setSerial(const HardwareSerial & serial = Serial);
|
|
||||||
void setDebugLevel(debug_level_t level);
|
|
||||||
|
|
||||||
// print always:
|
|
||||||
void printA(const String & text, const char * file, uint32_t line); // always
|
|
||||||
void printE(const String & text, const char * file, uint32_t line); // error
|
|
||||||
void printlnA(const String & text, const char * file, uint32_t line); // always with new line
|
|
||||||
void printlnE(const String & text, const char * file, uint32_t line); // error with new line
|
|
||||||
|
|
||||||
// depending on verbose level:
|
|
||||||
void printV(const String & text, const char * file, uint32_t line); // verbose
|
|
||||||
void printD(const String & text, const char * file, uint32_t line); // debug
|
|
||||||
void printI(const String & text, const char * file, uint32_t line); // information
|
|
||||||
void printW(const String & text, const char * file, uint32_t line); // warning
|
|
||||||
|
|
||||||
void printlnV(const String & text, const char * file, uint32_t line); // verbose with new line
|
|
||||||
void printlnD(const String & text, const char * file, uint32_t line); // debug with new line
|
|
||||||
void printlnI(const String & text, const char * file, uint32_t line); // information with new line
|
|
||||||
void printlnW(const String & text, const char * file, uint32_t line); // warning with new line
|
|
||||||
|
|
||||||
private:
|
|
||||||
HardwareSerial & _serial;
|
|
||||||
debug_level_t _level;
|
|
||||||
bool _printIsNewline;
|
|
||||||
|
|
||||||
void printStartColor(debug_level_t level);
|
|
||||||
void printHeader(debug_level_t level, const char * file, uint32_t line, bool isln);
|
|
||||||
void printEndColor(debug_level_t level);
|
|
||||||
char levelToChar(debug_level_t level);
|
|
||||||
|
|
||||||
Logger();
|
|
||||||
Logger(const Logger &);
|
|
||||||
Logger & operator = (const Logger &);
|
|
||||||
};
|
|
||||||
|
|
||||||
#define logPrintA(text) Logger::instance().printA(text, __FILE__, __LINE__)
|
|
||||||
#define logPrintE(text) Logger::instance().printE(text, __FILE__, __LINE__)
|
|
||||||
#define logPrintlnA(text) Logger::instance().printlnA(text, __FILE__, __LINE__)
|
|
||||||
#define logPrintlnE(text) Logger::instance().printlnE(text, __FILE__, __LINE__)
|
|
||||||
#define logPrintV(text) Logger::instance().printV(text, __FILE__, __LINE__)
|
|
||||||
#define logPrintD(text) Logger::instance().printD(text, __FILE__, __LINE__)
|
|
||||||
#define logPrintI(text) Logger::instance().printI(text, __FILE__, __LINE__)
|
|
||||||
#define logPrintW(text) Logger::instance().printW(text, __FILE__, __LINE__)
|
|
||||||
#define logPrintlnV(text) Logger::instance().printlnV(text, __FILE__, __LINE__)
|
|
||||||
#define logPrintlnD(text) Logger::instance().printlnD(text, __FILE__, __LINE__)
|
|
||||||
#define logPrintlnI(text) Logger::instance().printlnI(text, __FILE__, __LINE__)
|
|
||||||
#define logPrintlnW(text) Logger::instance().printlnW(text, __FILE__, __LINE__)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
56
src/pins.h
56
src/pins.h
|
|
@ -1,56 +0,0 @@
|
||||||
#ifndef PINS_H_
|
|
||||||
#define PINS_H_
|
|
||||||
|
|
||||||
#undef OLED_SDA
|
|
||||||
#undef OLED_SCL
|
|
||||||
#undef OLED_RST
|
|
||||||
|
|
||||||
#if defined(HELTEC_WIFI_LORA_32_V1) || defined(HELTEC_WIFI_LORA_32_V2) || defined(TTGO_LORA32_V1)
|
|
||||||
#define OLED_SDA 4
|
|
||||||
#define OLED_SCL 15
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(TTGO_LORA32_V2) || defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0)
|
|
||||||
#define OLED_SDA 21
|
|
||||||
#define OLED_SCL 22
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TRACKERD
|
|
||||||
#define OLED_SDA 5
|
|
||||||
#define OLED_SCL 4
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ETH_BOARD
|
|
||||||
#define OLED_SDA 33
|
|
||||||
#define OLED_SCL 32
|
|
||||||
#define ETH_POWER_PIN -1
|
|
||||||
#define ETH_TYPE ETH_PHY_LAN8720
|
|
||||||
#define ETH_ADDR 0
|
|
||||||
#define ETH_MDC_PIN 23
|
|
||||||
#define ETH_MDIO_PIN 18
|
|
||||||
#define NRST 5
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ETH_BOARD_V1_0
|
|
||||||
#define ETH_CLK ETH_CLOCK_GPIO17_OUT // TTGO PoE V1.0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ETH_BOARD_V1_2
|
|
||||||
#define ETH_CLK ETH_CLOCK_GPIO0_OUT // TTGO PoE V1.2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#undef KEY_BUILTIN
|
|
||||||
#if defined(TTGO_T_Beam_V0_7)
|
|
||||||
#define KEY_BUILTIN 39
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(TTGO_T_Beam_V1_0)
|
|
||||||
#define KEY_BUILTIN 38
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef KEY_BUILTIN
|
|
||||||
#define KEY_BUILTIN 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
|
|
||||||
#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)
|
|
||||||
{
|
|
||||||
axp.setDCDC1Voltage(3300);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void PowerManagement::activateLoRa()
|
|
||||||
{
|
|
||||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON);
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void PowerManagement::deactivateLoRa()
|
|
||||||
{
|
|
||||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
void PowerManagement::decativateOLED()
|
|
||||||
{
|
|
||||||
axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
#ifndef POWER_MANAGEMENT_H_
|
|
||||||
#define POWER_MANAGEMENT_H_
|
|
||||||
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <axp20x.h>
|
|
||||||
|
|
||||||
class PowerManagement
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PowerManagement();
|
|
||||||
bool begin(TwoWire & port);
|
|
||||||
|
|
||||||
void activateLoRa();
|
|
||||||
void deactivateLoRa();
|
|
||||||
|
|
||||||
void activateGPS();
|
|
||||||
void deactivateGPS();
|
|
||||||
|
|
||||||
void activateOLED();
|
|
||||||
void decativateOLED();
|
|
||||||
|
|
||||||
private:
|
|
||||||
AXP20X_Class axp;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
109
src/project_configuration.cpp
Normal file
109
src/project_configuration.cpp
Normal file
|
|
@ -0,0 +1,109 @@
|
||||||
|
#include <SPIFFS.h>
|
||||||
|
|
||||||
|
#include "project_configuration.h"
|
||||||
|
#include "logger.h"
|
||||||
|
|
||||||
|
Configuration * ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocument & data)
|
||||||
|
{
|
||||||
|
Configuration * conf = new Configuration;
|
||||||
|
if(data.containsKey("callsign"))
|
||||||
|
conf->callsign = data["callsign"].as<String>();
|
||||||
|
|
||||||
|
conf->wifi.active = data["wifi"]["active"] | false;
|
||||||
|
JsonArray aps = data["wifi"]["AP"].as<JsonArray>();
|
||||||
|
for(JsonVariant v : aps)
|
||||||
|
{
|
||||||
|
Configuration::Wifi::AP ap;
|
||||||
|
ap.SSID = v["SSID"].as<String>();
|
||||||
|
ap.password = v["password"].as<String>();
|
||||||
|
conf->wifi.APs.push_back(ap);
|
||||||
|
}
|
||||||
|
if(data.containsKey("beacon") && data["beacon"].containsKey("message"))
|
||||||
|
conf->beacon.message = data["beacon"]["message"].as<String>();
|
||||||
|
conf->beacon.positionLatitude = data["beacon"]["position"]["latitude"] | 0.0;
|
||||||
|
conf->beacon.positionLongitude = data["beacon"]["position"]["longitude"] | 0.0;
|
||||||
|
conf->aprs_is.active = data["aprs_is"]["active"] | false;
|
||||||
|
if(data.containsKey("aprs_is") && data["aprs_is"].containsKey("password"))
|
||||||
|
conf->aprs_is.password = data["aprs_is"]["password"].as<String>();
|
||||||
|
if(data.containsKey("aprs_is") && data["aprs_is"].containsKey("server"))
|
||||||
|
conf->aprs_is.server = data["aprs_is"]["server"].as<String>();
|
||||||
|
conf->aprs_is.port = data["aprs_is"]["port"] | 14580;
|
||||||
|
conf->aprs_is.beacon = data["aprs_is"]["beacon"] | true;
|
||||||
|
conf->aprs_is.beaconTimeout = data["aprs_is"]["beacon_timeout"] | 15;
|
||||||
|
conf->digi.active = data["digi"]["active"] | false;
|
||||||
|
conf->digi.forwardTimeout = data["digi"]["forward_timeout"] | 5;
|
||||||
|
conf->digi.beacon = data["digi"]["beacon"] | true;
|
||||||
|
conf->digi.beaconTimeout = data["digi"]["beacon_timeout"] | 30;
|
||||||
|
|
||||||
|
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->ftp.active = data["ftp"]["active"] | false;
|
||||||
|
JsonArray users = data["ftp"]["user"].as<JsonArray>();
|
||||||
|
for(JsonVariant u : users)
|
||||||
|
{
|
||||||
|
Configuration::Ftp::User us;
|
||||||
|
us.name = u["name"].as<String>();
|
||||||
|
us.password = u["password"].as<String>();
|
||||||
|
conf->ftp.users.push_back(us);
|
||||||
|
}
|
||||||
|
if(conf->ftp.users.empty())
|
||||||
|
{
|
||||||
|
Configuration::Ftp::User us;
|
||||||
|
us.name = "ftp";
|
||||||
|
us.password = "ftp";
|
||||||
|
conf->ftp.users.push_back(us);
|
||||||
|
}
|
||||||
|
|
||||||
|
return conf;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectConfigurationManagement::writeProjectConfiguration(Configuration * conf, DynamicJsonDocument & data)
|
||||||
|
{
|
||||||
|
data["callsign"] = conf->callsign;
|
||||||
|
data["wifi"]["active"] = conf->wifi.active;
|
||||||
|
JsonArray aps = data["wifi"].createNestedArray("AP");
|
||||||
|
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["aprs_is"]["active"] = conf->aprs_is.active;
|
||||||
|
data["aprs_is"]["password"] = conf->aprs_is.password;
|
||||||
|
data["aprs_is"]["server"] = conf->aprs_is.server;
|
||||||
|
data["aprs_is"]["port"] = conf->aprs_is.port;
|
||||||
|
data["aprs_is"]["beacon"] = conf->aprs_is.beacon;
|
||||||
|
data["aprs_is"]["beacon_timeout"] = conf->aprs_is.beaconTimeout;
|
||||||
|
data["digi"]["active"] = conf->digi.active;
|
||||||
|
data["digi"]["forward_timeout"] = conf->digi.forwardTimeout;
|
||||||
|
data["digi"]["beacon"] = conf->digi.beacon;
|
||||||
|
data["digi"]["beacon_timeout"] = conf->digi.beaconTimeout;
|
||||||
|
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["ftp"]["active"] = conf->ftp.active;
|
||||||
|
JsonArray users = data["ftp"].createNestedArray("user");
|
||||||
|
for(Configuration::Ftp::User u : conf->ftp.users)
|
||||||
|
{
|
||||||
|
JsonObject v = users.createNestedObject();
|
||||||
|
v["name"] = u.name;
|
||||||
|
v["password"] = u.password;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,7 @@
|
||||||
#ifndef CONFIGURATION_H_
|
#ifndef PROJECT_CONFIGURATION_H_
|
||||||
#define CONFIGURATION_H_
|
#define PROJECT_CONFIGURATION_H_
|
||||||
|
|
||||||
#include <list>
|
#include "configuration.h"
|
||||||
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <ArduinoJson.h>
|
|
||||||
|
|
||||||
class Configuration
|
class Configuration
|
||||||
{
|
{
|
||||||
|
|
@ -110,16 +107,15 @@ public:
|
||||||
Ftp ftp;
|
Ftp ftp;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConfigurationManagement
|
class ProjectConfigurationManagement : public ConfigurationManagement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ConfigurationManagement(String FilePath);
|
explicit ProjectConfigurationManagement() : ConfigurationManagement("/is-cfg.json") {}
|
||||||
|
virtual ~ProjectConfigurationManagement() {}
|
||||||
Configuration readConfiguration();
|
|
||||||
void writeConfiguration(Configuration conf);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const String mFilePath;
|
virtual Configuration * readProjectConfiguration(DynamicJsonDocument & data) override;
|
||||||
|
virtual void writeProjectConfiguration(Configuration * conf, DynamicJsonDocument & data) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Loading…
Reference in a new issue