From 36c1a09bdd0c8c62a2a7c561fb1202016fb5a822 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 16 Sep 2021 13:42:36 -0500 Subject: [PATCH] Number telemetry sequence correctly. --- include/preference_storage.h | 2 ++ platformio.ini | 3 ++- src/TTGO_T-Beam_LoRa_APRS.ino | 38 +++++++++++++++++++++++++++++------ 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/include/preference_storage.h b/include/preference_storage.h index 9d1f9aa..2eabc67 100644 --- a/include/preference_storage.h +++ b/include/preference_storage.h @@ -39,6 +39,8 @@ static const char *const PREF_ENABLE_TNC_SELF_TELEMETRY = "tnc_tel"; static const char *const PREF_ENABLE_TNC_SELF_TELEMETRY_INIT = "tnc_tel_i"; static const char *const PREF_TNC_SELF_TELEMETRY_INTERVAL = "tnc_tel_int"; static const char *const PREF_TNC_SELF_TELEMETRY_INTERVAL_INIT = "tnc_tel_int_i"; +static const char *const PREF_TNC_SELF_TELEMETRY_SEQ = "tnc_tel_seq"; +static const char *const PREF_TNC_SELF_TELEMETRY_SEQ_INIT = "tnc_tel_seq_i"; // SMART BEACONING static const char *const PREF_APRS_SB_MIN_INTERVAL_PRESET = "sb_min_interv"; static const char *const PREF_APRS_SB_MIN_INTERVAL_PRESET_INIT = "sb_min_interv_i"; diff --git a/platformio.ini b/platformio.ini index ab71b65..c9e20bb 100644 --- a/platformio.ini +++ b/platformio.ini @@ -53,7 +53,8 @@ build_flags = -D 'FIX_BEACON_INTERVAL=1800000L' ; can be set from www interface -D 'NETWORK_GPS_PORT=10110' ; GPS NMEA Port -D 'ENABLE_TNC_SELF_TELEMETRY' ; can be set from www interface - -D 'TNC_SELF_TELEMETRY_INTERVAL=60L' ; telemetry interval (milliseconds) + -D 'TNC_SELF_TELEMETRY_INTERVAL=3600L' ; can be set from www interface (seconds) + -D 'TNC_SELF_TELEMETRY_SEQ=0L' [env:ttgo-t-beam-v1.0] platform = espressif32 @ 3.0.0 diff --git a/src/TTGO_T-Beam_LoRa_APRS.ino b/src/TTGO_T-Beam_LoRa_APRS.ino index 33c3571..b2763e6 100644 --- a/src/TTGO_T-Beam_LoRa_APRS.ino +++ b/src/TTGO_T-Beam_LoRa_APRS.ino @@ -104,6 +104,7 @@ boolean t_lock = false; boolean fixed_beacon_enabled = false; boolean show_cmt = true; int tel_interval; +int tel_sequence; #ifdef SHOW_ALT boolean showAltitude = true; @@ -499,10 +500,16 @@ String prepareCallsign(const String& callsign){ sprintf_P(Tcall_message_char, "%-9s", Tcall); String Tcall_message = String(Tcall_message_char); + // Determine sequence number (or 'MIC') + // Pad to 3 digits + char tel_sequence_char[3]; + sprintf_P(tel_sequence_char, "%03i", tel_sequence); + String tel_sequence_str = String(tel_sequence_char); + String telemetryParamsNames = String(":") + Tcall_message + ":PARM.B Volt,B In,B Out,AC V,AC C"; String telemetryUnitNames = String(":") + Tcall_message + ":UNIT.mV,mA,mA,mV,mA"; String telemetryEquations = String(":") + Tcall_message + ":EQNS.0,5.1,3000,0,10,0,0,10,0,0,28,3000,0,10,0"; - String telemetryData = String("T#") + String(b_volt) + ","+ String(b_in_c) + ","+ String(b_out_c) + ","+ String(ac_volt) + ","+ String(ac_c) + ",00000000"; + String telemetryData = String("T#") + tel_sequence_str + "," + String(b_volt) + "," + String(b_in_c) + "," + String(b_out_c) + "," + String(ac_volt) + "," + String(ac_c) + ",00000000"; String telemetryBase = ""; telemetryBase += Tcall + ">APLO01," + relay_path + ":"; Serial.print(telemetryBase); @@ -510,6 +517,19 @@ String prepareCallsign(const String& callsign){ sendToTNC(telemetryBase + telemetryUnitNames); sendToTNC(telemetryBase + telemetryEquations); sendToTNC(telemetryBase + telemetryData); + + // Show when telemetry is being sent + writedisplaytext("((TEL TX))","","","","",""); + + // Flash the light when telemetry is being sent + // CODE HERE + + // Update the telemetry sequence number + if(tel_sequence >= 0 & tel_sequence < 999){ + tel_sequence = tel_sequence + 1; + } else { + tel_sequence = 0; + } } #endif } @@ -532,11 +552,11 @@ void setup(){ relay_path = ""; #endif - //#ifdef TNC_SELF_TELEMETRY_INTERVAL - // tel_interval = TNC_SELF_TELEMETRY_INTERVAL; - //#else - // tel_interval = 60; - //#endif + #ifdef TNC_SELF_TELEMETRY_SEQ + tel_sequence = TNC_SELF_TELEMETRY_SEQ; + #else + tel_sequence = 0; + #endif #ifdef FIXED_BEACON_EN fixed_beacon_enabled = true; @@ -620,6 +640,12 @@ void setup(){ } tel_interval = preferences.getInt(PREF_TNC_SELF_TELEMETRY_INTERVAL); + if (!preferences.getBool(PREF_TNC_SELF_TELEMETRY_SEQ_INIT)){ + preferences.putBool(PREF_TNC_SELF_TELEMETRY_SEQ_INIT, true); + preferences.putInt(PREF_TNC_SELF_TELEMETRY_SEQ, tel_sequence); + } + tel_sequence = preferences.getInt(PREF_TNC_SELF_TELEMETRY_SEQ); + if (!preferences.getBool(PREF_APRS_LATITUDE_PRESET_INIT)){ preferences.putBool(PREF_APRS_LATITUDE_PRESET_INIT, true); preferences.putString(PREF_APRS_LATITUDE_PRESET, LATIDUDE_PRESET);