diff --git a/data/preferences.cfg b/data/preferences.cfg index 14a24b2..715bd9b 100644 --- a/data/preferences.cfg +++ b/data/preferences.cfg @@ -14,6 +14,7 @@ "lora_rx_en": true, "lora_tx_en": true, "txPower": 23, + "preambleLen": 8, "lora_cradapt": false, "lora_rssi2p": 34, "snraprsis": true, diff --git a/data_embed/index.html b/data_embed/index.html index a2cd2a9..22e3410 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..1db8659 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 +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 @@ -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());