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:
Denny Sheirer
2018-12-24 09:08:34 -05:00
committed by GitHub
parent 735fca16d6
commit b67d4d92dc
869 changed files with 64776 additions and 45233 deletions

View File

@@ -1,161 +0,0 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014,2015 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.mdc1200;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.module.decode.event.CallEvent;
public class MDCCallEvent extends CallEvent
{
public MDCCallEvent( CallEventType callEventType,
AliasList aliasList,
String fromID,
String toID,
String details )
{
super( DecoderType.MDC1200, callEventType,
aliasList, fromID, toID, details );
}
private Alias getAlias( String ident )
{
if( hasAliasList() )
{
return getAliasList().getMDC1200Alias( ident );
}
return null;
}
@Override
public Alias getFromIDAlias()
{
return getAlias( getFromID() );
}
@Override
public Alias getToIDAlias()
{
return getAlias( getToID() );
}
@Override
public String getChannel()
{
return null;
}
@Override
public long getFrequency()
{
return 0;
}
public static class Builder
{
/* Required parameters */
private CallEventType mCallEventType;
/* Optional parameters */
private AliasList mAliasList;
private String mFromID;
private String mToID;
private String mDetails;
public Builder( CallEventType callEventType )
{
mCallEventType = callEventType;
}
public Builder aliasList( AliasList aliasList )
{
mAliasList = aliasList;
return this;
}
public Builder from( String val )
{
mFromID = val;
return this;
}
public Builder details( String details )
{
mDetails = details;
return this;
}
public Builder to( String toID )
{
mToID = toID;
return this;
}
public MDCCallEvent build()
{
return new MDCCallEvent( this );
}
}
/**
* Private constructor for the builder
*/
private MDCCallEvent( Builder builder )
{
this( builder.mCallEventType,
builder.mAliasList,
builder.mFromID,
builder.mToID,
builder.mDetails );
}
public static MDCCallEvent
getMDCCallEvent( MDCMessage message )
{
CallEventType type = CallEventType.UNKNOWN;
StringBuilder sbDetails = new StringBuilder();
sbDetails.append( "MDC-1200 OPCODE:" );
sbDetails.append( String.valueOf( message.getOpcode() ) );
switch( message.getMessageType() )
{
case ACKNOWLEDGE:
type = CallEventType.RESPONSE;
break;
case ANI:
type = CallEventType.ID_ANI;
break;
case EMERGENCY:
type = CallEventType.EMERGENCY;
break;
case PAGING:
type = CallEventType.PAGE;
break;
default:
break;
}
return new MDCCallEvent.Builder( type )
.details( sbDetails.toString() )
.from( message.getFromID() )
.to( message.getToID() )
.build();
}
}

View File

@@ -1,21 +1,24 @@
/*******************************************************************************
* sdr-trunk
/*
* ******************************************************************************
* 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 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.
* 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/>
*
******************************************************************************/
* 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.mdc1200;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.bits.MessageFramer;
import io.github.dsheirer.bits.SyncPattern;
import io.github.dsheirer.dsp.NRZDecoder;
@@ -34,25 +37,25 @@ public class MDCDecoder extends AbstractAFSKDecoder
private MessageFramer mMessageFramer;
private MDCMessageProcessor mMessageProcessor;
public MDCDecoder(AliasList aliasList)
public MDCDecoder()
{
super(AFSK1200Decoder.Output.INVERTED);
init(aliasList);
init();
}
protected MDCDecoder(AFSK1200Decoder decoder, AliasList aliasList)
protected MDCDecoder(AFSK1200Decoder decoder)
{
super(decoder);
init(aliasList);
init();
}
private void init(AliasList aliasList)
private void init()
{
mNRZDecoder = new NRZDecoder(NRZDecoder.MODE_INVERTED);
getDecoder().setSymbolProcessor(mNRZDecoder);
mMessageFramer = new MessageFramer(SyncPattern.MDC1200.getPattern(), MESSAGE_LENGTH);
mNRZDecoder.setListener(mMessageFramer);
mMessageProcessor = new MDCMessageProcessor(aliasList);
mMessageProcessor = new MDCMessageProcessor();
mMessageFramer.addMessageListener(mMessageProcessor);
mMessageProcessor.addMessageListener(getMessageListener());
}

