mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
Identifier Framework and Message/Event Processing Overhaul (#455)
* WIP on new P25 message framer. * WIP on new P25 message framer. * Adds new 1/2 and 3/4 rate trellis decoders. Still trying to chase down why there is a sync pattern mismatch in the NID buffer queue. * WIP - new p25 message framer works correctly now. PDU's are dectected and decoded using the 1/2 and 3/4 rate trellis decoders. Packet Sequences are assembled. Need to add a new packet sequence message factory that can detect Motorola Auto Registration Service (ARS) formatted UDP/ID packets and SNDCP command packets. * WIP - removes nullify on channel results queue. * WIP - updates message framer for TSBK 1/2/3 processing. * WIP removing P25 sync pattern and nid bits from all message parsers. * WIP - merges identifier framework branch changes into this branch. * WIP on updating link control words to new format and identifier framework. * WIP - implements rest of link control words for extended formats * WIP - initial work on ISP/OSP TSBK message restructuring. * WIP - adds more TSBK ISP and OSP messages * WIP - finished updating most of the TSBK ISP and OSP messages. Converted all messages to no longer include the NID (nac + dataunitID) so that each message can simply hold the parsed values. Removed AliasList as an argument to each message and updated all messges to use the new IIdentifer and IAPCO25Channel interfaces. Removed legacy TDU and LDU link control messages and replaced with a single LinkControlWord class hierarchy. P25 decoder state is not yet updated for the new message structure. PDU message parsing is not fully implemented. * WIP - adds some Multi-Block trunking control messages with Alternate and Unconfirmed formats. * WIP - Fully implements AMBTC and UMBTC PDU message parsers. Some package restructuring. * WIP - Resolves Link control parsing in LDU1 and 2 messages. * WIP - finishes updating TSBK and Link Control messages. Adds support for moto link control messages for patch groups. * WIP - finishes updating TSBK and Link Control messages. Adds support for moto link control messages for patch groups. Adds support for moto ARS service, IPV4 decoding, and UDP/IP packets. * WIP - finishes SNDCP packet data with header parsing. Compressed IP or UDP headers are not yet supported, but are logged as such. * WIP - converts all talkgroup identifiers to integers and updates alias list to create a per-protocol map of talkgroup id's to alias. Inserts a legacy talkgroup (ltr, p25, passport, mpt1327, mdc, etc.) conversion utility to convert existing legacy (string) talkgroups to new integer talkgroup format. Creates an audio packet manager to insert metadata into audio packets before streaming packets for playback, recording, and/or streaming. Creates identifier collection to manage current identifiers in each of the channel and decoder states. Creates simplified channel metadata to maintain the now playing display. Moves channel attributes (alias list, system, site, name) as configuration identifiers in the channel state. Many other refactoring and updates. * WIP - numerous updates to push use of identifier collection throughout the system. Updates the channel metadata and audio packet processing logic. Implements a large portion of the P25 decode state processing. Updates traffic channel management. Adds user preferences for timestamp and identifier formatting, however doesn't add a user interface yet. * WIP - initial implementation of user preferences editor window. * WIP - updates preferences editor window to close and dispose window but retain javafx event thread running. * WIP - fully updates p25 decoder state and traffic channel processing to use the new identifier framework. Cleans up channel event processing and removes channel model as the sole broadcaster of channel events. Channel processing manager now listens for all start/stop events and requestors dispatch event directly to the channel processing manager. Resolves issue in airspy that was causing user interface to lock-up. The issue appears to occur when the dongle is plugged into a usb port that can't fully support the data rate. sdrtrunk now recognizes these errors and warns the user that they should use another usb port. * WIP - updates alias action manager and adds new talkgroup range alias identifier. Updates playlist to incorporate a version number so that the playlist updater only runs when needed, to update a playlist to the correct version format. Updates user preferences to use the google event bus to broadcast preference update notifications to remove the need for listeners to register directly on the user preferences instance. * WIP - updates alias id editors to flag invalid values and moves legacy alias ids to legacy package. Updates event logging configuration to add traffic channel decode events and decoded message logging. Removes binary message logging since that is now replaced with demodulated bitstream recording. * Removes system properties from user preferences. Preferences are stored in the OS-dependent settings store (windows - registry) * Updates MapService to use new PlottableDecodeEvent instead of monitoring all of the decoded messages. Updates Fleetsync decoder and related messages to identifier framework. * Updates LTR-Net, Fleetsync and LJ1200 decoders to new identifier framework and adds support for user preferences for formatting of LTR-Net and fleetsync talkgroup identifiers. Breaks LTR-Net messages into various message types and uses a new message factory. Removes alias list from message processing for ltr-net, fleetsync and lj1200. * Updates LTR-Standard messages to Identifier framework. * Removes Plottable and IPlottable from codebase. * wip * WIP on MPT-1327 messages. * Updates MPT1327 decoder to identifier framework and new traffic channel manager. This decoder still needs to be updated with a new message parser factory and a sync detector like what is now used for P25. * Updates MDC1200 decoder and message to identifier framework. * Updates Tait1200 and Passport decoders to identifier framework. * Merges changes from master branch. * Removes legacy alias support classes. Updates passport message processor to only pass valid messages. Adds support to playlist updater for converting passport mobile ids to become passport talkgroup values. * Updates P25 decoder state and channel state to better track allocated traffic channels. Resolves issue in timestamp manager for trackig message timestamps. Resolves issue in airspy tuner that was causing the tuner to stop sending samples to the application. * Update P25 Decoder state to process SNDCP management messages and PDU messages. Updates P25 activity summary to display network and site details. Resolves issue with overlay panel that prevented enabled channels from rendering correctly when zoomed in. * Creates a new FilePreferences as part of the user preferences to begin the transition of SystemProperties over to user preferences and consolidate file preferences in one location. Updates playlist manager to use the new file preferences and to use default.xml as the new default playlist name, following conversion of a playlist_v2.xml format to the new format. In the near future, the user will be able to edit file locations and to create/use other playlists. Resolved an issue with all decoder states where not all identifiers were being included in decode events.
This commit is contained in:
@@ -53,7 +53,7 @@ public class LTRStandardDecoder extends Decoder implements IReusableBufferListen
|
||||
|
||||
mLTRDecoder.setMessageFramer(mLTRMessageFramer);
|
||||
mLTRMessageFramer.setSyncDetectListener(mLTRDecoder);
|
||||
mLTRMessageProcessor = new LTRStandardMessageProcessor(direction, aliasList);
|
||||
mLTRMessageProcessor = new LTRStandardMessageProcessor(direction);
|
||||
mLTRMessageFramer.addMessageListener(mLTRMessageProcessor);
|
||||
mLTRMessageProcessor.setMessageListener(getMessageListener());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*******************************************************************************
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -14,28 +15,30 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
******************************************************************************/
|
||||
* *****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.module.decode.ltrstandard;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.alias.id.AliasIDType;
|
||||
import io.github.dsheirer.channel.metadata.AliasedStringAttributeMonitor;
|
||||
import io.github.dsheirer.channel.metadata.Attribute;
|
||||
import io.github.dsheirer.channel.metadata.AttributeChangeRequest;
|
||||
import io.github.dsheirer.channel.state.DecoderState;
|
||||
import io.github.dsheirer.channel.state.DecoderStateEvent;
|
||||
import io.github.dsheirer.channel.state.DecoderStateEvent.Event;
|
||||
import io.github.dsheirer.channel.state.State;
|
||||
import io.github.dsheirer.message.Message;
|
||||
import io.github.dsheirer.identifier.Form;
|
||||
import io.github.dsheirer.identifier.Identifier;
|
||||
import io.github.dsheirer.identifier.IdentifierClass;
|
||||
import io.github.dsheirer.identifier.Role;
|
||||
import io.github.dsheirer.identifier.configuration.FrequencyConfigurationIdentifier;
|
||||
import io.github.dsheirer.identifier.decoder.DecoderLogicalChannelNameIdentifier;
|
||||
import io.github.dsheirer.identifier.talkgroup.LTRTalkgroup;
|
||||
import io.github.dsheirer.message.IMessage;
|
||||
import io.github.dsheirer.module.decode.DecoderType;
|
||||
import io.github.dsheirer.module.decode.event.CallEvent;
|
||||
import io.github.dsheirer.module.decode.ltrnet.LTRCallEvent;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.message.CallEndMessage;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.message.CallMessage;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.message.IdleMessage;
|
||||
import io.github.dsheirer.module.decode.event.DecodeEvent;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.channel.LtrChannel;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.message.Call;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.message.CallEnd;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.message.Idle;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.message.LTRStandardMessage;
|
||||
import io.github.dsheirer.protocol.Protocol;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -49,23 +52,17 @@ import java.util.TreeSet;
|
||||
|
||||
public class LTRStandardDecoderState extends DecoderState
|
||||
{
|
||||
private final static Logger mLog =
|
||||
LoggerFactory.getLogger(LTRStandardDecoderState.class);
|
||||
private final static Logger mLog = LoggerFactory.getLogger(LTRStandardDecoderState.class);
|
||||
|
||||
private Map<Integer,LTRCallEvent> mActiveCalls = new HashMap<>();
|
||||
private Set<String> mTalkgroupsFirstHeard = new HashSet<>();
|
||||
private Set<String> mTalkgroups = new TreeSet<>();
|
||||
|
||||
private AliasedStringAttributeMonitor mTalkgroupAttribute;
|
||||
private long mFrequency;
|
||||
private Map<Integer,DecodeEvent> mActiveCalls = new HashMap<>();
|
||||
private Set<LTRTalkgroup> mTalkgroupsFirstHeard = new HashSet<>();
|
||||
private Set<LTRTalkgroup> mTalkgroups = new TreeSet<>();
|
||||
private LCNTracker mLCNTracker = new LCNTracker();
|
||||
private DecodeEvent mCurrentCallEvent;
|
||||
private LTRTalkgroup mCurrentTalkgroup;
|
||||
|
||||
public LTRStandardDecoderState(AliasList aliasList)
|
||||
public LTRStandardDecoderState()
|
||||
{
|
||||
super(aliasList);
|
||||
|
||||
mTalkgroupAttribute = new AliasedStringAttributeMonitor(Attribute.PRIMARY_ADDRESS_TO,
|
||||
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.TALKGROUP);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,116 +72,76 @@ public class LTRStandardDecoderState extends DecoderState
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(Message message)
|
||||
public void receive(IMessage message)
|
||||
{
|
||||
if(message.isValid() && message instanceof LTRStandardMessage)
|
||||
{
|
||||
switch(((LTRStandardMessage) message).getMessageType())
|
||||
switch(((LTRStandardMessage)message).getMessageType())
|
||||
{
|
||||
case CA_STRT:
|
||||
CallMessage start = (CallMessage) message;
|
||||
|
||||
int channel = start.getChannel();
|
||||
|
||||
setChannelNumber(channel);
|
||||
|
||||
mLCNTracker.processFreeChannel(start.getFree());
|
||||
|
||||
//Only process calls on this LCN, or call detects for
|
||||
//talkgroups that are homed on this LCN
|
||||
if(mLCNTracker.isValidChannel(channel) &&
|
||||
(mLCNTracker.isCurrentChannel(channel) ||
|
||||
mLCNTracker.isCurrentChannel(start.getHomeRepeater())))
|
||||
case CALL:
|
||||
if(message instanceof Call)
|
||||
{
|
||||
LTRCallEvent event = mActiveCalls.get(channel);
|
||||
Call start = (Call)message;
|
||||
|
||||
if(event == null || !event.isMatchingTalkgroup(start.getToID()))
|
||||
int channel = start.getChannel();
|
||||
setChannelNumber(channel);
|
||||
mLCNTracker.processFreeChannel(start.getFree());
|
||||
|
||||
//Only process calls or call detects for valid channels
|
||||
if(mLCNTracker.isValidChannel(channel) && mLCNTracker.isCurrentChannel(channel))
|
||||
{
|
||||
//Check for different talkgroup
|
||||
if(event != null)
|
||||
if(mCurrentTalkgroup == null || !mCurrentTalkgroup.equals(start.getTalkgroup()))
|
||||
{
|
||||
event.end();
|
||||
mActiveCalls.remove(channel);
|
||||
mCurrentTalkgroup = start.getTalkgroup();
|
||||
getIdentifierCollection().remove(IdentifierClass.USER);
|
||||
getIdentifierCollection().update(start.getTalkgroup());
|
||||
mCurrentCallEvent = DecodeEvent.builder(start.getTimestamp())
|
||||
.protocol(Protocol.LTR_STANDARD)
|
||||
.identifiers(getIdentifierCollection().copyOf())
|
||||
.channel(getCurrentChannel())
|
||||
.eventDescription("Call")
|
||||
.build();
|
||||
}
|
||||
|
||||
boolean current = mLCNTracker.isCurrentChannel(channel);
|
||||
|
||||
event = new LTRCallEvent.Builder(
|
||||
DecoderType.LTR_STANDARD,
|
||||
current ? CallEvent.CallEventType.CALL : CallEvent.CallEventType.CALL_DETECT)
|
||||
.to(start.getToID())
|
||||
.aliasList(getAliasList())
|
||||
.channel(start.getChannelFormatted())
|
||||
.frequency(current ? mFrequency : 0)
|
||||
.build();
|
||||
|
||||
mActiveCalls.put(channel, event);
|
||||
|
||||
broadcast(event);
|
||||
|
||||
if(mLCNTracker.isCurrentChannel(channel))
|
||||
else
|
||||
{
|
||||
String talkgroup = start.getToID();
|
||||
mTalkgroupAttribute.process(talkgroup);
|
||||
processTalkgroup(talkgroup);
|
||||
mCurrentCallEvent.update(start.getTimestamp());
|
||||
}
|
||||
broadcast(mCurrentCallEvent);
|
||||
broadcast(new DecoderStateEvent(this, Event.START, State.CALL));
|
||||
}
|
||||
|
||||
broadcast(new DecoderStateEvent(this, Event.CONTINUATION, State.CALL));
|
||||
}
|
||||
break;
|
||||
case CA_ENDD:
|
||||
CallEndMessage end = (CallEndMessage) message;
|
||||
|
||||
//Home channel is 31 for call end -- use the free channel
|
||||
//as the call end channel
|
||||
int repeater = end.getFree();
|
||||
|
||||
setChannelNumber(repeater);
|
||||
|
||||
if(mLCNTracker.isCurrentChannel(repeater))
|
||||
case CALL_END:
|
||||
if(message instanceof CallEnd)
|
||||
{
|
||||
String talkgroup = end.getToID();
|
||||
mTalkgroupAttribute.process(talkgroup);
|
||||
processTalkgroup(talkgroup);
|
||||
CallEnd end = (CallEnd)message;
|
||||
|
||||
LTRCallEvent event = mActiveCalls.remove(repeater);
|
||||
|
||||
if(event != null)
|
||||
//Home channel is 31 for call end -- use the free channel as the call end channel
|
||||
int repeater = end.getFree();
|
||||
setChannelNumber(repeater);
|
||||
if(mLCNTracker.isCurrentChannel(repeater))
|
||||
{
|
||||
event.end();
|
||||
broadcast(event);
|
||||
if(mCurrentCallEvent != null)
|
||||
{
|
||||
mCurrentCallEvent.end(end.getTimestamp());
|
||||
}
|
||||
|
||||
broadcast(new DecoderStateEvent(this, Event.END, State.FADE));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SY_IDLE:
|
||||
IdleMessage idle = (IdleMessage) message;
|
||||
|
||||
int lcn = idle.getChannel();
|
||||
|
||||
mLCNTracker.processCallChannel(lcn);
|
||||
|
||||
case IDLE:
|
||||
if(message instanceof Idle)
|
||||
{
|
||||
mLCNTracker.processCallChannel(((Idle)message).getChannel());
|
||||
}
|
||||
break;
|
||||
case UN_KNWN:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processTalkgroup(String talkgroup)
|
||||
{
|
||||
if(mTalkgroupsFirstHeard.contains(talkgroup))
|
||||
{
|
||||
mTalkgroups.add(talkgroup);
|
||||
}
|
||||
else
|
||||
{
|
||||
mTalkgroupsFirstHeard.add(talkgroup);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a full reset
|
||||
*/
|
||||
@@ -201,41 +158,25 @@ public class LTRStandardDecoderState extends DecoderState
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a temporal reset following a call or other decode event
|
||||
*/
|
||||
private void resetState()
|
||||
protected void resetState()
|
||||
{
|
||||
for(Integer key : mActiveCalls.keySet())
|
||||
{
|
||||
LTRCallEvent event = mActiveCalls.get(key);
|
||||
|
||||
if(event != null)
|
||||
{
|
||||
event.end();
|
||||
|
||||
broadcast(event);
|
||||
}
|
||||
}
|
||||
|
||||
super.resetState();
|
||||
mActiveCalls.clear();
|
||||
|
||||
mTalkgroupAttribute.reset();
|
||||
}
|
||||
|
||||
public boolean hasChannelNumber()
|
||||
@@ -256,8 +197,20 @@ public class LTRStandardDecoderState extends DecoderState
|
||||
|
||||
if(mLCNTracker.getCurrentChannel() != original)
|
||||
{
|
||||
broadcast(new AttributeChangeRequest<String>(Attribute.CHANNEL_FREQUENCY_LABEL,
|
||||
"LCN:" + mLCNTracker.getCurrentChannel()));
|
||||
getIdentifierCollection().update(DecoderLogicalChannelNameIdentifier
|
||||
.create(String.valueOf(mLCNTracker.getCurrentChannel()), Protocol.LTR_STANDARD));
|
||||
|
||||
LtrChannel ltrChannel = new LtrChannel(mLCNTracker.getCurrentChannel());
|
||||
|
||||
Identifier identifier = getIdentifierCollection().getIdentifier(IdentifierClass.CONFIGURATION,
|
||||
Form.CHANNEL_FREQUENCY, Role.ANY);
|
||||
|
||||
if(identifier instanceof FrequencyConfigurationIdentifier)
|
||||
{
|
||||
ltrChannel.setDownlink(((FrequencyConfigurationIdentifier)identifier).getValue());
|
||||
}
|
||||
|
||||
setCurrentChannel(ltrChannel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,11 +222,6 @@ public class LTRStandardDecoderState extends DecoderState
|
||||
case RESET:
|
||||
resetState();
|
||||
break;
|
||||
case SOURCE_FREQUENCY:
|
||||
mFrequency = event.getFrequency();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,22 +269,10 @@ public class LTRStandardDecoderState extends DecoderState
|
||||
}
|
||||
else
|
||||
{
|
||||
for(String talkgroup : mTalkgroups)
|
||||
for(LTRTalkgroup talkgroup : mTalkgroups)
|
||||
{
|
||||
sb.append(" ");
|
||||
sb.append(talkgroup);
|
||||
sb.append(" ");
|
||||
|
||||
if(hasAliasList())
|
||||
{
|
||||
Alias alias = getAliasList().getTalkgroupAlias(talkgroup);
|
||||
|
||||
if(alias != null)
|
||||
{
|
||||
sb.append(alias.getName());
|
||||
}
|
||||
}
|
||||
|
||||
sb.append(talkgroup.formatted());
|
||||
sb.append("\n");
|
||||
|
||||
}
|
||||
@@ -425,7 +361,7 @@ public class LTRStandardDecoderState extends DecoderState
|
||||
|
||||
int count = mFreeLCNCounts[channel];
|
||||
|
||||
int threshold = (int) ((double) mFreeHighestCount * 0.2);
|
||||
int threshold = (int)((double)mFreeHighestCount * 0.2);
|
||||
|
||||
return count >= threshold;
|
||||
}
|
||||
|
||||
@@ -1,57 +1,73 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ltrstandard;
|
||||
|
||||
import io.github.dsheirer.filter.Filter;
|
||||
import io.github.dsheirer.filter.FilterElement;
|
||||
import io.github.dsheirer.message.Message;
|
||||
import io.github.dsheirer.message.MessageType;
|
||||
import io.github.dsheirer.message.IMessage;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.message.LTRStandardMessage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class LTRStandardMessageFilter extends Filter<Message>
|
||||
public class LTRStandardMessageFilter extends Filter<IMessage>
|
||||
{
|
||||
private HashMap<MessageType, FilterElement<MessageType>> mElements =
|
||||
new HashMap<MessageType, FilterElement<MessageType>>();
|
||||
|
||||
public LTRStandardMessageFilter()
|
||||
{
|
||||
super( "LTR Message Filter" );
|
||||
private Map<LtrStandardMessageType,FilterElement<LtrStandardMessageType>> mElements = new HashMap<>();
|
||||
|
||||
mElements.put( MessageType.CA_STRT,
|
||||
new FilterElement<MessageType>( MessageType.CA_STRT ) );
|
||||
mElements.put( MessageType.CA_ENDD,
|
||||
new FilterElement<MessageType>( MessageType.CA_ENDD ) );
|
||||
mElements.put( MessageType.SY_IDLE,
|
||||
new FilterElement<MessageType>( MessageType.SY_IDLE ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passes( Message message )
|
||||
public LTRStandardMessageFilter()
|
||||
{
|
||||
if( mEnabled && canProcess( message ) )
|
||||
{
|
||||
LTRStandardMessage ltr = (LTRStandardMessage)message;
|
||||
|
||||
if( mElements.containsKey( ltr.getMessageType() ) )
|
||||
{
|
||||
return mElements.get( ltr.getMessageType() ).isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
super("LTR Message Filter");
|
||||
|
||||
mElements.put(LtrStandardMessageType.CALL, new FilterElement<>(LtrStandardMessageType.CALL));
|
||||
mElements.put(LtrStandardMessageType.CALL_END, new FilterElement<>(LtrStandardMessageType.CALL_END));
|
||||
mElements.put(LtrStandardMessageType.IDLE, new FilterElement<>(LtrStandardMessageType.IDLE));
|
||||
mElements.put(LtrStandardMessageType.UNKNOWN, new FilterElement<>(LtrStandardMessageType.UNKNOWN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProcess( Message message )
|
||||
@Override
|
||||
public boolean passes(IMessage message)
|
||||
{
|
||||
return message instanceof LTRStandardMessage;
|
||||
if(mEnabled && canProcess(message))
|
||||
{
|
||||
LTRStandardMessage ltr = (LTRStandardMessage)message;
|
||||
|
||||
if(mElements.containsKey(ltr.getMessageType()))
|
||||
{
|
||||
return mElements.get(ltr.getMessageType()).isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProcess(IMessage message)
|
||||
{
|
||||
return message instanceof LTRStandardMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FilterElement<?>> getFilterElements()
|
||||
{
|
||||
return new ArrayList<FilterElement<?>>( mElements.values() );
|
||||
return new ArrayList<FilterElement<?>>(mElements.values());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,121 +1,114 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.module.decode.ltrstandard;
|
||||
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
import io.github.dsheirer.bits.CorrectedBinaryMessage;
|
||||
import io.github.dsheirer.edac.CRC;
|
||||
import io.github.dsheirer.edac.CRCLTR;
|
||||
import io.github.dsheirer.message.Message;
|
||||
import io.github.dsheirer.message.IMessage;
|
||||
import io.github.dsheirer.message.MessageDirection;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.message.CallEndMessage;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.message.CallMessage;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.message.IdleMessage;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.message.Call;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.message.CallEnd;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.message.Idle;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.message.LTRStandardMessage;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.message.UnknownMessage;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
|
||||
public class LTRStandardMessageProcessor implements Listener<BinaryMessage>
|
||||
public class LTRStandardMessageProcessor implements Listener<CorrectedBinaryMessage>
|
||||
{
|
||||
private MessageDirection mDirection;
|
||||
private AliasList mAliasList;
|
||||
private Listener<Message> mMessageListener;
|
||||
|
||||
/**
|
||||
* Processes raw binary messages and converts them to the correct message class
|
||||
*
|
||||
* @param direction - inbound (ISW) or outbound (OSW)
|
||||
* @param list - alias list
|
||||
*/
|
||||
public LTRStandardMessageProcessor( MessageDirection direction, AliasList list )
|
||||
{
|
||||
mDirection = direction;
|
||||
mAliasList = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( BinaryMessage binaryMessage )
|
||||
private MessageDirection mDirection;
|
||||
private Listener<IMessage> mMessageListener;
|
||||
|
||||
/**
|
||||
* Processes raw binary messages and converts them to the correct message class
|
||||
*
|
||||
* @param direction - inbound (ISW) or outbound (OSW)
|
||||
*/
|
||||
public LTRStandardMessageProcessor(MessageDirection direction)
|
||||
{
|
||||
if( mMessageListener != null )
|
||||
{
|
||||
//Inbound Status Word (ISW) is a bit-flipped version of the Outbound
|
||||
//(OSW), so flip the bits and process it as an OSW
|
||||
if( mDirection == MessageDirection.ISW )
|
||||
{
|
||||
binaryMessage.flip( 0, 40 );
|
||||
}
|
||||
|
||||
CRC crc = CRCLTR.check( binaryMessage, mDirection );
|
||||
|
||||
if( crc != CRC.FAILED_CRC &&
|
||||
crc != CRC.FAILED_PARITY )
|
||||
{
|
||||
LTRStandardMessage message;
|
||||
|
||||
int channel = binaryMessage.getInt( LTRStandardMessage.CHANNEL );
|
||||
int home = binaryMessage.getInt( LTRStandardMessage.HOME_REPEATER );
|
||||
int free = binaryMessage.getInt( LTRStandardMessage.FREE );
|
||||
int group = binaryMessage.getInt( LTRStandardMessage.GROUP );
|
||||
|
||||
if( isValidChannel( channel ) &&
|
||||
isValidChannel( home ) &&
|
||||
isValidChannel( free ) )
|
||||
{
|
||||
if( channel == free && group == 255 )
|
||||
{
|
||||
message = new IdleMessage( binaryMessage, mDirection, mAliasList, crc );
|
||||
}
|
||||
else
|
||||
{
|
||||
message = new CallMessage( binaryMessage, mDirection, mAliasList, crc );
|
||||
}
|
||||
}
|
||||
else if( channel == 31 &&
|
||||
isValidChannel( home ) &&
|
||||
isValidChannel( free ) )
|
||||
{
|
||||
message = new CallEndMessage( binaryMessage, mDirection, mAliasList, crc );
|
||||
}
|
||||
else
|
||||
{
|
||||
message = new UnknownMessage( binaryMessage, mDirection, mAliasList, crc );
|
||||
}
|
||||
|
||||
mMessageListener.receive( message );
|
||||
}
|
||||
}
|
||||
mDirection = direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the channel (LCN) number to ensure it is in the range 1 -20
|
||||
*/
|
||||
private boolean isValidChannel( int channel )
|
||||
{
|
||||
return ( 1 <= channel && channel <= 20 );
|
||||
}
|
||||
|
||||
public void setMessageListener( Listener<Message> listener )
|
||||
|
||||
@Override
|
||||
public void receive(CorrectedBinaryMessage binaryMessage)
|
||||
{
|
||||
mMessageListener = listener;
|
||||
if(mMessageListener != null)
|
||||
{
|
||||
//Inbound Status Word (ISW) is a bit-flipped version of the Outbound (OSW), so flip the bits and process it
|
||||
// as an OSW
|
||||
if(mDirection == MessageDirection.ISW)
|
||||
{
|
||||
binaryMessage.flip(0, 40);
|
||||
}
|
||||
|
||||
CRC crc = CRCLTR.check(binaryMessage, mDirection);
|
||||
|
||||
if(crc.passes())
|
||||
{
|
||||
LTRStandardMessage message;
|
||||
|
||||
int channel = binaryMessage.getInt(LTRStandardMessage.CHANNEL);
|
||||
int home = binaryMessage.getInt(LTRStandardMessage.HOME_REPEATER);
|
||||
int free = binaryMessage.getInt(LTRStandardMessage.FREE);
|
||||
int group = binaryMessage.getInt(LTRStandardMessage.GROUP);
|
||||
|
||||
if(isValidChannel(channel) && isValidChannel(home) && isValidChannel(free))
|
||||
{
|
||||
if(channel == free && group == 255)
|
||||
{
|
||||
message = new Idle(binaryMessage, mDirection, crc);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = new Call(binaryMessage, mDirection, crc);
|
||||
}
|
||||
}
|
||||
else if(channel == 31 && isValidChannel(home) && isValidChannel(free))
|
||||
{
|
||||
message = new CallEnd(binaryMessage, mDirection, crc);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = new UnknownMessage(binaryMessage, mDirection, crc);
|
||||
}
|
||||
|
||||
mMessageListener.receive(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the channel (LCN) number to ensure it is in the range 1 -20
|
||||
*/
|
||||
private boolean isValidChannel(int channel)
|
||||
{
|
||||
return (1 <= channel && channel <= 20);
|
||||
}
|
||||
|
||||
public void setMessageListener(Listener<IMessage> listener)
|
||||
{
|
||||
mMessageListener = listener;
|
||||
}
|
||||
|
||||
public void removeMessageListener()
|
||||
{
|
||||
mMessageListener = null;
|
||||
mMessageListener = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ltrstandard;
|
||||
|
||||
public enum LtrStandardMessageType
|
||||
{
|
||||
CALL,
|
||||
CALL_END,
|
||||
IDLE,
|
||||
UNKNOWN;
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.module.decode.ltrstandard.channel;
|
||||
|
||||
import io.github.dsheirer.channel.IChannelDescriptor;
|
||||
import io.github.dsheirer.module.decode.p25.message.IFrequencyBand;
|
||||
import io.github.dsheirer.protocol.Protocol;
|
||||
|
||||
public class LtrChannel implements IChannelDescriptor, Comparable<LtrChannel>
|
||||
{
|
||||
private long mDownlink;
|
||||
private int mChannel;
|
||||
|
||||
public LtrChannel(int channel)
|
||||
{
|
||||
mChannel = channel;
|
||||
}
|
||||
|
||||
public int getChannel()
|
||||
{
|
||||
return mChannel;
|
||||
}
|
||||
|
||||
public void setDownlink(long downlink)
|
||||
{
|
||||
mDownlink = downlink;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDownlinkFrequency()
|
||||
{
|
||||
return mDownlink;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUplinkFrequency()
|
||||
{
|
||||
return mDownlink;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getFrequencyBandIdentifiers()
|
||||
{
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFrequencyBand(IFrequencyBand bandIdentifier)
|
||||
{
|
||||
//No-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTDMAChannel()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTimeslotCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Protocol getProtocol()
|
||||
{
|
||||
return Protocol.LTR_STANDARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.valueOf(getChannel());
|
||||
}
|
||||
|
||||
public String description()
|
||||
{
|
||||
return "TRANSMIT: " + getDownlinkFrequency();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(LtrChannel o)
|
||||
{
|
||||
return Integer.compare(getChannel(), o.getChannel());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.module.decode.ltrstandard.message;
|
||||
|
||||
import io.github.dsheirer.bits.CorrectedBinaryMessage;
|
||||
import io.github.dsheirer.edac.CRC;
|
||||
import io.github.dsheirer.identifier.Identifier;
|
||||
import io.github.dsheirer.message.MessageDirection;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.LtrStandardMessageType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Call extends LTRStandardMessage
|
||||
{
|
||||
private List<Identifier> mIdentifiers;
|
||||
|
||||
public Call(CorrectedBinaryMessage message, MessageDirection direction, CRC crc)
|
||||
{
|
||||
super(message, direction, crc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LtrStandardMessageType getMessageType()
|
||||
{
|
||||
return LtrStandardMessageType.CALL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("CALL TO ").append(getTalkgroup().formatted());
|
||||
sb.append(" LCN:").append(getChannel());
|
||||
sb.append(" FREE:").append(getFree());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Identifier> getIdentifiers()
|
||||
{
|
||||
if(mIdentifiers == null)
|
||||
{
|
||||
mIdentifiers = new ArrayList<>();
|
||||
mIdentifiers.add(getTalkgroup());
|
||||
}
|
||||
|
||||
return mIdentifiers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.module.decode.ltrstandard.message;
|
||||
|
||||
import io.github.dsheirer.bits.CorrectedBinaryMessage;
|
||||
import io.github.dsheirer.edac.CRC;
|
||||
import io.github.dsheirer.identifier.Identifier;
|
||||
import io.github.dsheirer.message.MessageDirection;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.LtrStandardMessageType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CallEnd extends LTRStandardMessage
|
||||
{
|
||||
private List<Identifier> mIdentifiers;
|
||||
|
||||
public CallEnd(CorrectedBinaryMessage message, MessageDirection direction, CRC crc)
|
||||
{
|
||||
super(message, direction, crc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LtrStandardMessageType getMessageType()
|
||||
{
|
||||
return LtrStandardMessageType.CALL_END;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("CALL END ").append(getTalkgroup().formatted());
|
||||
sb.append(" LCN:").append(getChannel());
|
||||
sb.append(" FREE:").append(getFree());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Identifier> getIdentifiers()
|
||||
{
|
||||
if(mIdentifiers == null)
|
||||
{
|
||||
mIdentifiers = new ArrayList<>();
|
||||
mIdentifiers.add(getTalkgroup());
|
||||
}
|
||||
|
||||
return mIdentifiers;
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.module.decode.ltrstandard.message;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
import io.github.dsheirer.edac.CRC;
|
||||
import io.github.dsheirer.message.MessageDirection;
|
||||
import io.github.dsheirer.message.MessageType;
|
||||
|
||||
public class CallEndMessage extends LTRStandardMessage
|
||||
{
|
||||
public CallEndMessage(BinaryMessage message, MessageDirection direction,
|
||||
AliasList list, CRC crc )
|
||||
{
|
||||
super( message, direction, list, crc );
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageType getMessageType()
|
||||
{
|
||||
return MessageType.CA_ENDD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( "END* AREA:" );
|
||||
sb.append( getArea() );
|
||||
sb.append( " LCN:" );
|
||||
sb.append( getChannelFormatted() );
|
||||
sb.append( " TG [" );
|
||||
sb.append( getToID() );
|
||||
sb.append( "/" );
|
||||
Alias endAlias = getToIDAlias();
|
||||
if( endAlias != null )
|
||||
{
|
||||
sb.append( getToIDAlias().getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append( "UNKNOWN" );
|
||||
}
|
||||
sb.append( "] FREE:" );
|
||||
sb.append( getFreeFormatted() );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.module.decode.ltrstandard.message;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
import io.github.dsheirer.edac.CRC;
|
||||
import io.github.dsheirer.message.MessageDirection;
|
||||
import io.github.dsheirer.message.MessageType;
|
||||
|
||||
public class CallMessage extends LTRStandardMessage
|
||||
{
|
||||
public CallMessage(BinaryMessage message, MessageDirection direction, AliasList list, CRC crc )
|
||||
{
|
||||
super( message, direction, list, crc );
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageType getMessageType()
|
||||
{
|
||||
return MessageType.CA_STRT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( "CALL LCN:" );
|
||||
sb.append( getChannelFormatted() );
|
||||
sb.append( " TG [ " );
|
||||
sb.append( getToID() );
|
||||
sb.append( "/" );
|
||||
|
||||
Alias alias = getToIDAlias();
|
||||
|
||||
if( alias != null )
|
||||
{
|
||||
sb.append( getToIDAlias().getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append( "UNKNOWN" );
|
||||
}
|
||||
|
||||
sb.append( " ] FREE:" );
|
||||
sb.append( getFreeFormatted() );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.module.decode.ltrstandard.message;
|
||||
|
||||
import io.github.dsheirer.bits.CorrectedBinaryMessage;
|
||||
import io.github.dsheirer.edac.CRC;
|
||||
import io.github.dsheirer.identifier.Identifier;
|
||||
import io.github.dsheirer.message.MessageDirection;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.LtrStandardMessageType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Indicates the repeater is IDLE and available for use
|
||||
*/
|
||||
public class Idle extends LTRStandardMessage
|
||||
{
|
||||
public Idle(CorrectedBinaryMessage message, MessageDirection direction, CRC crc)
|
||||
{
|
||||
super(message, direction, crc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LtrStandardMessageType getMessageType()
|
||||
{
|
||||
return LtrStandardMessageType.IDLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("IDLE AREA:").append(getArea());
|
||||
sb.append(" LCN:").append(getChannel());
|
||||
sb.append(" HOME:").append(getHomeRepeater());
|
||||
sb.append(" GRP:").append(getGroup());
|
||||
sb.append(" FREE:").append(getFree());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Identifier> getIdentifiers()
|
||||
{
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.module.decode.ltrstandard.message;
|
||||
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
import io.github.dsheirer.edac.CRC;
|
||||
import io.github.dsheirer.message.MessageDirection;
|
||||
import io.github.dsheirer.message.MessageType;
|
||||
|
||||
public class IdleMessage extends LTRStandardMessage
|
||||
{
|
||||
public IdleMessage(BinaryMessage message, MessageDirection direction,
|
||||
AliasList list, CRC crc )
|
||||
{
|
||||
super( message, direction, list, crc );
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageType getMessageType()
|
||||
{
|
||||
return MessageType.SY_IDLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( "IDLE AREA:" );
|
||||
sb.append( getArea() );
|
||||
sb.append( " LCN:" );
|
||||
sb.append( getChannelFormatted() );
|
||||
sb.append( " HOME:" );
|
||||
sb.append( getHomeRepeaterFormatted() );
|
||||
sb.append( " GRP:" );
|
||||
sb.append( getGroupFormatted() );
|
||||
sb.append( " FREE:" );
|
||||
sb.append( getFreeFormatted() );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,211 +1,148 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.module.decode.ltrstandard.message;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
import io.github.dsheirer.bits.CorrectedBinaryMessage;
|
||||
import io.github.dsheirer.edac.CRC;
|
||||
import io.github.dsheirer.identifier.talkgroup.LTRTalkgroup;
|
||||
import io.github.dsheirer.message.Message;
|
||||
import io.github.dsheirer.message.MessageDirection;
|
||||
import io.github.dsheirer.message.MessageType;
|
||||
import io.github.dsheirer.module.decode.DecoderType;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.LtrStandardMessageType;
|
||||
import io.github.dsheirer.protocol.Protocol;
|
||||
|
||||
/**
|
||||
* LTR Standard Base Message
|
||||
*/
|
||||
public abstract class LTRStandardMessage extends Message
|
||||
{
|
||||
protected SimpleDateFormat mDatestampFormatter =
|
||||
new SimpleDateFormat( "yyyyMMdd HHmmss" );
|
||||
|
||||
public static final int[] SYNC = { 0,1,2,3,4,5,6,7,8 };
|
||||
public static final int[] AREA = { 9 };
|
||||
public static final int[] CHANNEL = { 10,11,12,13,14 };
|
||||
public static final int[] HOME_REPEATER = { 15,16,17,18,19 };
|
||||
public static final int[] GROUP = { 20,21,22,23,24,25,26,27 };
|
||||
public static final int[] FREE = { 28,29,30,31,32 };
|
||||
public static final int[] CHECKSUM = { 33,34,35,36,37,38,39 };
|
||||
|
||||
protected BinaryMessage mMessage;
|
||||
protected MessageDirection mMessageDirection;
|
||||
protected AliasList mAliasList;
|
||||
protected CRC mCRC;
|
||||
|
||||
public LTRStandardMessage( BinaryMessage message,
|
||||
MessageDirection direction,
|
||||
AliasList list,
|
||||
CRC crc )
|
||||
public static final int[] SYNC = {0, 1, 2, 3, 4, 5, 6, 7, 8};
|
||||
public static final int[] AREA = {9};
|
||||
public static final int[] CHANNEL = {10, 11, 12, 13, 14};
|
||||
public static final int[] HOME_REPEATER = {15, 16, 17, 18, 19};
|
||||
public static final int[] GROUP = {20, 21, 22, 23, 24, 25, 26, 27};
|
||||
public static final int[] FREE = {28, 29, 30, 31, 32};
|
||||
public static final int[] CHECKSUM = {33, 34, 35, 36, 37, 38, 39};
|
||||
|
||||
private CorrectedBinaryMessage mMessage;
|
||||
private MessageDirection mMessageDirection;
|
||||
private CRC mCRC;
|
||||
private LTRTalkgroup mTalkgroup;
|
||||
|
||||
/**
|
||||
* Constructs the message
|
||||
* @param message containing the raw bits
|
||||
* @param direction of the messsage, ISW or OSW
|
||||
* @param crc error check
|
||||
*/
|
||||
public LTRStandardMessage(CorrectedBinaryMessage message, MessageDirection direction, CRC crc)
|
||||
{
|
||||
mMessage = message;
|
||||
mMessageDirection = direction;
|
||||
mAliasList = list;
|
||||
mCRC = crc;
|
||||
}
|
||||
|
||||
public abstract MessageType getMessageType();
|
||||
|
||||
public boolean isValid()
|
||||
/**
|
||||
* Identifies the type of message
|
||||
*/
|
||||
public abstract LtrStandardMessageType getMessageType();
|
||||
|
||||
/**
|
||||
* Indicates if this message passes the CRC check
|
||||
*/
|
||||
public boolean isValid()
|
||||
{
|
||||
return mCRC != CRC.FAILED_CRC && mCRC != CRC.FAILED_PARITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( mDatestampFormatter.format(
|
||||
new Date( System.currentTimeMillis() ) ) );
|
||||
sb.append( " LTR " );
|
||||
sb.append( mMessageDirection.name() );
|
||||
sb.append( " [" );
|
||||
sb.append( mCRC.getAbbreviation() );
|
||||
sb.append( "] " );
|
||||
sb.append( getMessage() );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBinaryMessage()
|
||||
{
|
||||
return mMessage.toString();
|
||||
return mCRC.passes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Raw binary message
|
||||
*/
|
||||
public CorrectedBinaryMessage getMessage()
|
||||
{
|
||||
return mMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* CRC error check stats
|
||||
*/
|
||||
public CRC getCRC()
|
||||
{
|
||||
return mCRC;
|
||||
}
|
||||
|
||||
public int getArea()
|
||||
{
|
||||
return mMessage.getInt( AREA );
|
||||
}
|
||||
|
||||
public int getChannel()
|
||||
{
|
||||
return mMessage.getInt( CHANNEL );
|
||||
}
|
||||
|
||||
public String getChannelFormatted()
|
||||
{
|
||||
return StringUtils.leftPad( String.valueOf( getChannel() ), 2, "0" );
|
||||
}
|
||||
|
||||
public int getHomeRepeater()
|
||||
{
|
||||
return mMessage.getInt( HOME_REPEATER );
|
||||
}
|
||||
|
||||
public String getHomeRepeaterFormatted()
|
||||
{
|
||||
return StringUtils.leftPad( String.valueOf( getHomeRepeater() ), 2, "0" );
|
||||
}
|
||||
|
||||
public int getGroup()
|
||||
{
|
||||
return mMessage.getInt( GROUP );
|
||||
}
|
||||
|
||||
public String getGroupFormatted()
|
||||
{
|
||||
return StringUtils.leftPad( String.valueOf( getGroup() ), 3, "0" );
|
||||
}
|
||||
|
||||
public int getFree()
|
||||
{
|
||||
return mMessage.getInt( FREE );
|
||||
}
|
||||
|
||||
public String getFreeFormatted()
|
||||
{
|
||||
return StringUtils.leftPad( String.valueOf( getFree() ), 2, "0" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFromID()
|
||||
{
|
||||
return null;
|
||||
return mCRC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alias getFromIDAlias()
|
||||
/**
|
||||
* Area: 0 or 1
|
||||
*/
|
||||
public int getArea()
|
||||
{
|
||||
return null;
|
||||
return mMessage.getInt(AREA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToID()
|
||||
/**
|
||||
* Logical Channel Number (LCN) for the repeater
|
||||
*/
|
||||
public int getChannel()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( getArea() );
|
||||
sb.append( "-" );
|
||||
sb.append( getHomeRepeaterFormatted() );
|
||||
sb.append( "-" );
|
||||
sb.append( getGroupFormatted() );
|
||||
|
||||
return sb.toString();
|
||||
return mMessage.getInt(CHANNEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alias getToIDAlias()
|
||||
/**
|
||||
* Home repeater number for the talkgroup
|
||||
*/
|
||||
public int getHomeRepeater()
|
||||
{
|
||||
return mAliasList.getTalkgroupAlias( getToID() );
|
||||
return mMessage.getInt(HOME_REPEATER);
|
||||
}
|
||||
|
||||
public List<Alias> getAliases()
|
||||
{
|
||||
List<Alias> aliases = new ArrayList<>();
|
||||
|
||||
Alias talkgroupAlias = getToIDAlias();
|
||||
|
||||
if( talkgroupAlias != null )
|
||||
{
|
||||
aliases.add( talkgroupAlias );
|
||||
}
|
||||
|
||||
return aliases;
|
||||
}
|
||||
|
||||
public int getCRCChecksum()
|
||||
{
|
||||
return mMessage.getInt( CHECKSUM );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocol()
|
||||
/**
|
||||
* Talkgroup number
|
||||
*/
|
||||
public int getGroup()
|
||||
{
|
||||
return DecoderType.LTR_STANDARD.getDisplayString();
|
||||
return mMessage.getInt(GROUP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType()
|
||||
/**
|
||||
* Free or available repeater channel for other subscribers to use when this repeater channel is busy
|
||||
*/
|
||||
public int getFree()
|
||||
{
|
||||
return getMessageType().getDisplayText();
|
||||
return mMessage.getInt(FREE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorStatus()
|
||||
/**
|
||||
* Talkgroup identifier
|
||||
*/
|
||||
public LTRTalkgroup getTalkgroup()
|
||||
{
|
||||
return mCRC.getDisplayText();
|
||||
if(mTalkgroup == null)
|
||||
{
|
||||
mTalkgroup = LTRTalkgroup.create((getHomeRepeater() << 8) + getGroup());
|
||||
}
|
||||
|
||||
return mTalkgroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Protocol getProtocol()
|
||||
{
|
||||
return Protocol.LTR_STANDARD;
|
||||
}
|
||||
}
|
||||
@@ -1,57 +1,64 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.module.decode.ltrstandard.message;
|
||||
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.bits.BinaryMessage;
|
||||
import io.github.dsheirer.bits.CorrectedBinaryMessage;
|
||||
import io.github.dsheirer.edac.CRC;
|
||||
import io.github.dsheirer.identifier.Identifier;
|
||||
import io.github.dsheirer.message.MessageDirection;
|
||||
import io.github.dsheirer.message.MessageType;
|
||||
import io.github.dsheirer.module.decode.ltrstandard.LtrStandardMessageType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Unknown message type
|
||||
*/
|
||||
public class UnknownMessage extends LTRStandardMessage
|
||||
{
|
||||
public UnknownMessage(BinaryMessage message, MessageDirection direction, AliasList list, CRC crc )
|
||||
public UnknownMessage(CorrectedBinaryMessage message, MessageDirection direction, CRC crc)
|
||||
{
|
||||
super( message, direction, list, crc );
|
||||
super(message, direction, crc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageType getMessageType()
|
||||
{
|
||||
return MessageType.UN_KNWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
@Override
|
||||
public LtrStandardMessageType getMessageType()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
return LtrStandardMessageType.UNKNOWN;
|
||||
}
|
||||
|
||||
sb.append( "UNKNOWN AREA:" );
|
||||
sb.append( getArea() );
|
||||
sb.append( " LCN:" );
|
||||
sb.append( getChannelFormatted() );
|
||||
sb.append( " HOME:" );
|
||||
sb.append( getHomeRepeaterFormatted() );
|
||||
sb.append( " GRP:" );
|
||||
sb.append( getGroupFormatted() );
|
||||
sb.append( " FREE:" );
|
||||
sb.append( getFreeFormatted() );
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("UNKNOWN AREA:").append(getArea());
|
||||
sb.append(" LCN:").append(getChannel());
|
||||
sb.append(" HOME:").append(getHomeRepeater());
|
||||
sb.append(" GRP:").append(getGroup());
|
||||
sb.append(" FREE:").append(getFree());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
@Override
|
||||
public List<Identifier> getIdentifiers()
|
||||
{
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user