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

View file

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

View file

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

View file

@ -1,8 +1,8 @@
#ifndef CONFIGURATION_H_ #ifndef CONFIGURATION_H_
#define CONFIGURATION_H_ #define CONFIGURATION_H_
#include <list>
#include <iterator> #include <iterator>
#include <list>
#include <Arduino.h> #include <Arduino.h>
@ -10,10 +10,11 @@ class Configuration {
public: public:
class Beacon { class Beacon {
public: 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 callsign;
String path;
String message; String message;
int timeout; int timeout;
String symbol; String symbol;
@ -69,16 +70,16 @@ public:
int alt_message; 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 debug;
bool enhance_precision; bool enhance_precision;
std::list<Beacon> beacons; std::list<Beacon> beacons;
int current_beacon_index; int current_beacon_index;
Smart_Beacon smart_beacon; Smart_Beacon smart_beacon;
LoRa lora; LoRa lora;
PTT ptt; PTT ptt;
Button button; Button button;
Beacon GetCurrentBeacon(); Beacon GetCurrentBeacon();
Beacon SetNextBeacon(); Beacon SetNextBeacon();