View File

@@ -1,18 +1,22 @@
/*******************************************************************************
* sdr-trunk
/*
* ******************************************************************************
* 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 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.
* 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/>
*
******************************************************************************/
* 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.mdc1200;
import io.github.dsheirer.dsp.afsk.AFSK1200DecoderInstrumented;
@@ -29,7 +33,7 @@ public class MDCDecoderInstrumented extends MDCDecoder implements IInstrumentedA
public MDCDecoderInstrumented()
{
super(new AFSK1200DecoderInstrumented(false), null);
super(new AFSK1200DecoderInstrumented(false));
}
@Override

View File

@@ -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,42 +15,32 @@
*
* 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.mdc1200;
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.IdentifierClass;
import io.github.dsheirer.identifier.MutableIdentifierCollection;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.util.StringUtils;
import io.github.dsheirer.module.decode.event.DecodeEvent;
import io.github.dsheirer.module.decode.mdc1200.identifier.MDC1200Identifier;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
public class MDCDecoderState extends DecoderState
{
private TreeSet<String> mIdents = new TreeSet<String>();
private TreeSet<String> mEmergencyIdents = new TreeSet<String>();
private Set<MDC1200Identifier> mIdents = new TreeSet<>();
private Set<MDC1200Identifier> mEmergencyIdents = new TreeSet<>();
private AliasedStringAttributeMonitor mFromAttribute;
private String mMessage;
private String mMessageType;
public MDCDecoderState(AliasList aliasList)
public MDCDecoderState()
{
super(aliasList);
mFromAttribute = new AliasedStringAttributeMonitor(Attribute.SECONDARY_ADDRESS_FROM,
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.MDC1200);
}
@Override
@@ -85,37 +76,26 @@ public class MDCDecoderState extends DecoderState
}
private void resetState()
{
mFromAttribute.reset();
mMessage = null;
mMessageType = null;
}
@Override
public void receive(Message message)
public void receive(IMessage message)
{
if(message instanceof MDCMessage)
{
MDCMessage mdc = (MDCMessage) message;
MDCMessage mdc = (MDCMessage)message;
mIdents.add(mdc.getUnitID());
mIdents.add(mdc.getFromIdentifier());
if(mdc.isEmergency())
{
mEmergencyIdents.add(mdc.getUnitID());
mEmergencyIdents.add(mdc.getFromIdentifier());
}
mFromAttribute.process(mdc.getFromID());
MDCMessageType type = mdc.getMessageType();
setMessageType(type.getLabel());
StringBuilder sb = new StringBuilder();
sb.append("OPCODE ");
sb.append(String.valueOf(mdc.getOpcode()));
sb.append(mdc.getOpcode());
if(mdc.isBOT())
{
@@ -127,11 +107,15 @@ public class MDCDecoderState extends DecoderState
sb.append(" TYPE:EOT");
}
setMessage(sb.toString());
MutableIdentifierCollection ic = new MutableIdentifierCollection(getIdentifierCollection().getIdentifiers());
ic.remove(IdentifierClass.USER);
ic.update(message.getIdentifiers());
MDCCallEvent event = MDCCallEvent.getMDCCallEvent(mdc);
event.setAliasList(getAliasList());
broadcast(event);
broadcast(DecodeEvent.builder(mdc.getTimestamp())
.eventDescription(type.getLabel())
.details(mdc.toString())
.identifiers(ic)
.build());
switch(type)
{
@@ -150,34 +134,6 @@ public class MDCDecoderState extends DecoderState
}
}
public String getMessage()
{
return mMessage;
}
public void setMessage(String message)
{
if(!StringUtils.isEqual(mMessage, message))
{
mMessage = message;
broadcast(new AttributeChangeRequest<String>(Attribute.MESSAGE, mMessage));
}
}
public String getMessageType()
{
return mMessageType;
}
public void setMessageType(String type)
{
if(!StringUtils.isEqual(mMessageType, type))
{
mMessageType = type;
broadcast(new AttributeChangeRequest<String>(Attribute.MESSAGE_TYPE, "MDC:" + mMessageType));
}
}
@Override
public String getActivitySummary()
{
@@ -193,27 +149,11 @@ public class MDCDecoderState extends DecoderState
}
else
{
Iterator<String> it = mIdents.iterator();
Iterator<MDC1200Identifier> it = mIdents.iterator();
while(it.hasNext())
{
String ident = it.next();
sb.append(" ");
sb.append(ident);
sb.append(" ");
if(hasAliasList())
{
Alias alias = getAliasList().getMDC1200Alias(ident);
if(alias != null)
{
sb.append(alias.getName());
}
}
sb.append("\n");
sb.append(" ").append(it.next()).append("\n");
}
}
@@ -225,27 +165,16 @@ public class MDCDecoderState extends DecoderState
}
else
{
Iterator<String> it = mEmergencyIdents.iterator();
Iterator<MDC1200Identifier> it = mEmergencyIdents.iterator();
while(it.hasNext())
{
String ident = it.next();
Iterator<MDC1200Identifier> it2 = mIdents.iterator();
sb.append(" ");
sb.append(ident);
sb.append(" ");
if(hasAliasList())
while(it2.hasNext())
{
Alias alias = getAliasList().getMDC1200Alias(ident);
if(alias != null)
{
sb.append(alias.getName());
}
sb.append(" ").append(it2.next()).append("\n");
}
sb.append("\n");
}
}

