This commit is contained in:
Peter Buchegger 2021-12-19 22:27:29 +01:00
parent 6f2fd7e959
commit a87c3ddb76
4 changed files with 32 additions and 31 deletions

View File

@ -1,23 +1,21 @@
{
"debug": false,
"enhance_precision": true,
"beacons":
[
"beacons": [
{
"callsign": "NOCALL-7",
"path": "WIDE1-1",
"message": "LoRa Tracker",
"timeout": 1,
"symbol": "[",
"overlay": "/"
}
],
"button":
{
"button": {
"tx": true,
"alt_message": true
},
"smart_beacon":
{
"smart_beacon": {
"active": true,
"turn_min": 25,
"slow_rate": 300,
@ -27,8 +25,7 @@
"min_tx_dist": 100,
"min_bcn": 5
},
"lora":
{
"lora": {
"frequency_rx": 433775000,
"frequency_tx": 433775000,
"power": 20,
@ -36,12 +33,11 @@
"signal_bandwidth": 125000,
"coding_rate4": 5
},
"ptt_output":
{
"ptt_output": {
"active": false,
"io_pin": 4,
"start_delay": 0,
"end_delay": 0,
"reverse": false
}
}
}

View File

@ -186,7 +186,7 @@ void loop() {
}
if (send_update && gps_loc_update) {
send_update = false;
send_update = false;
Configuration::Beacon beacon = Config.GetCurrentBeacon();
nextBeaconTimeStamp = now() + (Config.smart_beacon.active ? Config.smart_beacon.slow_rate : (beacon.timeout * SECS_PER_MIN));
@ -197,6 +197,7 @@ void loop() {
String dao;
msg.setSource(beacon.callsign);
msg.setPath(beacon.path);
msg.setDestination("APLT00-1");
if (!Config.enhance_precision) {

View File

@ -43,6 +43,8 @@ Configuration ConfigurationManagement::readConfiguration() {
if (v.containsKey("callsign"))
beacon.callsign = v["callsign"].as<String>();
if (v.containsKey("path"))
beacon.path = v["path"].as<String>();
if (v.containsKey("message"))
beacon.message = v["message"].as<String>();
beacon.timeout = v["timeout"] | 1;
@ -62,9 +64,9 @@ Configuration ConfigurationManagement::readConfiguration() {
conf.smart_beacon.fast_speed = data["smart_beacon"]["fast_speed"] | 100;
conf.smart_beacon.min_tx_dist = data["smart_beacon"]["min_tx_dist"] | 100;
conf.smart_beacon.min_bcn = data["smart_beacon"]["min_bcn"] | 5;
conf.button.tx = data["button"]["tx"] | false;
conf.button.alt_message = data["button"]["alt_message"] | false;
conf.button.tx = data["button"]["tx"] | false;
conf.button.alt_message = data["button"]["alt_message"] | false;
conf.lora.frequencyRx = data["lora"]["frequency_rx"] | 433775000;
conf.lora.frequencyTx = data["lora"]["frequency_tx"] | 433775000;
@ -95,17 +97,18 @@ void ConfigurationManagement::writeConfiguration(Configuration conf) {
for (Configuration::Beacon beacon : conf.beacons) {
JsonObject v = beacons.createNestedObject();
v["callsign"] = beacon.callsign;
v["path"] = beacon.path;
v["message"] = beacon.message;
v["timeout"] = beacon.timeout;
v["symbol"] = beacon.symbol;
v["overlay"] = beacon.overlay;
}
data["debug"] = conf.debug;
data["enhance_precision"] = conf.enhance_precision;
data["debug"] = conf.debug;
data["enhance_precision"] = conf.enhance_precision;
data["button"]["tx"] = conf.button.tx;
data["button"]["alt_message"] = conf.button.alt_message;
data["button"]["tx"] = conf.button.tx;
data["button"]["alt_message"] = conf.button.alt_message;
data["smart_beacon"]["active"] = conf.smart_beacon.active;
data["smart_beacon"]["turn_min"] = conf.smart_beacon.turn_min;
@ -144,4 +147,4 @@ Configuration::Beacon Configuration::SetNextBeacon() {
if (this->current_beacon_index >= this->beacons.size())
this->current_beacon_index = 0;
return this->GetCurrentBeacon();
}
}

View File

@ -1,8 +1,8 @@
#ifndef CONFIGURATION_H_
#define CONFIGURATION_H_
#include <list>
#include <iterator>
#include <list>
#include <Arduino.h>
@ -10,10 +10,11 @@ class Configuration {
public:
class Beacon {
public:
Beacon() : callsign("NOCALL-10"), message("LoRa Tracker, Info: github.com/lora-aprs/LoRa_APRS_Tracker"), timeout(1), symbol("["), overlay("/") {
Beacon() : callsign("NOCALL-10"), path("WIDE1-1"), message("LoRa Tracker"), timeout(1), symbol("["), overlay("/") {
}
String callsign;
String path;
String message;
int timeout;
String symbol;
@ -69,16 +70,16 @@ public:
int alt_message;
};
Configuration() : debug(false), enhance_precision(true), current_beacon_index(0) {};
Configuration() : debug(false), enhance_precision(true), current_beacon_index(0){};
bool debug;
bool enhance_precision;
std::list<Beacon> beacons;
int current_beacon_index;
Smart_Beacon smart_beacon;
LoRa lora;
PTT ptt;
Button button;
bool debug;
bool enhance_precision;
std::list<Beacon> beacons;
int current_beacon_index;
Smart_Beacon smart_beacon;
LoRa lora;
PTT ptt;
Button button;
Beacon GetCurrentBeacon();
Beacon SetNextBeacon();