NAC mismatch detection, false sync suppression, SPS hunt stabilization#73
Open
bdwyertech wants to merge 2 commits intoarancormonk:mainfrom
Open
NAC mismatch detection, false sync suppression, SPS hunt stabilization#73bdwyertech wants to merge 2 commits intoarancormonk:mainfrom
bdwyertech wants to merge 2 commits intoarancormonk:mainfrom
Conversation
Owner
|
@bdwyertech Thanks for the contribution and for digging into the CC reacquisition issue. I pushed a maintainer follow-up commit to this PR. I kept the intent of your fix, but tightened the behavior in a few places:
Could you test the updated branch against the setup or capture that showed the original issue and confirm it still solves the problem on your end? |
Author
|
Yep, looks good -- I will give it a shot, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three fixes for P25 trunked scanning stability, identified from debug logs on a Motorola P25 Phase 1 system with RTL-SDR R828D tuner.
1. NAC mismatch detection in trunk state machine
Files: p25_trunk_sm.c, p25_trunk_sm.h
When the decoder lands on a wrong frequency (e.g., adjacent traffic channel after a mis-tune), it sees a different NAC but the state machine only detects cc-lost via timestamp staleness after the full cc_grace window (5 seconds). During that time, every frame is duid:EE with frequent NID parity mismatches.
Added a nac_mismatch_count field to p25_sm_ctx_t and a check in the ON_CC tick handler that compares state->nac against state->p2_cc (the expected CC NAC from Network Status Broadcast). After 3 consecutive mismatches, triggers cc-lost-nac-mismatch and immediately hunts for the correct CC. Transient NAC values 0 and 0xFFF (which appear during signal drops) are ignored.
Reduces wrong-NAC dwell from ~7 seconds to under 1 second.
2. False D-STAR/YSF sync suppression when locked to P25
File: dsd_frame_sync.c
On noisy P25 frames, the 20-symbol YSF and 24-symbol D-STAR sync patterns occasionally match by chance, causing a brief false protocol switch that disrupts P25 decoding. Observed as Sync: +DSTAR VOICE and Sync: +YSF with garbage data in debug logs while actively tracking a P25 control channel.
Added !DSD_SYNC_IS_P25(state->lastsynctype) guards to both the YSF and D-STAR sync detection blocks. When the decoder is currently tracking a P25 signal, it skips YSF and D-STAR pattern matching entirely.
3. SPS hunt cycle stabilization
File: dsd_frame_sync.c
The multi-rate SPS hunting cycled every 3 buffer passes (~0.5 seconds), causing rapid oscillation between 4800 and 6000 sym/s on secondary control channels with marginal signal. This produced repeated ON_CC → HUNT → ON_CC cycles at startup (6+ cycles in 17 seconds observed).
Increased the cycle interval from 3 to 5 buffer passes (~0.8 seconds) to give each symbol rate more time to acquire sync before switching.
Testing
All three fixes validated on live air against the same Motorola P25 Phase 1 trunked system. Compared debug logs before and after across multiple sessions (~20 minutes total):
NAC mismatch episodes: eliminated (0 occurrences vs 1 sustained 7-second episode)
False D-STAR/YSF syncs: eliminated (0 vs 2 in previous logs)
SPS hunt cycles at startup: eliminated (1 normal cc-lost/hunt vs 6+ rapid oscillations)
Voice call grant/tune/decode/release cycle: working correctly throughout
No regressions in TSBK decoding, frequency mapping, or adjacent site tracking