View File

@@ -1,345 +1,261 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 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.mdc1200;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.map.Plottable;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.module.decode.mdc1200.identifier.MDC1200Identifier;
import io.github.dsheirer.protocol.Protocol;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class MDCMessage extends Message
{
private static SimpleDateFormat mSDF = new SimpleDateFormat( "yyyyMMdd HHmmss" );
private static int[] SYNC1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39};
private static int[] sSYNC1 = { 0,1,2,3,4,5,6,7,8,9,
10,11,12,13,14,15,16,17,18,19,
20,21,22,23,24,25,26,27,28,29,
30,31,32,33,34,35,36,37,38,39 };
private static int[] sOPCODE = { 47,46,45,44,43,42,41,40 };
private static int sANI_FLAG = 40;
private static int sDIRECTION_FLAG = 45;
private static int sACKNOWLEDGE_REQUIRED_FLAG = 46;
private static int sPACKET_TYPE_FLAG = 47;
private static int sEMERGENCY_FLAG = 48;
private static int[] sARGUMENT = { 49,50,51,52,53,54 };
private static int sBOT_EOT_FLAG = 55;
private static int[] sDIGIT_2 = { 59,58,57,56 };
private static int[] sDIGIT_1 = { 63,62,61,60 };
private static int[] sDIGIT_4 = { 67,66,65,64 };
private static int[] sDIGIT_3 = { 71,70,69,68 };
private static int[] OPCODE = {47, 46, 45, 44, 43, 42, 41, 40};
private static int ANI_FLAG = 40;
private static int DIRECTION_FLAG = 45;
private static int ACKNOWLEDGE_REQUIRED_FLAG = 46;
private static int PACKET_TYPE_FLAG = 47;
private static int EMERGENCY_FLAG = 48;
private static int[] ARGUMENT = {49, 50, 51, 52, 53, 54};
private static int BOT_EOT_FLAG = 55;
private static int[] DIGIT_2 = {59, 58, 57, 56};
private static int[] DIGIT_1 = {63, 62, 61, 60};
private static int[] DIGIT_4 = {67, 66, 65, 64};
private static int[] DIGIT_3 = {71, 70, 69, 68};
private static int[] IDENTITY = {63, 62, 61, 60, 59, 58, 57, 56, 71, 70, 69, 68, 67, 66, 65, 64};
private BinaryMessage mMessage;
private AliasList mAliasList;
public MDCMessage( BinaryMessage message, AliasList list )
private CorrectedBinaryMessage mMessage;
private MDC1200Identifier mFromIdentifier;
private List<Identifier> mIdentifiers;
public MDCMessage(CorrectedBinaryMessage message)
{
mMessage = message;
mAliasList = list;
}
public CorrectedBinaryMessage getMessage()
{
return mMessage;
}
public MDC1200Identifier getFromIdentifier()
{
if(mFromIdentifier == null)
{
mFromIdentifier = MDC1200Identifier.createFrom(getMessage().getInt(IDENTITY));
}
return mFromIdentifier;
}
@Override
public List<Identifier> getIdentifiers()
{
if(mIdentifiers == null)
{
mIdentifiers = new ArrayList<>();
mIdentifiers.add(getFromIdentifier());
}
return mIdentifiers;
}
public boolean isValid()
{
//TODO: add CRC and/or convolution decoding/repair
//TODO: add CRC and/or convolution decoding/repair
return true;
}
public PacketType getPacketType()
{
if( mMessage.get( sPACKET_TYPE_FLAG ) )
{
return PacketType.DATA;
}
else
{
return PacketType.CMND;
}
if(mMessage.get(PACKET_TYPE_FLAG))
{
return PacketType.DATA;
}
else
{
return PacketType.CMND;
}
}
public Acknowledge getResponse()
{
if( mMessage.get( sACKNOWLEDGE_REQUIRED_FLAG ) )
{
return Acknowledge.YES;
}
else
{
return Acknowledge.NO;
}
if(mMessage.get(ACKNOWLEDGE_REQUIRED_FLAG))
{
return Acknowledge.YES;
}
else
{
return Acknowledge.NO;
}
}
public Direction getDirection()
{
if( mMessage.get( sDIRECTION_FLAG ) )
{
return Direction.OUT;
}
else
{
return Direction.IN;
}
if(mMessage.get(DIRECTION_FLAG))
{
return Direction.OUT;
}
else
{
return Direction.IN;
}
}
public int getOpcode()
{
return mMessage.getInt( sOPCODE );
return mMessage.getInt(OPCODE);
}
public int getArgument()
{
return mMessage.getInt( sARGUMENT );
return mMessage.getInt(ARGUMENT);
}
public boolean isEmergency()
{
return mMessage.get( sEMERGENCY_FLAG );
return mMessage.get(EMERGENCY_FLAG);
}
public boolean isANI()
{
return mMessage.get( sANI_FLAG );
return mMessage.get(ANI_FLAG);
}
public boolean isBOT()
{
return mMessage.get( sBOT_EOT_FLAG );
return mMessage.get(BOT_EOT_FLAG);
}
public boolean isEOT()
{
return !mMessage.get( sBOT_EOT_FLAG );
return !mMessage.get(BOT_EOT_FLAG);
}
public String getUnitID()
{
StringBuilder sb = new StringBuilder();
sb.append( Integer.toHexString( mMessage.getInt( sDIGIT_1 ) ).toUpperCase() );
sb.append( Integer.toHexString( mMessage.getInt( sDIGIT_2 ) ).toUpperCase() );
sb.append( Integer.toHexString( mMessage.getInt( sDIGIT_3 ) ).toUpperCase() );
sb.append( Integer.toHexString( mMessage.getInt( sDIGIT_4 ) ).toUpperCase() );
return sb.toString();
}
public MDCMessageType getMessageType()
{
switch( getOpcode() )
{
case 0:
if( isEmergency() )
{
return MDCMessageType.EMERGENCY;
}
case 1:
return MDCMessageType.ANI;
default:
return MDCMessageType.UNKNOWN;
}
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append( mSDF.format( new Date( System.currentTimeMillis() ) ) );
sb.append( getMessage() );
sb.append( " [" + mMessage.toString() + "]" );
return sb.toString();
switch(getOpcode())
{
case 0:
if(isEmergency())
{
return MDCMessageType.EMERGENCY;
}
case 1:
return MDCMessageType.ANI;
default:
return MDCMessageType.UNKNOWN;
}
}
/**
* Pads spaces onto the end of the value to make it 'places' long
*/
public String pad( String value, int places, String padCharacter )
public String pad(String value, int places, String padCharacter)
{
StringBuilder sb = new StringBuilder();
sb.append( value );
while( sb.length() < places )
{
sb.append( padCharacter );
}
return sb.toString();
StringBuilder sb = new StringBuilder();
sb.append(value);
while(sb.length() < places)
{
sb.append(padCharacter);
}
return sb.toString();
}
/**
* Pads an integer value with additional zeroes to make it decimalPlaces long
*/
public String format( int number, int decimalPlaces )
public String format(int number, int decimalPlaces)
{
StringBuilder sb = new StringBuilder();
StringBuilder sb = new StringBuilder();
int paddingRequired = decimalPlaces - ( String.valueOf( number ).length() );
int paddingRequired = decimalPlaces - (String.valueOf(number).length());
for( int x = 0; x < paddingRequired; x++)
{
sb.append( "0" );
}
sb.append( number );
return sb.toString();
}
@SuppressWarnings( "unused" )
private int getInt( int[] bits )
{
int retVal = 0;
for( int x = 0; x < bits.length; x++ )
{
if( mMessage.get( bits[ x ] ) )
{
retVal += 1<<x;
}
}
return retVal;
for(int x = 0; x < paddingRequired; x++)
{
sb.append("0");
}
sb.append(number);
return sb.toString();
}
@Override
public String getBinaryMessage()
@Override
public Protocol getProtocol()
{
return mMessage.toString();
}
@Override
public String getProtocol()
{
return "MDC-1200";
return Protocol.MDC1200;
}
@Override
public String getEventType()
@Override
public String toString()
{
// TODO Auto-generated method stub
return null;
StringBuilder sb = new StringBuilder();
sb.append("MDC1200 UNIT:" + getFromIdentifier());
if(isEmergency())
{
sb.append(" **EMERGENCY**");
}
if(isBOT())
{
sb.append(" BOT");
}
if(isEOT())
{
sb.append(" EOT");
}
sb.append(" OPCODE:" + format(getOpcode(), 2));
sb.append(" ARG:" + format(getArgument(), 3));
sb.append(" TYPE:" + getPacketType().toString());
sb.append(" ACK:" + getResponse().toString());
sb.append(" DIR:" + pad(getDirection().toString(), 3, " "));
return sb.toString();
}
@Override
public String getFromID()
private enum PacketType
{
return getUnitID();
CMND, DATA
}
@Override
public Alias getFromIDAlias()
private enum Acknowledge
{
return mAliasList.getMDC1200Alias( getFromID() );
YES, NO
}
@Override
public String getToID()
private enum Direction
{
// TODO Auto-generated method stub
return null;
IN, OUT
}
@Override
public Alias getToIDAlias()
{
// TODO Auto-generated method stub
return null;
}
@Override
public String getMessage()
{
StringBuilder sb = new StringBuilder();
sb.append( "MDC1200 UNIT:" + getUnitID() );
if( isEmergency() )
{
sb.append( " **EMERGENCY**" );
}
if( isBOT() )
{
sb.append( " BOT" );
}
if( isEOT() )
{
sb.append( " EOT" );
}
sb.append( " OPCODE:" + format( getOpcode(), 2 ) );
sb.append( " ARG:" + format( getArgument(), 3 ) );
sb.append( " TYPE:" + getPacketType().toString() );
sb.append( " ACK:" + getResponse().toString() );
sb.append( " DIR:" + pad( getDirection().toString(), 3, " " ) );
return sb.toString();
}
@Override
public String getErrorStatus()
{
// TODO Auto-generated method stub
return null;
}
@Override
public Plottable getPlottable()
{
// TODO Auto-generated method stub
return null;
}
/**
* Provides a listing of aliases contained in the message.
*/
public List<Alias> getAliases()
{
List<Alias> aliases = new ArrayList<Alias>();
Alias from = getFromIDAlias();
if( from != null )
{
aliases.add( from );
}
Alias to = getToIDAlias();
if( to != null )
{
aliases.add( to );
}
return aliases;
}
private enum PacketType { CMND, DATA };
private enum Acknowledge { YES, NO };
private enum Direction { IN, OUT };
}

