mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-21 04:55:55 -05:00
On sparse channels, noise false syncs accumulated across long idle periods and permanently locked the sync mode monitor to the wrong mode (ie DIRECT_ONLY), so the repeater's base station syncs were never detected again until the channel was restarted. - Only sync detections that follow a previous sync within the max sync interval are counted toward the sync mode. - Restore AUTOMATIC sync mode after 5 seconds without a sync detection, unless the mode is locked (ie BASE_ONLY for traffic channels). Co-authored-by: denny <dennis.sheirer@gmail.com>
This commit is contained in:
@@ -271,6 +271,26 @@ public abstract class C4FMSymbolProcessor
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of symbols without a sync detection after which syncInactivityTimeout() is invoked. Default is zero,
|
||||
* which disables the timeout.
|
||||
* @return timeout as a count of symbols, or zero to disable.
|
||||
*/
|
||||
protected int getSyncInactivityTimeoutSymbolCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification that no sync was detected for the sync inactivity timeout period (see
|
||||
* getSyncInactivityTimeoutSymbolCount()). Invoked once per period of inactivity. Subclasses can override this to
|
||||
* reset protocol specific state that was learned from the signal. Default implementation is a no-op.
|
||||
*/
|
||||
protected void syncInactivityTimeout()
|
||||
{
|
||||
//No-op default implementation
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of consecutive sync periods (capped at 3) where a sync was detected within the max message length.
|
||||
*/
|
||||
@@ -406,6 +426,11 @@ public abstract class C4FMSymbolProcessor
|
||||
|
||||
symbolsSinceLastSync++;
|
||||
|
||||
if(symbolsSinceLastSync == getSyncInactivityTimeoutSymbolCount())
|
||||
{
|
||||
syncInactivityTimeout();
|
||||
}
|
||||
|
||||
//Clear synchronized state when we miss a sync period.
|
||||
if(mSynchronized && symbolsSinceLastSync > getMaxMessageDibitLength())
|
||||
{
|
||||
|
||||
@@ -72,6 +72,10 @@ public class DMRSymbolProcessor extends C4FMSymbolProcessor
|
||||
//recordings with injected noise, where valid link control improved. A max of 10 leaks noise false syncs and 6
|
||||
//costs more multipath data bursts. Applying the max once synchronized cost 3 - 20% of valid bursts.
|
||||
private static final int SYNC_ACQUISITION_MAX_BIT_ERRORS = 8;
|
||||
//Restores automatic sync mode detection after this many symbols (5 seconds) without a sync detection, so that a
|
||||
//sync mode that was established on earlier traffic (ie direct mode) doesn't prevent detection of later traffic
|
||||
//that uses a different sync mode (ie a repeater) on the same channel.
|
||||
private static final int SYNC_MODE_INACTIVITY_TIMEOUT_SYMBOLS = SYMBOL_RATE * 5;
|
||||
private final DMRSyncModeMonitor mSyncModeMonitor = new DMRSyncModeMonitor();
|
||||
private final DMRMessageFramer mMessageFramer;
|
||||
|
||||
@@ -116,6 +120,10 @@ public class DMRSymbolProcessor extends C4FMSymbolProcessor
|
||||
|
||||
/**
|
||||
* Captures the detected sync pattern to update the sync mode monitor and the message framer.
|
||||
*
|
||||
* Only sync detections that follow a previous sync detection within the max sync interval (ie consecutive sync
|
||||
* periods) are counted toward the sync mode, since noise produces isolated false sync detections while acquiring
|
||||
* that would otherwise accumulate across long idle periods and lock the sync mode to the wrong mode.
|
||||
* @param syncDetector that triggered the sync detection.
|
||||
*/
|
||||
@Override
|
||||
@@ -124,11 +132,32 @@ public class DMRSymbolProcessor extends C4FMSymbolProcessor
|
||||
if(syncDetector instanceof DMRSoftSyncDetector dmrSyncDetector)
|
||||
{
|
||||
DMRSyncPattern pattern = dmrSyncDetector.getDetectedPattern();
|
||||
mSyncModeMonitor.detected(pattern);
|
||||
|
||||
if(getConsecutiveSyncPeriods() >= 2)
|
||||
{
|
||||
mSyncModeMonitor.detected(pattern);
|
||||
}
|
||||
|
||||
mMessageFramer.setSyncPattern(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSyncInactivityTimeoutSymbolCount()
|
||||
{
|
||||
return SYNC_MODE_INACTIVITY_TIMEOUT_SYMBOLS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores automatic sync mode detection after a period of inactivity, unless the mode was locked (ie BASE_ONLY
|
||||
* for a traffic channel).
|
||||
*/
|
||||
@Override
|
||||
protected void syncInactivityTimeout()
|
||||
{
|
||||
mSyncModeMonitor.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Once synchronized with at least two consecutive sync detections, only allows sync detections within a small
|
||||
* window around each expected burst boundary (multiples of the burst length) to prevent false sync detections
|
||||
|
||||
@@ -26,6 +26,11 @@ import java.util.List;
|
||||
* Monitors sync pattern detections to automatically detect the prevailing or dominant sync mode group used on a channel
|
||||
* and optimizes the DMR sync detectors to reduce the quantity of false detects of unused sync patterns and the overall
|
||||
* sync detection processing workload.
|
||||
*
|
||||
* An automatically detected mode is not permanent: reset() restores AUTOMATIC mode so that the dominant mode can be
|
||||
* re-established, for example after a period of inactivity on a channel that carries sparse or mixed mode (ie
|
||||
* repeater and direct mode) traffic. A mode that is set via setMode() (ie BASE_ONLY for a traffic channel) is locked
|
||||
* and is not affected by sync detections or reset().
|
||||
*/
|
||||
public class DMRSyncModeMonitor
|
||||
{
|
||||
@@ -34,6 +39,7 @@ public class DMRSyncModeMonitor
|
||||
private int mBaseCount;
|
||||
private int mMobileCount;
|
||||
private int mDirectCount;
|
||||
private DMRSyncDetectMode mLockedMode = DMRSyncDetectMode.AUTOMATIC;
|
||||
private DMRSyncDetectMode mMode = DMRSyncDetectMode.AUTOMATIC;
|
||||
|
||||
/**
|
||||
@@ -45,17 +51,39 @@ public class DMRSyncModeMonitor
|
||||
|
||||
/**
|
||||
* Sets (and locks) the sync detection mode. This can be directly invoked when the operating mode is known
|
||||
* in advance, such as for a repeated traffic channel where the expected mode is BASE_ONLY, otherwise this method
|
||||
* is automatically invoked by this monitor when operating in ALL mode, once the dominant mode is established.
|
||||
* in advance, such as for a repeated traffic channel where the expected mode is BASE_ONLY. Setting AUTOMATIC
|
||||
* unlocks the mode so that this monitor detects the dominant mode from the sync detections.
|
||||
* @param mode to set
|
||||
*/
|
||||
public void setMode(DMRSyncDetectMode mode)
|
||||
{
|
||||
mMode = mode;
|
||||
mLockedMode = mode;
|
||||
clearCounts();
|
||||
applyMode(mode);
|
||||
}
|
||||
|
||||
for(DMRSyncDetector detector : mSyncDetectors)
|
||||
/**
|
||||
* Current sync detection mode.
|
||||
*/
|
||||
public DMRSyncDetectMode getMode()
|
||||
{
|
||||
return mMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores AUTOMATIC mode and clears the sync detection counts so that the dominant mode is re-established from
|
||||
* subsequent sync detections. Has no effect when the mode is locked via setMode().
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
if(mLockedMode == DMRSyncDetectMode.AUTOMATIC)
|
||||
{
|
||||
detector.setMode(mode);
|
||||
clearCounts();
|
||||
|
||||
if(mMode != DMRSyncDetectMode.AUTOMATIC)
|
||||
{
|
||||
applyMode(DMRSyncDetectMode.AUTOMATIC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,15 +120,32 @@ public class DMRSyncModeMonitor
|
||||
|
||||
if(mBaseCount - mMobileCount > DOMINANT_THRESHOLD && mBaseCount - mDirectCount > DOMINANT_THRESHOLD)
|
||||
{
|
||||
setMode(DMRSyncDetectMode.BASE_ONLY);
|
||||
applyMode(DMRSyncDetectMode.BASE_ONLY);
|
||||
}
|
||||
else if(mMobileCount - mBaseCount > DOMINANT_THRESHOLD && mMobileCount - mDirectCount > DOMINANT_THRESHOLD)
|
||||
{
|
||||
setMode(DMRSyncDetectMode.MOBILE_ONLY);
|
||||
applyMode(DMRSyncDetectMode.MOBILE_ONLY);
|
||||
}
|
||||
else if(mDirectCount - mBaseCount > DOMINANT_THRESHOLD && mDirectCount - mMobileCount > DOMINANT_THRESHOLD)
|
||||
{
|
||||
setMode(DMRSyncDetectMode.DIRECT_ONLY);
|
||||
applyMode(DMRSyncDetectMode.DIRECT_ONLY);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearCounts()
|
||||
{
|
||||
mBaseCount = 0;
|
||||
mMobileCount = 0;
|
||||
mDirectCount = 0;
|
||||
}
|
||||
|
||||
private void applyMode(DMRSyncDetectMode mode)
|
||||
{
|
||||
mMode = mode;
|
||||
|
||||
for(DMRSyncDetector detector : mSyncDetectors)
|
||||
{
|
||||
detector.setMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user