Skip to content

Commit e3018b3

Browse files
author
sheirerd
committed
#1787 Resolves issue with channel rotation and rest channel reallocation for Capacity Plus systems.
1 parent e2a0325 commit e3018b3

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

src/main/java/io/github/dsheirer/module/decode/dmr/DMRDecoderState.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,10 +1361,11 @@ public void receiveDecoderStateEvent(DecoderStateEvent event)
13611361
}
13621362
break;
13631363
case NOTIFICATION_SOURCE_FREQUENCY:
1364+
long previous = mCurrentFrequency;
13641365
mCurrentFrequency = event.getFrequency();
13651366
if(hasTrafficChannelManager())
13661367
{
1367-
mTrafficChannelManager.setCurrentControlFrequency(mCurrentFrequency, mChannel);
1368+
mTrafficChannelManager.setCurrentControlFrequency(previous, mCurrentFrequency, mChannel);
13681369
}
13691370
break;
13701371
default:

src/main/java/io/github/dsheirer/module/decode/dmr/DMRMessageProcessor.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import io.github.dsheirer.module.decode.dmr.identifier.DMRTalkgroup;
2626
import io.github.dsheirer.module.decode.dmr.message.CACH;
2727
import io.github.dsheirer.module.decode.dmr.message.DMRBurst;
28+
import io.github.dsheirer.module.decode.dmr.message.data.DataMessageWithLinkControl;
2829
import io.github.dsheirer.module.decode.dmr.message.data.IDLEMessage;
2930
import io.github.dsheirer.module.decode.dmr.message.data.block.DataBlock;
3031
import io.github.dsheirer.module.decode.dmr.message.data.csbk.CSBKMessage;
@@ -48,12 +49,13 @@
4849
import io.github.dsheirer.module.decode.dmr.message.voice.VoiceMessage;
4950
import io.github.dsheirer.module.decode.dmr.message.voice.VoiceSuperFrameProcessor;
5051
import io.github.dsheirer.sample.Listener;
52+
import org.slf4j.Logger;
53+
import org.slf4j.LoggerFactory;
54+
5155
import java.util.ArrayList;
5256
import java.util.List;
5357
import java.util.Map;
5458
import java.util.TreeMap;
55-
import org.slf4j.Logger;
56-
import org.slf4j.LoggerFactory;
5759

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

159+
//Process data messages carrying a link control payload so that the LC payload can be processed/enriched
160+
if(message instanceof DataMessageWithLinkControl linkControlCarrier)
161+
{
162+
receive(linkControlCarrier.getLCMessage());
163+
}
164+
157165
//Enrich messages that carry DMR Logical Channel Numbers with LCN to frequency mappings
158166
if(message instanceof ITimeslotFrequencyReceiver)
159167
{

src/main/java/io/github/dsheirer/module/decode/dmr/DMRTrafficChannelManager.java

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,38 @@ public DMRTrafficChannelManager(Channel parentChannel)
134134
/**
135135
* Sets the current parent control channel frequency so that channel grants for the current frequency do not
136136
* produce an additional traffic channel allocation.
137-
* @param currentControlFrequency for current control channel.
137+
* @param previousControlFrequency for the current control channel (to remove from allocated channels)
138+
* @param currentControlFrequency for current control channel (to add to allocated channels)
138139
* @param channel for the current control channel
139140
*/
140-
public void setCurrentControlFrequency(long currentControlFrequency, Channel channel)
141+
public void setCurrentControlFrequency(long previousControlFrequency, long currentControlFrequency, Channel channel)
141142
{
142-
mAllocatedChannelFrequencyMap.put(currentControlFrequency, channel);
143+
if(previousControlFrequency == currentControlFrequency)
144+
{
145+
return;
146+
}
147+
148+
mLock.lock();
149+
150+
try
151+
{
152+
Channel existing = mAllocatedChannelFrequencyMap.get(previousControlFrequency);
153+
154+
//Only remove the channel if it is non-null and it matches the current control channel.
155+
if(channel.equals(existing))
156+
{
157+
//Unlock the frequency in the channel rotation monitor
158+
getInterModuleEventBus().post(FrequencyLockChangeRequest.unlock(previousControlFrequency));
159+
mAllocatedChannelFrequencyMap.remove(previousControlFrequency);
160+
}
161+
162+
mAllocatedChannelFrequencyMap.put(currentControlFrequency, channel);
163+
getInterModuleEventBus().post(FrequencyLockChangeRequest.lock(currentControlFrequency));
164+
}
165+
finally
166+
{
167+
mLock.unlock();
168+
}
143169
}
144170

145171
/**
@@ -197,6 +223,10 @@ public void convertToTrafficChannel(Channel channel, long currentFrequency, ICha
197223
{
198224
long rest = restChannel.getDownlinkFrequency();
199225

226+
mLog.info("CONVERT TO TRAFFIC - RESTFREQ:" + rest +
227+
" ALLOCATED:" + (mAllocatedChannelFrequencyMap.containsKey(rest)) +
228+
" CONFIG TYPE:" + channel.getSourceConfiguration().getSourceType());
229+
200230
//Only do the conversion of the original channel has multiple frequencies defined and the rest channel is
201231
//one of those frequencies
202232
if(rest > 0 && !mAllocatedChannelFrequencyMap.containsKey(rest) &&

0 commit comments

Comments
 (0)