From 5f8346d2907540fbe7aa7e9bdf97866e69420a1c Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Sat, 25 May 2024 18:16:24 +0200 Subject: [PATCH] agc: update squelch threshold more often This fixes the noise level tracking in test cases like the loopback test where the signal has already ramped up before the first noise level update. --- impl/src/layer1/rx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/impl/src/layer1/rx.c b/impl/src/layer1/rx.c index d0fae51..1a4e30a 100644 --- a/impl/src/layer1/rx.c +++ b/impl/src/layer1/rx.c @@ -184,7 +184,7 @@ static enum squelch_state_t update_and_check_squelch(layer1_rx_t *rx, unsigned i float level = agc_crcf_get_rssi(rx->agc); enum squelch_state_t result = SQUELCH_CLOSED; - if((sample_idx & 0xFF) == 0) { // every 256 samples + if((sample_idx & 0x3F) == 0) { // every 64 samples if(level < rx->noise_floor_level) { rx->noise_floor_level = level; } else { @@ -197,7 +197,7 @@ static enum squelch_state_t update_and_check_squelch(layer1_rx_t *rx, unsigned i switch(agc_crcf_squelch_get_status(rx->agc)) { case LIQUID_AGC_SQUELCH_RISE: - DEBUG_LOG("Squelch disabled at #%u RSSI = %.3f dB [thr: %.3f dB]\n", sample_idx, level, agc_crcf_squelch_get_threshold(rx->agc)); + DEBUG_LOG("Squelch disabled at #%zu RSSI = %.3f dB [thr: %.3f dB]\n", rx->sample_index, level, agc_crcf_squelch_get_threshold(rx->agc)); result = SQUELCH_JUST_OPENED; break; @@ -206,7 +206,7 @@ static enum squelch_state_t update_and_check_squelch(layer1_rx_t *rx, unsigned i break; case LIQUID_AGC_SQUELCH_FALL: - DEBUG_LOG("Squelch enabled at #%u RSSI = %.3f dB [thr: %.3f dB]\n", sample_idx, level, agc_crcf_squelch_get_threshold(rx->agc)); + DEBUG_LOG("Squelch enabled at #%zu RSSI = %.3f dB [thr: %.3f dB]\n", rx->sample_index, level, agc_crcf_squelch_get_threshold(rx->agc)); // fall through case LIQUID_AGC_SQUELCH_SIGNALLO: case LIQUID_AGC_SQUELCH_ENABLED: