From 88c7994e4745da517d74f23ede1af87c4cd7e4ce Mon Sep 17 00:00:00 2001 From: Piotr Lewandowski Date: Sat, 20 Apr 2024 13:15:02 +0200 Subject: [PATCH 1/4] tx preamle len settings, extended rx timeout --- data_embed/index.html | 4 ++++ include/preference_storage.h | 2 ++ src/TTGO_T-Beam_LoRa_APRS.ino | 19 +++++++++++++++++-- src/taskWebServer.cpp | 4 ++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/data_embed/index.html b/data_embed/index.html index a2cd2a9..851d9e3 100644 --- a/data_embed/index.html +++ b/data_embed/index.html @@ -154,6 +154,10 @@ You like to enable, if you use your tracker portable and it should automatically +
+ + +
diff --git a/include/preference_storage.h b/include/preference_storage.h index 7fb03c1..2ad226e 100644 --- a/include/preference_storage.h +++ b/include/preference_storage.h @@ -37,6 +37,8 @@ static const char *const PREF_LORA_TX_ENABLE_INIT = "lora_tx_en_i"; static const char *const PREF_LORA_TX_ENABLE = "lora_tx_en"; static const char *const PREF_LORA_TX_POWER_INIT = "txPower_i"; static const char *const PREF_LORA_TX_POWER = "txPower"; +static const char *const PREF_LORA_TX_PREAMBLE_LEN_INIT = "preambleLen_i"; +static const char *const PREF_LORA_TX_PREAMBLE_LEN = "preambleLen"; static const char *const PREF_LORA_ADD_SNR_RSSI_TO_PATH_PRESET_INIT = "lora_rssi2p_i"; static const char *const PREF_LORA_ADD_SNR_RSSI_TO_PATH_PRESET = "lora_rssi2p"; static const char *const PREF_LORA_ADD_SNR_RSSI_TO_PATH_END_AT_KISS_PRESET_INIT = "snraprsis_i"; diff --git a/src/TTGO_T-Beam_LoRa_APRS.ino b/src/TTGO_T-Beam_LoRa_APRS.ino index 551fe3c..ebb6892 100644 --- a/src/TTGO_T-Beam_LoRa_APRS.ino +++ b/src/TTGO_T-Beam_LoRa_APRS.ino @@ -448,6 +448,8 @@ boolean lora_tx_enabled = true; uint8_t txPower_cross_digi = 23; #endif #endif +uint32_t preambleLen = 64; // default tx preamble len +constexpr uint32_t rxTimeoutSymbols = 1024; // extended rx timout to avoid rejecting packets with long preamble #define UNITS_SPEED_KMH 1 #define UNITS_SPEED_MS 2 @@ -1208,6 +1210,7 @@ void loraSend(byte lora_LTXPower, float lora_FREQ, ulong lora_SPEED, uint8_t fla lora_set_speed(lora_SPEED); rf95.setFrequency(lora_FREQ); rf95.setTxPower(lora_LTXPower); + rf95.setPreambleLength(preambleLen); #ifdef ENABLE_LED_SIGNALING digitalWrite(TXLED, LOW); @@ -3027,6 +3030,7 @@ void load_preferences_cfg_file() lora_rx_enabled = jsonElementFromPreferenceCFGBool(PREF_LORA_RX_ENABLE,PREF_LORA_RX_ENABLE_INIT); lora_tx_enabled = jsonElementFromPreferenceCFGBool(PREF_LORA_TX_ENABLE,PREF_LORA_TX_ENABLE_INIT); txPower = jsonElementFromPreferenceCFGInt(PREF_LORA_TX_POWER,PREF_LORA_TX_POWER_INIT); + preambleLen = jsonElementFromPreferenceCFGInt(PREF_LORA_TX_PREAMBLE_LEN, PREF_LORA_TX_PREAMBLE_LEN_INIT); lora_automatic_cr_adaption = jsonElementFromPreferenceCFGBool(PREF_LORA_AUTOMATIC_CR_ADAPTION_PRESET,PREF_LORA_AUTOMATIC_CR_ADAPTION_PRESET_INIT); lora_add_snr_rssi_to_path = jsonElementFromPreferenceCFGInt(PREF_LORA_ADD_SNR_RSSI_TO_PATH_PRESET,PREF_LORA_ADD_SNR_RSSI_TO_PATH_PRESET_INIT); kiss_add_snr_rssi_to_path_at_position_without_digippeated_flag = jsonElementFromPreferenceCFGBool(PREF_LORA_ADD_SNR_RSSI_TO_PATH_END_AT_KISS_PRESET,PREF_LORA_ADD_SNR_RSSI_TO_PATH_END_AT_KISS_PRESET_INIT); @@ -3196,6 +3200,12 @@ void load_preferences_from_flash() } txPower = lora_tx_enabled ? preferences.getInt(PREF_LORA_TX_POWER) : 0; + if (!preferences.getBool(PREF_LORA_TX_PREAMBLE_LEN_INIT)){ + preferences.putBool(PREF_LORA_TX_PREAMBLE_LEN_INIT, true); + preferences.putInt(PREF_LORA_TX_PREAMBLE_LEN, preambleLen); + } + preambleLen = preferences.getInt(PREF_LORA_TX_PREAMBLE_LEN); + if (!preferences.getBool(PREF_LORA_AUTOMATIC_CR_ADAPTION_PRESET_INIT)){ preferences.putBool(PREF_LORA_AUTOMATIC_CR_ADAPTION_PRESET_INIT, true); preferences.putBool(PREF_LORA_AUTOMATIC_CR_ADAPTION_PRESET, lora_automatic_cr_adaption); @@ -3740,9 +3750,12 @@ void setup_phase2_soft_reconfiguration(boolean runtime_reconfiguration) { // we tx on main and/or secondary frequency. For tx, loraSend is called (and always has desired txpower as argument) rf95.setTxPower((lora_digipeating_mode < 2 || lora_cross_digipeating_mode < 1) ? txPower : txPower_cross_digi); - + Serial.printf("LoRa PWR: %d, LoRa PWR XDigi: %d, RX Enable: %d, TX Enable: %d\r\n", txPower, txPower_cross_digi, lora_rx_enabled, lora_tx_enabled); - + + // setting rx TO, default to allow rx of long preamble packets + rf95.setPreambleLength(rxTimeoutSymbols); + // APRS fixed location and icon settings init_and_validate_aprs_position_and_icon(); @@ -6751,6 +6764,8 @@ invalid_packet: if (sema_lora_lock_success) { rf95.setFrequency(lora_freq_rx_curr); lora_set_speed(lora_speed_rx_curr); + // setting rx TO, default to allow rx of long preamble packets + rf95.setPreambleLength(rxTimeoutSymbols); // Avoid packet in rx queue from secondary qrg being interpreted to come from main qrg if (lora_freq_rx_curr == lora_freq) rf95.recvAPRS(0, 0); diff --git a/src/taskWebServer.cpp b/src/taskWebServer.cpp index c79fdff..aaa652e 100644 --- a/src/taskWebServer.cpp +++ b/src/taskWebServer.cpp @@ -485,6 +485,7 @@ void refill_preferences_as_jsonData() s = s + "\n " + jsonLineFromPreferenceBool(PREF_LORA_RX_ENABLE); s = s + "\n " + jsonLineFromPreferenceBool(PREF_LORA_TX_ENABLE); s = s + "\n " + jsonLineFromPreferenceInt(PREF_LORA_TX_POWER); + s = s + "\n " + jsonLineFromPreferenceInt(PREF_LORA_TX_PREAMBLE_LEN); s = s + "\n " + jsonLineFromPreferenceBool(PREF_LORA_AUTOMATIC_CR_ADAPTION_PRESET); s = s + "\n " + jsonLineFromPreferenceInt(PREF_LORA_ADD_SNR_RSSI_TO_PATH_PRESET); s = s + "\n " + jsonLineFromPreferenceBool(PREF_LORA_ADD_SNR_RSSI_TO_PATH_END_AT_KISS_PRESET); @@ -961,6 +962,9 @@ void handle_SaveAPRSCfg() { if (server.hasArg(PREF_LORA_TX_POWER)) { preferences.putInt(PREF_LORA_TX_POWER, server.arg(PREF_LORA_TX_POWER).toInt()); } + if (server.hasArg(PREF_LORA_TX_PREAMBLE_LEN)) { + preferences.putInt(PREF_LORA_TX_PREAMBLE_LEN, server.arg(PREF_LORA_TX_PREAMBLE_LEN).toInt()); + } preferences.putBool(PREF_LORA_AUTOMATIC_CR_ADAPTION_PRESET, server.hasArg(PREF_LORA_AUTOMATIC_CR_ADAPTION_PRESET)); if (server.hasArg(PREF_LORA_ADD_SNR_RSSI_TO_PATH_PRESET)){ preferences.putInt(PREF_LORA_ADD_SNR_RSSI_TO_PATH_PRESET, server.arg(PREF_LORA_ADD_SNR_RSSI_TO_PATH_PRESET).toInt()); From 307aeb0c8087a42951a4a68a70d5dcd8c00451c9 Mon Sep 17 00:00:00 2001 From: Piotr Lewandowski Date: Sat, 20 Apr 2024 14:13:32 +0200 Subject: [PATCH 2/4] preambleLen added in preferences.cfg --- data/preferences.cfg | 1 + src/TTGO_T-Beam_LoRa_APRS.ino | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/data/preferences.cfg b/data/preferences.cfg index 14a24b2..0e762b0 100644 --- a/data/preferences.cfg +++ b/data/preferences.cfg @@ -14,6 +14,7 @@ "lora_rx_en": true, "lora_tx_en": true, "txPower": 23, + "preambleLen": 64, "lora_cradapt": false, "lora_rssi2p": 34, "snraprsis": true, diff --git a/src/TTGO_T-Beam_LoRa_APRS.ino b/src/TTGO_T-Beam_LoRa_APRS.ino index ebb6892..4654bd9 100644 --- a/src/TTGO_T-Beam_LoRa_APRS.ino +++ b/src/TTGO_T-Beam_LoRa_APRS.ino @@ -3030,7 +3030,7 @@ void load_preferences_cfg_file() lora_rx_enabled = jsonElementFromPreferenceCFGBool(PREF_LORA_RX_ENABLE,PREF_LORA_RX_ENABLE_INIT); lora_tx_enabled = jsonElementFromPreferenceCFGBool(PREF_LORA_TX_ENABLE,PREF_LORA_TX_ENABLE_INIT); txPower = jsonElementFromPreferenceCFGInt(PREF_LORA_TX_POWER,PREF_LORA_TX_POWER_INIT); - preambleLen = jsonElementFromPreferenceCFGInt(PREF_LORA_TX_PREAMBLE_LEN, PREF_LORA_TX_PREAMBLE_LEN_INIT); + preambleLen = jsonElementFromPreferenceCFGInt(PREF_LORA_TX_PREAMBLE_LEN,PREF_LORA_TX_PREAMBLE_LEN_INIT); lora_automatic_cr_adaption = jsonElementFromPreferenceCFGBool(PREF_LORA_AUTOMATIC_CR_ADAPTION_PRESET,PREF_LORA_AUTOMATIC_CR_ADAPTION_PRESET_INIT); lora_add_snr_rssi_to_path = jsonElementFromPreferenceCFGInt(PREF_LORA_ADD_SNR_RSSI_TO_PATH_PRESET,PREF_LORA_ADD_SNR_RSSI_TO_PATH_PRESET_INIT); kiss_add_snr_rssi_to_path_at_position_without_digippeated_flag = jsonElementFromPreferenceCFGBool(PREF_LORA_ADD_SNR_RSSI_TO_PATH_END_AT_KISS_PRESET,PREF_LORA_ADD_SNR_RSSI_TO_PATH_END_AT_KISS_PRESET_INIT); From bfa18ff5ebfde83c7cc37a5230239a5b05ba9c3a Mon Sep 17 00:00:00 2001 From: Piotr Lewandowski Date: Sat, 20 Apr 2024 14:17:51 +0200 Subject: [PATCH 3/4] updated-description --- data_embed/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_embed/index.html b/data_embed/index.html index 851d9e3..ef6e4f8 100644 --- a/data_embed/index.html +++ b/data_embed/index.html @@ -156,7 +156,7 @@ You like to enable, if you use your tracker portable and it should automatically
- +
From 3c645ca232f7c3ccf939cc52e23865cafff043cc Mon Sep 17 00:00:00 2001 From: Piotr Lewandowski Date: Sun, 21 Apr 2024 13:25:52 +0200 Subject: [PATCH 4/4] added preamble conf placeholder with def val, changed def to 8 symbols --- data/preferences.cfg | 2 +- data_embed/index.html | 2 +- src/TTGO_T-Beam_LoRa_APRS.ino | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data/preferences.cfg b/data/preferences.cfg index 0e762b0..715bd9b 100644 --- a/data/preferences.cfg +++ b/data/preferences.cfg @@ -14,7 +14,7 @@ "lora_rx_en": true, "lora_tx_en": true, "txPower": 23, - "preambleLen": 64, + "preambleLen": 8, "lora_cradapt": false, "lora_rssi2p": 34, "snraprsis": true, diff --git a/data_embed/index.html b/data_embed/index.html index ef6e4f8..22e3410 100644 --- a/data_embed/index.html +++ b/data_embed/index.html @@ -156,7 +156,7 @@ You like to enable, if you use your tracker portable and it should automatically
- +
diff --git a/src/TTGO_T-Beam_LoRa_APRS.ino b/src/TTGO_T-Beam_LoRa_APRS.ino index 4654bd9..1db8659 100644 --- a/src/TTGO_T-Beam_LoRa_APRS.ino +++ b/src/TTGO_T-Beam_LoRa_APRS.ino @@ -448,8 +448,8 @@ boolean lora_tx_enabled = true; uint8_t txPower_cross_digi = 23; #endif #endif -uint32_t preambleLen = 64; // default tx preamble len -constexpr uint32_t rxTimeoutSymbols = 1024; // extended rx timout to avoid rejecting packets with long preamble +uint16_t preambleLen = 8; // default tx preamble len +constexpr uint16_t rxTimeoutSymbols = 1024; // extended rx timout to avoid rejecting packets with long preamble #define UNITS_SPEED_KMH 1 #define UNITS_SPEED_MS 2