View File

@@ -2,55 +2,56 @@ package io.github.dsheirer.module.decode.mdc1200;
import io.github.dsheirer.filter.Filter;
import io.github.dsheirer.filter.FilterElement;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.message.Message;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MDCMessageFilter extends Filter<Message>
public class MDCMessageFilter extends Filter<IMessage>
{
private HashMap<MDCMessageType, FilterElement<MDCMessageType>> mElements =
new HashMap<MDCMessageType, FilterElement<MDCMessageType>>();
public MDCMessageFilter()
{
super( "MDC-1200 Message Filter" );
private Map<MDCMessageType, FilterElement<MDCMessageType>> mElements = new HashMap<MDCMessageType, FilterElement<MDCMessageType>>();
for( MDCMessageType type: MDCMessageType.values() )
{
if( type != MDCMessageType.UNKNOWN )
{
mElements.put( type, new FilterElement<MDCMessageType>( type ) );
}
}
}
@Override
public boolean passes( Message message )
public MDCMessageFilter()
{
if( mEnabled && canProcess( message ) )
{
MDCMessage mdc = (MDCMessage)message;
if( mElements.containsKey( mdc.getMessageType() ) )
{
return mElements.get( mdc.getMessageType() ).isEnabled();
}
}
return false;
super("MDC-1200 Message Filter");
for(MDCMessageType type : MDCMessageType.values())
{
if(type != MDCMessageType.UNKNOWN)
{
mElements.put(type, new FilterElement<MDCMessageType>(type));
}
}
}
@Override
public boolean canProcess( Message message )
@Override
public boolean passes(IMessage message)
{
return message instanceof MDCMessage;
if(mEnabled && canProcess(message))
{
MDCMessage mdc = (MDCMessage) message;
if(mElements.containsKey(mdc.getMessageType()))
{
return mElements.get(mdc.getMessageType()).isEnabled();
}
}
return false;
}
@Override
@Override
public boolean canProcess(IMessage message)
{
return message instanceof MDCMessage;
}
@Override
public List<FilterElement<?>> getFilterElements()
{
return new ArrayList<FilterElement<?>>( mElements.values() );
return new ArrayList<FilterElement<?>>(mElements.values());
}
}

