Delay squelch activation by 2 ms

Delaying the squelch activation by 2 ms helps to avoid dropped samples if the
signal is barely above the squelch threshold.
This commit is contained in:
Thomas Kolb 2024-09-20 23:08:43 +02:00
parent 4dc2c60c8b
commit ccd9af6664

View file

@ -36,6 +36,8 @@
#define AGC_BW_ACQUISITION 5e-2f #define AGC_BW_ACQUISITION 5e-2f
#define AGC_BW_TRACKING 1e-4f #define AGC_BW_TRACKING 1e-4f
#define SQUELCH_TIMEOUT_MS 2
#define MAX_COARSE_FREQ_OFFSET 0.20f #define MAX_COARSE_FREQ_OFFSET 0.20f
#define PLL_BW_HEADER 0.03f #define PLL_BW_HEADER 0.03f
@ -216,15 +218,15 @@ static enum squelch_state_t update_and_check_squelch(layer1_rx_t *rx, unsigned i
break; break;
case LIQUID_AGC_SQUELCH_SIGNALHI: case LIQUID_AGC_SQUELCH_SIGNALHI:
case LIQUID_AGC_SQUELCH_FALL:
case LIQUID_AGC_SQUELCH_SIGNALLO:
result = SQUELCH_OPEN; result = SQUELCH_OPEN;
break; break;
case LIQUID_AGC_SQUELCH_FALL: case LIQUID_AGC_SQUELCH_TIMEOUT:
LOG(LVL_DEBUG, "Squelch enabled at #%zu RSSI = %.3f dB [thr: %.3f dB]", rx->sample_index, level, agc_crcf_squelch_get_threshold(rx->agc)); LOG(LVL_DEBUG, "Squelch enabled at #%zu RSSI = %.3f dB [thr: %.3f dB]", rx->sample_index, level, agc_crcf_squelch_get_threshold(rx->agc));
// fall through // fall through
case LIQUID_AGC_SQUELCH_SIGNALLO:
case LIQUID_AGC_SQUELCH_ENABLED: case LIQUID_AGC_SQUELCH_ENABLED:
case LIQUID_AGC_SQUELCH_TIMEOUT:
result = SQUELCH_CLOSED; result = SQUELCH_CLOSED;
break; break;
} }
@ -239,13 +241,13 @@ static bool is_squelch_open(const layer1_rx_t *rx)
switch(agc_crcf_squelch_get_status(rx->agc)) { switch(agc_crcf_squelch_get_status(rx->agc)) {
case LIQUID_AGC_SQUELCH_RISE: case LIQUID_AGC_SQUELCH_RISE:
case LIQUID_AGC_SQUELCH_SIGNALHI: case LIQUID_AGC_SQUELCH_SIGNALHI:
case LIQUID_AGC_SQUELCH_FALL:
case LIQUID_AGC_SQUELCH_SIGNALLO:
result = true; result = true;
break; break;
case LIQUID_AGC_SQUELCH_FALL:
case LIQUID_AGC_SQUELCH_SIGNALLO:
case LIQUID_AGC_SQUELCH_ENABLED:
case LIQUID_AGC_SQUELCH_TIMEOUT: case LIQUID_AGC_SQUELCH_TIMEOUT:
case LIQUID_AGC_SQUELCH_ENABLED:
result = false; result = false;
break; break;
} }
@ -560,6 +562,7 @@ result_t layer1_rx_init(layer1_rx_t *rx, rx_callback_t callback)
rx->noise_floor_level = 0.0f; rx->noise_floor_level = 0.0f;
agc_crcf_squelch_set_threshold(rx->agc, rx->noise_floor_level + 3.0f); // in dB agc_crcf_squelch_set_threshold(rx->agc, rx->noise_floor_level + 3.0f); // in dB
agc_crcf_squelch_enable(rx->agc); agc_crcf_squelch_enable(rx->agc);
agc_crcf_squelch_set_timeout(rx->agc, SQUELCH_TIMEOUT_MS * SYMBOL_RATE * RRC_SPS / 1000);
// create NCOs for carrier frequency compensation // create NCOs for carrier frequency compensation
rx->carrier_coarse_nco = nco_crcf_create(LIQUID_NCO); rx->carrier_coarse_nco = nco_crcf_create(LIQUID_NCO);