Skip to content

Commit

Permalink
#1787 Resolves issue with channel rotation and rest channel reallocat…
Browse files Browse the repository at this point in the history
…ion for Capacity Plus systems. (#1798)

Co-authored-by: sheirerd <sheirerd@ainfosec.com>
  • Loading branch information
DSheirer and sheirerd committed Jan 19, 2024
1 parent e2a0325 commit 1c420b8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
Expand Up @@ -1361,10 +1361,11 @@ public void receiveDecoderStateEvent(DecoderStateEvent event)
}
break;
case NOTIFICATION_SOURCE_FREQUENCY:
long previous = mCurrentFrequency;
mCurrentFrequency = event.getFrequency();
if(hasTrafficChannelManager())
{
mTrafficChannelManager.setCurrentControlFrequency(mCurrentFrequency, mChannel);
mTrafficChannelManager.setCurrentControlFrequency(previous, mCurrentFrequency, mChannel);
}
break;
default:
Expand Down
Expand Up @@ -25,6 +25,7 @@
import io.github.dsheirer.module.decode.dmr.identifier.DMRTalkgroup;
import io.github.dsheirer.module.decode.dmr.message.CACH;
import io.github.dsheirer.module.decode.dmr.message.DMRBurst;
import io.github.dsheirer.module.decode.dmr.message.data.DataMessageWithLinkControl;
import io.github.dsheirer.module.decode.dmr.message.data.IDLEMessage;
import io.github.dsheirer.module.decode.dmr.message.data.block.DataBlock;
import io.github.dsheirer.module.decode.dmr.message.data.csbk.CSBKMessage;
Expand All @@ -48,12 +49,13 @@
import io.github.dsheirer.module.decode.dmr.message.voice.VoiceMessage;
import io.github.dsheirer.module.decode.dmr.message.voice.VoiceSuperFrameProcessor;
import io.github.dsheirer.sample.Listener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Processes DMR messages and performs re-assembly of link control fragments
Expand Down Expand Up @@ -154,6 +156,12 @@ else if(message instanceof DMRBurst dmrBurst && isValid(dmrBurst))
}
}

//Process data messages carrying a link control payload so that the LC payload can be processed/enriched
if(message instanceof DataMessageWithLinkControl linkControlCarrier)
{
receive(linkControlCarrier.getLCMessage());
}

//Enrich messages that carry DMR Logical Channel Numbers with LCN to frequency mappings
if(message instanceof ITimeslotFrequencyReceiver)
{
Expand Down
Expand Up @@ -134,12 +134,38 @@ public DMRTrafficChannelManager(Channel parentChannel)
/**
* Sets the current parent control channel frequency so that channel grants for the current frequency do not
* produce an additional traffic channel allocation.
* @param currentControlFrequency for current control channel.
* @param previousControlFrequency for the current control channel (to remove from allocated channels)
* @param currentControlFrequency for current control channel (to add to allocated channels)
* @param channel for the current control channel
*/
public void setCurrentControlFrequency(long currentControlFrequency, Channel channel)
public void setCurrentControlFrequency(long previousControlFrequency, long currentControlFrequency, Channel channel)
{
mAllocatedChannelFrequencyMap.put(currentControlFrequency, channel);
if(previousControlFrequency == currentControlFrequency)
{
return;
}

mLock.lock();

try
{
Channel existing = mAllocatedChannelFrequencyMap.get(previousControlFrequency);

//Only remove the channel if it is non-null and it matches the current control channel.
if(channel.equals(existing))
{
//Unlock the frequency in the channel rotation monitor
getInterModuleEventBus().post(FrequencyLockChangeRequest.unlock(previousControlFrequency));
mAllocatedChannelFrequencyMap.remove(previousControlFrequency);
}

mAllocatedChannelFrequencyMap.put(currentControlFrequency, channel);
getInterModuleEventBus().post(FrequencyLockChangeRequest.lock(currentControlFrequency));
}
finally
{
mLock.unlock();
}
}

/**
Expand Down

0 comments on commit 1c420b8

Please sign in to comment.