View File

@@ -1,155 +1,155 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 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.mdc1200;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.sample.Broadcaster;
import io.github.dsheirer.sample.Listener;
public class MDCMessageProcessor implements Listener<BinaryMessage>
public class MDCMessageProcessor implements Listener<CorrectedBinaryMessage>
{
private static int sMESSAGE_LENGTH = 112;
private Broadcaster<Message> mBroadcaster = new Broadcaster<Message>();
private AliasList mAliasList;
public MDCMessageProcessor( AliasList aliasList )
{
mAliasList = aliasList;
}
public void dispose()
{
mBroadcaster.dispose();
}
@Override
public void receive( BinaryMessage buffer )
{
/**
* De-interleave the 112 bits of message one, starting after the sync
* pattern
*/
deinterleave( buffer, 40 );
private static int sMESSAGE_LENGTH = 112;
/**
* For simplicity, we also deinterleave message 2, which may or may not
* be there, starting after the initial sync ( 0 - 39 ) and the initial
* message ( 40 - 151 ) and the second sync ( 152 - 191 ).
*/
deinterleave( buffer, 192 );
private Broadcaster<IMessage> mBroadcaster = new Broadcaster<>();
/**
* Wrap the buffer in a message along with the designated alias list
* and send it on its merry way
*/
MDCMessage message = new MDCMessage( buffer, mAliasList );
mBroadcaster.receive( message );
}
public void addMessageListener( Listener<Message> listener )
public MDCMessageProcessor()
{
mBroadcaster.addListener( listener );
}
public void removeMessageListener( Listener<Message> listener )
public void dispose()
{
mBroadcaster.removeListener( listener );
mBroadcaster.dispose();
}
/**
* Removes NRZ-I encoding from the entire buffer. Assumes that the initial
* bit will be a 0 after decode, despite what is currently in the buffer,
* in order to maintain correct polarity of the decoded message.
*/
private void removeNRZIEncoding( BinaryMessage buffer )
{
/**
* Clear bit position 0, the first bit of the sync pattern, to start
* the decode with the correct polarity
*/
buffer.clear( 0 );
/**
* Set each bit according to the state of the previous bit using XOR
* as follows:
*
* 0 = same as previous state
* 1 = inverse of previous state
*/
for( int x = 1; x < buffer.size(); x++ )
{
if( buffer.get( x - 1 ) ^ buffer.get( x ) )
{
buffer.set( x );
}
else
{
buffer.clear( x );
}
}
}
/**
* Deinterleaves a 112-bit packet, starting at the offset into the buffer
*/
private void deinterleave( BinaryMessage buffer, int offset )
{
if( buffer.size() < sMESSAGE_LENGTH + offset )
{
throw new IllegalArgumentException( "MDCMessageProcessor - "
+ "cannot deinterleave message - message buffer too short" );
}
BinaryMessage deinterleaved = new BinaryMessage( 112 );
@Override
public void receive(CorrectedBinaryMessage buffer)
{
/**
* De-interleave the 112 bits of message one, starting after the sync
* pattern
*/
deinterleave(buffer, 40);
int deinterleavedPointer = 0;
for( int column = 0; column < 16; column++ )
{
for( int row = 0; row < 7; row++ )
{
if( buffer.get( ( row * 16 ) + column + offset ) )
{
deinterleaved.set( deinterleavedPointer );
}
deinterleavedPointer++;
}
}
/**
* For simplicity, we also deinterleave message 2, which may or may not
* be there, starting after the initial sync ( 0 - 39 ) and the initial
* message ( 40 - 151 ) and the second sync ( 152 - 191 ).
*/
deinterleave(buffer, 192);
//Overlay the deinterleaved bits back onto the source message and
//return it
buffer.clear( offset, offset + sMESSAGE_LENGTH );
for( int x = 0; x < sMESSAGE_LENGTH; x++ )
{
if( deinterleaved.get( x ) )
{
buffer.set( x + offset );
}
else
{
buffer.clear( x + offset );
}
}
}
/**
* Wrap the buffer in a message along with the designated alias list
* and send it on its merry way
*/
MDCMessage message = new MDCMessage(buffer);
mBroadcaster.receive(message);
}
public void addMessageListener(Listener<IMessage> listener)
{
mBroadcaster.addListener(listener);
}
public void removeMessageListener(Listener<IMessage> listener)
{
mBroadcaster.removeListener(listener);
}
/**
* Removes NRZ-I encoding from the entire buffer. Assumes that the initial
* bit will be a 0 after decode, despite what is currently in the buffer,
* in order to maintain correct polarity of the decoded message.
*/
private void removeNRZIEncoding(BinaryMessage buffer)
{
/**
* Clear bit position 0, the first bit of the sync pattern, to start
* the decode with the correct polarity
*/
buffer.clear(0);
/**
* Set each bit according to the state of the previous bit using XOR
* as follows:
*
* 0 = same as previous state
* 1 = inverse of previous state
*/
for(int x = 1; x < buffer.size(); x++)
{
if(buffer.get(x - 1) ^ buffer.get(x))
{
buffer.set(x);
}
else
{
buffer.clear(x);
}
}
}
/**
* Deinterleaves a 112-bit packet, starting at the offset into the buffer
*/
private void deinterleave(BinaryMessage buffer, int offset)
{
if(buffer.size() < sMESSAGE_LENGTH + offset)
{
throw new IllegalArgumentException("MDCMessageProcessor - "
+ "cannot deinterleave message - message buffer too short");
}
BinaryMessage deinterleaved = new BinaryMessage(112);
int deinterleavedPointer = 0;
for(int column = 0; column < 16; column++)
{
for(int row = 0; row < 7; row++)
{
if(buffer.get((row * 16) + column + offset))
{
deinterleaved.set(deinterleavedPointer);
}
deinterleavedPointer++;
}
}
//Overlay the deinterleaved bits back onto the source message and
//return it
buffer.clear(offset, offset + sMESSAGE_LENGTH);
for(int x = 0; x < sMESSAGE_LENGTH; x++)
{
if(deinterleaved.get(x))
{
buffer.set(x + offset);
}
else
{
buffer.clear(x + offset);
}
}
}
}

View File

@@ -0,0 +1,62 @@
/*
* ******************************************************************************
* 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.mdc1200.identifier;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.talkgroup.TalkgroupIdentifier;
import io.github.dsheirer.protocol.Protocol;
/**
* Identifier for an MDC1200 radio identity
*/
public class MDC1200Identifier extends TalkgroupIdentifier
{
/**
* Constructs an MDC1200 talkgroup Identifier
*/
public MDC1200Identifier(Integer value, Role role)
{
super(value, role, false);
}
@Override
public Protocol getProtocol()
{
return Protocol.MDC1200;
}
/**
* Creates an MDC1200 talkgroup identifier for the TO identity
*/
public static MDC1200Identifier createTo(int value)
{
return new MDC1200Identifier(value, Role.TO);
}
/**
* Creates an MDC1200 talkgroup identifier for the FROM identity
*/
public static MDC1200Identifier createFrom(int value)
{
return new MDC1200Identifier(value, Role.FROM);
}
}