diff --git a/data/tracker.json b/data/tracker.json index 8114e3d..a6439ab 100644 --- a/data/tracker.json +++ b/data/tracker.json @@ -28,5 +28,13 @@ "spreading_factor":12, "signal_bandwidth":125000, "coding_rate4":5 + }, + "ptt_output": + { + "active":false, + "io_pin": 4, + "start_delay": 0, + "end_delay": 0, + "reverse":false } } diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index 2b10e60..8c93220 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -63,6 +63,12 @@ void setup() setup_gps(); setup_lora(); + if (Config.ptt.active) + { + pinMode(Config.ptt.io_pin, OUTPUT); + digitalWrite(Config.ptt.io_pin, Config.ptt.reverse ? HIGH : LOW); + } + // make sure wifi and bt is off as we don't need it: WiFi.mode(WIFI_OFF); btStop(); @@ -263,6 +269,13 @@ void loop() String data = msg.encode(); logPrintlnD(data); show_display("<< TX >>", data); + + if (Config.ptt.active) + { + digitalWrite(Config.ptt.io_pin, Config.ptt.reverse ? LOW : HIGH); + delay(Config.ptt.start_delay); + } + LoRa.beginPacket(); // Header: LoRa.write('<'); @@ -280,6 +293,12 @@ void loop() lastTxdistance = 0.0; lastTxTime = millis(); } + + if (Config.ptt.active) + { + delay(Config.ptt.end_delay); + digitalWrite(Config.ptt.io_pin, Config.ptt.reverse ? HIGH : LOW); + } } if(gps_time_update) diff --git a/src/configuration.cpp b/src/configuration.cpp index f8c603f..3aa226c 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -68,6 +68,12 @@ Configuration ConfigurationManagement::readConfiguration() conf.lora.signalBandwidth = data["lora"]["signal_bandwidth"] | 125000; conf.lora.codingRate4 = data["lora"]["coding_rate4"] | 5; + conf.ptt.active = data["ptt_output"]["active"] | false; + conf.ptt.io_pin = data["ptt_output"]["io_pin"] | 4; + conf.ptt.start_delay = data["ptt_output"]["start_delay"] | 0; + conf.ptt.end_delay = data["ptt_output"]["end_delay"] | 0; + conf.ptt.reverse = data["ptt_output"]["reverse"] | false; + return conf; } @@ -105,6 +111,12 @@ void ConfigurationManagement::writeConfiguration(Configuration conf) data["lora"]["signal_bandwidth"] = conf.lora.signalBandwidth; data["lora"]["coding_rate4"] = conf.lora.codingRate4; + data["ptt_out"]["active"] = conf.ptt.active; + data["ptt_out"]["io_pin"] = conf.ptt.io_pin; + data["ptt_out"]["start_delay"] = conf.ptt.start_delay; + data["ptt_out"]["end_delay"] = conf.ptt.end_delay; + data["ptt_out"]["reverse"] = conf.ptt.reverse; + serializeJson(data, file); file.close(); } diff --git a/src/configuration.h b/src/configuration.h index 1ad2df3..b39a687 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -47,6 +47,18 @@ public: int codingRate4; }; + class PTT + { + public: + PTT() : active(false), io_pin(4), start_delay(0), end_delay(0), reverse(false) {} + + bool active; + int io_pin; + int start_delay; + int end_delay; + bool reverse; + }; + Configuration() : callsign("NOCALL-10"), debug(false), enhance_precision(true) {}; String callsign; @@ -55,6 +67,7 @@ public: Beacon beacon; Smart_Beacon smart_beacon; LoRa lora; + PTT ptt; }; class ConfigurationManagement