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

@@ -17,6 +17,7 @@
******************************************************************************/
package io.github.dsheirer.module.decode;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.message.IMessageProvider;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.module.Module;
@@ -25,8 +26,8 @@ import io.github.dsheirer.sample.Listener;
public abstract class Decoder extends Module implements IMessageProvider
{
/* This has to be a broadcaster in order for references to persist */
private Listener<Message> mMessageDistributor = new MessageDistributor();
protected Listener<Message> mMessageListener;
private Listener<IMessage> mMessageDistributor = new MessageDistributor();
protected Listener<IMessage> mMessageListener;
/**
* Decoder - parent class for all decoders, demodulators and components.
@@ -66,7 +67,7 @@ public abstract class Decoder extends Module implements IMessageProvider
* Adds a listener for receiving decoded messages from this decoder
*/
@Override
public void setMessageListener(Listener<Message> listener)
public void setMessageListener(Listener<IMessage> listener)
{
mMessageListener = listener;
}
@@ -84,7 +85,7 @@ public abstract class Decoder extends Module implements IMessageProvider
/**
* Message listener for receiving the output from this decoder
*/
protected Listener<Message> getMessageListener()
protected Listener<IMessage> getMessageListener()
{
return mMessageDistributor;
}
@@ -92,10 +93,10 @@ public abstract class Decoder extends Module implements IMessageProvider
/**
* Distributes/forwards messages from sub-class decoder implementations to the registered message listener.
*/
public class MessageDistributor implements Listener<Message>
public class MessageDistributor implements Listener<IMessage>
{
@Override
public void receive(Message message)
public void receive(IMessage message)
{
if(mMessageListener != null)
{

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,20 +15,17 @@
*
* 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;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.alias.action.AliasActionManager;
import io.github.dsheirer.audio.AudioModule;
import io.github.dsheirer.channel.metadata.Metadata;
import io.github.dsheirer.channel.state.AlwaysUnsquelchedDecoderState;
import io.github.dsheirer.channel.traffic.TrafficChannelManager;
import io.github.dsheirer.controller.channel.Channel;
import io.github.dsheirer.controller.channel.Channel.ChannelType;
import io.github.dsheirer.controller.channel.ChannelModel;
import io.github.dsheirer.controller.channel.ChannelProcessingManager;
import io.github.dsheirer.controller.channel.map.ChannelMap;
import io.github.dsheirer.controller.channel.map.ChannelMapModel;
import io.github.dsheirer.filter.AllPassFilter;
@@ -35,7 +33,7 @@ import io.github.dsheirer.filter.FilterSet;
import io.github.dsheirer.filter.IFilter;
import io.github.dsheirer.gui.editor.EmptyValidatingEditor;
import io.github.dsheirer.gui.editor.ValidatingEditor;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.message.MessageDirection;
import io.github.dsheirer.module.Module;
import io.github.dsheirer.module.decode.am.AMDecoder;
@@ -67,16 +65,17 @@ import io.github.dsheirer.module.decode.mpt1327.MPT1327Decoder;
import io.github.dsheirer.module.decode.mpt1327.MPT1327DecoderEditor;
import io.github.dsheirer.module.decode.mpt1327.MPT1327DecoderState;
import io.github.dsheirer.module.decode.mpt1327.MPT1327MessageFilter;
import io.github.dsheirer.module.decode.mpt1327.MPT1327TrafficChannelManager;
import io.github.dsheirer.module.decode.mpt1327.Sync;
import io.github.dsheirer.module.decode.nbfm.DecodeConfigNBFM;
import io.github.dsheirer.module.decode.nbfm.NBFMDecoder;
import io.github.dsheirer.module.decode.nbfm.NBFMDecoderEditor;
import io.github.dsheirer.module.decode.p25.DecodeConfigP25Phase1;
import io.github.dsheirer.module.decode.p25.P25Decoder.Modulation;
import io.github.dsheirer.module.decode.p25.P25DecoderC4FM;
import io.github.dsheirer.module.decode.p25.P25DecoderEditor;
import io.github.dsheirer.module.decode.p25.P25DecoderLSM;
import io.github.dsheirer.module.decode.p25.P25DecoderState;
import io.github.dsheirer.module.decode.p25.P25TrafficChannelManager;
import io.github.dsheirer.module.decode.p25.audio.P25AudioModule;
import io.github.dsheirer.module.decode.p25.message.filter.P25MessageFilterSet;
import io.github.dsheirer.module.decode.passport.DecodeConfigPassport;
@@ -110,37 +109,31 @@ public class DecoderFactory
*
* @return list of configured decoders
*/
public static List<Module> getModules(ChannelModel channelModel,
ChannelMapModel channelMapModel,
ChannelProcessingManager channelProcessingManager,
AliasModel aliasModel,
Channel channel,
Metadata metadata)
public static List<Module> getModules(ChannelMapModel channelMapModel, Channel channel, AliasModel aliasModel)
{
/* Get the optional alias list for the decode modules to use */
AliasList aliasList = aliasModel.getAliasList(channel.getAliasListName());
List<Module> modules = getPrimaryModules(channelModel, channelMapModel, channelProcessingManager, aliasList,
channel, metadata);
modules.addAll(getAuxiliaryDecoders(channel.getAuxDecodeConfiguration(), aliasList));
List<Module> modules = getPrimaryModules(channelMapModel, channel, aliasModel);
modules.addAll(getAuxiliaryDecoders(channel.getAuxDecodeConfiguration()));
return modules;
}
/**
* Constructs a primary decoder as specified in the decode configuration
*/
public static List<Module> getPrimaryModules(ChannelModel channelModel,
ChannelMapModel channelMapModel,
ChannelProcessingManager channelProcessingManager,
AliasList aliasList,
Channel channel,
Metadata metadata)
public static List<Module> getPrimaryModules(ChannelMapModel channelMapModel, Channel channel, AliasModel aliasModel)
{
List<Module> modules = new ArrayList<Module>();
//Adds an alias action manager when there are alias actions specified
if(channel.getAliasListName() != null && !channel.getAliasListName().isEmpty())
{
AliasList aliasList = aliasModel.getAliasList(channel.getAliasListName());
if(aliasList != null && aliasList.hasAliasActions())
{
modules.add(new AliasActionManager(aliasList));
}
}
ChannelType channelType = channel.getChannelType();
/* Baseband low-pass filter pass and stop frequencies */
@@ -151,7 +144,7 @@ public class DecoderFactory
case AM:
modules.add(new AMDecoder(decodeConfig));
modules.add(new AlwaysUnsquelchedDecoderState(DecoderType.AM, channel.getName()));
modules.add(new AudioModule(metadata));
modules.add(new AudioModule());
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
{
modules.add(new AMDemodulatorModule(AM_CHANNEL_BANDWIDTH, DEMODULATED_AUDIO_SAMPLE_RATE));
@@ -160,87 +153,92 @@ public class DecoderFactory
case NBFM:
modules.add(new NBFMDecoder(decodeConfig));
modules.add(new AlwaysUnsquelchedDecoderState(DecoderType.NBFM, channel.getName()));
modules.add(new AudioModule(metadata));
modules.add(new AudioModule());
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
{
modules.add(new FMDemodulatorModule(FM_CHANNEL_BANDWIDTH, DEMODULATED_AUDIO_SAMPLE_RATE));
}
break;
case LTR_STANDARD:
MessageDirection direction = ((DecodeConfigLTRStandard) decodeConfig).getMessageDirection();
modules.add(new LTRStandardDecoder(aliasList, direction));
modules.add(new LTRStandardDecoderState(aliasList));
modules.add(new AudioModule(metadata));
MessageDirection direction = ((DecodeConfigLTRStandard)decodeConfig).getMessageDirection();
modules.add(new LTRStandardDecoder(null, direction));
modules.add(new LTRStandardDecoderState());
modules.add(new AudioModule());
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
{
modules.add(new FMDemodulatorModule(FM_CHANNEL_BANDWIDTH, DEMODULATED_AUDIO_SAMPLE_RATE));
}
break;
case LTR_NET:
modules.add(new LTRNetDecoder((DecodeConfigLTRNet) decodeConfig, aliasList));
modules.add(new LTRNetDecoderState(aliasList));
modules.add(new AudioModule(metadata));
modules.add(new LTRNetDecoder((DecodeConfigLTRNet)decodeConfig));
modules.add(new LTRNetDecoderState());
modules.add(new AudioModule());
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
{
modules.add(new FMDemodulatorModule(FM_CHANNEL_BANDWIDTH, DEMODULATED_AUDIO_SAMPLE_RATE));
}
break;
case MPT1327:
DecodeConfigMPT1327 mptConfig = (DecodeConfigMPT1327) decodeConfig;
DecodeConfigMPT1327 mptConfig = (DecodeConfigMPT1327)decodeConfig;
ChannelMap channelMap = channelMapModel.getChannelMap(mptConfig.getChannelMapName());
Sync sync = mptConfig.getSync();
modules.add(new MPT1327Decoder(aliasList, sync));
modules.add(new MPT1327DecoderState(aliasList, channelMap, channelType, mptConfig.getCallTimeout() * 1000));
modules.add(new AudioModule(metadata));
modules.add(new MPT1327Decoder(sync));
modules.add(new AudioModule());
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
{
modules.add(new FMDemodulatorModule(FM_CHANNEL_BANDWIDTH, DEMODULATED_AUDIO_SAMPLE_RATE));
}
long timeout = mptConfig.getCallTimeout() * 1000;
if(channelType == ChannelType.STANDARD)
{
modules.add(new TrafficChannelManager(channelModel, decodeConfig,
channel.getRecordConfiguration(), channel.getSystem(), channel.getSite(),
(aliasList != null ? aliasList.getName() : null), mptConfig.getTrafficChannelPoolSize()));
MPT1327TrafficChannelManager trafficChannelManager = new MPT1327TrafficChannelManager(channel, channelMap);
modules.add(trafficChannelManager);
modules.add(new MPT1327DecoderState(trafficChannelManager, channelType, timeout));
}
else
{
modules.add(new MPT1327DecoderState(channelType, timeout));
}
break;
case PASSPORT:
modules.add(new PassportDecoder(decodeConfig, aliasList));
modules.add(new PassportDecoderState(aliasList));
modules.add(new AudioModule(metadata));
modules.add(new PassportDecoder(decodeConfig));
modules.add(new PassportDecoderState());
modules.add(new AudioModule());
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
{
modules.add(new FMDemodulatorModule(FM_CHANNEL_BANDWIDTH, DEMODULATED_AUDIO_SAMPLE_RATE));
}
break;
case P25_PHASE1:
DecodeConfigP25Phase1 p25Config = (DecodeConfigP25Phase1) decodeConfig;
DecodeConfigP25Phase1 p25Config = (DecodeConfigP25Phase1)decodeConfig;
Modulation modulation = p25Config.getModulation();
switch(modulation)
switch(p25Config.getModulation())
{
case C4FM:
modules.add(new P25DecoderC4FM(aliasList));
modules.add(new P25DecoderState(aliasList, channelType, Modulation.C4FM,
p25Config.getIgnoreDataCalls()));
modules.add(new P25DecoderC4FM());
break;
case CQPSK:
modules.add(new P25DecoderLSM(aliasList));
modules.add(new P25DecoderState(aliasList, channelType, Modulation.CQPSK, p25Config.getIgnoreDataCalls()));
modules.add(new P25DecoderLSM());
break;
default:
throw new IllegalArgumentException("Unrecognized P25 Phase 1 Modulation [" + modulation + "]");
throw new IllegalArgumentException("Unrecognized P25 Phase 1 Modulation [" +
p25Config.getModulation() + "]");
}
if(channelType == ChannelType.STANDARD)
{
modules.add(new TrafficChannelManager(channelModel, decodeConfig,
channel.getRecordConfiguration(), channel.getSystem(), channel.getSite(),
(aliasList != null ? aliasList.getName() : null), p25Config.getTrafficChannelPoolSize()));
P25TrafficChannelManager trafficChannelManager = new P25TrafficChannelManager(channel);
modules.add(trafficChannelManager);
modules.add(new P25DecoderState(channel, trafficChannelManager));
}
else
{
modules.add(new P25DecoderState(channel));
}
modules.add(new P25AudioModule(metadata));
modules.add(new P25AudioModule());
break;
default:
throw new IllegalArgumentException("Unknown decoder type [" + decodeConfig.getDecoderType().toString() + "]");
@@ -253,11 +251,9 @@ public class DecoderFactory
* Constructs a list of auxiliary decoders, as specified in the configuration
*
* @param config - auxiliary configuration
* @param aliasList - optional alias list
* @return - list of auxiliary decoders
*/
public static List<Module> getAuxiliaryDecoders(AuxDecodeConfiguration config,
AliasList aliasList)
public static List<Module> getAuxiliaryDecoders(AuxDecodeConfiguration config)
{
List<Module> modules = new ArrayList<>();
@@ -268,24 +264,23 @@ public class DecoderFactory
switch(auxDecoder)
{
case FLEETSYNC2:
modules.add(new Fleetsync2Decoder(aliasList));
modules.add(new Fleetsync2DecoderState(aliasList));
modules.add(new Fleetsync2Decoder());
modules.add(new Fleetsync2DecoderState());
break;
case MDC1200:
modules.add(new MDCDecoder(aliasList));
modules.add(new MDCDecoderState(aliasList));
modules.add(new MDCDecoder());
modules.add(new MDCDecoderState());
break;
case LJ_1200:
modules.add(new LJ1200Decoder(aliasList));
modules.add(new LJ1200DecoderState(aliasList));
modules.add(new LJ1200Decoder());
modules.add(new LJ1200DecoderState());
break;
case TAIT_1200:
modules.add(new Tait1200Decoder(aliasList));
modules.add(new Tait1200DecoderState(aliasList));
modules.add(new Tait1200Decoder());
modules.add(new Tait1200DecoderState());
break;
default:
throw new IllegalArgumentException("Unrecognized auxiliary "
+ "decoder type [" + auxDecoder + "]");
throw new IllegalArgumentException("Unrecognized auxiliary decoder type [" + auxDecoder + "]");
}
}
}
@@ -297,9 +292,9 @@ public class DecoderFactory
* Assembles a filter set containing filters for the primary channel
* decoder and each of the auxiliary decoders
*/
public static FilterSet<Message> getMessageFilters(List<Module> modules)
public static FilterSet<IMessage> getMessageFilters(List<Module> modules)
{
FilterSet<Message> filterSet = new FilterSet<>();
FilterSet<IMessage> filterSet = new FilterSet<>();
for(Module module : modules)
{
@@ -312,7 +307,7 @@ public class DecoderFactory
/* If we don't have any filters, add an ALL-PASS filter */
if(filterSet.getFilters().isEmpty())
{
filterSet.addFilter(new AllPassFilter<Message>());
filterSet.addFilter(new AllPassFilter<>());
}
return filterSet;
@@ -322,9 +317,9 @@ public class DecoderFactory
* Returns a set of IMessageFilter objects (FilterSets or Filters) that
* can process all of the messages produced by the specified decoder type.
*/
public static List<IFilter<Message>> getMessageFilter(DecoderType decoder)
public static List<IFilter<IMessage>> getMessageFilter(DecoderType decoder)
{
ArrayList<IFilter<Message>> filters = new ArrayList<IFilter<Message>>();
ArrayList<IFilter<IMessage>> filters = new ArrayList<>();
switch(decoder)
{
@@ -424,21 +419,19 @@ public class DecoderFactory
switch(config.getDecoderType())
{
case AM:
DecodeConfigAM originalAM = (DecodeConfigAM) config;
DecodeConfigAM copyAM = new DecodeConfigAM();
return copyAM;
return new DecodeConfigAM();
case LTR_NET:
DecodeConfigLTRNet originalLTRNet = (DecodeConfigLTRNet) config;
DecodeConfigLTRNet originalLTRNet = (DecodeConfigLTRNet)config;
DecodeConfigLTRNet copyLTRNet = new DecodeConfigLTRNet();
copyLTRNet.setMessageDirection(originalLTRNet.getMessageDirection());
return copyLTRNet;
case LTR_STANDARD:
DecodeConfigLTRStandard originalLTRStandard = (DecodeConfigLTRStandard) config;
DecodeConfigLTRStandard originalLTRStandard = (DecodeConfigLTRStandard)config;
DecodeConfigLTRStandard copyLTRStandard = new DecodeConfigLTRStandard();
copyLTRStandard.setMessageDirection(originalLTRStandard.getMessageDirection());
return copyLTRStandard;
case MPT1327:
DecodeConfigMPT1327 originalMPT = (DecodeConfigMPT1327) config;
DecodeConfigMPT1327 originalMPT = (DecodeConfigMPT1327)config;
DecodeConfigMPT1327 copyMPT = new DecodeConfigMPT1327();
copyMPT.setCallTimeout(originalMPT.getCallTimeout());
copyMPT.setChannelMapName(originalMPT.getChannelMapName());
@@ -446,20 +439,16 @@ public class DecoderFactory
copyMPT.setTrafficChannelPoolSize(originalMPT.getTrafficChannelPoolSize());
return copyMPT;
case NBFM:
DecodeConfigNBFM originalNBFM = (DecodeConfigNBFM) config;
DecodeConfigNBFM copyNBFM = new DecodeConfigNBFM();
return copyNBFM;
return new DecodeConfigNBFM();
case P25_PHASE1:
DecodeConfigP25Phase1 originalP25 = (DecodeConfigP25Phase1) config;
DecodeConfigP25Phase1 originalP25 = (DecodeConfigP25Phase1)config;
DecodeConfigP25Phase1 copyP25 = new DecodeConfigP25Phase1();
copyP25.setIgnoreDataCalls(originalP25.getIgnoreDataCalls());
copyP25.setModulation(originalP25.getModulation());
copyP25.setTrafficChannelPoolSize(originalP25.getTrafficChannelPoolSize());
return copyP25;
case PASSPORT:
DecodeConfigPassport originalPass = (DecodeConfigPassport) config;
DecodeConfigPassport copyPass = new DecodeConfigPassport();
return copyPass;
return new DecodeConfigPassport();
default:
throw new IllegalArgumentException("Unrecognized decoder configuration type:" + config.getDecoderType());
}
@@ -469,12 +458,12 @@ public class DecoderFactory
}
/**
* Decoder(s) that support bitstreams.
* Decoder(s) that support bitstreams indicating that they produce ReusableByteBuffers of decoded bits.
*
* @return set of decoders that support bitstreams.
*/
public static EnumSet<DecoderType> getBitstreamDecoders()
{
return EnumSet.of(DecoderType.P25_PHASE1);
return EnumSet.of(DecoderType.P25_PHASE1, DecoderType.MPT1327);
}
}

View File

@@ -1,20 +1,26 @@
/*******************************************************************************
* 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;
import io.github.dsheirer.protocol.Protocol;
import java.util.ArrayList;
import java.util.EnumSet;
@@ -24,27 +30,29 @@ import java.util.EnumSet;
public enum DecoderType
{
//Primary Decoders
AM("AM", "AM"),
LTR_STANDARD("LTR-Standard", "LTR"),
LTR_NET("LTR-Net", "LTR-Net"),
MPT1327("MPT1327", "MPT1327"),
NBFM("NBFM", "NBFM"),
PASSPORT("Passport", "Passport"),
P25_PHASE1("P25 Phase I", "P25-1"),
AM("AM", "AM", Protocol.UNKNOWN),
LTR_STANDARD("LTR-Standard", "LTR", Protocol.LTR_STANDARD),
LTR_NET("LTR-Net", "LTR-Net", Protocol.LTR_NET),
MPT1327("MPT1327", "MPT1327", Protocol.MPT1327),
NBFM("NBFM", "NBFM", Protocol.UNKNOWN),
PASSPORT("Passport", "Passport", Protocol.PASSPORT),
P25_PHASE1("P25 Phase I", "P25-1", Protocol.APCO25),
//Auxiliary Decoders
FLEETSYNC2("Fleetsync II", "Fleetsync2"),
LJ_1200("LJ1200 173.075", "LJ1200"),
MDC1200("MDC1200", "MDC1200"),
TAIT_1200("Tait 1200", "Tait 1200");
FLEETSYNC2("Fleetsync II", "Fleetsync2", Protocol.FLEETSYNC),
LJ_1200("LJ1200 173.075", "LJ1200", Protocol.LOJACK),
MDC1200("MDC1200", "MDC1200", Protocol.MDC1200),
TAIT_1200("Tait 1200", "Tait 1200", Protocol.TAIT1200);
private String mDisplayString;
private String mShortDisplayString;
private Protocol mProtocol;
DecoderType(String displayString, String shortDisplayString)
DecoderType(String displayString, String shortDisplayString, Protocol protocol)
{
mDisplayString = displayString;
mShortDisplayString = shortDisplayString;
mProtocol = protocol;
}
/**
@@ -76,6 +84,11 @@ public enum DecoderType
return decoders;
}
public Protocol getProtocol()
{
return mProtocol;
}
public String getDisplayString()
{
return mDisplayString;

View File

@@ -17,10 +17,11 @@
******************************************************************************/
package io.github.dsheirer.module.decode.event;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.sample.Listener;
public interface ActivitySummaryProvider extends Listener<Message>
public interface ActivitySummaryProvider extends Listener<IMessage>
{
public String getActivitySummary();
}

View File

@@ -20,9 +20,12 @@ package io.github.dsheirer.module.decode.event;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.channel.IChannelDescriptor;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.module.decode.DecoderType;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
public abstract class CallEvent implements Comparable<CallEvent>
@@ -40,8 +43,31 @@ public abstract class CallEvent implements Comparable<CallEvent>
protected String mToID;
protected String mDetails;
//New call event format member variables
protected IChannelDescriptor mChannelDescriptor;
protected Collection<Identifier> mIdentifiers;
private boolean mValid = true;
/**
* Constructs a call event
* @param decoder type
* @param callEventType description
* @param channelDescriptor that identifies the channel and frequency value(s)
* @param identifiers for to, from, comments, etc.
*/
public CallEvent(DecoderType decoder, CallEventType callEventType, IChannelDescriptor channelDescriptor, Collection<Identifier> identifiers)
{
mDecoderType = decoder;
mCallEventType = callEventType;
mChannelDescriptor = channelDescriptor;
mIdentifiers = identifiers;
}
/**
* Legacy call event constructor
*/
@Deprecated //Remove once all decoder states have been updated to new constructor
public CallEvent(DecoderType decoder, CallEventType callEventType, AliasList aliasList, String fromID,
String toID, String details)
{
@@ -53,6 +79,14 @@ public abstract class CallEvent implements Comparable<CallEvent>
mDetails = details;
}
/**
* Identifier collection for this call event
*/
public Collection<Identifier> getIdentifiers()
{
return mIdentifiers;
}
/**
* Indicates if this event is valid. Use this method to mark a previously
* dispatched event as invalid and resend it so that any downstream
@@ -168,7 +202,7 @@ public abstract class CallEvent implements Comparable<CallEvent>
public static String getCSVHeader()
{
return "START_DATE,START_TIME,END_DATE,END_TIME,DECODER,EVENT,FROM,FROM_ALIAS,TO,TO_ALIAS,CHANNEL," +
return "START_DATE,START_TIME,END_DATE,END_TIME,DECODER,EVENT,FROM,FROM_ALIAS,TO,TO_ALIAS,CHANNEL_NUMBER," +
"FREQUENCY,DETAILS";
}
@@ -252,6 +286,7 @@ public abstract class CallEvent implements Comparable<CallEvent>
public enum CallEventType
{
ANNOUNCEMENT("Announcement"),
AUTOMATIC_REGISTRATION_SERVICE("Motorola ARS"),
CALL("Call"),
CALL_ALERT("Call Alert"),
CALL_DETECT("Call Detect"),
@@ -262,6 +297,7 @@ public abstract class CallEvent implements Comparable<CallEvent>
CALL_TIMEOUT("Call Timeout"),
COMMAND("Command"),
DATA_CALL("Data Call"),
DATA_PACKET("Data Packet"),
DEREGISTER("Deregister"),
EMERGENCY("EMERGENCY"),
ENCRYPTED_CALL("Encrypted Call"),
@@ -270,6 +306,7 @@ public abstract class CallEvent implements Comparable<CallEvent>
GROUP_CALL("Group Call"),
ID_ANI("ANI"),
ID_UNIQUE("Unique ID"),
IP_PACKET("IP Packet"),
NOTIFICATION("Notification"),
PAGE("Page"),
PATCH_GROUP_ADD("Patch Group Add"),
@@ -279,10 +316,14 @@ public abstract class CallEvent implements Comparable<CallEvent>
REGISTER("Register"),
REGISTER_ESN("ESN"),
RESPONSE("Response"),
RESPONSE_PACKET("Response Packet"),
SDM("Short Data Message"),
SNDCP_PACKET("SNDCP Packet"),
STATION_ID("Station ID"),
STATUS("Status"),
TCP_PACKET("TCP/IP Packet"),
TELEPHONE_INTERCONNECT("Telephone Interconnect"),
UDP_PACKET("UDP/IP Packet"),
UNIT_TO_UNIT_CALL("Unit To Unit Call"),
UNKNOWN("Unknown"),
INVALID("Invalid");

View File

@@ -1,70 +0,0 @@
/*******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2017 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.event;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.icon.IconManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;
/**
* Custom renderer for JTable cells that contain Alias objects. Renders the
* alias name, and if there is an icon name, attempts to get that icon from
* the settings manager and render it.
*/
public class CallEventAliasCellRenderer extends DefaultTableCellRenderer
{
private static final long serialVersionUID = 1L;
private final static Logger mLog = LoggerFactory.getLogger(CallEventAliasCellRenderer.class);
private IconManager mIconManager;
public CallEventAliasCellRenderer(IconManager iconManager)
{
super();
mIconManager = iconManager;
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if(value instanceof Alias)
{
Alias alias = (Alias)value;
label.setText(alias.getName());
label.setForeground(alias.getDisplayColor());
label.setIcon(mIconManager.getIcon(alias.getIconName(), IconManager.DEFAULT_ICON_SIZE));
}
else
{
label.setText("");
label.setForeground(table.getForeground());
label.setIcon(null);
}
return label;
}
}

View File

@@ -1,220 +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.event;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.sample.Listener;
import javax.swing.table.AbstractTableModel;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
public class CallEventModel extends AbstractTableModel implements Listener<CallEvent>
{
private static final long serialVersionUID = 1L;
private static DecimalFormat mFrequencyFormatter = new DecimalFormat("0.000000");
public static final int TIME = 0;
public static final int EVENT = 1;
public static final int FROM_ID = 2;
public static final int FROM_ALIAS = 3;
public static final int TO_ID = 4;
public static final int TO_ALIAS = 5;
public static final int CHANNEL = 6;
public static final int FREQUENCY = 7;
public static final int DETAILS = 8;
protected int mMaxMessages = 500;
protected List<CallEvent> mEvents = new ArrayList<CallEvent>();
protected String[] mHeaders = new String[]{"Time",
"Event",
"From",
"Alias",
"To",
"Alias",
"Channel",
"Frequency",
"Details"};
private SimpleDateFormat mSDFTime = new SimpleDateFormat("HH:mm:ss");
public CallEventModel()
{
}
public void dispose()
{
mEvents.clear();
}
public void reset()
{
mEvents.clear();
fireTableDataChanged();
}
public int getMaxMessageCount()
{
return mMaxMessages;
}
public void setMaxMessageCount(int count)
{
mMaxMessages = count;
}
/**
* Adds, updates or deletes the event from the model. Producers can send
* the same call event multiple times to indicate that information in the
* event is updated. Producers can also mark the event as invalid and the
* event will be removed from the model.
*/
public void receive(final CallEvent event)
{
if(event.isValid())
{
if(!mEvents.contains(event))
{
mEvents.add(0, event);
fireTableRowsInserted(0, 0);
prune();
}
else
{
int row = mEvents.indexOf(event);
fireTableRowsUpdated(row, row);
}
}
else
{
if(mEvents.contains(event))
{
int row = mEvents.indexOf(event);
mEvents.remove(event);
fireTableRowsDeleted(row, row);
}
}
}
private void prune()
{
while(mEvents.size() > mMaxMessages)
{
int index = mEvents.size() - 1;
mEvents.remove(index);
fireTableRowsDeleted(index, index);
}
}
@Override
public int getRowCount()
{
return mEvents.size();
}
@Override
public int getColumnCount()
{
return mHeaders.length;
}
public String getColumnName(int column)
{
return mHeaders[column];
}
@Override
public Object getValueAt(int rowIndex, int columnIndex)
{
synchronized(mEvents)
{
switch(columnIndex)
{
case TIME:
StringBuilder sb = new StringBuilder();
sb.append(mSDFTime.format(
mEvents.get(rowIndex).getEventStartTime()));
if(mEvents.get(rowIndex).getEventEndTime() != 0)
{
sb.append(" - ");
sb.append(mSDFTime.format(
mEvents.get(rowIndex).getEventEndTime()));
}
else if(mEvents.get(rowIndex)
.getCallEventType() == CallEvent.CallEventType.CALL)
{
sb.append(" - In Progress");
}
return sb.toString();
case EVENT:
return mEvents.get(rowIndex).getCallEventType();
case FROM_ID:
return mEvents.get(rowIndex).getFromID();
case FROM_ALIAS:
return mEvents.get(rowIndex).getFromIDAlias();
case TO_ID:
return mEvents.get(rowIndex).getToID();
case TO_ALIAS:
return mEvents.get(rowIndex).getToIDAlias();
case CHANNEL:
return mEvents.get(rowIndex).getChannel();
case FREQUENCY:
long frequency = mEvents.get(rowIndex).getFrequency();
if(frequency != 0)
{
return mFrequencyFormatter.format((double) frequency / 1E6d);
}
else
{
return null;
}
case DETAILS:
return mEvents.get(rowIndex).getDetails();
}
}
return null;
}
@Override
public Class<?> getColumnClass(int columnIndex)
{
if(columnIndex == FROM_ALIAS || columnIndex == TO_ALIAS)
{
return Alias.class;
}
return super.getColumnClass(columnIndex);
}
}

View File

@@ -1,75 +0,0 @@
/*******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2017 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.event;
import io.github.dsheirer.icon.IconManager;
import io.github.dsheirer.module.ProcessingChain;
import io.github.dsheirer.sample.Listener;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.*;
public class CallEventPanel extends JPanel implements Listener<ProcessingChain>
{
private static final long serialVersionUID = 1L;
private JTable mTable;
private CallEventModel mEmptyCallEventModel = new CallEventModel();
private JScrollPane mEmptyScroller;
private CallEventAliasCellRenderer mRenderer;
/**
* View for call event table
* @param iconManager to display alias icons in table rows
*/
public CallEventPanel(IconManager iconManager)
{
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));
mTable = new JTable(mEmptyCallEventModel);
mTable.setAutoCreateRowSorter(true);
mTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
mRenderer = new CallEventAliasCellRenderer(iconManager);
mEmptyScroller = new JScrollPane(mTable);
add(mEmptyScroller);
}
@Override
public void receive(ProcessingChain processingChain)
{
EventQueue.invokeLater(new Runnable()
{
@Override
public void run()
{
mTable.setModel(processingChain != null ? processingChain.getCallEventModel() : mEmptyCallEventModel);
if(processingChain != null)
{
mTable.getColumnModel().getColumn(CallEventModel.FROM_ALIAS).setCellRenderer(mRenderer);
mTable.getColumnModel().getColumn(CallEventModel.TO_ALIAS).setCellRenderer(mRenderer);
}
}
});
}
}

View File

@@ -0,0 +1,297 @@
/*
* ******************************************************************************
* 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.event;
import io.github.dsheirer.channel.IChannelDescriptor;
import io.github.dsheirer.identifier.IdentifierCollection;
import io.github.dsheirer.protocol.Protocol;
/**
* Decode event implementation. A decode event is a discrete event such as a call or text message
* or radio registration.
*/
public class DecodeEvent implements IDecodeEvent
{
private long mTimeStart;
private long mDuration;
private String mEventDescription;
private IdentifierCollection mIdentifierCollection;
private IChannelDescriptor mChannelDescriptor;
private String mDetails;
private Protocol mProtocol;
public DecodeEvent(long start)
{
mTimeStart = start;
}
/**
* Creates a new decode event builder with the specified start timestamp.
* @param timeStart for the event
* @return builder
*/
public static DecodeEventBuilder builder(long timeStart)
{
return new DecodeEventBuilder(timeStart);
}
/**
* Updates the duration value using the end - start timestamps. Note: this method can be
* invoked multiple times and the duration will be set to the value of the final invocation.
* @param timestamp for end of the event.
*/
public void end(long timestamp)
{
if(timestamp > mTimeStart)
{
mDuration = timestamp - mTimeStart;
}
}
/**
* Updates the current in-progress call with the latest timestamp
*/
public void update(long timestamp)
{
end(timestamp);
}
/**
* Event start in milliseconds
*/
@Override
public long getTimeStart()
{
return mTimeStart;
}
/**
* Event duration in milliseconds
*/
@Override
public long getDuration()
{
return mDuration;
}
/**
* Sets the event duration in milliseconds
*/
public void setDuration(long duration)
{
mDuration = duration;
}
/**
* Event description
*/
@Override
public String getEventDescription()
{
return mEventDescription;
}
/**
* Sets the event description text
*/
public void setEventDescription(String description)
{
mEventDescription = description;
}
/**
* Identifier collection for this event.
*/
@Override
public IdentifierCollection getIdentifierCollection()
{
return mIdentifierCollection;
}
/**
* Sets the identifier collection for this event. Note: identifier collection should contain
* a FrequencyConfigurationIdentifier and optionally an AliasListConfigurationIdentifier so that
* display elements can be properly configured to display the event.
*/
public void setIdentifierCollection(IdentifierCollection identifierCollection)
{
mIdentifierCollection = identifierCollection;
}
/**
* Channel descriptor for the channel
*/
@Override
public IChannelDescriptor getChannelDescriptor()
{
return mChannelDescriptor;
}
/**
* Sets the channel descriptor for the event
*/
public void setChannelDescriptor(IChannelDescriptor channelDescriptor)
{
mChannelDescriptor = channelDescriptor;
}
/**
* Event details text
*/
@Override
public String getDetails()
{
return mDetails;
}
/**
* Sets the event details text
*/
public void setDetails(String details)
{
mDetails = details;
}
/**
* Protocol (ie decoder type) for the event
*/
@Override
public Protocol getProtocol()
{
return mProtocol;
}
/**
* Sets the protocol for the event
*/
public void setProtocol(Protocol protocol)
{
mProtocol = protocol;
}
/**
* Builder pattern for constructing decode events.
*/
public static class DecodeEventBuilder
{
protected long mTimeStart;
protected long mDuration;
protected String mEventDescription;
protected IdentifierCollection mIdentifierCollection;
protected IChannelDescriptor mChannelDescriptor;
protected String mDetails;
protected Protocol mProtocol = Protocol.UNKNOWN;
/**
* Constructs a builder instance with the specified start time in milliseconds
*/
public DecodeEventBuilder(long timeStart)
{
mTimeStart = timeStart;
}
/**
* Sets the duration value
* @param duration in milliseconds
*/
public DecodeEventBuilder duration(long duration)
{
mDuration = duration;
return this;
}
/**
* Sets the duration value using the end - start timestamps
* @param timestamp for end of event
*/
public DecodeEventBuilder end(long timestamp)
{
mDuration = timestamp - mTimeStart;
return this;
}
/**
* Sets the channel descriptor for this event
* @param channelDescriptor
*/
public DecodeEventBuilder channel(IChannelDescriptor channelDescriptor)
{
mChannelDescriptor = channelDescriptor;
return this;
}
/**
* Sets the event description text
* @param description of the event
*/
public DecodeEventBuilder eventDescription(String description)
{
mEventDescription = description;
return this;
}
/**
* Sets the identifier collection.
* @param identifierCollection containing optional identifiers like TO, FROM, frequency and
* alias list configuration name.
*/
public DecodeEventBuilder identifiers(IdentifierCollection identifierCollection)
{
mIdentifierCollection = identifierCollection;
return this;
}
/**
* Sets the details for the event
* @param details
*/
public DecodeEventBuilder details(String details)
{
mDetails = details;
return this;
}
/**
* Sets the protocol for this event
* @param protocol
*/
public DecodeEventBuilder protocol(Protocol protocol)
{
mProtocol = protocol;
return this;
}
/**
* Builds the decode event
*/
public DecodeEvent build()
{
DecodeEvent decodeEvent = new DecodeEvent(mTimeStart);
decodeEvent.setChannelDescriptor(mChannelDescriptor);
decodeEvent.setDetails(mDetails);
decodeEvent.setDuration(mDuration);
decodeEvent.setEventDescription(mEventDescription);
decodeEvent.setIdentifierCollection(mIdentifierCollection);
decodeEvent.setProtocol(mProtocol);
return decodeEvent;
}
}
}

View File

@@ -0,0 +1,222 @@
/*******************************************************************************
* 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.event;
import com.google.common.eventbus.Subscribe;
import io.github.dsheirer.channel.IChannelDescriptor;
import io.github.dsheirer.eventbus.MyEventBus;
import io.github.dsheirer.identifier.IdentifierCollection;
import io.github.dsheirer.preference.PreferenceType;
import io.github.dsheirer.sample.Listener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.table.AbstractTableModel;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class DecodeEventModel extends AbstractTableModel implements Listener<IDecodeEvent>
{
private static final long serialVersionUID = 1L;
private final static Logger mLog = LoggerFactory.getLogger(DecodeEventModel.class);
public static final int COLUMN_TIME = 0;
public static final int COLUMN_DURATION = 1;
public static final int COLUMN_EVENT = 2;
public static final int COLUMN_FROM_ID = 3;
public static final int COLUMN_FROM_ALIAS = 4;
public static final int COLUMN_TO_ID = 5;
public static final int COLUMN_TO_ALIAS = 6;
public static final int COLUMN_CHANNEL = 7;
public static final int COLUMN_FREQUENCY = 8;
public static final int COLUMN_DETAILS = 9;
protected int mMaxMessages = 500;
protected List<IDecodeEvent> mEvents = new ArrayList<>();
protected String[] mHeaders = new String[]{"Time", "Duration", "Event", "From", "Alias", "To", "Alias", "Channel", "Frequency", "Details"};
public DecodeEventModel()
{
MyEventBus.getEventBus().register(this);
}
/**
* Receives preference update notifications via the event bus
* @param preferenceType that was updated
*/
@Subscribe
public void preferenceUpdated(PreferenceType preferenceType)
{
if(preferenceType == PreferenceType.DECODE_EVENT)
{
for(int row = 0; row < mEvents.size(); row++)
{
fireTableCellUpdated(row, COLUMN_TIME);
}
}
else if(preferenceType == PreferenceType.IDENTIFIER)
{
for(int row = 0; row < mEvents.size(); row++)
{
fireTableCellUpdated(row, COLUMN_FROM_ID);
fireTableCellUpdated(row, COLUMN_TO_ID);
}
}
}
public void dispose()
{
MyEventBus.getEventBus().unregister(this);
Iterator<IDecodeEvent> it = mEvents.iterator();
while(it.hasNext())
{
it.remove();
}
}
public void reset()
{
dispose();
fireTableDataChanged();
}
public int getMaxMessageCount()
{
return mMaxMessages;
}
public void setMaxMessageCount(int count)
{
mMaxMessages = count;
}
/**
* Adds, updates or deletes the event from the model. Producers can send
* the same call event multiple times to indicate that information in the
* event is updated. Producers can also mark the event as invalid and the
* event will be removed from the model.
*/
public void receive(final IDecodeEvent event)
{
if(!mEvents.contains(event))
{
mEvents.add(0, event);
fireTableRowsInserted(0, 0);
prune();
}
else
{
int row = mEvents.indexOf(event);
fireTableRowsUpdated(row, row);
}
}
private void prune()
{
while(mEvents.size() > mMaxMessages)
{
int index = mEvents.size() - 1;
mEvents.remove(index);
fireTableRowsDeleted(index, index);
}
}
@Override
public int getRowCount()
{
return mEvents.size();
}
@Override
public int getColumnCount()
{
return mHeaders.length;
}
public String getColumnName(int column)
{
return mHeaders[column];
}
@Override
public Object getValueAt(int rowIndex, int columnIndex)
{
synchronized(mEvents)
{
IDecodeEvent event = mEvents.get(rowIndex);
if(event != null)
{
switch(columnIndex)
{
case COLUMN_TIME:
return event.getTimeStart();
case COLUMN_DURATION:
return event.getDuration();
case COLUMN_EVENT:
return event.getEventDescription();
case COLUMN_FROM_ID:
return event.getIdentifierCollection();
case COLUMN_FROM_ALIAS:
return event.getIdentifierCollection();
case COLUMN_TO_ID:
return event.getIdentifierCollection();
case COLUMN_TO_ALIAS:
return event.getIdentifierCollection();
case COLUMN_CHANNEL:
return event.getChannelDescriptor();
case COLUMN_FREQUENCY:
return event.getChannelDescriptor();
case COLUMN_DETAILS:
return event.getDetails();
}
}
}
return null;
}
@Override
public Class<?> getColumnClass(int columnIndex)
{
switch(columnIndex)
{
case COLUMN_DURATION:
case COLUMN_TIME:
return Long.class;
case COLUMN_DETAILS:
case COLUMN_EVENT:
return String.class;
case COLUMN_FREQUENCY:
case COLUMN_FROM_ALIAS:
case COLUMN_FROM_ID:
case COLUMN_TO_ALIAS:
case COLUMN_TO_ID:
return IdentifierCollection.class;
case COLUMN_CHANNEL:
return IChannelDescriptor.class;
}
return super.getColumnClass(columnIndex);
}
}

View File

@@ -0,0 +1,411 @@
/*
* ******************************************************************************
* 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.event;
import com.google.common.eventbus.Subscribe;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.channel.IChannelDescriptor;
import io.github.dsheirer.eventbus.MyEventBus;
import io.github.dsheirer.icon.IconManager;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.IdentifierCollection;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.module.ProcessingChain;
import io.github.dsheirer.preference.PreferenceType;
import io.github.dsheirer.preference.UserPreferences;
import io.github.dsheirer.sample.Listener;
import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.Color;
import java.awt.Component;
import java.awt.EventQueue;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
public class DecodeEventPanel extends JPanel implements Listener<ProcessingChain>
{
private final static Logger mLog = LoggerFactory.getLogger(DecodeEventPanel.class);
private static final long serialVersionUID = 1L;
private JTable mTable;
private DecodeEventModel mEmptyDecodeEventModel;
private JScrollPane mEmptyScroller;
private IconManager mIconManager;
private AliasModel mAliasModel;
private UserPreferences mUserPreferences;
private TimestampCellRenderer mTimestampCellRenderer;
/**
* View for call event table
* @param iconManager to display alias icons in table rows
*/
public DecodeEventPanel(IconManager iconManager, UserPreferences userPreferences, AliasModel aliasModel)
{
MyEventBus.getEventBus().register(this);
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));
mIconManager = iconManager;
mAliasModel = aliasModel;
mUserPreferences = userPreferences;
mTimestampCellRenderer = new TimestampCellRenderer();
mEmptyDecodeEventModel = new DecodeEventModel();
mTable = new JTable(mEmptyDecodeEventModel);
mTable.setAutoCreateRowSorter(true);
mTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
updateCellRenderers();
mEmptyScroller = new JScrollPane(mTable);
add(mEmptyScroller);
}
/**
* Receives preference update notifications via the event bus
* @param preferenceType that was updated
*/
@Subscribe
public void preferenceUpdated(PreferenceType preferenceType)
{
if(preferenceType == PreferenceType.DECODE_EVENT || preferenceType == PreferenceType.IDENTIFIER)
{
EventQueue.invokeLater(() -> mTimestampCellRenderer.updatePreferences());
}
}
private void updateCellRenderers()
{
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TIME)
.setCellRenderer(mTimestampCellRenderer);
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_DURATION)
.setCellRenderer(new DurationCellRenderer());
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FROM_ID)
.setCellRenderer(new IdentifierCellRenderer(Role.FROM));
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FROM_ALIAS)
.setCellRenderer(new AliasedIdentifierCellRenderer(Role.FROM));
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TO_ID)
.setCellRenderer(new IdentifierCellRenderer(Role.TO));
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TO_ALIAS)
.setCellRenderer(new AliasedIdentifierCellRenderer(Role.TO));
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_CHANNEL)
.setCellRenderer(new ChannelDescriptorCellRenderer());
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FREQUENCY)
.setCellRenderer(new FrequencyCellRenderer());
}
@Override
public void receive(ProcessingChain processingChain)
{
EventQueue.invokeLater(() -> {
mTable.setModel(processingChain != null ? processingChain.getDecodeEventModel() : mEmptyDecodeEventModel);
if(processingChain != null)
{
updateCellRenderers();
}
});
}
/**
* Custom cell renderer for displaying identifiers from an identifier collection
*/
public class IdentifierCellRenderer extends DefaultTableCellRenderer
{
protected Role mRole;
/**
* Constructs an instance of the cell renderer.
*
* @param role of the identifier
*/
public IdentifierCellRenderer(Role role)
{
mRole = role;
setHorizontalAlignment(JLabel.CENTER);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if(value instanceof IdentifierCollection)
{
List<Identifier> identifiers = ((IdentifierCollection)value).getIdentifiers(mRole);
// if(identifiers.size() > 1)
// {
// StringBuilder sb = new StringBuilder();
// sb.append("Multiple Identifiers:\n");
// for(Identifier identifier: identifiers)
// {
// sb.append("ID:").append(identifier.debug()).append("\n");
// }
// mLog.debug(sb.toString());
// }
label.setText(format(identifiers));
}
else
{
label.setText(null);
}
return label;
}
/**
* Formats a list of identifiers as a comma separated list of values
* @param identifiers to format
* @return formatted list or null
*/
protected String format(List<Identifier> identifiers)
{
if(identifiers == null || identifiers.isEmpty())
{
return null;
}
StringBuilder sb = new StringBuilder();
for(Identifier identifier: identifiers)
{
if(sb.length() > 0)
{
sb.append(",");
}
sb.append(mUserPreferences.getTalkgroupFormatPreference().format(identifier));
}
return sb.toString();
}
}
/**
* Cell renderer for identifier aliases
*/
public class AliasedIdentifierCellRenderer extends DefaultTableCellRenderer
{
private Role mRole;
/**
* Constructs an instance of the cell renderer.
*
* @param role of the identifier
*/
public AliasedIdentifierCellRenderer(Role role)
{
mRole = role;
setHorizontalAlignment(JLabel.CENTER);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
Color color = mTable.getForeground();
ImageIcon icon = null;
String text = null;
if(value instanceof IdentifierCollection)
{
IdentifierCollection identifierCollection = (IdentifierCollection)value;
List<Identifier> identifiers = identifierCollection.getIdentifiers(mRole);
if(identifiers != null && !identifiers.isEmpty())
{
AliasList aliasList = mAliasModel.getAliasList(identifierCollection);
if(aliasList != null)
{
StringBuilder sb = new StringBuilder();
for(Identifier identifier: identifiers)
{
Alias alias = aliasList.getAlias(identifier);
if(alias != null)
{
if(sb.length() > 0)
{
sb.append(",");
}
sb.append(alias.getName());
color = alias.getDisplayColor();
icon = mIconManager.getIcon(alias.getIconName(), IconManager.DEFAULT_ICON_SIZE);
}
}
text = sb.toString();
}
}
}
label.setText(text);
label.setForeground(color);
label.setIcon(icon);
return label;
}
}
public class TimestampCellRenderer extends DefaultTableCellRenderer
{
private SimpleDateFormat mTimestampFormatter;
public TimestampCellRenderer()
{
setHorizontalAlignment(JLabel.CENTER);
updatePreferences();
}
public void updatePreferences()
{
mTimestampFormatter = mUserPreferences.getDecodeEventPreference().getTimestampFormat().getFormatter();
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if(value instanceof Long)
{
label.setText(mTimestampFormatter.format(new Date((long)value)));
}
else
{
label.setText(null);
}
return label;
}
}
public class DurationCellRenderer extends DefaultTableCellRenderer
{
private DecimalFormat mDecimalFormat = new DecimalFormat("0.0");
public DurationCellRenderer()
{
setHorizontalAlignment(JLabel.CENTER);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
String formatted = null;
if(value instanceof Long)
{
long duration = (long)value;
if(duration > 0)
{
formatted = mDecimalFormat.format((double)duration / 1e3d);
}
}
label.setText(formatted);
return label;
}
}
/**
* Frequency value cell renderer
*/
public class FrequencyCellRenderer extends DefaultTableCellRenderer
{
private DecimalFormat mFrequencyFormatter = new DecimalFormat("0.00000 MHz");
public FrequencyCellRenderer()
{
setHorizontalAlignment(JLabel.CENTER);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
String formatted = null;
if(value instanceof IChannelDescriptor)
{
IChannelDescriptor channelDescriptor = (IChannelDescriptor)value;
long frequency = channelDescriptor.getDownlinkFrequency();
if(frequency > 0)
{
formatted = mFrequencyFormatter.format(frequency / 1e6d);
}
}
label.setText(formatted);
return label;
}
}
/**
* Channel descriptor value cell renderer
*/
public class ChannelDescriptorCellRenderer extends DefaultTableCellRenderer
{
public ChannelDescriptorCellRenderer()
{
setHorizontalAlignment(JLabel.CENTER);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if(value instanceof IChannelDescriptor)
{
label.setText(value.toString());
}
else
{
label.setText(null);
}
return label;
}
}
}

View File

@@ -0,0 +1,85 @@
/*
* ******************************************************************************
* 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.event;
public enum DecodeEventType
{
ANNOUNCEMENT("Announcement"),
AUTOMATIC_REGISTRATION_SERVICE("Motorola ARS"),
CALL("Call"),
CALL_ENCRYPTED("Encrypted Call"),
CALL_GROUP("Group Call"),
CALL_GROUP_ENCRYPTED("Encrypted Group Call"),
CALL_PATCH_GROUP("Patch Call"),
CALL_PATCH_GROUP_ENCRYPTED("Encrypted Patch Call"),
CALL_ALERT("Call Alert"),
CALL_DETECT("Call Detect"),
CALL_DO_NOT_MONITOR("Call-Do Not Monitor"),
CALL_END("Call End"),
CALL_INTERCONNECT("Telephone Call"),
CALL_INTERCONNECT_ENCRYPTED("Encrypted Telephone Call"),
CALL_UNIQUE_ID("UID Call"),
CALL_UNIT_TO_UNIT("Unit To Unit Call"),
CALL_UNIT_TO_UNIT_ENCRYPTED("Encrypted Unit To Unit Call"),
CALL_NO_TUNER("Call - No Tuner"),
CALL_TIMEOUT("Call Timeout"),
COMMAND("Command"),
DATA_CALL("Data Call"),
DATA_CALL_ENCRYPTED("Encrypted Data Call"),
DATA_PACKET("Data Packet"),
DEREGISTER("Deregister"),
EMERGENCY("EMERGENCY"),
FUNCTION("Function"),
GPS("GPS"),
ID_ANI("ANI"),
ID_UNIQUE("Unique ID"),
IP_PACKET("IP Packet"),
NOTIFICATION("Notification"),
PAGE("Page"),
QUERY("Query"),
REGISTER("Register"),
REGISTER_ESN("ESN"),
REQUEST("Request"),
RESPONSE("Response"),
RESPONSE_PACKET("Response Packet"),
SDM("Short Data Message"),
STATION_ID("Station ID"),
STATUS("Status"),
UDP_PACKET("UDP/IP Packet"),
UNKNOWN("Unknown");
private String mLabel;
DecodeEventType(String label)
{
mLabel = label;
}
public String getLabel()
{
return mLabel;
}
public String toString()
{
return mLabel;
}
}

View File

@@ -1,8 +0,0 @@
package io.github.dsheirer.module.decode.event;
import io.github.dsheirer.sample.Listener;
public interface ICallEventListener
{
public Listener<CallEvent> getCallEventListener();
}

View File

@@ -1,9 +0,0 @@
package io.github.dsheirer.module.decode.event;
import io.github.dsheirer.sample.Listener;
public interface ICallEventProvider
{
public void addCallEventListener( Listener<CallEvent> listener );
public void removeCallEventListener( Listener<CallEvent> listener );
}

View File

@@ -0,0 +1,74 @@
/*
* ******************************************************************************
* 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.event;
import io.github.dsheirer.channel.IChannelDescriptor;
import io.github.dsheirer.identifier.IdentifierCollection;
import io.github.dsheirer.protocol.Protocol;
/**
* Decode event interface
*/
public interface IDecodeEvent
{
/**
* Event start time
*
* @return timestamp in milliseconds
*/
long getTimeStart();
/**
* Event duration.
*
* @return event duration in milliseconds or 0 if there is no duration
*/
long getDuration();
/**
* A description of the event or event type
*/
String getEventDescription();
/**
* Collection of identifiers associated with the event. This collection should contain a
* Role.FROM and a Role.TO identifier, a Decoder Type identifier, and (optionally) an Alias List
* Configuration identifier.
*/
IdentifierCollection getIdentifierCollection();
/**
* Channel descriptor for the channel where the event occurred
*
* @return descriptor or null
*/
IChannelDescriptor getChannelDescriptor();
/**
* Optional Details about the event
*/
String getDetails();
/**
* Protocol for the decoder that produced the event
*/
Protocol getProtocol();
}

View File

@@ -0,0 +1,28 @@
/*
* ******************************************************************************
* 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.event;
import io.github.dsheirer.sample.Listener;
public interface IDecodeEventListener
{
Listener<IDecodeEvent> getDecodeEventListener();
}

View File

@@ -0,0 +1,9 @@
package io.github.dsheirer.module.decode.event;
import io.github.dsheirer.sample.Listener;
public interface IDecodeEventProvider
{
void addDecodeEventListener(Listener<IDecodeEvent> listener );
void removeDecodeEventListener(Listener<IDecodeEvent> listener );
}

View File

@@ -1,193 +1,180 @@
/*******************************************************************************
* 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.event;
import io.github.dsheirer.filter.FilterSet;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.sample.Listener;
import javax.swing.table.AbstractTableModel;
import java.awt.*;
import java.awt.EventQueue;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
public class MessageActivityModel extends AbstractTableModel
implements Listener<Message>
public class MessageActivityModel extends AbstractTableModel implements Listener<IMessage>
{
private static final long serialVersionUID = 1L;
private static final int TIME = 0;
private static final int PROTOCOL = 1;
private static final int ERROR_STATUS = 2;
private static final int MESSAGE = 3;
private static final int MESSAGE_BITS = 4;
private static final int MESSAGE = 2;
protected int mMaxMessages = 500;
protected LinkedList<Message> mMessages = new LinkedList<Message>();
protected int mMaxMessages = 500;
protected LinkedList<MessageItem> mMessageItems = new LinkedList<>();
protected int[] mColumnWidths = {20, 20, 500};
protected String[] mHeaders = new String[]{"Time", "Protocol", "Message"};
protected int[] mColumnWidths = { 110, 110, 110, -1, -1 };
private SimpleDateFormat mSDFTime = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
protected String[] mHeaders = new String[] { "Time",
"Protocol",
"Error Check",
"Message",
"Binary" };
private FilterSet<IMessage> mMessageFilter;
private SimpleDateFormat mSDFTime = new SimpleDateFormat( "HH:mm:ss" );
private boolean mNewMessagesFirst = true;
private FilterSet<Message> mMessageFilter;
public MessageActivityModel( FilterSet<Message> messageFilter )
{
mMessageFilter = messageFilter;
}
public MessageActivityModel()
{
}
/**
* Clears all messages from history
*/
public void clear()
{
EventQueue.invokeLater( new Runnable()
{
@Override
public MessageActivityModel(FilterSet<IMessage> messageFilter)
{
mMessageFilter = messageFilter;
}
public MessageActivityModel()
{
}
/**
* Clears all messages from history
*/
public void clear()
{
EventQueue.invokeLater(new Runnable()
{
@Override
public void run()
{
int messageCount = mMessages.size();
mMessages.clear();
int messageCount = mMessageItems.size();
fireTableRowsDeleted( 0, messageCount - 1 );
mMessageItems.clear();
fireTableRowsDeleted(0, messageCount - 1);
}
});
}
public FilterSet<Message> getMessageFilter()
{
return mMessageFilter;
}
public void dispose()
{
mMessages.clear();
}
public int[] getColumnWidths()
{
return mColumnWidths;
}
public void setColumnWidths( int[] widths )
{
if( widths.length != 5 )
{
throw new IllegalArgumentException( "MessageActivityModel - "
+ "column widths array should have 5 elements" );
}
else
{
mColumnWidths = widths;
}
}
public int getMaxMessageCount()
{
return mMaxMessages;
}
});
}
public void setMaxMessageCount( int count )
{
mMaxMessages = count;
}
public void receive( final Message message )
{
if( message.isValid() && mMessageFilter.passes( message ) )
{
EventQueue.invokeLater( new Runnable()
{
@Override
public void run()
{
mMessages.addFirst( message );
public FilterSet<IMessage> getMessageFilter()
{
return mMessageFilter;
}
MessageActivityModel.this.fireTableRowsInserted( 0, 0 );
public void dispose()
{
mMessageItems.clear();
}
prune();
}
} );
}
}
private void prune()
{
while( mMessages.size() > mMaxMessages )
{
mMessages.removeLast();
super.fireTableRowsDeleted( mMessages.size() - 1, mMessages.size() - 1 );
}
}
public int[] getColumnWidths()
{
return mColumnWidths;
}
@Override
public void setColumnWidths(int[] widths)
{
if(widths.length != 3)
{
throw new IllegalArgumentException("MessageActivityModel - column widths array should have 3 elements");
}
else
{
mColumnWidths = widths;
}
}
public int getMaxMessageCount()
{
return mMaxMessages;
}
public void setMaxMessageCount(int count)
{
mMaxMessages = count;
}
public void receive(final IMessage message)
{
if(mMessageFilter.passes(message))
{
final MessageItem messageItem = new MessageItem(message);
EventQueue.invokeLater(new Runnable()
{
@Override
public void run()
{
mMessageItems.addFirst(messageItem);
MessageActivityModel.this.fireTableRowsInserted(0, 0);
prune();
}
});
}
}
private void prune()
{
while(mMessageItems.size() > mMaxMessages)
{
MessageItem removed = mMessageItems.removeLast();
removed.dispose();
super.fireTableRowsDeleted(mMessageItems.size() - 1, mMessageItems.size() - 1);
}
}
@Override
public int getRowCount()
{
return mMessages.size();
return mMessageItems.size();
}
@Override
@Override
public int getColumnCount()
{
return mHeaders.length;
return mHeaders.length;
}
public String getColumnName( int column )
{
return mHeaders[ column ];
}
@Override
public Object getValueAt( int rowIndex, int columnIndex )
public String getColumnName(int column)
{
if( 0 <= rowIndex && rowIndex < mMessages.size() )
{
Message message = mMessages.get( rowIndex );
switch( columnIndex )
{
case TIME:
return mSDFTime.format( new Date( message.getTimeReceived() ) );
case PROTOCOL:
return message.getProtocol();
case ERROR_STATUS:
return message.getErrorStatus();
case MESSAGE:
return message.getMessage();
case MESSAGE_BITS:
return message.getBinaryMessage();
}
}
return null;
return mHeaders[column];
}
@Override
public Object getValueAt(int rowIndex, int columnIndex)
{
if(0 <= rowIndex && rowIndex < mMessageItems.size())
{
MessageItem messageItem = mMessageItems.get(rowIndex);
switch(columnIndex)
{
case TIME:
return messageItem.getTimestamp(mSDFTime);
case PROTOCOL:
return messageItem.getProtocol();
case MESSAGE:
return messageItem.getText();
default:
break;
}
}
return null;
}
}

View File

@@ -23,7 +23,7 @@ import com.jidesoft.swing.JideSplitButton;
import io.github.dsheirer.controller.channel.ChannelProcessingManager;
import io.github.dsheirer.filter.FilterEditorPanel;
import io.github.dsheirer.filter.FilterSet;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.module.ProcessingChain;
import io.github.dsheirer.sample.Listener;
import net.miginfocom.swing.MigLayout;
@@ -81,6 +81,10 @@ public class MessageActivityPanel extends JPanel implements Listener<ProcessingC
{
mTable.setModel(processingChain != null ? processingChain.getMessageActivityModel() : EMPTY_MODEL);
mTable.getColumnModel().getColumn(0).setPreferredWidth(18);
mTable.getColumnModel().getColumn(1).setPreferredWidth(15);
mTable.getColumnModel().getColumn(2).setPreferredWidth(600);
if(processingChain != null)
{
mManagementPanel.enableButtons();
@@ -170,13 +174,13 @@ public class MessageActivityPanel extends JPanel implements Listener<ProcessingC
}
});
slider.setValue(((MessageActivityModel)mTable.getModel()).getMaxMessageCount());
slider.setValue(((MessageActivityModel) mTable.getModel()).getMaxMessageCount());
slider.addChangeListener(new ChangeListener()
{
@Override
public void stateChanged(ChangeEvent arg0)
{
((MessageActivityModel)mTable.getModel()).setMaxMessageCount(slider.getValue());
((MessageActivityModel) mTable.getModel()).setMaxMessageCount(slider.getValue());
}
});
@@ -184,13 +188,13 @@ public class MessageActivityPanel extends JPanel implements Listener<ProcessingC
add(historyPanel);
/* Clear messages */
/* Clear messages */
addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
((MessageActivityModel)mTable.getModel()).clear();
((MessageActivityModel) mTable.getModel()).clear();
}
});
}
@@ -216,12 +220,13 @@ public class MessageActivityPanel extends JPanel implements Listener<ProcessingC
editor.setLocationRelativeTo(MessageFilterButton.this);
editor.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
editor.setLayout(new MigLayout("", "[grow,fill]",
"[grow,fill][][]"));
"[grow,fill][][]"));
@SuppressWarnings("unchecked")
FilterSet<Message> filter = (FilterSet<Message>) ((MessageActivityModel)mTable.getModel()).getMessageFilter();
FilterSet<IMessage> filter = (FilterSet<IMessage>) ((MessageActivityModel) mTable.getModel())
.getMessageFilter();
FilterEditorPanel<Message> panel = new FilterEditorPanel<Message>(filter);
FilterEditorPanel<IMessage> panel = new FilterEditorPanel<>(filter);
JScrollPane scroller = new JScrollPane(panel);
scroller.setViewportView(panel);

View File

@@ -0,0 +1,97 @@
/*
* ******************************************************************************
* 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.event;
import io.github.dsheirer.message.IMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Simple message carrier class that persists activity model column values so that they do not need
* to be recalculated with each row update.
*/
public class MessageItem
{
private final static Logger mLog = LoggerFactory.getLogger(MessageItem.class);
private IMessage mMessage;
private String mTimestamp;
private String mProtocol;
private String mText;
public MessageItem(IMessage message)
{
mMessage = message;
}
public IMessage getMessage()
{
return mMessage;
}
public void dispose()
{
mMessage = null;
mTimestamp = null;
mProtocol = null;
mText = null;
}
public String getTimestamp(SimpleDateFormat simpleDateFormat)
{
if(mTimestamp == null)
{
mTimestamp = simpleDateFormat.format(new Date(getMessage().getTimestamp()));
}
return mTimestamp;
}
public String getText()
{
if(mText == null)
{
try
{
mText = getMessage().toString();
}
catch(Throwable t)
{
mLog.error("Error accessing message toString() method - protocol [" + getProtocol() + "]", t);
mText = "MESSAGE ITEM ENCOUNTERED PARSING ERROR";
}
}
return mText;
}
public String getProtocol()
{
if(mProtocol == null)
{
mProtocol = getMessage().getProtocol().toString();
}
return mProtocol;
}
}

View File

@@ -0,0 +1,239 @@
/*
* ******************************************************************************
* 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.event;
import io.github.dsheirer.channel.IChannelDescriptor;
import io.github.dsheirer.identifier.IdentifierCollection;
import io.github.dsheirer.protocol.Protocol;
import org.jdesktop.swingx.mapviewer.GeoPosition;
public class PlottableDecodeEvent extends DecodeEvent
{
private GeoPosition mGeoPosition;
private double mHeading;
private double mSpeed;
public PlottableDecodeEvent(long start)
{
super(start);
}
/**
* Creates a new decode event builder with the specified start timestamp.
* @param timeStart for the event
* @return builder
*/
public static PlottableDecodeEventBuilder plottableBuilder(long timeStart)
{
return new PlottableDecodeEventBuilder(timeStart);
}
/**
* Sets the location for the event
*/
public void setLocation(GeoPosition geoPosition)
{
mGeoPosition = geoPosition;
}
/**
* Location of the event
*/
public GeoPosition getLocation()
{
return mGeoPosition;
}
/**
* Sets the heading for the mobile plottable event
* @param heading
*/
public void setHeading(double heading)
{
mHeading = heading;
}
/**
* Heading of the mobile plottable event
*/
public double getHeading()
{
return mHeading;
}
/**
* Sets the speed of the mobile plottable event in kph
*/
public void setSpeed(double speed)
{
mSpeed = speed;
}
/**
* Speed of the mobile plottable event in kph
*/
public double getSpeed()
{
return mSpeed;
}
/**
* Builder pattern for constructing decode events.
*/
public static class PlottableDecodeEventBuilder
{
private long mTimeStart;
private long mDuration;
private String mEventDescription;
private IdentifierCollection mIdentifierCollection;
private IChannelDescriptor mChannelDescriptor;
private String mDetails;
private Protocol mProtocol = Protocol.UNKNOWN;
private GeoPosition mGeoPosition;
private double mHeading;
private double mSpeed;
/**
* Constructs a builder instance with the specified start time in milliseconds
*/
public PlottableDecodeEventBuilder(long timeStart)
{
mTimeStart = timeStart;
}
/**
* Sets the duration value
* @param duration in milliseconds
*/
public PlottableDecodeEventBuilder duration(long duration)
{
mDuration = duration;
return this;
}
/**
* Sets the duration value using the end - start timestamps
* @param timestamp for end of event
*/
public PlottableDecodeEventBuilder end(long timestamp)
{
mDuration = timestamp - mTimeStart;
return this;
}
/**
* Sets the channel descriptor for this event
* @param channelDescriptor
*/
public PlottableDecodeEventBuilder channel(IChannelDescriptor channelDescriptor)
{
mChannelDescriptor = channelDescriptor;
return this;
}
/**
* Sets the event description text
* @param description of the event
*/
public PlottableDecodeEventBuilder eventDescription(String description)
{
mEventDescription = description;
return this;
}
/**
* Sets the identifier collection.
* @param identifierCollection containing optional identifiers like TO, FROM, frequency and
* alias list configuration name.
*/
public PlottableDecodeEventBuilder identifiers(IdentifierCollection identifierCollection)
{
mIdentifierCollection = identifierCollection;
return this;
}
/**
* Sets the details for the event
* @param details
*/
public PlottableDecodeEventBuilder details(String details)
{
mDetails = details;
return this;
}
/**
* Sets the protocol for this event
* @param protocol
*/
public PlottableDecodeEventBuilder protocol(Protocol protocol)
{
mProtocol = protocol;
return this;
}
/**
* Sets the location for the plottable event
*/
public PlottableDecodeEventBuilder location(GeoPosition geoPosition)
{
mGeoPosition = geoPosition;
return this;
}
/**
* Sets the speed for the plottable event in kph
*/
public PlottableDecodeEventBuilder speed(double speed)
{
mSpeed = speed;
return this;
}
/**
* Sets the heading for the plottable event in degrees relative to true North
*/
public PlottableDecodeEventBuilder heading(double heading)
{
mHeading = heading;
return this;
}
/**
* Builds the decode event
*/
public PlottableDecodeEvent build()
{
PlottableDecodeEvent decodeEvent = new PlottableDecodeEvent(mTimeStart);
decodeEvent.setChannelDescriptor(mChannelDescriptor);
decodeEvent.setDetails(mDetails);
decodeEvent.setDuration(mDuration);
decodeEvent.setEventDescription(mEventDescription);
decodeEvent.setIdentifierCollection(mIdentifierCollection);
decodeEvent.setProtocol(mProtocol);
decodeEvent.setLocation(mGeoPosition);
decodeEvent.setHeading(mHeading);
decodeEvent.setSpeed(mSpeed);
return decodeEvent;
}
}
}

View File

@@ -1,201 +0,0 @@
/*******************************************************************************
* 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/>
******************************************************************************/
package io.github.dsheirer.module.decode.fleetsync1;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.map.Plottable;
import io.github.dsheirer.message.Message;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class Fleetsync1Message extends Message
{
private static SimpleDateFormat mSDF = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
private BinaryMessage mMessage;
public Fleetsync1Message( BinaryMessage message )
{
mMessage = message;
}
public boolean isValid()
{
return true;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append( mSDF.format( new Date( System.currentTimeMillis() ) ) );
sb.append( " " );
sb.append( "FS1 [" + mMessage.toString() + "]" );
return sb.toString();
}
/**
* Pads spaces onto the end of the value to make it 'places' long
*/
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();
}
/**
* Pads an integer value with additional zeroes to make it decimalPlaces long
*/
public String format( int number, int decimalPlaces )
{
StringBuilder sb = new StringBuilder();
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;
}
@Override
public String getBinaryMessage()
{
return mMessage.toString();
}
@Override
public String getProtocol()
{
// TODO Auto-generated method stub
return null;
}
@Override
public String getEventType()
{
// TODO Auto-generated method stub
return null;
}
@Override
public String getFromID()
{
// TODO Auto-generated method stub
return null;
}
@Override
public Alias getFromIDAlias()
{
// TODO Auto-generated method stub
return null;
}
@Override
public String getToID()
{
// TODO Auto-generated method stub
return null;
}
@Override
public Alias getToIDAlias()
{
// TODO Auto-generated method stub
return null;
}
@Override
public String getMessage()
{
// TODO Auto-generated method stub
return null;
}
@Override
public String getErrorStatus()
{
// TODO Auto-generated method stub
return null;
}
@Override
public Plottable getPlottable()
{
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;
}
}

View File

@@ -1,51 +0,0 @@
/*******************************************************************************
* 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/>
******************************************************************************/
package io.github.dsheirer.module.decode.fleetsync1;
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.sample.Broadcaster;
import io.github.dsheirer.sample.Listener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Fleetsync1MessageProcessor implements Listener<BinaryMessage>
{
private final static Logger mLog =
LoggerFactory.getLogger( Fleetsync1MessageProcessor.class );
private Broadcaster<Message> mBroadcaster = new Broadcaster<Message>();
@Override
public void receive( BinaryMessage buffer )
{
Fleetsync1Message message = new Fleetsync1Message( buffer );
mBroadcaster.receive( message );
}
public void addMessageListener( Listener<Message> listener )
{
mBroadcaster.addListener( listener );
}
public void removeMessageListener( Listener<Message> listener )
{
mBroadcaster.removeListener( listener );
}
}

View File

@@ -1,23 +1,24 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014,2015 Dennis Sheirer
/*
* ******************************************************************************
* 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.fleetsync2;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.bits.MessageFramer;
import io.github.dsheirer.bits.SyncPattern;
import io.github.dsheirer.dsp.afsk.AFSK1200Decoder;
@@ -36,34 +37,32 @@ public class Fleetsync2Decoder extends AbstractAFSKDecoder
/**
* Constructs a decoder for Fleetsync II protocol
*
* @param afsk1200Decoder to use for decoding the symbols
* @param aliasList to assign aliases to decoded values
*/
protected Fleetsync2Decoder(AFSK1200Decoder afsk1200Decoder, AliasList aliasList)
protected Fleetsync2Decoder(AFSK1200Decoder afsk1200Decoder)
{
super(afsk1200Decoder);
init(aliasList);
init();
}
/**
* Constructs a decoder for Fleetsync II protocol
* @param aliasList to assign aliases to decoded values
*/
public Fleetsync2Decoder(AliasList aliasList)
public Fleetsync2Decoder()
{
super(AFSK1200Decoder.Output.NORMAL);
init(aliasList);
init();
}
/**
* Initializes the decoding chain.
* @param aliasList to assign to the message processor
*/
private void init(AliasList aliasList)
private void init()
{
mMessageFramer = new MessageFramer(SyncPattern.FLEETSYNC2.getPattern(), MESSAGE_LENGTH);
getDecoder().setSymbolProcessor(mMessageFramer);
mMessageProcessor = new Fleetsync2MessageProcessor(aliasList);
mMessageProcessor = new Fleetsync2MessageProcessor();
mMessageFramer.addMessageListener(mMessageProcessor);
mMessageProcessor.setMessageListener(getMessageListener());
}

View File

@@ -29,7 +29,7 @@ public class Fleetsync2DecoderInstrumented extends Fleetsync2Decoder implements
public Fleetsync2DecoderInstrumented()
{
super(new AFSK1200DecoderInstrumented(false), null);
super(new AFSK1200DecoderInstrumented(false));
}
@Override

View File

@@ -18,42 +18,30 @@
******************************************************************************/
package io.github.dsheirer.module.decode.fleetsync2;
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.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.event.DecodeEventType;
import io.github.dsheirer.module.decode.event.PlottableDecodeEvent;
import io.github.dsheirer.module.decode.fleetsync2.identifier.FleetsyncIdentifier;
import io.github.dsheirer.module.decode.fleetsync2.message.Fleetsync2Message;
import io.github.dsheirer.protocol.Protocol;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
public class Fleetsync2DecoderState extends DecoderState
{
private TreeSet<String> mIdents = new TreeSet<String>();
private TreeSet<String> mEmergencyIdents = new TreeSet<String>();
private Set<FleetsyncIdentifier> mIdents = new TreeSet<>();
private AliasedStringAttributeMonitor mFromAttribute;
private AliasedStringAttributeMonitor mToAttribute;
private String mMessage;
private String mMessageType;
private long mFrequency;
public Fleetsync2DecoderState(AliasList aliasList)
public Fleetsync2DecoderState()
{
super(aliasList);
mFromAttribute = new AliasedStringAttributeMonitor(Attribute.SECONDARY_ADDRESS_FROM,
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.FLEETSYNC);
mToAttribute = new AliasedStringAttributeMonitor(Attribute.SECONDARY_ADDRESS_TO,
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.FLEETSYNC);
super();
}
@Override
@@ -62,12 +50,6 @@ public class Fleetsync2DecoderState extends DecoderState
return DecoderType.FLEETSYNC2;
}
@Override
public void dispose()
{
super.dispose();
}
/**
* Resets the overall decoder state and clears any accumulated event details
*/
@@ -75,21 +57,16 @@ public class Fleetsync2DecoderState extends DecoderState
public void reset()
{
mIdents.clear();
mEmergencyIdents.clear();
resetState();
}
@Override
public void start()
{
}
@Override
public void stop()
{
}
@Override
@@ -98,110 +75,60 @@ public class Fleetsync2DecoderState extends DecoderState
}
/**
* Resets this decoder state
*/
public void resetState()
{
mFromAttribute.reset();
mToAttribute.reset();
mMessage = null;
mMessageType = null;
}
@Override
public void receive(Message message)
public void receive(IMessage message)
{
if(message instanceof FleetsyncMessage)
if(message.isValid() && message instanceof Fleetsync2Message)
{
FleetsyncMessage fleetsync = (FleetsyncMessage) message;
Fleetsync2Message fleetsync = (Fleetsync2Message)message;
if(fleetsync.isValid())
getIdentifierCollection().update(fleetsync.getIdentifiers());
mIdents.add(fleetsync.getFromIdentifier());
mIdents.add(fleetsync.getToIdentifier());
switch(fleetsync.getMessageType())
{
State state = State.CALL;
case ANI:
case EMERGENCY:
case LONE_WORKER_EMERGENCY:
DecodeEvent aniEvent = DecodeEvent.builder(fleetsync.getTimestamp())
.channel(getCurrentChannel())
.eventDescription(fleetsync.getMessageType().toString())
.details(fleetsync.toString())
.identifiers(getIdentifierCollection().copyOf())
.build();
mFromAttribute.process(fleetsync.getFromID());
mIdents.add(fleetsync.getFromID());
FleetsyncMessageType type = fleetsync.getMessageType();
if(type != FleetsyncMessageType.ANI)
{
mToAttribute.process(fleetsync.getToID());
mIdents.add(fleetsync.getToID());
}
setMessageType(type.getLabel());
switch(type)
{
case GPS:
setMessage(fleetsync.getGPSLocation());
state = State.DATA;
break;
case STATUS:
StringBuilder sb = new StringBuilder();
sb.append(fleetsync.getStatus());
Alias status = fleetsync.getStatusAlias();
if(status != null)
{
sb.append("/");
sb.append(status.getName());
}
setMessage(sb.toString());
state = State.DATA;
break;
case EMERGENCY:
case LONE_WORKER_EMERGENCY:
mEmergencyIdents.add(fleetsync.getFromID());
state = State.DATA;
break;
default:
break;
}
FleetsyncCallEvent fsCallEvent =
FleetsyncCallEvent.getFleetsync2Event(fleetsync, mFrequency);
fsCallEvent.setAliasList(getAliasList());
broadcast(fsCallEvent);
/* Broadcast decode event so that the channel state will
* kick in and reset everything after a short delay */
broadcast(new DecoderStateEvent(this, Event.DECODE, state));
broadcast(aniEvent);
broadcast(new DecoderStateEvent(this, DecoderStateEvent.Event.DECODE, State.CALL));
break;
case ACKNOWLEDGE:
case PAGING:
case STATUS:
case UNKNOWN:
DecodeEvent statusEvent = DecodeEvent.builder(fleetsync.getTimestamp())
.channel(getCurrentChannel())
.eventDescription(fleetsync.getMessageType().toString())
.details(fleetsync.toString())
.identifiers(getIdentifierCollection().copyOf())
.build();
broadcast(statusEvent);
broadcast(new DecoderStateEvent(this, DecoderStateEvent.Event.DECODE, State.DATA));
break;
case GPS:
PlottableDecodeEvent plottableDecodeEvent = PlottableDecodeEvent.plottableBuilder(fleetsync.getTimestamp())
.channel(getCurrentChannel())
.eventDescription(DecodeEventType.GPS.toString())
.details(fleetsync.toString())
.identifiers(getIdentifierCollection().copyOf())
.protocol(Protocol.FLEETSYNC)
.build();
broadcast(plottableDecodeEvent);
broadcast(new DecoderStateEvent(this, DecoderStateEvent.Event.DECODE, State.DATA));
break;
}
}
}
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 "Fleetsync " + mMessageType;
}
public void setMessageType(String type)
{
if(!StringUtils.isEqual(mMessageType, type))
{
mMessageType = type;
broadcast(new AttributeChangeRequest<String>(Attribute.MESSAGE_TYPE, getMessageType()));
getIdentifierCollection().remove(IdentifierClass.USER);
}
}
@@ -214,10 +141,7 @@ public class Fleetsync2DecoderState extends DecoderState
switch(event.getEvent())
{
case RESET:
resetState();
break;
case SOURCE_FREQUENCY:
mFrequency = event.getFrequency();
reset();
break;
default:
break;
@@ -239,80 +163,14 @@ public class Fleetsync2DecoderState extends DecoderState
}
else
{
Iterator<String> it = mIdents.iterator();
Iterator<FleetsyncIdentifier> it = mIdents.iterator();
while(it.hasNext())
{
String ident = it.next();
sb.append(" ");
sb.append(formatIdent(ident));
if(hasAliasList())
{
Alias alias = getAliasList().getFleetsyncAlias(ident);
if(alias != null)
{
sb.append(" ");
sb.append(alias.getName());
}
}
sb.append("\n");
}
}
sb.append("\nFleetsync Emergency Activations\n");
if(mEmergencyIdents.isEmpty())
{
sb.append(" None\n");
}
else
{
Iterator<String> it = mEmergencyIdents.iterator();
while(it.hasNext())
{
String ident = it.next();
sb.append(" ");
sb.append(formatIdent(ident));
if(hasAliasList())
{
Alias alias = getAliasList().getFleetsyncAlias(ident);
if(alias != null)
{
sb.append(" ");
sb.append(alias.getName());
}
sb.append("\n");
}
sb.append(" ").append(it.next().formatted()).append("\n");
}
}
return sb.toString();
}
public static String formatIdent(String ident)
{
StringBuilder sb = new StringBuilder();
if(ident.length() == 7)
{
sb.append(ident.substring(0, 3));
sb.append("-");
sb.append(ident.substring(3, 7));
return sb.toString();
}
else
{
return ident;
}
}
}

View File

@@ -1,62 +1,97 @@
/*******************************************************************************
* 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.fleetsync2;
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.module.decode.fleetsync2.message.AutomaticNumberIdentification;
import io.github.dsheirer.module.decode.fleetsync2.message.Fleetsync2Message;
import io.github.dsheirer.module.decode.fleetsync2.message.LocationReport;
import io.github.dsheirer.module.decode.fleetsync2.message.Status;
import io.github.dsheirer.sample.Listener;
public class Fleetsync2MessageProcessor implements Listener<BinaryMessage>
/**
* Fleetsync message processor converts binary messages into IMessage implementations.
*/
public class Fleetsync2MessageProcessor implements Listener<CorrectedBinaryMessage>
{
private Listener<Message> mMessageListener;
private AliasList mAliasList;
public Fleetsync2MessageProcessor( AliasList list )
{
mAliasList = list;
}
public void dispose()
{
mMessageListener = null;
mAliasList = null;
}
@Override
public void receive( BinaryMessage buffer )
{
FleetsyncMessage message = new FleetsyncMessage( buffer, mAliasList );
private Listener<IMessage> mMessageListener;
if( mMessageListener != null )
{
mMessageListener.receive( message );
}
}
public void setMessageListener( Listener<Message> listener )
/**
* Constructs a message processor
*/
public Fleetsync2MessageProcessor()
{
mMessageListener = listener;
}
public void dispose()
{
mMessageListener = null;
}
/**
* Primary receive interface for demodulated binary messages
*/
@Override
public void receive(CorrectedBinaryMessage message)
{
FleetsyncMessageType messageType = Fleetsync2Message.getMessageType(message);
switch(messageType)
{
case GPS:
broadcast(new LocationReport(message, System.currentTimeMillis()));
break;
case STATUS:
broadcast(new Status(message, System.currentTimeMillis()));
break;
default:
broadcast(new AutomaticNumberIdentification(message, System.currentTimeMillis()));
break;
}
}
/**
* Broadcasts the message to an optional registered listener
*/
private void broadcast(IMessage message)
{
if(mMessageListener != null)
{
mMessageListener.receive(message);
}
}
/**
* Registers the listener to receive fleetsync messages
*/
public void setMessageListener(Listener<IMessage> listener)
{
mMessageListener = listener;
}
/**
* Unregisters the current listener from receiving fleetsync messages
*/
public void removeMessageListener()
{
mMessageListener = null;
mMessageListener = null;
}
}

View File

@@ -1,206 +0,0 @@
/*******************************************************************************
* 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/>
******************************************************************************/
package io.github.dsheirer.module.decode.fleetsync2;
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 FleetsyncCallEvent extends CallEvent
{
private long mFrequency = 0;
public FleetsyncCallEvent( CallEventType callEventType,
AliasList aliasList,
String fromID,
String toID,
String details,
long frequency )
{
super( DecoderType.FLEETSYNC2, callEventType,
aliasList, fromID, toID, details );
mFrequency = frequency;
}
private Alias getAlias( String ident )
{
if( hasAliasList() )
{
return getAliasList().getFleetsyncAlias( 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 mFrequency;
}
public static class Builder
{
/* Required parameters */
private CallEventType mCallEventType;
/* Optional parameters */
private AliasList mAliasList;
private String mFromID;
private String mToID;
private String mDetails;
private long mFrequency;
public Builder( CallEventType callEventType )
{
mCallEventType = callEventType;
}
public Builder aliasList( AliasList aliasList )
{
mAliasList = aliasList;
return this;
}
public Builder frequency( long frequency )
{
mFrequency = frequency;
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 FleetsyncCallEvent build()
{
return new FleetsyncCallEvent( this );
}
}
/**
* Private constructor for the builder
*/
private FleetsyncCallEvent( Builder builder )
{
this( builder.mCallEventType,
builder.mAliasList,
builder.mFromID,
builder.mToID,
builder.mDetails,
builder.mFrequency );
}
public static FleetsyncCallEvent getFleetsync2Event(
FleetsyncMessage message, long frequency )
{
CallEventType type = CallEventType.UNKNOWN;
StringBuilder sbDetails = new StringBuilder();
sbDetails.append( "Fleetsync " );
switch( message.getMessageType() )
{
case ACKNOWLEDGE:
type = CallEventType.RESPONSE;
sbDetails.append( "ACK" );
break;
case ANI:
type = CallEventType.ID_ANI;
break;
case EMERGENCY:
type = CallEventType.EMERGENCY;
break;
case GPS:
type = CallEventType.GPS;
sbDetails.append( message.getGPSLocation() );
break;
case LONE_WORKER_EMERGENCY:
type = CallEventType.EMERGENCY;
sbDetails.append( "LONE WORKER EMERGENCY ALERT" );
break;
case PAGING:
type = CallEventType.PAGE;
break;
case STATUS:
type = CallEventType.STATUS;
sbDetails.append( "Status: " );
sbDetails.append( message.getStatus() );
if( message.getStatusAlias() != null )
{
sbDetails.append( "/" );
sbDetails.append( message.getStatusAlias().getName() );
}
break;
default:
break;
}
if( type == CallEventType.ID_ANI ||
type == CallEventType.EMERGENCY )
{
return new FleetsyncCallEvent.Builder( type )
.details( sbDetails.toString() )
.frequency( frequency )
.from( message.getFromID() )
.build();
}
else
{
return new FleetsyncCallEvent.Builder( type )
.details( sbDetails.toString() )
.frequency( frequency )
.from( message.getFromID() )
.to( message.getToID() )
.build();
}
}
}

View File

@@ -1,894 +0,0 @@
/*******************************************************************************
* 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/>
******************************************************************************/
package io.github.dsheirer.module.decode.fleetsync2;
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.edac.CRCFleetsync;
import io.github.dsheirer.map.Plottable;
import io.github.dsheirer.message.Message;
import org.jdesktop.swingx.mapviewer.GeoPosition;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
public class FleetsyncMessage extends Message
{
private static DecimalFormat mDecimalFormatter = new DecimalFormat("#.#####");
private static SimpleDateFormat mSDF = new SimpleDateFormat( "yyyyMMdd HHmmss" );
//Calendar to use in calculating time hacks
Calendar mCalendar = new GregorianCalendar();
//Message parts are identified in big-endian order for correct translation
//Message Header
private static int[] sRevs = { 4,3,2,1,0 };
private static int[] sSync = { 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5 };
//Message Block 1
private static int[] sStatusMessage = { 27,26,25,24,23,22,21 };
private static int[] sMessageType = { 33,32,31,30,29 };
private static int sEmergencyFlag = 22;
private static int sLoneWorkerFlag = 24;
private static int sPagingFlag = 26;
private static int sEndOfTransmissionFlag = 27;
private static int sManualFlag = 28;
private static int sANIFlag = 29;
private static int sStatusFlag = 30;
private static int sAcknowledgeFlag = 31;
//32 - unknown - always 0
//33 - unknown - always 0
//34 - unknown - set for ACKNOWLEDGE
private static int sGPSExtensionFlag = 35;
private static int sFleetExtensionFlag = 36;
private static int[] sFleetFrom = { 44,43,42,41,40,39,38,37 };
private static int[] sIdentFrom = { 56,55,54,53,52,51,50,49,48,47,46,45 };
private static int[] sIdentTo = { 68,67,66,65,64,63,62,61,60,59,58,57 };
private static int[] sCRC1 = { 84,83,82,81,80,79,78,77,76,75,74,73,72,71,70,69 };
//Message Block 2
private static int[] sFleetTo = { 92,91,90,89,88,87,86,85 };
private static int[] sCRC2 = { 148,147,146,145,144,143,142,141,140,139,138,137,136,135,134,132 };
//Message Block 3
private static int[] sGPSHours = { 176,175,174,173,172 };
private static int[] sGPSMinutes = { 182,181,180,179,178,177 };
private static int[] sGPSSeconds = { 188,187,186,185,184,183 };
private static int[] sCRC3 = { 212,211,210,209,208,207,206,205,204,203,202,201,200,199,198,197 };
//Message Block 4
private static int[] sGPSChecksum = { 220,219,218,217,216,215,214,213 };
private static int[] sLatitudeDegreesMinutes = { 236,235,234,233,232,231,230,229,228,227,226,225,224,223,222,221 };
private static int[] sLatitudeDecimalMinutes = { 251,250,249,248,247,246,245,244,243,242,241,240,239,238 };
private static int[] sSpeed = { 276,275,274,273,272,271,270,269,268,267,266,265,264,263,262,261,260,259,258,257,256,255,254,253,252 };
private static int[] sCRC4 = { 276,275,274,273,272,271,270,269,268,267,266,265,264,263,262,261 };
//Message Block 5
private static int[] sGPSCentury = { 284,283,282,281,280,279,278,277 };
private static int[] sGPSYear = { 291,290,289,288,287,286,285 };
private static int[] sGPSMonth = { 295,294,293,292 };
private static int[] sGPSDay = { 300,299,298,297,296 };
private static int[] sLongitudeDegreesMinutes = { 316,315,314,313,312,311,310,309,308,307,306,305,304,303,302,301 };
private static int[] sLongitudeDecimalMinutes = { 331,330,329,328,327,326,325,324,323,322,321,320,319,318 };
private static int[] sCRC5 = { 340,339,338,337,336,335,334,333,332,331,330,329,328,327,326,325 };
//Message Block 6
private static int[] sGPSUnknown1 = { 352,351,350,349 };
private static int[] sGPSHeading = { 365,363,362,361,360,359,358,357,356,355,354,353 };
private static int[] sCRC6 = { 404,403,402,401,400,399,398,397,396,395,394,393,392,391,390,389 };
//Message Block 7
private static int[] sBLK7WhatIsIt = { 444,443,442,441,440,439,438,437,436,435,434,433,432,431,430,429 };
private static int[] sCRC7 = { 468,467,466,465,464,463,462,461,460,459,458,457,456,455,454,453 };
//Message Block 8
private static int[] sGPSSpeed = { 491,490,489,488,487,486,485,484 };
private static int[] sGPSSpeedFractional = { 499,498,497,496,495,494,493,492 };
private static int[] sCRC8 = { 532,531,530,529,528,527,526,525,524,523,522,521,520,519,518,517 };
private BinaryMessage mMessage;
private CRC[] mCRC = new CRC[ 8 ];
private AliasList mAliasList;
public FleetsyncMessage( BinaryMessage message, AliasList list )
{
mMessage = message;
mAliasList = list;
checkParity();
}
private void checkParity()
{
//Check message block 1
mCRC[ 0 ] = detectAndCorrect( 21, 85 );
//Only check subsequent blocks if we know block 1 is correct
if( mCRC[ 0 ] == CRC.PASSED || mCRC[ 0 ] == CRC.CORRECTED )
{
if( hasFleetExtensionFlag() )
{
//Check message block 2
mCRC[ 1 ] = detectAndCorrect( 85, 149 );
}
if( hasGPSFlag() )
{
//Check message block 3
mCRC[ 2 ] = detectAndCorrect( 149, 213 );
//Check message block 4
mCRC[ 3 ] = detectAndCorrect( 213, 277 );
//Check message block 5
mCRC[ 4 ] = detectAndCorrect( 277, 341 );
//Check message block 6
mCRC[ 5 ] = detectAndCorrect( 341, 405 );
//Check message block 7
mCRC[ 6 ] = detectAndCorrect( 405, 469 );
//Check message block 8
mCRC[ 7 ] = detectAndCorrect( 469, 533 );
}
}
}
private CRC detectAndCorrect( int start, int end )
{
BitSet original = mMessage.get( start, end );
CRC retVal = CRCFleetsync.check( original );
//Attempt to correct single-bit errors
if( retVal == CRC.FAILED_PARITY )
{
int[] errorBitPositions = CRCFleetsync.findBitErrors( original );
if( errorBitPositions != null )
{
for( int errorBitPosition: errorBitPositions )
{
mMessage.flip( start + errorBitPosition );
}
retVal = CRC.CORRECTED;
}
}
return retVal;
}
public boolean isValid()
{
boolean valid = true;
for( int x = 0; x < mCRC.length; x++ )
{
CRC crc = mCRC[ x ];
if( crc != null )
{
if( crc == CRC.FAILED_CRC ||
crc == CRC.FAILED_PARITY ||
crc == CRC.UNKNOWN )
{
valid = false;
}
}
}
return valid;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append( mSDF.format( new Date( System.currentTimeMillis() ) ) );
sb.append( " FSync2 " + getParity() );
sb.append( getMessage() );
sb.append( " [" + mMessage.toString() + "]" );
return sb.toString();
}
/**
* Pads spaces onto the end of the value to make it 'places' long
*/
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();
}
/**
* Pads an integer value with additional zeroes to make it decimalPlaces long
*/
public String format( int number, int decimalPlaces )
{
StringBuilder sb = new StringBuilder();
int paddingRequired = decimalPlaces - ( String.valueOf( number ).length() );
for( int x = 0; x < paddingRequired; x++)
{
sb.append( "0" );
}
sb.append( number );
return sb.toString();
}
public FleetsyncMessageType getMessageType()
{
if( hasStatusFlag() )
{
if( hasAcknowledgeFlag() )
{
return FleetsyncMessageType.ACKNOWLEDGE;
}
if( hasGPSFlag() )
{
return FleetsyncMessageType.GPS;
}
else
{
return FleetsyncMessageType.STATUS;
}
}
else
{
if( hasAcknowledgeFlag() )
{
return FleetsyncMessageType.ACKNOWLEDGE;
}
if( hasANIFlag() )
{
return FleetsyncMessageType.ANI;
}
if( hasGPSFlag() )
{
return FleetsyncMessageType.GPS;
}
if( hasPagingFlag() )
{
return FleetsyncMessageType.PAGING;
}
if( hasEmergencyFlag() )
{
if( hasLoneWorkerFlag() )
{
return FleetsyncMessageType.LONE_WORKER_EMERGENCY;
}
else
return FleetsyncMessageType.EMERGENCY;
}
}
return FleetsyncMessageType.UNKNOWN;
}
public int getStatus()
{
return getStatusNumber() + 9;
}
/**
* Returns the RAW status number. The actual status number should be
* accessed via the getStatus() method.
* @return
*/
public int getStatusNumber()
{
return getInt( sStatusMessage );
}
/**
* @return
*/
public Alias getStatusAlias()
{
if( mAliasList != null )
{
return mAliasList.getStatus( getStatus() );
}
return null;
}
public int getFleetFrom()
{
return getInt( sFleetFrom ) + 99;
}
public int getIdentifierFrom()
{
return getInt( sIdentFrom ) + 999;
}
/**
* Inverted Flags - 0 = flag is true
* @return
*/
public boolean hasEndOfTransmissionFlag()
{
return !mMessage.get( sEndOfTransmissionFlag );
}
public boolean hasEmergencyFlag()
{
return !mMessage.get( sEmergencyFlag );
}
public boolean hasLoneWorkerFlag()
{
return !mMessage.get( sLoneWorkerFlag );
}
public boolean hasPagingFlag()
{
return !mMessage.get( sPagingFlag );
}
/**
* Normal Flags - 1 = flag is true
* @return
*/
public boolean hasANIFlag()
{
return mMessage.get( sANIFlag );
}
public boolean hasAcknowledgeFlag()
{
return mMessage.get( sAcknowledgeFlag );
}
public boolean hasFleetExtensionFlag()
{
return mMessage.get( sFleetExtensionFlag );
}
public boolean hasGPSFlag()
{
return mMessage.get( sGPSExtensionFlag );
}
public boolean hasStatusFlag()
{
return mMessage.get( sStatusFlag );
}
public int getFleetTo()
{
if( hasFleetExtensionFlag() )
{
return getInt( sFleetTo ) + 99;
}
else
{
return getInt( sFleetFrom ) + 99;
}
}
public int getIdentifierTo()
{
return getInt( sIdentTo ) + 999;
}
/**
* GPS Heading
* @return
*/
public double getHeading()
{
double retVal = 0.0;
int heading = getInt( sGPSHeading );
if( heading != 4095 )
{
retVal = (double)(heading / 10.0 );
}
return retVal;
}
public int getBlock7WhatIsIt()
{
int value = getInt( sBLK7WhatIsIt );
if( value == 65535 )
{
value = -1;
}
return value;
}
/**
* Speed in Kph - whole numbers and three decimal digits of precision
* @return
*/
public double getSpeed()
{
double retVal = 0.0;
int temp = getInt( sSpeed );
if( temp != 0 )
{
retVal = (double)temp / 1000.0D;
}
return retVal;
}
public double getLatitude()
{
//TODO: determine the correct hemisphere indicator and replace this
//hardcoded "0" with the correct hemisphere value
return convertDDMToDD( 0,
getInt( sLatitudeDegreesMinutes ),
getInt( sLatitudeDecimalMinutes ) );
}
public double getLongitude()
{
//TODO: determine the correct hemisphere indicator and replace this
//hardcoded "1" with the correct hemisphere value
return convertDDMToDD( 1,
getInt( sLongitudeDegreesMinutes ),
getInt( sLongitudeDecimalMinutes ) );
}
/**
* Converts Degrees Decimal Minutes to Decimal Degrees
*
* Latitude and Longitude values are represented by:
*
* @param hemisphere - 0=North & East, 1=South & West
* @param degreesMinutes - an integer value with the first 2-3 digits representing
* the degrees and the last two digits representing the minutes
*
* @param decimalDegrees - an integer value representing the fractional
* minutes
*
* @return - decimal degrees formatted value
*/
public double convertDDMToDD( int hemisphere, int degreesMinutes, int decimalDegrees )
{
double retVal = 0.0;
if( degreesMinutes != 0 )
{
//Degrees - divide value by 100 and retain the whole number value (ie degrees)
retVal += (double)( degreesMinutes / 100 );
//Minutes - modulus by 100 to get the whole minutes value
int wholeMinutes = degreesMinutes % 100;
if( wholeMinutes != 0 )
{
retVal += (double)( wholeMinutes / 60.0D );
}
}
if( decimalDegrees != 0 )
{
//Fractional Minutes - divide by 10,000 to get the decimal place correct
//then divide by 60 (minutes) to get the decimal value
//10,000 * 60 = 600,000
retVal += (double)( decimalDegrees / 600000.0D );
}
//Adjust the value +/- for the hemisphere
if( hemisphere == 1 ) //South and West values
{
retVal = -retVal;
}
return retVal;
}
public String getGPSTime()
{
StringBuilder sb = new StringBuilder();
sb.append( format( getInt( sGPSHours ), 2 ) );
sb.append( ":" );
sb.append( format( getInt( sGPSMinutes ), 2 ) );
sb.append( ":" );
sb.append( format( getInt( sGPSSeconds ), 2 ) );
sb.append( "z" );
return sb.toString();
}
/**
* 7 bit checksum that is part of the GPGGA message, I think
* @return
*/
public int getGPSChecksum()
{
return getInt( sGPSChecksum );
}
public String getGPSChecksumString()
{
String sum = Integer.toHexString( getGPSChecksum() );
if( sum.length() == 1 )
{
return "*0" + sum;
}
else
{
return "*" + sum;
}
}
/**
* Returns 1-based calendar day of month
* 1 = 1st day of month
*/
public int getGPSDay()
{
return getInt( sGPSDay ) + 1;
}
/**
* Returns 0-based GPS Month
* 0 = January
*
* Note: actual day of month value is 1-based, so we subtract 1 to get
* the actual day of month value
*/
public int getGPSMonth()
{
return getInt( sGPSMonth );
}
/**
* Returns year, which is a combination of the century bit field + 1, times
* 100, plus the year bit field
*/
public int getGPSYear()
{
// return ( ( getInt( sGPSCentury ) + 1 ) * 100 ) + getInt( sGPSYear );
return ( 2000 ) + getInt( sGPSYear );
}
public String getGPSLocation()
{
StringBuilder sb = new StringBuilder();
sb.append( pad( String.valueOf( mDecimalFormatter.format( getLatitude() ) ), 8, "0" ) + " " );
sb.append( pad( String.valueOf( mDecimalFormatter.format( getLongitude() ) ), 10, "0" ) );
return sb.toString();
}
public String getGPSDate()
{
StringBuilder sb = new StringBuilder();
sb.append( getGPSYear() + "-" );
int month = getGPSMonth();
if( month < 10 )
{
sb.append( "0" );
}
sb.append( month + "-" );
int day = getGPSDay();
if( day < 10 )
{
sb.append( "0" );
}
sb.append( day );
return sb.toString();
}
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;
}
@Override
public String getBinaryMessage()
{
return mMessage.toString();
}
/**
* String representing results of the parity check
*
* [P] = passes parity check
* [f] = fails parity check
* [C] = corrected message
* [-] = message section not present
*/
public String getParity()
{
return "[" + CRC.format( mCRC ) + "]";
}
@Override
public String getProtocol()
{
return "Fleetsync II";
}
@Override
public String getEventType()
{
return getMessageType().toString();
}
@Override
public String getFromID()
{
StringBuilder sb = new StringBuilder();
sb.append( getFleetFrom() );
sb.append( "-" );
sb.append( getIdentifierFrom() );
return sb.toString();
}
@Override
public Alias getFromIDAlias()
{
if( mAliasList != null )
{
return mAliasList.getFleetsyncAlias( getFromID() );
}
return null;
}
@Override
public String getToID()
{
StringBuilder sb = new StringBuilder();
sb.append( getFleetTo() );
sb.append( "-" );
sb.append( getIdentifierTo() );
return sb.toString();
}
@Override
public Alias getToIDAlias()
{
if( mAliasList != null )
{
return mAliasList.getFleetsyncAlias( getToID() );
}
return null;
}
private String getFromTo( boolean includeFrom, boolean includeTo )
{
StringBuilder sb = new StringBuilder();
if( includeFrom )
{
sb.append( "FM:" );
sb.append( getFromID() );
Alias from = getFromIDAlias();
if( from != null )
{
sb.append( " " );
sb.append( from.getName() );
}
}
if( includeFrom && includeTo )
{
sb.append( " " );
}
if( includeTo )
{
sb.append( "TO:" );
sb.append( getToID() );
Alias to = getToIDAlias();
if( to != null )
{
sb.append( " " );
sb.append( to.getName() );
}
}
return sb.toString();
}
@Override
public String getMessage()
{
StringBuilder sb = new StringBuilder();
FleetsyncMessageType type = getMessageType();
switch( type )
{
case ACKNOWLEDGE:
sb.append( "ACKNOWLEDGE " );
sb.append( getFromTo( true, true ) );
break;
case ANI:
sb.append( "ANI " );
sb.append( getFromTo( true, false ) );
break;
case EMERGENCY:
sb.append( "**EMERGENCY** " );
sb.append( getFromTo( true, true ) );
break;
case GPS:
sb.append( "GPS [" );
sb.append( getGPSLocation() );
sb.append( "] " );
sb.append( getFromTo( true, true ) );
sb.append( " HDG:" );
sb.append( pad( String.valueOf( getHeading() ), 5, " " ) );
sb.append( " GPSDate[" );
sb.append( getGPSDate() );
sb.append( " " );
sb.append( getGPSTime() );
sb.append( "]" );
break;
case LONE_WORKER_EMERGENCY:
sb.append( "**LONE WORKER EMERGENCY** " );
sb.append( getFromTo( true, true ) );
break;
case PAGING:
sb.append( "PAGING " );
sb.append( getFromTo( true, true ) );
break;
case STATUS:
sb.append( "STATUS: " + format( getStatus(), 2 ) );
Alias status = getStatusAlias();
if( status != null )
{
sb.append( "/" );
sb.append( status.getName() );
}
sb.append( getFromTo( true, true ) );
break;
case UNKNOWN:
default:
sb.append( "*** UNKNOWN *** " );
sb.append( getFromTo( true, true ) );
break;
}
return sb.toString();
}
@Override
public String getErrorStatus()
{
return CRC.format( mCRC );
}
@Override
public Plottable getPlottable()
{
if( isValid() && getMessageType() == FleetsyncMessageType.GPS )
{
GeoPosition position =
new GeoPosition( getLatitude(), getLongitude() );
Alias alias = mAliasList.getFleetsyncAlias( getFromID() );
return new Plottable( mTimeReceived, position, getFromID(), alias );
}
else
{
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 );
}
Alias status = getStatusAlias();
if( status != null )
{
aliases.add( status );
}
return aliases;
}
}

View File

@@ -1,56 +1,77 @@
/*
* ******************************************************************************
* 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.fleetsync2;
import io.github.dsheirer.filter.Filter;
import io.github.dsheirer.filter.FilterElement;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.module.decode.fleetsync2.message.Fleetsync2Message;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class FleetsyncMessageFilter extends Filter<Message>
public class FleetsyncMessageFilter extends Filter<IMessage>
{
private HashMap<FleetsyncMessageType, FilterElement<FleetsyncMessageType>> mElements =
new HashMap<FleetsyncMessageType, FilterElement<FleetsyncMessageType>>();
public FleetsyncMessageFilter()
{
super( "Fleetsync Message Filter" );
private HashMap<FleetsyncMessageType,FilterElement<FleetsyncMessageType>> mElements =
new HashMap<FleetsyncMessageType,FilterElement<FleetsyncMessageType>>();
for( FleetsyncMessageType type: FleetsyncMessageType.values() )
{
if( type != FleetsyncMessageType.UNKNOWN )
{
mElements.put( type, new FilterElement<FleetsyncMessageType>( type ) );
}
}
}
@Override
public boolean passes( Message message )
public FleetsyncMessageFilter()
{
if( mEnabled && canProcess( message ) )
{
FleetsyncMessage fleet = (FleetsyncMessage)message;
if( mElements.containsKey( fleet.getMessageType() ) )
{
return mElements.get( fleet.getMessageType() ).isEnabled();
}
}
return false;
super("Fleetsync Message Filter");
for(FleetsyncMessageType type : FleetsyncMessageType.values())
{
if(type != FleetsyncMessageType.UNKNOWN)
{
mElements.put(type, new FilterElement<FleetsyncMessageType>(type));
}
}
}
@Override
public boolean canProcess( Message message )
@Override
public boolean passes(IMessage message)
{
return message instanceof FleetsyncMessage;
if(mEnabled && canProcess(message))
{
Fleetsync2Message fleet = (Fleetsync2Message)message;
if(mElements.containsKey(fleet.getMessageType()))
{
return mElements.get(fleet.getMessageType()).isEnabled();
}
}
return false;
}
@Override
@Override
public boolean canProcess(IMessage message)
{
return message instanceof Fleetsync2Message;
}
@Override
public List<FilterElement<?>> getFilterElements()
{
return new ArrayList<FilterElement<?>>( mElements.values() );
return new ArrayList<FilterElement<?>>(mElements.values());
}
}

View File

@@ -0,0 +1,88 @@
/*
* ******************************************************************************
* 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.fleetsync2.identifier;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.talkgroup.TalkgroupIdentifier;
import io.github.dsheirer.protocol.Protocol;
/**
* Fleetsync talkgroup identifier
*/
public class FleetsyncIdentifier extends TalkgroupIdentifier implements Comparable<FleetsyncIdentifier>
{
public FleetsyncIdentifier(Integer talkgroup, Role role)
{
super(talkgroup, role, false);
}
@Override
public Protocol getProtocol()
{
return Protocol.FLEETSYNC;
}
/**
* This identifier formatted as FFF:IIII where F=fleet and I=ident
*/
public String formatted()
{
return String.format("%03d:%04d", getFleet(), getIdent());
}
/**
* Fleet prefix for the identifier
*/
public int getFleet()
{
return (getValue() >> 12) & 0xFF;
}
/**
* Unit identifier
*/
public int getIdent()
{
return getValue() & 0xFFF;
}
/**
* Creates a fleetsync identifier from the integer value that contains both the fleet and the ident with a FROM role
*/
public static FleetsyncIdentifier createFromUser(int talkgroup)
{
return new FleetsyncIdentifier(talkgroup, Role.FROM);
}
/**
* Creates a fleetsync identifier from the integer value that contains both the fleet and the ident with a TO role
*/
public static FleetsyncIdentifier createToUser(int talkgroup)
{
return new FleetsyncIdentifier(talkgroup, Role.TO);
}
@Override
public int compareTo(FleetsyncIdentifier o)
{
return getValue().compareTo(o.getValue());
}
}

View File

@@ -0,0 +1,59 @@
/*
* ******************************************************************************
* 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.fleetsync2.identifier;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.integer.IntegerIdentifier;
import io.github.dsheirer.protocol.Protocol;
/**
* Fleetsync User status
*/
public class FleetsyncStatus extends IntegerIdentifier
{
private Role mRole;
/**
* Constructs an APCO-25 status
* @param status value
* @param role of the user/unit that the status applies to
*/
public FleetsyncStatus(int status, IdentifierClass identifierClass, Form form, Role role)
{
super(status, identifierClass, form, role);
mRole = role;
}
@Override
public Protocol getProtocol()
{
return Protocol.FLEETSYNC;
}
/**
* Creates a User status
*/
public static FleetsyncStatus createUserStatus(int status)
{
return new FleetsyncStatus(status, IdentifierClass.USER, Form.USER_STATUS, Role.FROM);
}
}

View File

@@ -0,0 +1,93 @@
/*
* ******************************************************************************
* 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.fleetsync2.message;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.identifier.Identifier;
import java.util.ArrayList;
import java.util.List;
/**
* Automatic Number Identification (ANI).
*/
public class AutomaticNumberIdentification extends Fleetsync2Message
{
private List<Identifier> mIdentifers;
public AutomaticNumberIdentification(CorrectedBinaryMessage message, long timestamp)
{
super(message, timestamp);
}
@Override
protected int getBlockCount()
{
return hasFleetExtensionFlag(getMessage()) ? 2 : 1;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("FROM:").append(getFromIdentifier().formatted());
if(hasEmergencyFlag(getMessage()))
{
sb.append(" EMERGENCY");
}
if(hasLoneWorkerFlag(getMessage()))
{
sb.append(" LONE WORKER");
}
if(hasPagingFlag(getMessage()))
{
sb.append(" PAGING");
}
if(hasAcknowledgeFlag(getMessage()))
{
sb.append(" ACKNOWLEDGE");
}
if(hasANIFlag(getMessage()))
{
sb.append(" ANI");
}
return sb.toString().trim();
}
@Override
public List<Identifier> getIdentifiers()
{
if(mIdentifers == null)
{
mIdentifers = new ArrayList<>();
mIdentifers.add(getFromIdentifier());
}
return mIdentifers;
}
}

View File

@@ -0,0 +1,304 @@
/*
* ******************************************************************************
* 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.fleetsync2.message;
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.edac.CRC;
import io.github.dsheirer.edac.CRCFleetsync;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.module.decode.fleetsync2.FleetsyncMessageType;
import io.github.dsheirer.module.decode.fleetsync2.identifier.FleetsyncIdentifier;
import io.github.dsheirer.protocol.Protocol;
import java.util.BitSet;
public abstract class Fleetsync2Message extends Message
{
//Message Header
private static int[] BIT_REVERSALS = {0, 1, 2, 3, 4};
private static int[] SYNC_PATTERN = {5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
//Message Block 1
private static int[] STATUS = {21, 22, 23, 24, 25, 26, 27};
private static int[] MESSAGE_TYPE = {29, 30, 31, 32, 33};
//Message Type Flags
private static int FLAG_UNKNOWN_1 = 21;
private static int FLAG_EMERGENCY_WORKER = 22;
private static int FLAG_UNKNOWN_2 = 23;
private static int FLAG_LONE_WORKER = 24;
private static int FLAG_UNKNOWN_3 = 25;
private static int FLAG_PAGING = 26;
private static int FLAG_END_OF_TRANSMISSION = 27;
private static int FLAG_MANUAL = 28;
private static int FLAG_AUTOMATIC_NUMBER_IDENTIFIER = 29;
private static int FLAG_STATUS = 30;
private static int FLAG_ACKNOWLEDGE = 31;
private static int FLAG_UNKNOWN_4 = 32;
private static int FLAG_UNKNOWN_5 = 33;
private static int FLAG_UNKNOWN_6 = 34; //Always set for Acknowledge
private static int FLAG_GPS_EXTENSION = 35;
private static int FLAG_FLEET_EXTENSION = 36;
//From and To talkgroups share a common fleet value for single-block messages.
private static int[] FLEET = {37, 38, 39, 40, 41, 42, 43, 44};
private static int[] FROM_IDENT = {45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56};
private static int[] TO_IDENT = {57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68};
private static int[] CRC_BLOCK_1 = {69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84};
//Message Block 2
private static int[] FLEET_TO = {85, 86, 87, 88, 89, 90, 91, 92};
private static int[] CRC_BLOCK_2 = {132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148};
private CorrectedBinaryMessage mMessage;
private CRC[] mCRC = new CRC[2];
private FleetsyncIdentifier mFromIdentifier;
private FleetsyncIdentifier mToIdentifier;
public Fleetsync2Message(CorrectedBinaryMessage message, long timestamp)
{
super(timestamp);
mMessage = message;
checkParity();
}
protected CorrectedBinaryMessage getMessage()
{
return mMessage;
}
@Override
public Protocol getProtocol()
{
return Protocol.FLEETSYNC;
}
/**
* Indicates the number of 64-bit blocks that makeup this message.
*/
protected abstract int getBlockCount();
/**
* Fleetsync identifier for the from or transmitting radio.
*/
public FleetsyncIdentifier getFromIdentifier()
{
if(mFromIdentifier == null)
{
mFromIdentifier = FleetsyncIdentifier.createFromUser(getCommonFleet() + getFromIdent());
}
return mFromIdentifier;
}
/**
* Fleetsync identifier for the to or receiving radio
*/
public FleetsyncIdentifier getToIdentifier()
{
if(mToIdentifier == null)
{
int value = (hasFleetExtensionFlag(getMessage()) ? getExtendedFleet() : getCommonFleet()) + getToIdent();
mToIdentifier = FleetsyncIdentifier.createToUser(value);
}
return mToIdentifier;
}
/**
* Shared or common fleet value. Note: this value is added to 99 and then left shifted by 12 to obtain fleets in
* the range of 1 - 127.
*/
private int getCommonFleet()
{
return (getMessage().getInt(FLEET) + 99) << 12;
}
/**
* Extended fleet for the TO identifier. This value is only valid when the extended fleet flag is set.
* Note: this value is added to 99 and then left shifted by 12 to obtain fleets in the range of 1 - 127.
*/
private int getExtendedFleet()
{
return (getMessage().getInt(FLEET_TO) + 99) << 12;
}
/**
* From ident value. Transmitted value is added to 999 to obtain ident values in range of 1000 - 4996
*/
private int getFromIdent()
{
return getMessage().getInt(FROM_IDENT) + 999;
}
/**
* To ident value. Transmitted value is added to 999 to obtain ident values in range of 1000 - 4996
*/
private int getToIdent()
{
return getMessage().getInt(TO_IDENT) + 999;
}
private void checkParity()
{
//Check message block 1
CRC block1Crc = detectAndCorrect(getMessage(), 21, 85);
mCRC = new CRC[getBlockCount()];
mCRC[0] = block1Crc;
for(int x = 1; x < getBlockCount(); x++)
{
int blockStart = 21 + (x * 64);
mCRC[x] = detectAndCorrect(getMessage(), blockStart, blockStart + 64);
}
}
public static CRC detectAndCorrect(CorrectedBinaryMessage message, int start, int end)
{
BitSet original = message.get(start, end);
CRC retVal = CRCFleetsync.check(original);
//Attempt to correct single-bit errors
if(retVal == CRC.FAILED_PARITY)
{
int[] errorBitPositions = CRCFleetsync.findBitErrors(original);
if(errorBitPositions != null)
{
for(int errorBitPosition : errorBitPositions)
{
message.flip(start + errorBitPosition);
message.incrementCorrectedBitCount(1);
}
retVal = CRC.CORRECTED;
}
}
return retVal;
}
public boolean isValid()
{
return mCRC[0].passes();
}
/**
* Type of message
*/
public FleetsyncMessageType getMessageType()
{
return getMessageType(getMessage());
}
public static FleetsyncMessageType getMessageType(BinaryMessage message)
{
if(hasAcknowledgeFlag(message))
{
return FleetsyncMessageType.ACKNOWLEDGE;
}
if(hasGPSFlag(message))
{
return FleetsyncMessageType.GPS;
}
if(hasStatusFlag(message))
{
return FleetsyncMessageType.STATUS;
}
if(hasANIFlag(message))
{
return FleetsyncMessageType.ANI;
}
if(hasPagingFlag(message))
{
return FleetsyncMessageType.PAGING;
}
if(hasLoneWorkerFlag(message) && hasEmergencyFlag(message))
{
return FleetsyncMessageType.LONE_WORKER_EMERGENCY;
}
return FleetsyncMessageType.UNKNOWN;
}
/**
* Message Type Indicator Flags. The flags have inverted values where 0 = flag is true
*/
public static boolean hasEndOfTransmissionFlag(BinaryMessage message)
{
return !message.get(FLAG_END_OF_TRANSMISSION);
}
public static boolean hasEmergencyFlag(BinaryMessage message)
{
return !message.get(FLAG_EMERGENCY_WORKER);
}
public static boolean hasLoneWorkerFlag(BinaryMessage message)
{
return !message.get(FLAG_LONE_WORKER);
}
public static boolean hasPagingFlag(BinaryMessage message)
{
return !message.get(FLAG_PAGING);
}
/**
* Message Type Indicator Flags. The flags have normal values where 1 = true
*
* @return
*/
public static boolean hasANIFlag(BinaryMessage message)
{
return message.get(FLAG_AUTOMATIC_NUMBER_IDENTIFIER);
}
public static boolean hasAcknowledgeFlag(BinaryMessage message)
{
return message.get(FLAG_ACKNOWLEDGE);
}
public static boolean hasFleetExtensionFlag(BinaryMessage message)
{
return message.get(FLAG_FLEET_EXTENSION);
}
public static boolean hasGPSFlag(BinaryMessage message)
{
return message.get(FLAG_GPS_EXTENSION);
}
public static boolean hasStatusFlag(BinaryMessage message)
{
return message.get(FLAG_STATUS);
}
}

View File

@@ -0,0 +1,250 @@
/*
* ******************************************************************************
* 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.fleetsync2.message;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.identifier.Identifier;
import org.jdesktop.swingx.mapviewer.GeoPosition;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
/**
* Status message containing a numeric status indicator where the numeric value is pre-defined.
*/
public class LocationReport extends Fleetsync2Message
{
//Message Block 3
private static int[] GPS_HOURS = {172, 173, 174, 175, 176};
private static int[] GPS_MINUTES = {177, 178, 179, 180, 181, 182};
private static int[] GPS_SECONDS = {183, 184, 185, 186, 187, 188};
//Message Block 4
private static int[] GPS_CHECKSUM = {213, 214, 215, 216, 217, 218, 219, 220};
private static int[] LATITUDE_DEGREES_MINUTES = {221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236};
private static int[] LATITUDE_FRACTIONAL_MINUTES = {238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251};
private static int[] SPEED = {252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268,
269, 270, 271, 272, 273, 274, 275, 276};
//Message Block 5
private static int[] GPS_CENTURY = {277, 278, 279, 280, 281, 282, 283, 284};
private static int[] GPS_YEAR = {284, 286, 287, 288, 289, 290, 291};
private static int[] GPS_MONTH = {292, 293, 294, 295};
private static int[] GPS_DAY = {296, 297, 298, 299, 300};
private static int[] LONGITUDE_DEGREES_MINUTES = {301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316};
//TODO: this overlaps with the CRC block address space ...
private static int[] LONGITUDE_FRACTIONAL_MINUTES = {318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331};
//Message Block 6
private static int[] GPS_HEADING = {353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365};
//Message Block 7
//Message Block 8
private static int[] GPS_SPEED = {484, 485, 486, 487, 488, 489, 490, 491};
private static int[] GPS_SPEED_FRACTIONAL = {492, 493, 494, 495, 496, 497, 498, 499};
private GeoPosition mGeoPosition;
private Long mGPSTimestamp;
private Double mGPSHeading;
private Double mGPSSpeed;
private List<Identifier> mIdentifers;
public LocationReport(CorrectedBinaryMessage message, long timestamp)
{
super(message, timestamp);
}
@Override
protected int getBlockCount()
{
return 8;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("GPS FROM:").append(getFromIdentifier());
sb.append(" TO:").append(getToIdentifier());
sb.append(" ").append(getLocation());
sb.append(" HEADING:").append(getHeading());
sb.append(" SPEED:").append(getSpeed());
sb.append(" TIME:").append(new Date(getGPSTime()));
return sb.toString();
}
@Override
public List<Identifier> getIdentifiers()
{
if(mIdentifers == null)
{
mIdentifers = new ArrayList<>();
mIdentifers.add(getFromIdentifier());
mIdentifers.add(getToIdentifier());
}
return mIdentifers;
}
/**
* GPS Heading in degrees relative to true North.
*/
public double getHeading()
{
if(mGPSHeading == null)
{
if(hasHeading())
{
mGPSHeading = (double)getHeadingValue() / 10.0;
}
else
{
mGPSHeading = 0.0;
}
}
return mGPSHeading;
}
private int getHeadingValue()
{
return getMessage().getInt(GPS_HEADING);
}
private boolean hasHeading()
{
return getHeadingValue() != 4095;
}
/**
* Speed in kph
*/
public double getSpeed()
{
if(mGPSSpeed == null)
{
mGPSSpeed = (double)getMessage().getInt(GPS_SPEED) + ((double)getMessage().getInt(GPS_SPEED_FRACTIONAL) / 255.0);
}
return mGPSSpeed;
}
/**
* Latitude and Longitude location/position.
*/
public GeoPosition getLocation()
{
if(mGeoPosition == null)
{
mGeoPosition = new GeoPosition(getLatitude(), getLongitude());
}
return mGeoPosition;
}
private double getLatitude()
{
//TODO: determine the correct hemisphere indicator and replace this
return convertDDMToDD(0, getMessage().getInt(LATITUDE_DEGREES_MINUTES),
getMessage().getInt(LATITUDE_FRACTIONAL_MINUTES));
}
private double getLongitude()
{
//TODO: determine the correct hemisphere indicator and replace this
return convertDDMToDD(1, getMessage().getInt(LONGITUDE_DEGREES_MINUTES),
getMessage().getInt(LONGITUDE_FRACTIONAL_MINUTES));
}
/**
* Converts Degrees Decimal Minutes to Decimal Degrees
*
* Latitude and Longitude values are represented by:
*
* @param hemisphere - 0=North & East, 1=South & West
* @param degreesMinutes - an integer value with the first 2-3 digits representing
* the degrees and the last two digits representing the minutes
* @param decimalDegrees - an integer value representing the fractional
* minutes
* @return - decimal degrees formatted value
*/
public double convertDDMToDD(int hemisphere, int degreesMinutes, int decimalDegrees)
{
double retVal = 0.0;
if(degreesMinutes != 0)
{
//Degrees - divide value by 100 and retain the whole number value (ie degrees)
retVal += (double)(degreesMinutes / 100);
//Minutes - modulus by 100 to get the whole minutes value
int wholeMinutes = degreesMinutes % 100;
if(wholeMinutes != 0)
{
retVal += (double)(wholeMinutes / 60.0D);
}
}
if(decimalDegrees != 0)
{
//Fractional Minutes - divide by 10,000 to get the decimal place correct
//then divide by 60 (minutes) to get the decimal value
//10,000 * 60 = 600,000
retVal += (double)(decimalDegrees / 600000.0D);
}
//Adjust the value +/- for the hemisphere
if(hemisphere == 1) //South and West values
{
retVal = -retVal;
}
return retVal;
}
/**
* GPS Timestamp in milliseconds
*/
public long getGPSTime()
{
if(mGPSTimestamp == null)
{
Calendar calendar = new GregorianCalendar();
calendar.add(Calendar.YEAR, 2000 + getMessage().getInt(GPS_YEAR));
calendar.add(Calendar.MONTH, getMessage().getInt(GPS_MONTH));
calendar.add(Calendar.DAY_OF_MONTH, getMessage().getInt(GPS_DAY));
calendar.add(Calendar.HOUR_OF_DAY, getMessage().getInt(GPS_HOURS));
calendar.add(Calendar.MINUTE, getMessage().getInt(GPS_MINUTES));
calendar.add(Calendar.SECOND, getMessage().getInt(GPS_SECONDS));
mGPSTimestamp = calendar.getTimeInMillis();
}
return mGPSTimestamp;
}
}

View File

@@ -0,0 +1,110 @@
/*
* ******************************************************************************
* 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.fleetsync2.message;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.module.decode.fleetsync2.identifier.FleetsyncStatus;
import java.util.ArrayList;
import java.util.List;
/**
* Status message containing a numeric status indicator where the numeric value is pre-defined.
*/
public class Status extends Fleetsync2Message
{
private static int[] STATUS = {21, 22, 23, 24, 25, 26, 27};
private FleetsyncStatus mStatusIdentifier;
private List<Identifier> mIdentifers;
public Status(CorrectedBinaryMessage message, long timestamp)
{
super(message, timestamp);
}
@Override
protected int getBlockCount()
{
return hasFleetExtensionFlag(getMessage()) ? 2 : 1;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("FROM:").append(getFromIdentifier()).append(" TO:").append(getToIdentifier());
sb.append(" STATUS:").append(getStatus());
if(hasEmergencyFlag(getMessage()))
{
sb.append(" EMERGENCY");
}
if(hasLoneWorkerFlag(getMessage()))
{
sb.append(" LONE WORKER");
}
if(hasPagingFlag(getMessage()))
{
sb.append(" PAGING");
}
if(hasAcknowledgeFlag(getMessage()))
{
sb.append(" ACKNOWLEDGE");
}
if(hasANIFlag(getMessage()))
{
sb.append(" ANI");
}
return sb.toString();
}
public FleetsyncStatus getStatus()
{
if(mStatusIdentifier == null)
{
mStatusIdentifier = FleetsyncStatus.createUserStatus(getMessage().getInt(STATUS));
}
return mStatusIdentifier;
}
@Override
public List<Identifier> getIdentifiers()
{
if(mIdentifers == null)
{
mIdentifers = new ArrayList<>();
mIdentifers.add(getFromIdentifier());
mIdentifers.add(getToIdentifier());
mIdentifers.add(getStatus());
}
return mIdentifers;
}
}

View File

@@ -0,0 +1,74 @@
/*
* ******************************************************************************
* 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.ip;
import io.github.dsheirer.bits.BinaryMessage;
public abstract class Header implements IHeader
{
private BinaryMessage mMessage;
private int mOffset;
private boolean mValid = true;
/**
* Constructs a parser for a header contained within a binary message starting at the offset.
* @param message containing the header
* @param offset to the header within the message
*/
public Header(BinaryMessage message, int offset)
{
mMessage = message;
mOffset = offset;
}
/**
* Underlying message that contains this header
*/
public BinaryMessage getMessage()
{
return mMessage;
}
/**
* Offset to this header in the underlying message
*/
public int getOffset()
{
return mOffset;
}
/**
* Indicates if this header is valid
*/
@Override
public boolean isValid()
{
return mValid;
}
/**
* Sets the valid flag for this header
*/
protected void setValid(boolean valid)
{
mValid = valid;
}
}

View File

@@ -0,0 +1,39 @@
/*
* ******************************************************************************
* 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.ip;
/**
* Data Packet Header
*/
public interface IHeader
{
/**
* Indicates that this header is valid and that it meets the length requirements.
*/
boolean isValid();
/**
* Indicates the length of this header. An implicit understanding is that any data that follows
* the header (ie payload) starts after the header length.
* @return length of this header in bytes.
*/
int getLength();
}

View File

@@ -1,4 +1,24 @@
package io.github.dsheirer.module.decode.p25.reference;
/*
* ******************************************************************************
* 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.ip;
public enum IPProtocol
{

View File

@@ -0,0 +1,43 @@
/*
* ******************************************************************************
* 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.ip;
/**
* Data packet interface
*/
public interface IPacket
{
/**
* Header for the data packet.
*/
public IHeader getHeader();
/**
* Optional payload for the packet
* @return null if there is no payload
*/
public IPacket getPayload();
/**
* Indicates if this packet contains an optional payload
*/
public boolean hasPayload();
}

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.ip;
import io.github.dsheirer.bits.BinaryMessage;
public abstract class Packet implements IPacket
{
private BinaryMessage mMessage;
private int mOffset;
/**
* Constructs a parser for a header contained within a binary message starting at the offset.
* @param message containing the packet
* @param offset to the packet within the message
*/
public Packet(BinaryMessage message, int offset)
{
mMessage = message;
mOffset = offset;
}
/**
* Underlying message that contains this packet
*/
public BinaryMessage getMessage()
{
return mMessage;
}
/**
* Offset to this packet in the underlying message
*/
public int getOffset()
{
return mOffset;
}
@Override
public boolean hasPayload()
{
return getPayload() != null;
}
}

View File

@@ -0,0 +1,108 @@
/*
* ******************************************************************************
* 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.ip;
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.module.decode.ip.ars.ARSPacket;
import io.github.dsheirer.module.decode.ip.ipv4.IPV4Header;
import io.github.dsheirer.module.decode.ip.ipv4.IPV4Packet;
import io.github.dsheirer.module.decode.ip.udp.UDPPacket;
import io.github.dsheirer.module.decode.p25.message.pdu.packet.sndcp.SNDCPPacketHeader;
import io.github.dsheirer.module.decode.p25.reference.IPHeaderCompression;
/**
* Message parser factory for packet based binary sequences.
*/
public class PacketMessageFactory
{
/**
* Creates an IP packet message parser
*
* @param message containing an IP packet
* @param offset to the IP packet within the message
* @return constructed packet message parser
*/
public static IPacket create(SNDCPPacketHeader sndcpPacketHeader, BinaryMessage message, int offset)
{
if(sndcpPacketHeader.getIPHeaderCompression() == IPHeaderCompression.NONE)
{
int version = IPV4Header.getIPVersion(message, offset);
switch(version)
{
case 4:
return new IPV4Packet(message, offset);
default:
return new UnknownPacket(message, offset);
}
}
else
{
return new UnknownCompressedHeaderPacket(sndcpPacketHeader, message, offset);
}
}
/**
* Creates an IP packet protocol payload message parser.
*
* @param protocol of the IP packet payload
* @param binaryMessage containing the IP packet and payload
* @param offset to the start of the IP packet payload
* @return constructed packet message parser
*/
public static IPacket create(IPProtocol protocol, BinaryMessage binaryMessage, int offset)
{
switch(protocol)
{
case UDP:
return new UDPPacket(binaryMessage, offset);
default:
return new UnknownPacket(binaryMessage, offset);
}
}
/**
* Creates a UDP/IP packet payload parser
*
* @param destinationPort for the packet (to identify the protocol/format)
* @param binaryMessage containing the IP/UDP payload
* @param offset in the message to the start of the payload
* @return constructed packet messge parser
*/
public static IPacket createUDPPayload(int destinationPort, BinaryMessage binaryMessage, int offset)
{
switch(destinationPort)
{
case 4001: //Location Service
break;
case 4004: //XCMP Service
break;
case 4005: //Automatic Registration Service
return new ARSPacket(binaryMessage, offset);
case 4007: //Text Message Service
break;
case 4008: //Telemetry Service
break;
}
return new UnknownPacket(binaryMessage, offset);
}
}

View File

@@ -0,0 +1,90 @@
/*
* ******************************************************************************
* 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.ip;
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.module.decode.p25.message.pdu.packet.sndcp.SNDCPPacketHeader;
public class UnknownCompressedHeaderPacket implements IPacket
{
private SNDCPPacketHeader mSNDCPPacketHeader;
private BinaryMessage mMessage;
private int mOffset;
public UnknownCompressedHeaderPacket(SNDCPPacketHeader SNDCPPacketHeader, BinaryMessage message, int offset)
{
mSNDCPPacketHeader = SNDCPPacketHeader;
mMessage = message;
mOffset = offset;
}
public SNDCPPacketHeader getSNDCPHeader()
{
return mSNDCPPacketHeader;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append(getSNDCPHeader());
sb.append(" PACKET:");
if(getMessage().size() > getOffset())
{
sb.append(mMessage.getSubMessage(getOffset(), getMessage().size()).toHexString());
}
else
{
sb.append("(EMPTY)");
}
return sb.toString();
}
public BinaryMessage getMessage()
{
return mMessage;
}
public int getOffset()
{
return mOffset;
}
@Override
public IHeader getHeader()
{
return null;
}
@Override
public IPacket getPayload()
{
return null;
}
@Override
public boolean hasPayload()
{
return false;
}
}

View File

@@ -0,0 +1,81 @@
/*
* ******************************************************************************
* 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.ip;
import io.github.dsheirer.bits.BinaryMessage;
public class UnknownPacket implements IPacket
{
private BinaryMessage mMessage;
private int mOffset;
public UnknownPacket(BinaryMessage message, int offset)
{
mMessage = message;
mOffset = offset;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("PACKET:");
if(getMessage().size() > getOffset())
{
sb.append(mMessage.getSubMessage(getOffset(), getMessage().size()).toHexString());
}
else
{
sb.append("(EMPTY)");
}
return sb.toString();
}
public BinaryMessage getMessage()
{
return mMessage;
}
public int getOffset()
{
return mOffset;
}
@Override
public IHeader getHeader()
{
return null;
}
@Override
public IPacket getPayload()
{
return null;
}
@Override
public boolean hasPayload()
{
return false;
}
}

View File

@@ -0,0 +1,144 @@
/*
* ******************************************************************************
* 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.ip.ars;
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.module.decode.ip.Header;
public class ARSHeader extends Header
{
private static final int[] LENGTH = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
private static final int HEADER_EXTENSION_FLAG = 16;
private static final int ACKNOWLEDGEMENT_FLAG = 17;
private static final int PRIORITY_FLAG = 18;
private static final int CONTROL_USER_FLAG = 19;
private static final int[] PDU_TYPE = {20, 21, 22, 23};
/**
* Constructs a parser for a header contained within a binary message starting at the offset.
*
* @param message containing the header
* @param offset to the header within the message
*/
public ARSHeader(BinaryMessage message, int offset)
{
super(message, offset);
}
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("ARS ").append(getPDUType());
if(getPDUType() == ARSPDUType.UNKNOWN)
{
sb.append(" PACKET:").append(getMessage().toHexString());
}
return sb.toString();
}
/**
* Checks that the underlying message is long enough to contain the PDU
*/
private void checkValid()
{
setValid(getMessage().size() >= (getOffset() + getLength() + getPayloadLength()));
}
/**
* Indicates the type of ARS PDU
*/
public ARSPDUType getPDUType()
{
return getPDUType(getMessage(), getOffset());
}
/**
* Indicates the type of ARS PDU contained in the message starting at the offset index.
*/
public static ARSPDUType getPDUType(BinaryMessage message, int offset)
{
return ARSPDUType.fromValue(message.getInt(PDU_TYPE, offset));
}
/**
* Indicates if this message has a header extension byte
*/
public boolean hasHeaderExtension()
{
return getMessage().get(HEADER_EXTENSION_FLAG + getOffset());
}
/**
* Indicates if this is an acknowledgement type PDU
*/
public boolean isAcknowledge()
{
return getMessage().get(ACKNOWLEDGEMENT_FLAG + getOffset());
}
/**
* Indicates if this PDU was sent with the priority flag
*/
public boolean isPriority()
{
return getMessage().get(PRIORITY_FLAG + getOffset());
}
/**
* Indicates if this packet is a control packet (true) or a user packet (false).
*/
public boolean isControl()
{
return getMessage().get(CONTROL_USER_FLAG + getOffset());
}
/**
* Length of the payload
* @return
*/
public int getPayloadLength()
{
return getMessage().getInt(LENGTH, getOffset());
}
/**
* Length of this header in bits
*
* Note this length value includes the first 2 bytes of the message that indicates the overall
* message length and the length of the PDU header byte(s).
*
* This method may need to be overridden if there is more than 1 extension header in a PDU.
*/
@Override
public int getLength()
{
if(hasHeaderExtension())
{
return 16 + 16;
}
else
{
return 16 + 8;
}
}
}

View File

@@ -0,0 +1,50 @@
/*
* ******************************************************************************
* 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.ip.ars;
import io.github.dsheirer.bits.BinaryMessage;
public class ARSHeaderFactory
{
public static ARSHeader create(ARSPDUType pduType, BinaryMessage message, int offset)
{
switch(pduType)
{
case DEVICE_REGISTRATION:
return new DeviceRegistration(message, offset);
case DEVICE_DEREGISTRATION:
return new DeviceDeRegistration(message, offset);
case QUERY:
return new QueryMessage(message, offset);
case USER_REGISTRATION:
return new UserRegistration(message, offset);
case USER_DEREGISTRATION:
return new UserDeRegistration(message, offset);
case USER_REGISTRATION_ACKNOWLEDGEMENT:
return new UserRegistrationAcknowledge(message, offset);
case REGISTRATION_ACKNOWLEDGEMENT:
return new RegistrationAcknowledgement(message, offset);
case UNKNOWN:
default:
return new ARSHeader(message, offset);
}
}
}

View File

@@ -0,0 +1,63 @@
/*
* ******************************************************************************
* 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.ip.ars;
public enum ARSPDUType
{
DEVICE_REGISTRATION(0x0),
DEVICE_DEREGISTRATION(0x1),
QUERY(0x4),
USER_REGISTRATION(0x5),
USER_DEREGISTRATION(0x6),
USER_REGISTRATION_ACKNOWLEDGEMENT(0x7),
REGISTRATION_ACKNOWLEDGEMENT(0xF),
UNKNOWN(-1);
private int mValue;
ARSPDUType(int value)
{
mValue = value;
}
public static ARSPDUType fromValue(int value)
{
switch(value)
{
case 0x0:
return DEVICE_REGISTRATION;
case 0x1:
return DEVICE_DEREGISTRATION;
case 0x4:
return QUERY;
case 0x5:
return USER_REGISTRATION;
case 0x6:
return USER_DEREGISTRATION;
case 0x7:
return USER_REGISTRATION_ACKNOWLEDGEMENT;
case 0xF:
return REGISTRATION_ACKNOWLEDGEMENT;
}
return UNKNOWN;
}
}

View File

@@ -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.ip.ars;
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.module.decode.ip.IPacket;
import io.github.dsheirer.module.decode.ip.Packet;
public class ARSPacket extends Packet
{
private ARSHeader mHeader;
/**
* Constructs a parser for a header contained within a binary message starting at the offset.
*
* @param message containing the packet
* @param offset to the packet within the message
*/
public ARSPacket(BinaryMessage message, int offset)
{
super(message, offset);
}
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("ARS ").append(getHeader());
return sb.toString();
}
@Override
public ARSHeader getHeader()
{
if(mHeader == null)
{
ARSPDUType pduType = ARSHeader.getPDUType(getMessage(), getOffset());
mHeader = ARSHeaderFactory.create(pduType, getMessage(), getOffset());
}
return mHeader;
}
@Override
public IPacket getPayload()
{
//There are no payloads for ARS packets ... the header parses all of the information.
return null;
}
}

View File

@@ -0,0 +1,44 @@
/*
* ******************************************************************************
* 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.ip.ars;
import io.github.dsheirer.bits.BinaryMessage;
public class DeviceDeRegistration extends ARSHeader
{
/**
* Constructs a parser for a header contained within a binary message starting at the offset.
*
* @param message containing the header
* @param offset to the header within the message
*/
public DeviceDeRegistration(BinaryMessage message, int offset)
{
super(message, offset);
}
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("ARS DEVICE/USER DE-REGISTRATION");
return sb.toString();
}
}

View File

@@ -0,0 +1,153 @@
/*
* ******************************************************************************
* 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.ip.ars;
import io.github.dsheirer.bits.BinaryMessage;
public class DeviceRegistration extends ARSHeader
{
private static final int SECOND_HEADER_EXTENSION_FLAG = 24;
private static final int[] EVENT = {25, 26};
private static final int[] ENCODING = {27, 28, 29, 30, 31};
private static final int DEVICE_IDENTIFIER_START = 24;
private static final int DEVICE_IDENTIFIER_START_EXTENDED_HEADER = 32;
private static final int[] BYTE_VALUE = {0, 1, 2, 3, 4, 5, 6, 7};
/**
* Constructs a parser for a header contained within a binary message starting at the offset.
*
* @param message containing the header
* @param offset to the header within the message
*/
public DeviceRegistration(BinaryMessage message, int offset)
{
super(message, offset);
}
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("DEVICE REGISTRATION");
if(isValid())
{
if(hasHeaderExtension())
{
sb.append(isInitialEvent() ? "-INITIAL " : "-REFRESH ");
}
sb.append(" ").append(getPayload());
}
else
{
sb.append(" - ERROR INVALID MESSAGE LENGTH");
}
return sb.toString();
}
/**
* Indicates if this is an initial registration event (true) or refresh event (false)
*/
public boolean isInitialEvent()
{
return getMessage().getInt(EVENT, getOffset()) == 1;
}
/**
* Device, user and password values contained in the registration packet.
*/
public String getPayload()
{
StringBuilder sb = new StringBuilder();
sb.append("DEVICE:");
int pointer = getOffset();
if(hasHeaderExtension())
{
pointer += DEVICE_IDENTIFIER_START_EXTENDED_HEADER;
}
else
{
pointer += DEVICE_IDENTIFIER_START;
}
int identifierSize = getMessage().getInt(BYTE_VALUE, pointer += 8);
if(identifierSize > 0)
{
for(int x = 0; x < identifierSize; x++)
{
sb.append(getCharacter(pointer += 8));
}
}
else
{
sb.append("(none)");
}
sb.append(" USER:");
int userIdentifierSize = getMessage().getInt(BYTE_VALUE, pointer += 8);
if(userIdentifierSize > 0)
{
for(int x = 0; x < userIdentifierSize; x++)
{
sb.append(getCharacter(pointer += 8));
}
}
else
{
sb.append("(none)");
}
sb.append(" PASSWORD:");
int passwordSize = getMessage().getInt(BYTE_VALUE, pointer += 8);
if(passwordSize > 0)
{
for(int x = 0; x < passwordSize; x++)
{
sb.append(getCharacter(pointer += 8));
}
}
else
{
sb.append("(none)");
}
return sb.toString();
}
/**
* Returns a UTF-8 encoded character that starts at the specified offset
*
* @param offset of the start of the 8-bit UTF-8 encoded character
* @return character
*/
private char getCharacter(int offset)
{
return (char)getMessage().getByte(BYTE_VALUE, offset);
}
}

View File

@@ -0,0 +1,44 @@
/*
* ******************************************************************************
* 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.ip.ars;
import io.github.dsheirer.bits.BinaryMessage;
public class DeviceRegistrationAcknowledge extends ARSHeader
{
/**
* Constructs a parser for a header contained within a binary message starting at the offset.
*
* @param message containing the header
* @param offset to the header within the message
*/
public DeviceRegistrationAcknowledge(BinaryMessage message, int offset)
{
super(message, offset);
}
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("DEVICE REGISTRATION ACKNOWLEDGED");
return sb.toString();
}
}

View File

@@ -0,0 +1,44 @@
/*
* ******************************************************************************
* 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.ip.ars;
import io.github.dsheirer.bits.BinaryMessage;
public class QueryMessage extends ARSHeader
{
/**
* Constructs a parser for a header contained within a binary message starting at the offset.
*
* @param message containing the header
* @param offset to the header within the message
*/
public QueryMessage(BinaryMessage message, int offset)
{
super(message, offset);
}
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("ARS QUERY MESSAGE");
return sb.toString();
}
}

View File

@@ -0,0 +1,96 @@
/*
* ******************************************************************************
* 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.ip.ars;
import io.github.dsheirer.bits.BinaryMessage;
public class RegistrationAcknowledgement extends ARSHeader
{
private static final int[] TIMER_OR_REASON = {25, 26, 27, 28, 29, 30, 31};
/**
* Constructs a parser for a header contained within a binary message starting at the offset.
*
* @param message containing the header
* @param offset to the header within the message
*/
public RegistrationAcknowledgement(BinaryMessage message, int offset)
{
super(message, offset);
}
public String toString()
{
StringBuilder sb = new StringBuilder();
if(isValid())
{
sb.append("REGISTRATION ");
if(isSuccessful())
{
sb.append("SUCCESS");
int units = getPayloadValue();
sb.append(" REFRESH IN:").append(units * 30).append("mins");
}
else
{
sb.append("FAIL");
int units = getPayloadValue();
if(units == 0)
{
sb.append(" - UNAUTHORIZED DEVICE");
}
else
{
sb.append(" REASON:").append(units);
}
}
}
else
{
sb.append("REGISTRATION ACKNOWLEDGE - ERROR - INVALID MESSAGE LENGTH");
}
return sb.toString();
}
/**
* Indicates if the registration succeeded (true) or failed (false)
*/
public boolean isSuccessful()
{
return !isAcknowledge();
}
/**
* Payload value. If successful, this is the number of 30 minute units until a registration
* refresh is required. If unsuccessful, this is the reason (0-unauthorized device).
*/
public int getPayloadValue()
{
return getMessage().getInt(TIMER_OR_REASON, getOffset());
}
}

View File

@@ -0,0 +1,44 @@
/*
* ******************************************************************************
* 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.ip.ars;
import io.github.dsheirer.bits.BinaryMessage;
public class UserDeRegistration extends ARSHeader
{
/**
* Constructs a parser for a header contained within a binary message starting at the offset.
*
* @param message containing the header
* @param offset to the header within the message
*/
public UserDeRegistration(BinaryMessage message, int offset)
{
super(message, offset);
}
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("ARS USER DE-REGISTRATION");
return sb.toString();
}
}

View File

@@ -0,0 +1,44 @@
/*
* ******************************************************************************
* 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.ip.ars;
import io.github.dsheirer.bits.BinaryMessage;
public class UserDeRegistrationAcknowledge extends ARSHeader
{
/**
* Constructs a parser for a header contained within a binary message starting at the offset.
*
* @param message containing the header
* @param offset to the header within the message
*/
public UserDeRegistrationAcknowledge(BinaryMessage message, int offset)
{
super(message, offset);
}
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("ARS USER DE-REGISTRATION ACKNOWLEDGED");
return sb.toString();
}
}

View File

@@ -0,0 +1,140 @@
/*
* ******************************************************************************
* 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.ip.ars;
import io.github.dsheirer.bits.BinaryMessage;
public class UserRegistration extends ARSHeader
{
private static final int HEADER_EXTENSION_FLAG = 24;
private static final int[] EVENT = {25, 26};
private static final int[] ENCODING = {27, 28, 29, 30, 31};
private static final int DEVICE_IDENTIFIER_START = 24;
private static final int DEVICE_IDENTIFIER_START_EXTENDED_HEADER = 32;
private static final int[] BYTE_VALUE = {0, 1, 2, 3, 4, 5, 6, 7};
/**
* Constructs a parser for a header contained within a binary message starting at the offset.
*
* @param message containing the header
* @param offset to the header within the message
*/
public UserRegistration(BinaryMessage message, int offset)
{
super(message, offset);
}
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("USER REGISTRATION");
if(isValid())
{
sb.append(" ").append(getPayload());
}
else
{
sb.append(" - ERROR INVALID MESSAGE LENGTH");
}
return sb.toString();
}
/**
* Device, user and password values contained in the registration packet.
*/
public String getPayload()
{
StringBuilder sb = new StringBuilder();
sb.append("DEVICE:");
int pointer = getOffset();
if(hasHeaderExtension())
{
pointer += DEVICE_IDENTIFIER_START_EXTENDED_HEADER;
}
else
{
pointer += DEVICE_IDENTIFIER_START;
}
int identifierSize = getMessage().getInt(BYTE_VALUE, pointer += 8);
if(identifierSize > 0)
{
for(int x = 0; x < identifierSize; x++)
{
sb.append(getCharacter(pointer += 8));
}
}
else
{
sb.append("(none)");
}
sb.append(" USER:");
int userIdentifierSize = getMessage().getInt(BYTE_VALUE, pointer += 8);
if(userIdentifierSize > 0)
{
for(int x = 0; x < userIdentifierSize; x++)
{
sb.append(getCharacter(pointer += 8));
}
}
else
{
sb.append("(none)");
}
sb.append(" PASSWORD:");
int passwordSize = getMessage().getInt(BYTE_VALUE, pointer += 8);
if(passwordSize > 0)
{
for(int x = 0; x < passwordSize; x++)
{
sb.append(getCharacter(pointer += 8));
}
}
else
{
sb.append("(none)");
}
return sb.toString();
}
/**
* Returns a UTF-8 encoded character that starts at the specified offset
*
* @param offset of the start of the 8-bit UTF-8 encoded character
* @return character
*/
private char getCharacter(int offset)
{
return (char)getMessage().getByte(BYTE_VALUE, offset);
}
}

View File

@@ -0,0 +1,88 @@
/*
* ******************************************************************************
* 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.ip.ars;
import io.github.dsheirer.bits.BinaryMessage;
public class UserRegistrationAcknowledge extends ARSHeader
{
private static final int[] SESSION_TIME_OR_REASON = {25, 26, 27, 28, 29, 30, 31};
/**
* Constructs a parser for a header contained within a binary message starting at the offset.
*
* @param message containing the header
* @param offset to the header within the message
*/
public UserRegistrationAcknowledge(BinaryMessage message, int offset)
{
super(message, offset);
}
public String toString()
{
StringBuilder sb = new StringBuilder();
if(isSuccessful())
{
sb.append("USER REGISTRATION SUCCESS - SESSION TIME:").append(getSessionTime());
}
else
{
sb.append("USER REGISTRATION FAILED - REASON:").append(getFailureReason());
}
return sb.toString();
}
public boolean isSuccessful()
{
return !isAcknowledge();
}
public int getSessionTime()
{
if(hasHeaderExtension())
{
return getMessage().getInt(SESSION_TIME_OR_REASON, getOffset());
}
return 0;
}
public String getFailureReason()
{
if(hasHeaderExtension())
{
int reason = getMessage().getInt(SESSION_TIME_OR_REASON, getOffset());
switch(reason)
{
case 0x01:
return "USER VALIDATION FAILED";
case 0x02:
return "USER VALIDATION TIMEOUT";
default:
return "TRANSMISSION FAILURE";
}
}
return "NONE";
}
}

View File

@@ -0,0 +1,161 @@
/*
* ******************************************************************************
* 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.ip.ipv4;
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.identifier.ipv4.IPV4Identifier;
import io.github.dsheirer.module.decode.ip.Header;
import io.github.dsheirer.module.decode.ip.IPProtocol;
import io.github.dsheirer.module.decode.p25.identifier.ipv4.APCO25IpAddress;
public class IPV4Header extends Header
{
private static final int[] VERSION = {0, 1, 2, 3};
private static final int[] HEADER_LENGTH = {4, 5, 6, 7};
private static final int[] TOTAL_LENGTH = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
private static final int[] PROTOCOL = {72, 73, 74, 75, 76, 77, 78, 79};
private static final int[] FROM_ADDRESS = {96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127};
private static final int[] TO_ADDRESS = {128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159};
private IPV4Identifier mFromAddress;
private IPV4Identifier mToAddress;
public IPV4Header(BinaryMessage message, int offset)
{
super(message, offset);
checkValid();
}
/**
* Performs simple header and packet length validations relative to the packet offset within the binary message.
*/
private void checkValid()
{
int headerLength = getLength();
if(headerLength < 40)
{
setValid(false);
return;
}
if(getMessage().size() < headerLength + getOffset())
{
setValid(false);
return;
}
int totalLength = getTotalLength();
if(totalLength < headerLength)
{
setValid(false);
return;
}
if(getMessage().size() < totalLength + getOffset())
{
setValid(false);
return;
}
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("IP FROM:").append(getFromAddress());
sb.append(" TO:").append(getToAddress());
return sb.toString();
}
/**
* Determines the IP version of the packet that starts at the indicated offset within the binary message.
*
* @param message message containing an IP packet
* @param offset to the start of the packet within the binary message
* @return
*/
public static int getIPVersion(BinaryMessage message, int offset)
{
return message.getInt(VERSION, offset);
}
/**
* IP Version of this packet
*/
public int getIPVersion()
{
return getIPVersion(getMessage(), getOffset());
}
/**
* Length of this IPV4 header in bits (NOT BYTES)
*/
public int getLength()
{
return getMessage().getInt(HEADER_LENGTH, getOffset()) * 32;
}
/**
* Total Length of this IPV4 packet in bits (NOT BYTES)
*/
public int getTotalLength()
{
return getMessage().getInt(TOTAL_LENGTH, getOffset()) * 8;
}
/**
* Protocol for the payload being carried by this IP packet
*/
public IPProtocol getProtocol()
{
return IPProtocol.fromValue(getMessage().getInt(PROTOCOL, getOffset()));
}
/**
* From IP Address
*/
public IPV4Identifier getFromAddress()
{
if(mFromAddress == null)
{
mFromAddress = APCO25IpAddress.createFrom(getMessage().getInt(FROM_ADDRESS, getOffset()));
}
return mFromAddress;
}
/**
* To IP Address
*/
public IPV4Identifier getToAddress()
{
if(mToAddress == null)
{
mToAddress = APCO25IpAddress.createTo(getMessage().getInt(TO_ADDRESS, getOffset()));
}
return mToAddress;
}
}

View File

@@ -0,0 +1,112 @@
/*
* ******************************************************************************
* 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.ip.ipv4;
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.module.decode.ip.IPacket;
import io.github.dsheirer.module.decode.ip.Packet;
import io.github.dsheirer.module.decode.ip.PacketMessageFactory;
import io.github.dsheirer.module.decode.ip.UnknownPacket;
/**
* IPV4 packet
*/
public class IPV4Packet extends Packet
{
private IPV4Header mHeader;
private IPacket mPayload;
/**
* Constructs an IPV4 packet parser
*
* @param message containing an IPV4 packet
* @param offset to the start of the packet within the binary message
*/
public IPV4Packet(BinaryMessage message, int offset)
{
super(message, offset);
}
public String toString()
{
StringBuilder sb = new StringBuilder();
if(getHeader().isValid())
{
sb.append(getHeader());
}
else
{
sb.append("IPV4 - INVALID HEADER");
sb.append(" HDR:").append(getHeader().getMessage().toHexString());
}
if(hasPayload())
{
if(getPayload() instanceof UnknownPacket)
{
sb.append(" PROTOCOL:").append(getHeader().getProtocol());
}
sb.append(" ").append(getPayload().toString());
}
else
{
sb.append(" NO PAYLOAD!");
}
return sb.toString();
}
@Override
public IPV4Header getHeader()
{
if(mHeader == null)
{
mHeader = new IPV4Header(getMessage(), getOffset());
}
return mHeader;
}
/**
* Payload packet for this IP packet.
*
* @return payload packet or null
*/
@Override
public IPacket getPayload()
{
if(mPayload == null)
{
if(getHeader().isValid())
{
mPayload = PacketMessageFactory.create(getHeader().getProtocol(), getMessage(),
getOffset() + getHeader().getLength());
}
else
{
mPayload = new UnknownPacket(getMessage(), getOffset());
}
}
return mPayload;
}
}

View File

@@ -0,0 +1,78 @@
/*
* ******************************************************************************
* 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.ip.udp;
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.module.decode.ip.Header;
public class UDPHeader extends Header
{
private static final int[] SOURCE_PORT = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
private static final int[] DESTINATION_PORT = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
/**
* Constructs a parser for a header contained within a binary message starting at the offset.
*
* @param message containing the header
* @param offset to the header within the message
*/
public UDPHeader(BinaryMessage message, int offset)
{
super(message, offset);
checkValid();
}
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("UDP PORT FROM:").append(getSourcePort());
sb.append(" TO:").append(getDestinationPort());
return sb.toString();
}
private void checkValid()
{
setValid(getMessage().size() >= getOffset() + getLength());
}
@Override
public int getLength()
{
return 64;
}
/**
* Source UDP port number
* @return
*/
public int getSourcePort()
{
return getMessage().getInt(SOURCE_PORT, getOffset());
}
/**
* Destination UDP port number
*/
public int getDestinationPort()
{
return getMessage().getInt(DESTINATION_PORT, getOffset());
}
}

View File

@@ -0,0 +1,88 @@
/*
* ******************************************************************************
* 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.ip.udp;
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.module.decode.ip.IPacket;
import io.github.dsheirer.module.decode.ip.Packet;
import io.github.dsheirer.module.decode.ip.PacketMessageFactory;
import io.github.dsheirer.module.decode.ip.UnknownPacket;
public class UDPPacket extends Packet
{
private UDPHeader mHeader;
private IPacket mPayload;
/**
* Constructs a parser for a header contained within a binary message starting at the offset.
*
* @param message containing the packet
* @param offset to the packet within the message
*/
public UDPPacket(BinaryMessage message, int offset)
{
super(message, offset);
}
public String toString()
{
StringBuilder sb = new StringBuilder();
if(getHeader().isValid())
{
sb.append(getHeader());
}
else
{
sb.append("INVALID HEADER");
}
sb.append(" ").append(getPayload());
return sb.toString();
}
@Override
public UDPHeader getHeader()
{
if(mHeader == null)
{
mHeader = new UDPHeader(getMessage(), getOffset());
}
return mHeader;
}
@Override
public IPacket getPayload()
{
if(mPayload == null && getHeader().isValid())
{
mPayload = PacketMessageFactory.createUDPPayload(getHeader().getDestinationPort(), getMessage(), getOffset() + getHeader().getLength());
}
else
{
//Set the offset to the message offset plus 64 bits for UDP header
mPayload = new UnknownPacket(getMessage(), getOffset() + 64);
}
return mPayload;
}
}

View File

@@ -0,0 +1,52 @@
/*
* ******************************************************************************
* 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.lj1200;
/**
* LoJack Function and Reply Code
*/
public class FunctionAndReplyCode
{
private LJ1200Message.Function mFunction;
private String mReplyCode;
public FunctionAndReplyCode(LJ1200Message.Function function, String replyCode)
{
mFunction = function;
mReplyCode = replyCode;
}
public LJ1200Message.Function getFunction()
{
return mFunction;
}
public String getReplyCode()
{
return mReplyCode;
}
@Override
public String toString()
{
return "FUNCTION:" + mFunction + " REPLY CODE:" + mReplyCode;
}
}

View File

@@ -0,0 +1,46 @@
/*
* ******************************************************************************
* 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.lj1200;
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.protocol.Protocol;
public class FunctionAndReplyCodeIdentifier extends Identifier<FunctionAndReplyCode>
{
public FunctionAndReplyCodeIdentifier(FunctionAndReplyCode functionAndReplyCode)
{
super(functionAndReplyCode, IdentifierClass.NETWORK, Form.LOJACK, Role.TO);
}
@Override
public Protocol getProtocol()
{
return Protocol.LOJACK;
}
public static FunctionAndReplyCodeIdentifier create(LJ1200Message.Function function, String replyCode)
{
return new FunctionAndReplyCodeIdentifier(new FunctionAndReplyCode(function, replyCode));
}
}

View File

@@ -1,20 +1,22 @@
/*******************************************************************************
* 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/>
******************************************************************************/
/*
* ******************************************************************************
* 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.lj1200;
import io.github.dsheirer.alias.Alias;
@@ -24,36 +26,26 @@ import io.github.dsheirer.module.decode.event.CallEvent;
public class LJ1200CallEvent extends CallEvent
{
public LJ1200CallEvent( CallEventType callEventType,
AliasList aliasList,
String fromID,
String toID,
String details )
public LJ1200CallEvent(CallEventType callEventType, AliasList aliasList, String fromID, String toID, String details)
{
super( DecoderType.LJ_1200, callEventType,
aliasList, fromID, toID, details );
super(DecoderType.LJ_1200, callEventType, aliasList, fromID, toID, details);
}
private Alias getAlias( String ident )
private Alias getAlias(String ident)
{
if( hasAliasList() )
{
return getAliasList().getFleetsyncAlias( ident );
}
return null;
}
@Override
public Alias getFromIDAlias()
{
return getAlias( getFromID() );
return getAlias(getFromID());
}
@Override
public Alias getToIDAlias()
{
return getAlias( getToID() );
return getAlias(getToID());
}
@Override
@@ -79,30 +71,30 @@ public class LJ1200CallEvent extends CallEvent
private String mToID;
private String mDetails;
public Builder( CallEventType callEventType )
public Builder(CallEventType callEventType)
{
mCallEventType = callEventType;
}
public Builder aliasList( AliasList aliasList )
public Builder aliasList(AliasList aliasList)
{
mAliasList = aliasList;
return this;
}
public Builder from( String val )
public Builder from(String val)
{
mFromID = val;
return this;
}
}
public Builder details( String details )
public Builder details(String details)
{
mDetails = details;
return this;
}
public Builder to( String toID )
public Builder to(String toID)
{
mToID = toID;
return this;
@@ -110,29 +102,25 @@ public class LJ1200CallEvent extends CallEvent
public LJ1200CallEvent build()
{
return new LJ1200CallEvent( this );
return new LJ1200CallEvent(this);
}
}
/**
* Private constructor for the builder
*/
private LJ1200CallEvent( Builder builder )
private LJ1200CallEvent(Builder builder)
{
this( builder.mCallEventType,
builder.mAliasList,
builder.mFromID,
builder.mToID,
builder.mDetails );
this(builder.mCallEventType,
builder.mAliasList,
builder.mFromID,
builder.mToID,
builder.mDetails);
}
public static LJ1200CallEvent getLJ1200Event( LJ1200Message message )
public static LJ1200CallEvent getLJ1200Event(LJ1200Message message)
{
CallEventType type = CallEventType.COMMAND;
return new LJ1200CallEvent.Builder( type )
.to( message.getAddress() )
.details( message.getMessage() )
.build();
return new LJ1200CallEvent.Builder(type).to(message.getAddress()).details(message.toString()).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.lj1200;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.bits.IBinarySymbolProcessor;
import io.github.dsheirer.bits.MessageFramer;
import io.github.dsheirer.bits.SyncPattern;
@@ -35,26 +38,26 @@ public class LJ1200Decoder extends AbstractAFSKDecoder implements IBinarySymbolP
private MessageFramer mTransponderMessageFramer;
private LJ1200MessageProcessor mMessageProcessor;
protected LJ1200Decoder(AFSK1200Decoder decoder, AliasList aliasList)
protected LJ1200Decoder(AFSK1200Decoder decoder)
{
super(decoder);
init(aliasList);
init();
}
public LJ1200Decoder(AliasList aliasList)
public LJ1200Decoder()
{
super(AFSK1200Decoder.Output.NORMAL);
init(aliasList);
init();
}
private void init(AliasList aliasList)
private void init()
{
getDecoder().setSymbolProcessor(this);
mTowerMessageFramer = new MessageFramer(SyncPattern.LJ1200.getPattern(), MESSAGE_LENGTH);
mTransponderMessageFramer = new MessageFramer(SyncPattern.LJ1200_TRANSPONDER.getPattern(), MESSAGE_LENGTH);
mMessageProcessor = new LJ1200MessageProcessor(aliasList);
mMessageProcessor = new LJ1200MessageProcessor();
mTowerMessageFramer.addMessageListener(mMessageProcessor);
mTransponderMessageFramer.addMessageListener(mMessageProcessor);
mMessageProcessor.setMessageListener(getMessageListener());
@@ -74,10 +77,10 @@ public class LJ1200Decoder extends AbstractAFSKDecoder implements IBinarySymbolP
}
@Override
public void receive(boolean symbol)
public void process(boolean symbol)
{
mTowerMessageFramer.receive(symbol);
mTransponderMessageFramer.receive(symbol);
mTowerMessageFramer.process(symbol);
mTransponderMessageFramer.process(symbol);
}
public MessageFramer getTowerMessageFramer()

View File

@@ -29,7 +29,7 @@ public class LJ1200DecoderInstrumented extends LJ1200Decoder implements IInstrum
public LJ1200DecoderInstrumented()
{
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,20 +15,19 @@
*
* 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.lj1200;
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.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.module.decode.event.DecodeEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,14 +43,8 @@ public class LJ1200DecoderState extends DecoderState
private Set<String> mAddresses = new TreeSet<String>();
private AliasedStringAttributeMonitor mAddressAttribute;
public LJ1200DecoderState(AliasList aliasList)
public LJ1200DecoderState()
{
super(aliasList);
mAddressAttribute = new AliasedStringAttributeMonitor(Attribute.SECONDARY_ADDRESS_TO,
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.SITE);
}
@Override
@@ -60,27 +54,49 @@ public class LJ1200DecoderState extends DecoderState
}
@Override
public void receive(Message message)
public void receive(IMessage message)
{
if(message instanceof LJ1200Message)
{
LJ1200Message lj = (LJ1200Message) message;
LJ1200Message lj = (LJ1200Message)message;
if(lj.isValid())
{
String address = lj.getAddress();
mAddressAttribute.process(address);
mAddresses.add(address);
broadcast(LJ1200CallEvent.getLJ1200Event(lj));
MutableIdentifierCollection ic = new MutableIdentifierCollection(getIdentifierCollection().getIdentifiers());
ic.remove(IdentifierClass.USER);
ic.update(lj.getIdentifiers());
DecodeEvent event = DecodeEvent.builder(System.currentTimeMillis())
.identifiers(ic)
.channel(getCurrentChannel())
.details("LOJACK")
.eventDescription(lj.toString())
.build();
broadcast(event);
broadcast(new DecoderStateEvent(this, Event.DECODE, State.DATA));
}
}
else if(message instanceof LJ1200TransponderMessage)
{
LJ1200TransponderMessage transponder = (LJ1200TransponderMessage)message;
MutableIdentifierCollection ic = new MutableIdentifierCollection(getIdentifierCollection().getIdentifiers());
ic.remove(IdentifierClass.USER);
ic.update(transponder.getIdentifiers());
DecodeEvent transponderEvent = DecodeEvent.builder(System.currentTimeMillis())
.identifiers(ic)
.channel(getCurrentChannel())
.details("LOJACK TRANSPONDER")
.eventDescription(transponder.toString())
.build();
broadcast(transponderEvent);
}
}
@@ -120,9 +136,9 @@ public class LJ1200DecoderState extends DecoderState
}
}
private void resetState()
protected void resetState()
{
mAddressAttribute.reset();
super.resetState();
}
@Override

View File

@@ -1,29 +1,30 @@
/*******************************************************************************
* 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.lj1200;
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.edac.CRCLJ;
import io.github.dsheirer.map.Plottable;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.esn.ESNIdentifier;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.protocol.Protocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,388 +33,305 @@ import java.util.List;
public class LJ1200Message extends Message
{
private final static Logger mLog = LoggerFactory.getLogger( LJ1200Message.class );
public static final String[] REPLY_CODE = { "0","1","2","3","4","5","6","7",
"8","9","A","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S",
"T","U","V","W","X","Y" };
private final static Logger mLog = LoggerFactory.getLogger(LJ1200Message.class);
public static int[] SYNC = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };
public static final String[] REPLY_CODE = {"0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "A", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S",
"T", "U", "V", "W", "X", "Y"};
public static int[] VRC = { 23,22,21,20,19,18,17,16 };
public static int[] LRC = { 31,30,29,28,27,26,25,24 };
public static int[] SYNC = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
public static int[] VRC = {23, 22, 21, 20, 19, 18, 17, 16};
public static int[] LRC = {31, 30, 29, 28, 27, 26, 25, 24};
public static int[] FUNCTION = {35, 34, 33, 32};
public static int[] ADDRESS = {63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43,
42, 41, 40, 39, 38, 37, 36};
public static int[] REPLY_1 = {39, 38, 37, 36, 43};
public static int[] REPLY_2 = {42, 41, 40, 47, 46};
public static int[] REPLY_3 = {45, 44, 51, 50, 49};
public static int[] REPLY_4 = {48, 55, 54, 53, 52};
public static int[] REPLY_5 = {59, 58, 57, 56, 63};
public static int[] FUNCTION = { 35,34,33,32 };
public static int[] MESSAGE_CRC = {79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64};
public static int[] ADDRESS = { 63,62,61,60,59,58,57,56,55,54,53,52,51,50,
49,48,47,46,45,44,43,42,41,40,39,38,37,36 };
public static int[] REPLY_1 = { 39,38,37,36,43 };
public static int[] REPLY_2 = { 42,41,40,47,46 };
public static int[] REPLY_3 = { 45,44,51,50,49 };
public static int[] REPLY_4 = { 48,55,54,53,52 };
public static int[] REPLY_5 = { 59,58,57,56,63 };
public static int[] MESSAGE_CRC = { 79,78,77,76,75,74,73,72,71,70,69,68,67,
66,65,64 };
private BinaryMessage mMessage;
private AliasList mAliasList;
private CRC mCRC;
public LJ1200Message( BinaryMessage message, AliasList list )
private FunctionAndReplyCodeIdentifier mFunctionAndReplyCodeIdentifier;
private ESNIdentifier mTransponderIdentifier;
private List<Identifier> mIdentifiers;
public LJ1200Message(BinaryMessage message)
{
mMessage = message;
mAliasList = list;
mMessage = message;
checkCRC();
switch( mCRC )
switch(mCRC)
{
case CORRECTED:
mLog.debug( "CORR:" + message.toString() );
break;
case FAILED_CRC:
mLog.debug( "FAIL:" + message.toString() );
break;
case PASSED:
mLog.debug( "PASS:" + message.toString() );
break;
default:
break;
case CORRECTED:
mLog.debug("CORR:" + message.toString());
break;
case FAILED_CRC:
mLog.debug("FAIL:" + message.toString());
break;
case PASSED:
mLog.debug("PASS:" + message.toString());
break;
default:
break;
}
}
private void checkCRC()
{
mCRC = CRCLJ.checkAndCorrect( mMessage );
mCRC = CRCLJ.checkAndCorrect(mMessage);
}
public boolean isValid()
{
return mCRC == CRC.PASSED || mCRC == CRC.CORRECTED;
return mCRC == CRC.PASSED || mCRC == CRC.CORRECTED;
}
public FunctionAndReplyCodeIdentifier getFunctionAndReplyCodeIdentifier()
{
if(mFunctionAndReplyCodeIdentifier == null)
{
mFunctionAndReplyCodeIdentifier = FunctionAndReplyCodeIdentifier.create(getFunction(), getReplyCode());
}
return mFunctionAndReplyCodeIdentifier;
}
public ESNIdentifier getTransponder()
{
if(mTransponderIdentifier == null)
{
mTransponderIdentifier = ESNIdentifier.create(getAddress(), Protocol.LOJACK, Role.TO);
}
return mTransponderIdentifier;
}
public String getVRC()
{
return mMessage.getHex( VRC, 2 );
return mMessage.getHex(VRC, 2);
}
public String getLRC()
{
return mMessage.getHex( LRC, 2 );
return mMessage.getHex(LRC, 2);
}
public String getCRC()
{
return mMessage.getHex( MESSAGE_CRC, 4 );
return mMessage.getHex(MESSAGE_CRC, 4);
}
public Function getFunction()
{
return Function.fromValue( mMessage.getInt( FUNCTION ),
mMessage.getInt( REPLY_3 ) );
return Function.fromValue(mMessage.getInt(FUNCTION), mMessage.getInt(REPLY_3));
}
public String getAddress()
{
return mMessage.getHex( ADDRESS, 7 );
}
public Alias getTransponderAlias()
{
if( mAliasList != null )
{
return mAliasList.getESNAlias( getAddress() );
}
return null;
}
public Alias getFunctionAndIDAlias()
{
if( mAliasList != null )
{
return mAliasList.getLoJackAlias( getFunction(), getReplyCode() );
}
return null;
return mMessage.getHex(ADDRESS, 7);
}
/**
* 5 character reply code for function E and F, transponder activation.
*
* @return - reply code
*/
public String getReplyCode()
{
StringBuilder sb = new StringBuilder();
sb.append( REPLY_CODE[ mMessage.getInt( REPLY_1 ) ] );
sb.append( REPLY_CODE[ mMessage.getInt( REPLY_2 ) ] );
sb.append( REPLY_CODE[ mMessage.getInt( REPLY_3 ) ] );
sb.append( REPLY_CODE[ mMessage.getInt( REPLY_4 ) ] );
sb.append( REPLY_CODE[ mMessage.getInt( REPLY_5 ) ] );
return sb.toString();
StringBuilder sb = new StringBuilder();
sb.append(REPLY_CODE[mMessage.getInt(REPLY_1)]);
sb.append(REPLY_CODE[mMessage.getInt(REPLY_2)]);
sb.append(REPLY_CODE[mMessage.getInt(REPLY_3)]);
sb.append(REPLY_CODE[mMessage.getInt(REPLY_4)]);
sb.append(REPLY_CODE[mMessage.getInt(REPLY_5)]);
return sb.toString();
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
StringBuilder sb = new StringBuilder();
Function function = getFunction();
sb.append( "FUNCTION: " );
sb.append( function.toString() );
Function function = getFunction();
switch( function )
{
case F1_SITE_ID:
sb.append( " SITE [" );
break;
case F1_SPEED_UP:
case F2_TEST:
case F3_DEACTIVATE:
case F4_ACTIVATE:
case FF_TRACK_PULSE:
default:
sb.append( " REPLY CODE [" );
break;
}
sb.append( getReplyCode() );
sb.append("FUNCTION: ");
sb.append(function.toString());
Alias site = getFunctionAndIDAlias();
if( site != null )
{
sb.append( "/" );
sb.append( site.getName() );
}
sb.append( "] ADDRESS [" );
sb.append( getAddress() );
sb.append( "] VRC [" + getVRC() );
sb.append( "] LRC [" + getLRC() );
sb.append( "] CRC [" + getCRC() );
sb.append( "]" );
switch(function)
{
case F1_SITE_ID:
sb.append(" SITE [");
break;
case F1_SPEED_UP:
case F2_TEST:
case F3_DEACTIVATE:
case F4_ACTIVATE:
case FF_TRACK_PULSE:
default:
sb.append(" REPLY CODE [");
break;
}
return sb.toString();
sb.append(getReplyCode());
sb.append("] ADDRESS [");
sb.append(getAddress());
sb.append("] VRC [" + getVRC());
sb.append("] LRC [" + getLRC());
sb.append("] CRC [" + getCRC());
sb.append("]");
return sb.toString();
}
/**
* 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();
}
@Override
public String getBinaryMessage()
{
return mMessage.toString();
}
for(int x = 0; x < paddingRequired; x++)
{
sb.append("0");
}
@Override
public String getProtocol()
{
return "LJ-1200";
sb.append(number);
return sb.toString();
}
@Override
public String getEventType()
@Override
public Protocol getProtocol()
{
if( getFunction() == Function.F1_SPEED_UP )
{
return "TRANSPONDER";
}
return "TOWER";
return Protocol.LOJACK;
}
@Override
public String getFromID()
public enum Function
{
return getReplyCode();
/* Big Endian Format */
F0_UNKNOWN("0-UNKNOWN"),
F1_SITE_ID("1Y-SITE ID"),
F1_SPEED_UP("1-SPEED UP"),
F2_TEST("2-TOWER TEST"),
F3_DEACTIVATE("3-DEACTIVATE"),
F4_ACTIVATE("4-ACTIVATE"),
F5_TRANSPONDER_TEST_REPLY("5-TRANSPONDER TEST REPLY"),
F6_TRANSPONDER_TEST_COMMAND("6-TRANSPONDER TEST COMMAND"),
F7_QUIET_COMMAND("7-QUIET COMMAND"),
F8_UNKNOWN("8-UNKNOWN"),
F9_UNKNOWN("9-UNKNOWN"),
FA_UNKNOWN("A-UNKNOWN"),
FB_UNKNOWN("B-UNKNOWN"),
FC_ALT_DEACTIVATE("C-ALT-DEACTIVATE"),
FD_UNKNOWN("D-UNKNOWN"),
FE_UNKNOWN("E-UNKNOWN"),
FF_TRACK_PULSE("F-TRACK PULSE"),
UNKNOWN("UNKNOWN");
private String mLabel;
private Function(String label)
{
mLabel = label;
}
public String getLabel()
{
return mLabel;
}
public String toString()
{
return getLabel();
}
public static Function fromValue(int value, int replyCodeDigit3)
{
switch(value)
{
case 0:
return Function.F0_UNKNOWN;
case 1:
if(replyCodeDigit3 == 31) /* 'Y' middle character */
{
return Function.F1_SITE_ID;
}
else
{
return Function.F1_SPEED_UP;
}
case 2:
return Function.F2_TEST;
case 3:
return Function.F3_DEACTIVATE;
case 4:
return Function.F4_ACTIVATE;
case 5:
return Function.F5_TRANSPONDER_TEST_REPLY;
case 6:
return Function.F6_TRANSPONDER_TEST_COMMAND;
case 7:
return Function.F7_QUIET_COMMAND;
case 8:
return Function.F8_UNKNOWN;
case 9:
return Function.F9_UNKNOWN;
case 10:
return Function.FA_UNKNOWN;
case 11:
return Function.FB_UNKNOWN;
case 12:
return Function.FC_ALT_DEACTIVATE;
case 13:
return Function.FD_UNKNOWN;
case 14:
return Function.FE_UNKNOWN;
case 15:
return Function.FF_TRACK_PULSE;
default:
return Function.UNKNOWN;
}
}
}
@Override
public Alias getFromIDAlias()
@Override
public List<Identifier> getIdentifiers()
{
return getFunctionAndIDAlias();
}
if(mIdentifiers == null)
{
mIdentifiers = new ArrayList<>();
mIdentifiers.add(getFunctionAndReplyCodeIdentifier());
mIdentifiers.add(getTransponder());
}
@Override
public String getToID()
{
return getAddress();
}
@Override
public Alias getToIDAlias()
{
return null;
return mIdentifiers;
}
@Override
public String getMessage()
{
return toString();
}
@Override
public String getErrorStatus()
{
return mCRC.getDisplayText();
}
@Override
public Plottable getPlottable()
{
return null;
}
public enum Function
{
/* Big Endian Format */
F0_UNKNOWN( "0-UNKNOWN" ),
F1_SITE_ID( "1Y-SITE ID" ),
F1_SPEED_UP( "1-SPEED UP" ),
F2_TEST( "2-TOWER TEST" ),
F3_DEACTIVATE( "3-DEACTIVATE" ),
F4_ACTIVATE( "4-ACTIVATE" ),
F5_TRANSPONDER_TEST_REPLY( "5-TRANSPONDER TEST REPLY" ),
F6_TRANSPONDER_TEST_COMMAND( "6-TRANSPONDER TEST COMMAND" ),
F7_QUIET_COMMAND( "7-QUIET COMMAND" ),
F8_UNKNOWN( "8-UNKNOWN" ),
F9_UNKNOWN( "9-UNKNOWN" ),
FA_UNKNOWN( "A-UNKNOWN" ),
FB_UNKNOWN( "B-UNKNOWN" ),
FC_ALT_DEACTIVATE( "C-ALT-DEACTIVATE" ),
FD_UNKNOWN( "D-UNKNOWN" ),
FE_UNKNOWN( "E-UNKNOWN" ),
FF_TRACK_PULSE( "F-TRACK PULSE" ),
UNKNOWN( "UNKNOWN" );
private String mLabel;
private Function( String label )
{
mLabel = label;
}
public String getLabel()
{
return mLabel;
}
public String toString()
{
return getLabel();
}
public static Function fromValue( int value, int replyCodeDigit3 )
{
switch( value )
{
case 0:
return Function.F0_UNKNOWN;
case 1:
if( replyCodeDigit3 == 31 ) /* 'Y' middle character */
{
return Function.F1_SITE_ID;
}
else
{
return Function.F1_SPEED_UP;
}
case 2:
return Function.F2_TEST;
case 3:
return Function.F3_DEACTIVATE;
case 4:
return Function.F4_ACTIVATE;
case 5:
return Function.F5_TRANSPONDER_TEST_REPLY;
case 6:
return Function.F6_TRANSPONDER_TEST_COMMAND;
case 7:
return Function.F7_QUIET_COMMAND;
case 8:
return Function.F8_UNKNOWN;
case 9:
return Function.F9_UNKNOWN;
case 10:
return Function.FA_UNKNOWN;
case 11:
return Function.FB_UNKNOWN;
case 12:
return Function.FC_ALT_DEACTIVATE;
case 13:
return Function.FD_UNKNOWN;
case 14:
return Function.FE_UNKNOWN;
case 15:
return Function.FF_TRACK_PULSE;
default:
return Function.UNKNOWN;
}
}
}
/**
* Provides a listing of aliases contained in the message.
*/
public List<Alias> getAliases()
{
List<Alias> aliases = new ArrayList<Alias>();
Alias functionAndID = getFunctionAndIDAlias();
if( functionAndID != null )
{
aliases.add( functionAndID );
}
Alias transponder = getTransponderAlias();
if( transponder != null )
{
aliases.add( transponder );
}
return aliases;
}
}

View File

@@ -1,17 +1,17 @@
/*******************************************************************************
* 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/>
******************************************************************************/
@@ -19,35 +19,34 @@ package io.github.dsheirer.module.decode.lj1200;
import io.github.dsheirer.filter.Filter;
import io.github.dsheirer.filter.FilterElement;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.message.IMessage;
import java.util.Collections;
import java.util.List;
public class LJ1200MessageFilter extends Filter<Message>
public class LJ1200MessageFilter extends Filter<IMessage>
{
public LJ1200MessageFilter()
{
super( "LJ-1200 Message Filter" );
}
@Override
public boolean passes( Message message )
public LJ1200MessageFilter()
{
return mEnabled && canProcess( message );
super("LJ-1200 Message Filter");
}
@Override
public boolean canProcess( Message message )
@Override
public boolean passes(IMessage message)
{
return message instanceof LJ1200Message ||
message instanceof LJ1200TransponderMessage;
return mEnabled && canProcess(message);
}
@Override
@Override
public boolean canProcess(IMessage message)
{
return message instanceof LJ1200Message || message instanceof LJ1200TransponderMessage;
}
@Override
public List<FilterElement<?>> getFilterElements()
{
return Collections.EMPTY_LIST;
return Collections.EMPTY_LIST;
}
}

View File

@@ -1,82 +1,78 @@
/*******************************************************************************
* 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/>
******************************************************************************/
/*
* ******************************************************************************
* 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.lj1200;
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.Listener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LJ1200MessageProcessor implements Listener<BinaryMessage>
public class LJ1200MessageProcessor implements Listener<CorrectedBinaryMessage>
{
private final static Logger mLog =
LoggerFactory.getLogger( LJ1200MessageProcessor.class );
private final static Logger mLog = LoggerFactory.getLogger(LJ1200MessageProcessor.class);
public static int[] SYNC = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };
public static int[] SYNC = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
public static int SYNC_TOWER = 0x550F;
public static int SYNC_TRANSPONDER = 0x2AD5;
public static int SYNC_TOWER = 0x550F;
public static int SYNC_TRANSPONDER = 0x2AD5;
private Listener<Message> mMessageListener;
private AliasList mAliasList;
public LJ1200MessageProcessor( AliasList list )
{
mAliasList = list;
}
public void dispose()
{
mAliasList = null;
mMessageListener = null;
}
@Override
public void receive( BinaryMessage buffer )
private Listener<IMessage> mMessageListener;
public LJ1200MessageProcessor()
{
int sync = buffer.getInt( SYNC );
if( sync == SYNC_TOWER )
{
if( mMessageListener != null )
{
mMessageListener.receive( new LJ1200Message( buffer, mAliasList ) );
}
}
else if( sync == SYNC_TRANSPONDER )
{
if( mMessageListener != null )
{
mMessageListener.receive( new LJ1200TransponderMessage( buffer, mAliasList ) );
}
}
}
public void setMessageListener( Listener<Message> listener )
public void dispose()
{
mMessageListener = listener;
mMessageListener = null;
}
@Override
public void receive(CorrectedBinaryMessage message)
{
int sync = message.getInt(SYNC);
if(sync == SYNC_TOWER)
{
if(mMessageListener != null)
{
mMessageListener.receive(new LJ1200Message(message));
}
}
else if(sync == SYNC_TRANSPONDER)
{
if(mMessageListener != null)
{
mMessageListener.receive(new LJ1200TransponderMessage(message));
}
}
}
public void setMessageListener(Listener<IMessage> listener)
{
mMessageListener = listener;
}
public void removeMessageListener()
{
mMessageListener = null;
mMessageListener = null;
}
}

View File

@@ -1,194 +1,145 @@
/*******************************************************************************
* 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.lj1200;
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.map.Plottable;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.protocol.Protocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.List;
public class LJ1200TransponderMessage extends Message
{
private final static Logger mLog = LoggerFactory.getLogger( LJ1200TransponderMessage.class );
private final static Logger mLog = LoggerFactory.getLogger(LJ1200TransponderMessage.class);
public static int[] SYNC = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };
public static int[] SYNC = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
public static int[] MESSAGE_CRC = { 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79 };
private static SimpleDateFormat mSDF = new SimpleDateFormat( "yyyyMMdd HHmmss" );
public static int[] MESSAGE_CRC = {64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79};
private BinaryMessage mMessage;
private AliasList mAliasList;
private static SimpleDateFormat mSDF = new SimpleDateFormat("yyyyMMdd HHmmss");
private CorrectedBinaryMessage mMessage;
private CRC mCRC;
public LJ1200TransponderMessage( BinaryMessage message, AliasList list )
public LJ1200TransponderMessage(CorrectedBinaryMessage message)
{
mMessage = message;
mAliasList = list;
mMessage = message;
checkCRC();
switch( mCRC )
switch(mCRC)
{
case CORRECTED:
mLog.debug( "CORR:" + message.toString() );
break;
case FAILED_CRC:
mLog.debug( "FAIL:" + message.toString() );
break;
case PASSED:
mLog.debug( "PASS:" + message.toString() );
break;
case UNKNOWN:
mLog.debug( "UNKNOWN:" + message.toString() );
break;
default:
break;
case CORRECTED:
mLog.debug("CORR:" + message.toString());
break;
case FAILED_CRC:
mLog.debug("FAIL:" + message.toString());
break;
case PASSED:
mLog.debug("PASS:" + message.toString());
break;
case UNKNOWN:
mLog.debug("UNKNOWN:" + message.toString());
break;
default:
break;
}
}
private void checkCRC()
{
mCRC = CRC.UNKNOWN;
mCRC = CRC.UNKNOWN;
}
public boolean isValid()
{
// return mCRC == CRC.PASSED || mCRC == CRC.CORRECTED;
/* Override validity check until proper CRC is implemented */
return true;
/* Override validity check until proper CRC is implemented */
return true;
}
public String getCRC()
{
return mMessage.getHex( MESSAGE_CRC, 4 );
return mMessage.getHex(MESSAGE_CRC, 4);
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append( "TRANSPONDER TEST" );
StringBuilder sb = new StringBuilder();
return sb.toString();
sb.append("TRANSPONDER TEST");
return sb.toString();
}
/**
* 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();
}
@Override
public String getBinaryMessage()
{
return mMessage.toString();
}
for(int x = 0; x < paddingRequired; x++)
{
sb.append("0");
}
@Override
public String getProtocol()
{
return "LJ-1200";
sb.append(number);
return sb.toString();
}
@Override
public String getEventType()
@Override
public Protocol getProtocol()
{
return "TRANSPONDER";
return Protocol.LOJACK;
}
@Override
public String getFromID()
@Override
public List<Identifier> getIdentifiers()
{
return null;
}
@Override
public Alias getFromIDAlias()
{
return null;
}
@Override
public String getToID()
{
return null;
}
@Override
public Alias getToIDAlias()
{
return null;
}
@Override
public String getMessage()
{
return toString();
}
@Override
public String getErrorStatus()
{
return mCRC.getDisplayText();
}
@Override
public Plottable getPlottable()
{
return null;
return Collections.EMPTY_LIST;
}
}

View File

@@ -1,212 +0,0 @@
/*******************************************************************************
* 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/>
******************************************************************************/
package io.github.dsheirer.module.decode.ltrnet;
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 LTRCallEvent extends CallEvent
{
private String mChannel;
private long mFrequency;
public LTRCallEvent( DecoderType type,
CallEventType callEventType,
AliasList aliasList,
String fromID,
String toID,
String channel,
long frequency,
String details )
{
super( type, callEventType, aliasList, fromID, toID, details );
mChannel = channel;
mFrequency = frequency;
}
/**
* Checks if the message's talkgroup matches this call event. Counts the
* number of messages that match this call event to use in determining if
* a call event is valid or an isolated (errant) message.
*
* See: isValid()
*/
public boolean isMatchingTalkgroup( LTRNetMessage message )
{
String talkgroup = message.getTalkgroupID();
if( talkgroup != null && getToID() != null &&
talkgroup.contentEquals( getToID() ) )
{
return true;
}
return isMatchingTalkgroup( message.getTalkgroupID() );
}
public boolean isMatchingTalkgroup( String talkgroup )
{
return talkgroup != null && getToID() != null && talkgroup.contentEquals( getToID() );
}
private Alias getAlias(String talkgroup )
{
if( hasAliasList() )
{
return getAliasList().getTalkgroupAlias( talkgroup );
}
return null;
}
@Override
public Alias getFromIDAlias()
{
if( mCallEventType == CallEventType.CALL ||
mCallEventType == CallEventType.REGISTER ||
mCallEventType == CallEventType.ID_UNIQUE )
{
if( hasAliasList() )
{
try
{
int radioID = Integer.parseInt( getFromID() );
return mAliasList.getUniqueID( radioID );
}
catch( Exception e )
{
//Do nothing, we couldn't parse the int radio id value
}
}
}
else if( mCallEventType == CallEventType.REGISTER_ESN )
{
if( hasAliasList() )
{
return mAliasList.getESNAlias( getFromID() );
}
}
else
{
return getAlias( getFromID() );
}
return null;
}
@Override
public Alias getToIDAlias()
{
return getAlias( getToID() );
}
@Override
public String getChannel()
{
return mChannel;
}
@Override
public long getFrequency()
{
return mFrequency;
}
public static class Builder
{
/* Required parameters */
private DecoderType mDecoderType;
private CallEventType mCallEventType;
/* Optional parameters */
private AliasList mAliasList;
private String mFromID;
private String mToID;
private String mDetails;
private String mChannel;
private long mFrequency;
public Builder( DecoderType decoderType, CallEventType callEventType )
{
mDecoderType = decoderType;
mCallEventType = callEventType;
}
public Builder aliasList( AliasList aliasList )
{
mAliasList = aliasList;
return this;
}
public Builder from( String val )
{
mFromID = val;
return this;
}
public Builder channel( String channel )
{
mChannel = channel;
return this;
}
public Builder details( String details )
{
mDetails = details;
return this;
}
public Builder frequency( long frequency )
{
mFrequency = frequency;
return this;
}
public Builder to( String toID )
{
mToID = toID;
return this;
}
public LTRCallEvent build()
{
return new LTRCallEvent( this );
}
}
/**
* Private constructor for the builder
*/
private LTRCallEvent( Builder builder )
{
this( builder.mDecoderType,
builder.mCallEventType,
builder.mAliasList,
builder.mFromID,
builder.mToID,
builder.mChannel,
builder.mFrequency,
builder.mDetails );
}
}

View File

@@ -15,7 +15,6 @@
******************************************************************************/
package io.github.dsheirer.module.decode.ltrnet;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.bits.MessageFramer;
import io.github.dsheirer.bits.SyncPattern;
import io.github.dsheirer.dsp.fsk.LTRDecoder;
@@ -37,7 +36,7 @@ public class LTRNetDecoder extends Decoder implements IReusableBufferListener, L
* LTR-Net Decoder. Decodes unfiltered (e.g. demodulated but with no DC or
* audio filtering) samples and produces LTR-Net messages.
*/
public LTRNetDecoder(DecodeConfigLTRNet config, AliasList aliasList, LTRDecoder ltrDecoder)
public LTRNetDecoder(DecodeConfigLTRNet config, LTRDecoder ltrDecoder)
{
mLTRDecoder = ltrDecoder;
@@ -52,7 +51,7 @@ public class LTRNetDecoder extends Decoder implements IReusableBufferListener, L
mLTRDecoder.setMessageFramer(mLTRMessageFramer);
mLTRMessageFramer.setSyncDetectListener(mLTRDecoder);
mLTRMessageProcessor = new LTRNetMessageProcessor(config.getMessageDirection(), aliasList);
mLTRMessageProcessor = new LTRNetMessageProcessor(config.getMessageDirection());
mLTRMessageFramer.addMessageListener(mLTRMessageProcessor);
mLTRMessageProcessor.setMessageListener(getMessageListener());
}
@@ -61,9 +60,9 @@ public class LTRNetDecoder extends Decoder implements IReusableBufferListener, L
* LTR-Net Decoder. Decodes unfiltered (e.g. demodulated but with no DC or
* audio filtering) samples and produces LTR-Net messages.
*/
public LTRNetDecoder(DecodeConfigLTRNet config, AliasList aliasList)
public LTRNetDecoder(DecodeConfigLTRNet config)
{
this(config, aliasList, new LTRDecoder(LTR_NET_MESSAGE_LENGTH));
this(config, new LTRDecoder(LTR_NET_MESSAGE_LENGTH));
}
@Override

View File

@@ -15,7 +15,6 @@
******************************************************************************/
package io.github.dsheirer.module.decode.ltrnet;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.dsp.fsk.LTRDecoderInstrumented;
import io.github.dsheirer.sample.buffer.ReusableFloatBuffer;
import javafx.beans.property.SimpleIntegerProperty;
@@ -24,9 +23,9 @@ public class LTRNetDecoderInstrumented extends LTRNetDecoder
{
public SimpleIntegerProperty bufferCount = new SimpleIntegerProperty();
public LTRNetDecoderInstrumented(DecodeConfigLTRNet config, AliasList aliasList)
public LTRNetDecoderInstrumented(DecodeConfigLTRNet config)
{
super(config, aliasList, new LTRDecoderInstrumented(LTR_NET_MESSAGE_LENGTH));
super(config, new LTRDecoderInstrumented(LTR_NET_MESSAGE_LENGTH));
}
public LTRDecoderInstrumented getLTRDecoder()

View File

@@ -1,345 +0,0 @@
/*******************************************************************************
* 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/>
******************************************************************************/
package io.github.dsheirer.module.decode.ltrnet;
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.edac.CRCLTR;
import io.github.dsheirer.map.Plottable;
import io.github.dsheirer.message.MessageDirection;
import io.github.dsheirer.message.MessageType;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class LTRNetISWMessage extends LTRNetMessage
{
private static final int sCHIU_UNIQUE_ID = 24;
private static final int sCHIU_ESN_LOW = 27;
private static final int sCHIU_ESN_HIGH = 29;
private static final int sFREE_CALL = 21;
private static final int sFREE_END_CALL = 23;
private static final int sFREE_REQUEST_ACCESS = 31;
private LTRNetISWMessage mAuxMessage;
public LTRNetISWMessage( BinaryMessage message, AliasList list )
{
super( message, MessageDirection.ISW, list );
/**
* If the CRC fails, test for a transmitted CRC of 127 and then check
* the Free field for special messages
*/
if( mCRC == CRC.FAILED_CRC && CRCLTR.getTransmittedChecksum( mMessage ) == 127 )
{
if( getFree() == sFREE_REQUEST_ACCESS ||
getFree() == sFREE_END_CALL )
{
mCRC = CRC.PASSED;
}
}
mMessageType = getMessageType();
}
public void setAuxiliaryMessage( LTRNetISWMessage message )
{
if( message != null )
{
mAuxMessage = message;
}
}
public String getESN()
{
if( mMessageType == MessageType.ID_ESNH )
{
if( mAuxMessage != null &&
mAuxMessage.getMessageType() == MessageType.ID_ESNL )
{
return getESNHigh() + mAuxMessage.getESNLow();
}
else
{
return getESNHigh() + "xxxx";
}
}
else
{
if( mAuxMessage != null &&
mAuxMessage.getMessageType() == MessageType.ID_ESNH )
{
return mAuxMessage.getESNHigh() + getESNLow();
}
else
{
return "xxxx" + getESNLow();
}
}
}
public Alias getESNAlias()
{
if( mAliasList != null )
{
return mAliasList.getESNAlias( getESN() );
}
return null;
}
public String getESNHigh()
{
int esnHigh = getInt( sSIXTEEN_BITS );
return String.format("%04X", esnHigh & 0xFFFF );
}
public String getESNLow()
{
int esnLow = getInt( sSIXTEEN_BITS );
return String.format("%04X", esnLow & 0xFFFF );
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append( mDatestampFormatter.format( new Date( System.currentTimeMillis() ) ) );
sb.append( " LTRNet ISW [" );
sb.append( mCRC.getAbbreviation() );
sb.append( "] " );
sb.append( getMessage() );
pad( sb, 100 );
sb.append( mMessage.toString() );
return sb.toString();
}
@Override
public String getMessage()
{
StringBuilder sb = new StringBuilder();
switch( mMessageType )
{
case CA_STRT:
sb.append( "CALL LCN:" );
sb.append( format( getChannel(), 2 ) );
sb.append( " TG [ " );
sb.append( getTalkgroupID() );
sb.append( "/" );
sb.append( getTalkgroupIDAlias() );
sb.append( " ] FREE:" );
sb.append( format( getFree(), 2 ) );
break;
case CA_ENDD:
sb.append( "END* AREA:" );
sb.append( getArea() );
sb.append( " LCN:" );
sb.append( format( getChannel(), 2 ) );
sb.append( " TG [" );
sb.append( getTalkgroupID() );
sb.append( "/" );
sb.append( getTalkgroupIDAlias() );
sb.append( "] FREE:" );
sb.append( format( getFree(), 2 ) );
break;
case RQ_ACCE:
sb.append( "REQUEST ACCESS LCN:" );
sb.append( format( getChannel(), 2 ) );
sb.append( " TG [ " );
sb.append( getTalkgroupID() );
sb.append( "/" );
sb.append( getTalkgroupIDAlias() );
sb.append( " ] FREE:" );
sb.append( format( getFree(), 2 ) );
break;
case ID_ESNL:
sb.append( "ESN LOW " );
sb.append( getESN() );
sb.append( "/" );
sb.append( getESNAlias() );
break;
case ID_ESNH:
sb.append( "ESN HIGH " );
sb.append( getESN() );
sb.append( "/" );
sb.append( getESNAlias() );
break;
case ID_UNIQ:
sb.append( "RADIO UNIQUE ID " );
sb.append( getRadioUniqueID() );
if( getRadioUniqueIDAlias() != null )
{
sb.append( "/" );
sb.append( getRadioUniqueIDAlias().getName() );
}
break;
default:
sb.append( "UNKNOWN " );
sb.append( getArea() );
sb.append( " " );
sb.append( format( getChannel(), 2 ) );
sb.append( " " );
sb.append( format( getHomeRepeater(), 2 ) );
sb.append( " " );
sb.append( format( getGroup(), 3 ) );
sb.append( " " );
sb.append( format( getFree(), 2 ) );
sb.append( " CRC:" );
sb.append( CRCLTR.getTransmittedChecksum( mMessage ) );
sb.append( " CALC:" );
sb.append( CRCLTR.getCalculatedChecksum( mMessage ) );
}
return sb.toString();
}
public int getRadioUniqueID()
{
int retVal = INT_NULL_VALUE;
if( mMessageType == MessageType.ID_UNIQ )
{
retVal = getInt( sSIXTEEN_BITS );
}
return retVal;
}
public Alias getRadioUniqueIDAlias()
{
if( mAliasList != null )
{
return mAliasList.getUniqueID( getRadioUniqueID() );
}
return null;
}
public MessageType getMessageType()
{
MessageType retVal = MessageType.UN_KNWN;
int channel = getChannel();
if( channel == 31 )
{
retVal = MessageType.CA_ENDD;
}
else if( channel > 20 )
{
switch( channel )
{
case sCHIU_UNIQUE_ID:
retVal = MessageType.ID_UNIQ;
break;
case sCHIU_ESN_LOW:
retVal = MessageType.ID_ESNH;
break;
case sCHIU_ESN_HIGH:
retVal = MessageType.ID_ESNL;
break;
}
}
else if( channel > 0 )
{
int free = getFree();
switch( free )
{
case sFREE_CALL:
retVal = MessageType.CA_STRT;
break;
case sFREE_END_CALL:
retVal = MessageType.CA_ENDD;
break;
case sFREE_REQUEST_ACCESS:
retVal = MessageType.RQ_ACCE;
break;
}
}
return retVal;
}
@Override
public String getFromID()
{
return null;
}
@Override
public Alias getFromIDAlias()
{
return null;
}
@Override
public void setAuxiliaryMessage( LTRNetOSWMessage message )
{
// TODO Auto-generated method stub
}
@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 );
}
Alias esn = getESNAlias();
if( esn != null )
{
aliases.add( esn );
}
return aliases;
}
}

View File

@@ -1,243 +0,0 @@
/*******************************************************************************
* 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/>
******************************************************************************/
package io.github.dsheirer.module.decode.ltrnet;
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.edac.CRCLTR;
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 java.text.DecimalFormat;
import java.text.SimpleDateFormat;
public abstract class LTRNetMessage extends Message
{
protected static final String sUNKNOWN = "**UNKNOWN**";
protected static final int INT_NULL_VALUE = -1;
protected static final double sDOUBLE_NULL_VALUE = -1.0D;
protected SimpleDateFormat mDatestampFormatter =
new SimpleDateFormat( "yyyyMMdd HHmmss" );
protected DecimalFormat mDecimalFormatter = new DecimalFormat("0.00000");
protected static final int[] sSYNC = { 8,7,6,5,4,3,2,1,0 };
protected static final int[] sAREA = { 9 };
protected static final int[] sCHANNEL = { 14,13,12,11,10 };
protected static final int[] sHOME_REPEATER = { 19,18,17,16,15 };
protected static final int[] sGROUP = { 27,26,25,24,23,22,21,20 };
protected static final int[] sFREE = { 32,31,30,29,28 };
protected static final int[] sCRC = { 39,38,37,36,35,34,33 };
protected static final int[] sSIXTEEN_BITS = { 32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17 };
protected static final int[] sMANUFACTURER_ID = { 23,22,21,20,19,18,17 };
protected BinaryMessage mMessage;
protected MessageType mMessageType;
protected CRC mCRC;
protected AliasList mAliasList;
public LTRNetMessage( BinaryMessage message,
MessageDirection direction,
AliasList list )
{
mMessage = message;
mCRC = CRCLTR.check( message, direction );
mAliasList = list;
}
public MessageType getMessageType()
{
return mMessageType;
}
public abstract void setAuxiliaryMessage( LTRNetOSWMessage message );
public boolean isValid()
{
return mCRC != CRC.FAILED_CRC && mCRC != CRC.FAILED_PARITY;
}
/**
* Appends spaces to the end of the stringbuilder to make it length long
*/
protected void pad( StringBuilder sb, int length )
{
while( sb.length() < length )
{
sb.append( " " );
}
}
@Override
public String getBinaryMessage()
{
return mMessage.toString();
}
/**
* Returns a value formatted in hex notation.
*
* @param value - integer value
* @return - hex digits returned
*/
protected static String getHex( int value, int digits )
{
return String.format( "%0" + digits + "X", value );
}
protected 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;
}
/**
* Pads an integer value with additional zeroes to make it decimalPlaces long
*/
public String format( int number, int decimalPlaces )
{
StringBuilder sb = new StringBuilder();
int paddingRequired = decimalPlaces - ( String.valueOf( number ).length() );
for( int x = 0; x < paddingRequired; x++)
{
sb.append( "0" );
}
sb.append( number );
return sb.toString();
}
public String format( String val, int places )
{
StringBuilder sb = new StringBuilder();
sb.append( val );
while( sb.length() < places )
{
sb.append( " " );
}
return sb.toString();
}
public CRC getCRC()
{
return mCRC;
}
public int getArea()
{
return getInt( sAREA );
}
public int getChannel()
{
return getInt( sCHANNEL );
}
public int getHomeRepeater()
{
return getInt( sHOME_REPEATER );
}
public int getGroup()
{
return getInt( sGROUP );
}
public String getTalkgroupID()
{
StringBuilder sb = new StringBuilder();
sb.append( getArea() );
sb.append( "-" );
sb.append( format( getHomeRepeater(), 2 ) );
sb.append( "-" );
sb.append( format( getGroup(), 3 ) );
return sb.toString();
}
public Alias getTalkgroupIDAlias()
{
return mAliasList.getTalkgroupAlias( getTalkgroupID() );
}
public int getFree()
{
return getInt( sFREE );
}
public int getCRCChecksum()
{
return getInt( sCRC );
}
@Override
public String getProtocol()
{
return DecoderType.LTR_NET.getDisplayString();
}
@Override
public String getEventType()
{
if( mMessageType != null )
{
return mMessageType.getDisplayText();
}
else
{
return MessageType.UN_KNWN.getDisplayText();
}
}
@Override
public String getToID()
{
return null;
}
@Override
public Alias getToIDAlias()
{
return null;
}
@Override
public String getErrorStatus()
{
return mCRC.getDisplayText();
}
}

View File

@@ -2,79 +2,53 @@ package io.github.dsheirer.module.decode.ltrnet;
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.ltrnet.message.LtrNetMessage;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class LTRNetMessageFilter extends Filter<Message>
public class LTRNetMessageFilter extends Filter<IMessage>
{
private HashMap<MessageType, FilterElement<MessageType>> mElements =
new HashMap<MessageType, FilterElement<MessageType>>();
public LTRNetMessageFilter()
{
super( "LTR-Net Message Filter" );
private Map<LtrNetMessageType, FilterElement<LtrNetMessageType>> 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 ) );
mElements.put( MessageType.ID_UNIQ,
new FilterElement<MessageType>( MessageType.ID_UNIQ ) );
mElements.put( MessageType.ID_ESNH,
new FilterElement<MessageType>( MessageType.ID_ESNH ) );
mElements.put( MessageType.ID_ESNL,
new FilterElement<MessageType>( MessageType.ID_ESNL ) );
mElements.put( MessageType.RQ_ACCE,
new FilterElement<MessageType>( MessageType.RQ_ACCE ) );
mElements.put( MessageType.ID_SITE,
new FilterElement<MessageType>( MessageType.ID_SITE ) );
mElements.put( MessageType.FQ_RXHI,
new FilterElement<MessageType>( MessageType.FQ_RXHI ) );
mElements.put( MessageType.FQ_RXLO,
new FilterElement<MessageType>( MessageType.FQ_RXLO ) );
mElements.put( MessageType.FQ_TXHI,
new FilterElement<MessageType>( MessageType.FQ_TXHI ) );
mElements.put( MessageType.FQ_TXLO,
new FilterElement<MessageType>( MessageType.FQ_TXLO ) );
mElements.put( MessageType.ID_NBOR,
new FilterElement<MessageType>( MessageType.ID_NBOR ) );
mElements.put( MessageType.MA_CHNH,
new FilterElement<MessageType>( MessageType.MA_CHNH ) );
mElements.put( MessageType.MA_CHNL,
new FilterElement<MessageType>( MessageType.MA_CHNL ) );
}
@Override
public boolean passes( Message message )
public LTRNetMessageFilter()
{
if( mEnabled && canProcess( message ) )
{
LTRNetMessage ltr = (LTRNetMessage)message;
if( mElements.containsKey( ltr.getMessageType() ) )
{
return mElements.get( ltr.getMessageType() ).isEnabled();
}
}
return false;
super("LTR-Net Message Filter");
for(LtrNetMessageType type: LtrNetMessageType.values())
{
mElements.put(type, new FilterElement<>(type));
}
}
@Override
public boolean canProcess( Message message )
@Override
public boolean passes(IMessage message)
{
return message instanceof LTRNetMessage;
if(mEnabled && canProcess(message))
{
LtrNetMessage ltr = (LtrNetMessage) message;
if(mElements.containsKey(ltr.getLtrNetMessageType()))
{
return mElements.get(ltr.getLtrNetMessageType()).isEnabled();
}
}
return false;
}
@Override
@Override
public boolean canProcess(IMessage message)
{
return message instanceof LtrNetMessage;
}
@Override
public List<FilterElement<?>> getFilterElements()
{
return new ArrayList<FilterElement<?>>( mElements.values() );
return new ArrayList<FilterElement<?>>(mElements.values());
}
}

View File

@@ -1,164 +1,132 @@
/*******************************************************************************
* 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.ltrnet;
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.message.MessageDirection;
import io.github.dsheirer.message.MessageType;
import io.github.dsheirer.module.decode.ltrnet.message.LtrNetMessage;
import io.github.dsheirer.module.decode.ltrnet.message.LtrNetMessageFactory;
import io.github.dsheirer.module.decode.ltrnet.message.isw.RegistrationRequestEsnHigh;
import io.github.dsheirer.module.decode.ltrnet.message.isw.RegistrationRequestEsnLow;
import io.github.dsheirer.module.decode.ltrnet.message.osw.ReceiveFrequencyHigh;
import io.github.dsheirer.module.decode.ltrnet.message.osw.ReceiveFrequencyLow;
import io.github.dsheirer.module.decode.ltrnet.message.osw.TransmitFrequencyHigh;
import io.github.dsheirer.module.decode.ltrnet.message.osw.TransmitFrequencyLow;
import io.github.dsheirer.sample.Listener;
import java.util.HashMap;
import java.util.Map;
public class LTRNetMessageProcessor implements Listener<BinaryMessage>
public class LTRNetMessageProcessor implements Listener<CorrectedBinaryMessage>
{
private Listener<Message> mMessageListener;
private Listener<IMessage> mMessageListener;
private HashMap<Integer,LTRNetOSWMessage> mReceiveHighAuxMessages =
new HashMap<Integer,LTRNetOSWMessage>();
private HashMap<Integer,LTRNetOSWMessage> mReceiveLowAuxMessages =
new HashMap<Integer,LTRNetOSWMessage>();
private Map<Integer,ReceiveFrequencyHigh> mReceiveHighMessageMap = new HashMap<>();
private Map<Integer,ReceiveFrequencyLow> mReceiveLowMessageMap = new HashMap<>();
private Map<Integer,TransmitFrequencyHigh> mTransmitHighMessageMap = new HashMap<>();
private Map<Integer,TransmitFrequencyLow> mTransmitLowMessageMap = new HashMap<>();
private HashMap<Integer,LTRNetOSWMessage> mTransmitHighAuxMessages =
new HashMap<Integer,LTRNetOSWMessage>();
private HashMap<Integer,LTRNetOSWMessage> mTransmitLowAuxMessages =
new HashMap<Integer,LTRNetOSWMessage>();
private RegistrationRequestEsnHigh mRegistrationRequestEsnHighMessage;
private RegistrationRequestEsnLow mRegistrationRequestEsnLowMessage;
private LTRNetISWMessage mESNHighMessage;
private LTRNetISWMessage mESNLowMessage;
private MessageDirection mDirection;
private AliasList mAliasList;
public LTRNetMessageProcessor( MessageDirection direction, AliasList list )
{
mDirection = direction;
mAliasList = list;
}
@Override
public void receive( BinaryMessage buffer )
private MessageDirection mDirection;
public LTRNetMessageProcessor(MessageDirection direction)
{
if( mMessageListener != null )
{
LTRNetMessage message;
if( mDirection == MessageDirection.OSW )
{
message = new LTRNetOSWMessage( buffer, mAliasList );
if( message.isValid() )
{
if( message.getMessageType() == MessageType.FQ_TXHI )
{
mTransmitHighAuxMessages.put( message.getHomeRepeater(), (LTRNetOSWMessage)message );
message.setAuxiliaryMessage( mTransmitLowAuxMessages.get(message.getHomeRepeater() ) );
}
else if( message.getMessageType() == MessageType.FQ_TXLO )
{
mTransmitLowAuxMessages.put( message.getHomeRepeater(),
(LTRNetOSWMessage)message );
message.setAuxiliaryMessage( mTransmitHighAuxMessages.get(
message.getHomeRepeater() ) );
}
else if( message.getMessageType() == MessageType.FQ_RXHI )
{
mReceiveHighAuxMessages.put( message.getHomeRepeater(),
(LTRNetOSWMessage)message );
message.setAuxiliaryMessage( mReceiveLowAuxMessages.get(
message.getHomeRepeater() ) );
}
else if( message.getMessageType() == MessageType.FQ_RXLO )
{
mReceiveLowAuxMessages.put( message.getHomeRepeater(),
(LTRNetOSWMessage)message );
message.setAuxiliaryMessage( mReceiveHighAuxMessages.get(
message.getHomeRepeater() ) );
}
}
}
else
{
buffer.flip( 0, 40 );
message = new LTRNetISWMessage( buffer, mAliasList );
if( message.isValid() )
{
/**
* Catch ESN High messages to marry up with ESN Low messages. Purge
* the ESN high message after 2 messages, so that it doesn't get
* paired with the wrong esn low message
*/
if( message.getMessageType() == MessageType.ID_ESNH )
{
mESNHighMessage = (LTRNetISWMessage)message;
if( mESNLowMessage != null )
{
/* Check that the stored message is not older than
* 5 seconds */
if( System.currentTimeMillis() -
mESNLowMessage.getTimeReceived() < 5000 )
{
((LTRNetISWMessage)message).setAuxiliaryMessage( mESNLowMessage );
}
else
{
mESNLowMessage = null;
}
}
}
else if( message.getMessageType() == MessageType.ID_ESNL )
{
mESNLowMessage = (LTRNetISWMessage)message;
if( mESNHighMessage != null )
{
/* Check that the stored message is not older than 5 seconds */
if( System.currentTimeMillis() - mESNHighMessage.getTimeReceived() < 5000 )
{
((LTRNetISWMessage)message).setAuxiliaryMessage( mESNHighMessage );
}
else
{
mESNHighMessage = null;
}
}
}
}
}
mMessageListener.receive( message );
}
mDirection = direction;
}
public void setMessageListener( Listener<Message> listener )
@Override
public void receive(CorrectedBinaryMessage buffer)
{
mMessageListener = listener;
LtrNetMessage message = LtrNetMessageFactory.create(mDirection, buffer, System.currentTimeMillis());
if(message.isValid())
{
switch(message.getLtrNetMessageType())
{
case OSW_TRANSMIT_FREQUENCY_HIGH:
if(message instanceof TransmitFrequencyHigh)
{
TransmitFrequencyHigh transmitFrequencyHigh = (TransmitFrequencyHigh)message;
mTransmitHighMessageMap.put(transmitFrequencyHigh.getChannel(), transmitFrequencyHigh);
transmitFrequencyHigh.setFrequencyLow(mTransmitLowMessageMap.get(transmitFrequencyHigh.getChannel()));
}
break;
case OSW_TRANSMIT_FREQUENCY_LOW:
if(message instanceof TransmitFrequencyLow)
{
TransmitFrequencyLow transmitFrequencyLow = (TransmitFrequencyLow)message;
mTransmitLowMessageMap.put(transmitFrequencyLow.getChannel(), transmitFrequencyLow);
transmitFrequencyLow.setFrequencyHigh(mTransmitHighMessageMap.get(transmitFrequencyLow.getChannel()));
}
break;
case OSW_RECEIVE_FREQUENCY_HIGH:
if(message instanceof ReceiveFrequencyHigh)
{
ReceiveFrequencyHigh receiveFrequencyHigh = (ReceiveFrequencyHigh)message;
mReceiveHighMessageMap.put(receiveFrequencyHigh.getChannel(), receiveFrequencyHigh);
receiveFrequencyHigh.setFrequencyLow(mReceiveLowMessageMap.get(receiveFrequencyHigh.getChannel()));
}
break;
case OSW_RECEIVE_FREQUENCY_LOW:
if(message instanceof ReceiveFrequencyLow)
{
ReceiveFrequencyLow receiveFrequencyLow = (ReceiveFrequencyLow)message;
mReceiveLowMessageMap.put(receiveFrequencyLow.getChannel(), receiveFrequencyLow);
receiveFrequencyLow.setFrequencyHigh(mReceiveHighMessageMap.get(receiveFrequencyLow.getChannel()));
}
break;
case ISW_REGISTRATION_REQUEST_ESN_HIGH:
if(message instanceof RegistrationRequestEsnHigh)
{
((RegistrationRequestEsnHigh)message).setEsnLowMessage(mRegistrationRequestEsnLowMessage);
}
break;
case ISW_REGISTRATION_REQUEST_ESN_LOW:
if(message instanceof RegistrationRequestEsnLow)
{
((RegistrationRequestEsnLow)message).setESNHighMessage(mRegistrationRequestEsnHighMessage);
}
break;
case ISW_CALL_START:
case ISW_CALL_END:
//Reset the esn messages
mRegistrationRequestEsnHighMessage = null;
mRegistrationRequestEsnLowMessage = null;
break;
}
if(mMessageListener != null)
{
mMessageListener.receive(message);
}
}
}
public void setMessageListener(Listener<IMessage> listener)
{
mMessageListener = listener;
}
public void removeMessageListener()
{
mMessageListener = null;
mMessageListener = null;
}
}

View File

@@ -1,644 +0,0 @@
/*******************************************************************************
* 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/>
******************************************************************************/
package io.github.dsheirer.module.decode.ltrnet;
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.message.MessageDirection;
import io.github.dsheirer.message.MessageType;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class LTRNetOSWMessage extends LTRNetMessage
{
private static final int CHANNEL_FREQUENCY_MESSAGE_TYPE_BIT = 20;
private static final int CHANNEL_MAP_MESSAGE_TYPE_BIT = 17;
private static final int CHIU_UNIQUE_ID = 17;
private static final int CHIU_SITE_ID = 18;
private static final int CHIU_TRANSMIT_FREQUENCY = 24;
private static final int CHIU_RECEIVE_FREQUENCY = 25;
private static final int CHIU_NEIGHBOR = 26;
private static final int CHIU_MAP = 28;
private static final int CHIU_CALL_END = 31;
private static final int HOME_DIRECTED_GROUP_CALL = 29;
private static final int HOME_CHANNEL_IN_USE_MUTE_AUDIO = 30;
private static final int GROUP_DO_NOTHING = 253;
private static final int GROUP_CWID = 254;
private static final int GROUP_CHANNEL_IDLE = 255;
private static final int FREE_ALL_CHANNELS_BUSY = 0;
private static final int FREE_LTR_GROUP_CALL = 30;
private static final int FREE_LTRNET_GROUP_CALL = 31;
private LTRNetOSWMessage mAuxMessage;
public LTRNetOSWMessage( BinaryMessage message, AliasList list )
{
super( message, MessageDirection.OSW, list );
mMessageType = getType();
}
public void setAuxiliaryMessage( LTRNetOSWMessage message )
{
if( message != null )
{
mAuxMessage = message;
}
}
public String getRadioUniqueIDText()
{
StringBuilder sb = new StringBuilder();
int radioId = getRadioUniqueID();
if( radioId != INT_NULL_VALUE )
{
sb.append( " RADIO UNIQUE ID: " );
sb.append( radioId );
}
return sb.toString();
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append( mDatestampFormatter.format(
new Date( System.currentTimeMillis() ) ) );
sb.append( " LTRNet OSW [" );
sb.append( mCRC.getAbbreviation() );
sb.append( "] " );
sb.append( getMessage() );
pad( sb, 100 );
sb.append( mMessage.toString() );
return sb.toString();
}
@Override
public String getMessage()
{
StringBuilder sb = new StringBuilder();
switch( mMessageType )
{
case SY_IDLE:
sb.append( "IDLE AREA:" );
sb.append( getArea() );
sb.append( " LCN:" );
sb.append( format( getChannel(), 2 ) );
sb.append( " HOME:" );
sb.append( format( getHomeRepeater(), 2 ) );
sb.append( " GRP:" );
sb.append( format( getGroup(), 3 ) );
sb.append( " FREE:" );
sb.append( format( getFree(), 2 ) );
break;
case CA_STRT:
sb.append( "CALL LCN:" );
sb.append( format( getChannel(), 2 ) );
sb.append( " TG [ " );
sb.append( getTalkgroupID() );
sb.append( "/" );
sb.append( getTalkgroupIDAlias() );
sb.append( " ] FREE:" );
sb.append( format( getFree(), 2 ) );
break;
case CA_ENDD:
sb.append( "END* AREA:" );
sb.append( getArea() );
sb.append( " LCN:" );
sb.append( format( getChannel(), 2 ) );
sb.append( " TG [" );
sb.append( getTalkgroupID() );
sb.append( "/" );
sb.append( getTalkgroupIDAlias() );
sb.append( "] FREE:" );
sb.append( format( getFree(), 2 ) );
break;
case MA_CHNL:
sb.append( "CHAN MAP LOW LCN [" );
sb.append( getChannelMapAsString( getChannelMapLow() ) );
sb.append( "]" );
break;
case MA_CHNH:
sb.append( "CHAN MAP HIGH LCN [" );
sb.append( getChannelMapAsString( getChannelMapHigh() ) );
sb.append( "]" );
break;
case FQ_RXLO:
sb.append( "CHAN RX LOW LCN:" );
sb.append( format( getHomeRepeater(), 2 ) );
sb.append( " = " );
long rxFreqLo = getFrequency();
if( rxFreqLo > 0 )
{
sb.append( mDecimalFormatter.format( (double)rxFreqLo / 1E6d ) );
}
else
{
sb.append( "000.00000" );
}
sb.append( " MHz" );
break;
case FQ_RXHI:
sb.append( "CHAN RX HIGH LCN:" );
sb.append( format( getHomeRepeater(), 2 ) );
sb.append( " = " );
long rxfreqhi = getFrequency();
if( rxfreqhi > 0 )
{
sb.append( mDecimalFormatter.format( (double)rxfreqhi / 1E6d ) );
}
else
{
sb.append( "000.00000" );
}
sb.append( " MHz" );
break;
case FQ_TXHI:
sb.append( "CHAN TX LOW LCN:" );
sb.append( format( getHomeRepeater(), 2 ) );
sb.append( " = " );
long txfreq = getFrequency();
if( txfreq > 0 )
{
sb.append( mDecimalFormatter.format( (double)txfreq / 1E6d ) );
}
else
{
sb.append( "000.00000" );
}
sb.append( " MHz" );
break;
case FQ_TXLO:
sb.append( "CHAN TX HIGH LCN:" );
sb.append( format( getHomeRepeater(), 2 ) );
sb.append( " = " );
long txFreqLo = getFrequency();
if( txFreqLo > 0 )
{
sb.append( mDecimalFormatter.format( (double)txFreqLo / 1E6d ) );
}
else
{
sb.append( "000.00000" );
}
sb.append( " MHz" );
break;
case ID_SITE:
String siteId = getSiteID();
if( siteId != null )
{
sb.append( "SITE ID: " );
sb.append( siteId );
sb.append( " " );
sb.append( getSiteIDAlias() );
}
break;
case ID_NBOR:
int neighborRank = getNeighborRank();
String neighborId = getNeighborID();
if( neighborRank != INT_NULL_VALUE &&
neighborId != null )
{
sb.append( "NEIGHBOR SITE " );
sb.append( neighborRank );
sb.append( ": " );
sb.append( neighborId );
sb.append( " " );
sb.append( getNeighborIDAlias() );
}
break;
case ID_UNIQ:
sb.append( "REGISTER RADIO UNIQUE ID:" );
sb.append( getRadioUniqueID() );
break;
default:
sb.append( "UNKNOWN " );
sb.append( getArea() );
sb.append( " " + format( getChannel(), 2 ) );
sb.append( " " + format( getHomeRepeater(), 2 ) );
sb.append( " " + format( getGroup(), 3 ) );
sb.append( " " + format( getFree(), 2 ) );
sb.append( " A:" );
sb.append( getArea() );
sb.append( " C:" );
sb.append( format( getChannel(), 2 ) );
sb.append( " H:" );
sb.append( format( getHomeRepeater(), 2 ) );
sb.append( " G:" );
sb.append( format( getGroup(), 3 ) );
sb.append( " F:" );
sb.append( format( getFree(), 2 ) );
}
return sb.toString();
}
public String getTalkgroupID()
{
StringBuilder sb = new StringBuilder();
sb.append( getArea() );
sb.append( "-" );
sb.append( format( getHomeRepeater(), 2 ) );
sb.append( "-" );
sb.append( format( getGroup(), 3 ) );
return sb.toString();
}
public Alias getTalkgroupIDAlias()
{
if( mAliasList != null )
{
return mAliasList.getTalkgroupAlias( getTalkgroupID() );
}
return null;
}
public ArrayList<Integer> getChannelMapLow()
{
ArrayList<Integer> retVal = new ArrayList<Integer>();
if( mMessageType == MessageType.MA_CHNL )
{
for( int x = 27; x >= 18; x-- )
{
if( mMessage.get( x ) )
{
retVal.add( 28 - x );
}
}
}
return retVal;
}
public ArrayList<Integer> getChannelMapHigh()
{
ArrayList<Integer> retVal = new ArrayList<Integer>();
if( mMessageType == MessageType.MA_CHNH )
{
for( int x = 27; x >= 18; x-- )
{
if( mMessage.get( x ) )
{
retVal.add( 38 - x );
}
}
}
return retVal;
}
public String getChannelMapAsString( ArrayList<Integer> channels )
{
StringBuilder sb = new StringBuilder();
for( Integer channel: channels )
{
sb.append( channel );
sb.append( " " );
}
return sb.toString();
}
public int getRadioUniqueID()
{
int retVal = INT_NULL_VALUE;
if( mMessageType == MessageType.ID_UNIQ )
{
retVal = mMessage.getInt( 17, 32 );
}
return retVal;
}
public Alias getRadioUniqueIDAlias()
{
if( mAliasList != null )
{
return mAliasList.getUniqueID( getRadioUniqueID() );
}
return null;
}
public String getSiteID()
{
if( mMessageType == MessageType.ID_SITE )
{
return String.valueOf( mMessage.getInt( 23, 32 ) );
}
return null;
}
public Alias getSiteIDAlias()
{
if( mAliasList != null )
{
return mAliasList.getSiteID( getSiteID() );
}
return null;
}
public String getNeighborID()
{
if( mMessageType == MessageType.ID_NBOR )
{
int id = mMessage.getInt( 23, 32 );
if( id > 0 )
{
return String.valueOf( id );
}
}
return null;
}
private Alias getNeighborIDAlias()
{
if( mAliasList != null )
{
return mAliasList.getSiteID( getNeighborID() );
}
return null;
}
public int getNeighborRank()
{
int retVal = INT_NULL_VALUE;
if( mMessageType == MessageType.ID_NBOR )
{
retVal = mMessage.getInt( 15, 18 ) + 1;
}
return retVal;
}
public long getFrequency()
{
long retVal = 0;
if( mAuxMessage != null )
{
int high;
int low;
MessageType type = getMessageType();
if( type == MessageType.FQ_RXHI || type == MessageType.FQ_TXHI )
{
high = getHighChannelUnits();
low = mAuxMessage.getLowChannelUnits();
}
else
{
high = mAuxMessage.getHighChannelUnits();
low = getLowChannelUnits();
}
if( high != INT_NULL_VALUE && low != INT_NULL_VALUE )
{
retVal = ( high + low ) * 1250 + 150000000;
}
}
return retVal;
}
/**
* Returns the value of the high order (15 - 12) frequency bits which are
* the lower 4 bits of the Free field, left shifted by 12, representing the
* frequency value in units of .00125 MHz
*/
public int getHighChannelUnits()
{
int retVal = INT_NULL_VALUE;
if( mAuxMessage != null &&
( mMessageType == MessageType.FQ_RXHI ||
mMessageType == MessageType.FQ_TXHI ) )
{
retVal = mMessage.getInt( 29, 32 );
retVal = Integer.rotateLeft( retVal, 12 );
}
return retVal;
}
/**
* Returns the value of the low order (11 - 0) frequency bits which are
* contained in the Group and Free fields representing the frequency value
* units of .00125 MHz
*/
public int getLowChannelUnits()
{
int retVal = INT_NULL_VALUE;
if( mMessageType == MessageType.FQ_RXLO ||
mMessageType == MessageType.FQ_TXLO )
{
retVal = mMessage.getInt( 21, 32 );
}
return retVal;
}
public MessageType getType()
{
MessageType retVal = MessageType.UN_KNWN;
int channel = getChannel();
int home = getHomeRepeater();
//LTR-Net messages
if( home != 31 && ( channel > 20 || home > 20 ) )
{
switch( channel )
{
case CHIU_UNIQUE_ID:
retVal = MessageType.ID_UNIQ;
break;
case CHIU_SITE_ID:
retVal = MessageType.ID_SITE;
break;
case CHIU_TRANSMIT_FREQUENCY:
if( getHomeRepeater() == 24 )
{
retVal = MessageType.ID_UNIQ;
}
else
{
if( mMessage.get( CHANNEL_FREQUENCY_MESSAGE_TYPE_BIT ) )
{
retVal = MessageType.FQ_TXHI;
}
else
{
retVal = MessageType.FQ_TXLO;
}
}
break;
case CHIU_RECEIVE_FREQUENCY:
if( mMessage.get( CHANNEL_FREQUENCY_MESSAGE_TYPE_BIT ) )
{
retVal = MessageType.FQ_RXHI;
}
else
{
retVal = MessageType.FQ_RXLO;
}
break;
case CHIU_NEIGHBOR:
retVal = MessageType.ID_NBOR;
break;
case CHIU_MAP:
if( mMessage.get( CHANNEL_MAP_MESSAGE_TYPE_BIT ) )
{
retVal = MessageType.MA_CHNH;
}
else
{
retVal = MessageType.MA_CHNL;
}
break;
case CHIU_CALL_END:
retVal = MessageType.CA_ENDD;
}
}
else
{
int group = getGroup();
if( group == GROUP_CHANNEL_IDLE )
{
retVal = MessageType.SY_IDLE;
}
else
{
retVal = MessageType.CA_STRT;
}
}
return retVal;
}
@Override
public String getFromID()
{
if( mMessageType == MessageType.CA_STRT ||
mMessageType == MessageType.CA_ENDD )
{
return getTalkgroupID();
}
else
{
return null;
}
}
@Override
public Alias getFromIDAlias()
{
if( mMessageType == MessageType.CA_STRT ||
mMessageType == MessageType.CA_ENDD )
{
return getTalkgroupIDAlias();
}
else
{
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 );
}
Alias neighbor = getNeighborIDAlias();
if( neighbor != null )
{
aliases.add( neighbor );
}
Alias uid = getRadioUniqueIDAlias();
if( uid != null )
{
aliases.add( uid );
}
Alias site = getSiteIDAlias();
if( site != null )
{
aliases.add( site );
}
return aliases;
}
}

View File

@@ -0,0 +1,46 @@
/*
* ******************************************************************************
* 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.ltrnet;
public enum LtrNetMessageType
{
ISW_CALL_END,
ISW_CALL_START,
ISW_REGISTRATION_REQUEST_ESN_HIGH,
ISW_REGISTRATION_REQUEST_ESN_LOW,
ISW_REQUEST_ACCESS,
ISW_UNIQUE_ID,
ISW_UNKNOWN,
OSW_CALL_END,
OSW_CALL_START,
OSW_CHANNEL_MAP_HIGH,
OSW_CHANNEL_MAP_LOW,
OSW_SYSTEM_IDLE,
OSW_NEIGHBOR_ID,
OSW_RECEIVE_FREQUENCY_HIGH,
OSW_RECEIVE_FREQUENCY_LOW,
OSW_REGISTRATION_ACCEPT,
OSW_SITE_ID,
OSW_TRANSMIT_FREQUENCY_HIGH,
OSW_TRANSMIT_FREQUENCY_LOW,
OSW_UNKNOWN
}

View File

@@ -0,0 +1,111 @@
/*
* ******************************************************************************
* 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.ltrnet.channel;
import io.github.dsheirer.channel.IChannelDescriptor;
import io.github.dsheirer.module.decode.p25.message.IFrequencyBand;
import io.github.dsheirer.protocol.Protocol;
public class LtrNetChannel implements IChannelDescriptor, Comparable<LtrNetChannel>
{
private long mDownlink;
private long mUplink;
private int mChannel;
public LtrNetChannel(int channel)
{
mChannel = channel;
}
public int getChannel()
{
return mChannel;
}
public void setDownlink(long downlink)
{
mDownlink = downlink;
}
public void setUplink(long uplink)
{
mUplink = uplink;
}
@Override
public long getDownlinkFrequency()
{
return mDownlink;
}
@Override
public long getUplinkFrequency()
{
return mUplink;
}
@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_NET;
}
@Override
public String toString()
{
return String.valueOf(getChannel());
}
public String description()
{
return "TRANSMIT: " + getDownlinkFrequency() + " RECEIVE:" + getUplinkFrequency();
}
@Override
public int compareTo(LtrNetChannel o)
{
return Integer.compare(getChannel(), o.getChannel());
}
}

View File

@@ -0,0 +1,46 @@
/*
* ******************************************************************************
* 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.ltrnet.identifier;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.integer.IntegerIdentifier;
import io.github.dsheirer.protocol.Protocol;
public class NeighborIdentifier extends IntegerIdentifier
{
public NeighborIdentifier(int site)
{
super(site, IdentifierClass.NETWORK, Form.NEIGHBOR_SITE, Role.BROADCAST);
}
@Override
public Protocol getProtocol()
{
return Protocol.LTR_NET;
}
public static NeighborIdentifier create(int site)
{
return new NeighborIdentifier(site);
}
}

View File

@@ -0,0 +1,46 @@
/*
* ******************************************************************************
* 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.ltrnet.identifier;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.integer.IntegerIdentifier;
import io.github.dsheirer.protocol.Protocol;
public class SiteIdentifier extends IntegerIdentifier
{
public SiteIdentifier(int site)
{
super(site, IdentifierClass.NETWORK, Form.SITE, Role.BROADCAST);
}
@Override
public Protocol getProtocol()
{
return Protocol.LTR_NET;
}
public static SiteIdentifier create(int site)
{
return new SiteIdentifier(site);
}
}

View File

@@ -0,0 +1,66 @@
/*
* ******************************************************************************
* 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.ltrnet.identifier;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.integer.IntegerIdentifier;
import io.github.dsheirer.protocol.Protocol;
/**
* Unique ID or radio ID for LTR-Net radios is a 16-bit logical network radio identifier value.
*/
public class UniqueIdentifier extends IntegerIdentifier implements Comparable<UniqueIdentifier>
{
public UniqueIdentifier(int value, Role role)
{
super(value, IdentifierClass.USER, Form.UNIQUE_ID, role);
}
@Override
public Protocol getProtocol()
{
return Protocol.LTR_NET;
}
/**
* Creates a unique identifier for the FROM radio role
*/
public static UniqueIdentifier createFrom(int value)
{
return new UniqueIdentifier(value, Role.FROM);
}
/**
* Creates a unique identifier for the TO radio role
*/
public static UniqueIdentifier createTo(int value)
{
return new UniqueIdentifier(value, Role.TO);
}
@Override
public int compareTo(UniqueIdentifier o)
{
return getValue().compareTo(o.getValue());
}
}

View File

@@ -0,0 +1,116 @@
/*
* ******************************************************************************
* 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.ltrnet.message;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.edac.CRC;
import io.github.dsheirer.edac.CRCLTR;
import io.github.dsheirer.identifier.talkgroup.LTRTalkgroup;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.message.MessageDirection;
import io.github.dsheirer.module.decode.ltrnet.LtrNetMessageType;
import io.github.dsheirer.protocol.Protocol;
public abstract class LtrNetMessage extends Message
{
protected static final int[] SYNC = {0, 1, 2, 3, 4, 5, 6, 7, 8};
protected static final int[] AREA = {9};
protected static final int[] CHANNEL = {10, 11, 12, 13, 14};
protected static final int[] HOME_REPEATER = {15, 16, 17, 18, 19};
protected static final int[] GROUP = {20, 21, 22, 23, 24, 25, 26, 27};
protected static final int[] FREE = {28, 29, 30, 31, 32};
protected static final int[] CRC_FIELD = {33, 34, 35, 36, 37, 38, 39};
protected static final int[] SIXTEEN_BITS = {17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32};
protected CorrectedBinaryMessage mMessage;
protected CRC mCRC;
private LTRTalkgroup mTalkgroup;
public LtrNetMessage(CorrectedBinaryMessage message, MessageDirection direction, long timestamp)
{
super(timestamp);
mMessage = message;
mCRC = CRCLTR.check(message, direction);
}
/**
* Underlying binary message
*/
protected CorrectedBinaryMessage getMessage()
{
return mMessage;
}
public abstract LtrNetMessageType getLtrNetMessageType();
@Override
public Protocol getProtocol()
{
return Protocol.LTR_NET;
}
/**
* Talkgroup identifier
*/
public LTRTalkgroup getTalkgroup()
{
if(mTalkgroup == null)
{
mTalkgroup = LTRTalkgroup.create((getHomeRepeater(getMessage()) << 8) + getGroup(getMessage()));
}
return mTalkgroup;
}
public boolean isValid()
{
return mCRC.passes();
}
public CRC getCRC()
{
return mCRC;
}
public static int getArea(CorrectedBinaryMessage message)
{
return message.getInt(AREA);
}
public static int getChannel(CorrectedBinaryMessage message)
{
return message.getInt(CHANNEL);
}
public static int getHomeRepeater(CorrectedBinaryMessage message)
{
return message.getInt(HOME_REPEATER);
}
public static int getGroup(CorrectedBinaryMessage message)
{
return message.getInt(GROUP);
}
public static int getFree(CorrectedBinaryMessage message)
{
return message.getInt(FREE);
}
}

View File

@@ -0,0 +1,119 @@
/*
* ******************************************************************************
* 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.ltrnet.message;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.message.MessageDirection;
import io.github.dsheirer.module.decode.ltrnet.LtrNetMessageType;
import io.github.dsheirer.module.decode.ltrnet.message.isw.IswCallEnd;
import io.github.dsheirer.module.decode.ltrnet.message.isw.IswCallStart;
import io.github.dsheirer.module.decode.ltrnet.message.isw.IswUniqueId;
import io.github.dsheirer.module.decode.ltrnet.message.isw.IswUnknown;
import io.github.dsheirer.module.decode.ltrnet.message.isw.LtrNetIswMessage;
import io.github.dsheirer.module.decode.ltrnet.message.isw.RegistrationRequestEsnHigh;
import io.github.dsheirer.module.decode.ltrnet.message.isw.RegistrationRequestEsnLow;
import io.github.dsheirer.module.decode.ltrnet.message.isw.RequestAccess;
import io.github.dsheirer.module.decode.ltrnet.message.osw.ChannelMapHigh;
import io.github.dsheirer.module.decode.ltrnet.message.osw.ChannelMapLow;
import io.github.dsheirer.module.decode.ltrnet.message.osw.LtrNetOswMessage;
import io.github.dsheirer.module.decode.ltrnet.message.osw.NeighborId;
import io.github.dsheirer.module.decode.ltrnet.message.osw.OswCallEnd;
import io.github.dsheirer.module.decode.ltrnet.message.osw.OswCallStart;
import io.github.dsheirer.module.decode.ltrnet.message.osw.OswUnknown;
import io.github.dsheirer.module.decode.ltrnet.message.osw.ReceiveFrequencyHigh;
import io.github.dsheirer.module.decode.ltrnet.message.osw.ReceiveFrequencyLow;
import io.github.dsheirer.module.decode.ltrnet.message.osw.RegistrationAccept;
import io.github.dsheirer.module.decode.ltrnet.message.osw.SiteId;
import io.github.dsheirer.module.decode.ltrnet.message.osw.SystemIdle;
import io.github.dsheirer.module.decode.ltrnet.message.osw.TransmitFrequencyHigh;
import io.github.dsheirer.module.decode.ltrnet.message.osw.TransmitFrequencyLow;
/**
* Message factory for creating LTR-Net messages
*/
public class LtrNetMessageFactory
{
public static LtrNetMessage create(MessageDirection messageDirection, CorrectedBinaryMessage message, long timestamp)
{
switch(messageDirection)
{
case ISW:
//Flip all of the message bits since ISW messages are inverted
message.flip(0, 40);
LtrNetMessageType iswType = LtrNetIswMessage.getMessageType(message);
switch(iswType)
{
case ISW_CALL_END:
return new IswCallEnd(message, timestamp);
case ISW_CALL_START:
return new IswCallStart(message, timestamp);
case ISW_REGISTRATION_REQUEST_ESN_HIGH:
return new RegistrationRequestEsnHigh(message, timestamp);
case ISW_REGISTRATION_REQUEST_ESN_LOW:
return new RegistrationRequestEsnLow(message, timestamp);
case ISW_REQUEST_ACCESS:
return new RequestAccess(message, timestamp);
case ISW_UNIQUE_ID:
return new IswUniqueId(message, timestamp);
case ISW_UNKNOWN:
default:
return new IswUnknown(message, timestamp);
}
case OSW:
LtrNetMessageType oswType = LtrNetOswMessage.getMessageType(message);
switch(oswType)
{
case OSW_CALL_END:
return new OswCallEnd(message, timestamp);
case OSW_CALL_START:
return new OswCallStart(message, timestamp);
case OSW_CHANNEL_MAP_HIGH:
return new ChannelMapHigh(message, timestamp);
case OSW_CHANNEL_MAP_LOW:
return new ChannelMapLow(message, timestamp);
case OSW_SYSTEM_IDLE:
return new SystemIdle(message, timestamp);
case OSW_NEIGHBOR_ID:
return new NeighborId(message, timestamp);
case OSW_RECEIVE_FREQUENCY_HIGH:
return new ReceiveFrequencyHigh(message, timestamp);
case OSW_RECEIVE_FREQUENCY_LOW:
return new ReceiveFrequencyLow(message, timestamp);
case OSW_REGISTRATION_ACCEPT:
return new RegistrationAccept(message, timestamp);
case OSW_SITE_ID:
return new SiteId(message, timestamp);
case OSW_TRANSMIT_FREQUENCY_HIGH:
return new TransmitFrequencyHigh(message, timestamp);
case OSW_TRANSMIT_FREQUENCY_LOW:
return new TransmitFrequencyLow(message, timestamp);
case OSW_UNKNOWN:
default:
return new OswUnknown(message, timestamp);
}
}
return null;
}
}

View File

@@ -0,0 +1,80 @@
/*
* ******************************************************************************
* 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.ltrnet.message.isw;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.module.decode.ltrnet.LtrNetMessageType;
import java.util.ArrayList;
import java.util.List;
/**
* Call End Message.
*/
public class IswCallEnd extends LtrNetIswMessage
{
private List<Identifier> mIdentifiers;
/**
* Constructs a message
*/
public IswCallEnd(CorrectedBinaryMessage message, long timestamp)
{
super(message, timestamp);
}
@Override
public LtrNetMessageType getLtrNetMessageType()
{
return LtrNetMessageType.ISW_CALL_END;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("CALL END TALKGROUP:").append(getTalkgroup().formatted());
sb.append(" AREA:").append(getArea(getMessage()));
sb.append(" LCN:").append(getChannel(getMessage()));
sb.append(" FREE:").append(getFree(getMessage()));
return sb.toString();
}
/**
* LCN for the call
*/
public int getChannel()
{
return getChannel(getMessage());
}
@Override
public List<Identifier> getIdentifiers()
{
if(mIdentifiers == null)
{
mIdentifiers = new ArrayList<>();
mIdentifiers.add(getTalkgroup());
}
return mIdentifiers;
}
}

View File

@@ -0,0 +1,80 @@
/*
* ******************************************************************************
* 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.ltrnet.message.isw;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.module.decode.ltrnet.LtrNetMessageType;
import java.util.ArrayList;
import java.util.List;
/**
* Call Start Message.
*/
public class IswCallStart extends LtrNetIswMessage
{
private List<Identifier> mIdentifiers;
/**
* Constructs a message
*/
public IswCallStart(CorrectedBinaryMessage message, long timestamp)
{
super(message, timestamp);
}
@Override
public LtrNetMessageType getLtrNetMessageType()
{
return LtrNetMessageType.ISW_CALL_START;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("CALL START TALKGROUP:").append(getTalkgroup().formatted());
sb.append(" AREA:").append(getArea(getMessage()));
sb.append(" LCN:").append(getChannel(getMessage()));
sb.append(" FREE:").append(getFree(getMessage()));
return sb.toString();
}
/**
* LCN for the call
*/
public int getChannel()
{
return getChannel(getMessage());
}
@Override
public List<Identifier> getIdentifiers()
{
if(mIdentifiers == null)
{
mIdentifiers = new ArrayList<>();
mIdentifiers.add(getTalkgroup());
}
return mIdentifiers;
}
}

View File

@@ -0,0 +1,83 @@
/*
* ******************************************************************************
* 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.ltrnet.message.isw;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.module.decode.ltrnet.LtrNetMessageType;
import io.github.dsheirer.module.decode.ltrnet.identifier.UniqueIdentifier;
import java.util.ArrayList;
import java.util.List;
/**
* ESN Low Message. ESN is transmitted over two messages with the ESNHigh message containing the high-order 16 bits
* and the ESNLow message containing the low-order 16 bits.
*/
public class IswUniqueId extends LtrNetIswMessage
{
private UniqueIdentifier mUniqueIdentifier;
private List<Identifier> mIdentifiers;
/**
* Constructs an ESN-High message
*/
public IswUniqueId(CorrectedBinaryMessage message, long timestamp)
{
super(message, timestamp);
}
@Override
public LtrNetMessageType getLtrNetMessageType()
{
return LtrNetMessageType.ISW_UNIQUE_ID;
}
public UniqueIdentifier getUniqueID()
{
if(mUniqueIdentifier == null)
{
mUniqueIdentifier = UniqueIdentifier.createFrom(getMessage().getInt(SIXTEEN_BITS));
}
return mUniqueIdentifier;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("RADIO UNIQUE ID: ").append(getUniqueID());
return sb.toString();
}
@Override
public List<Identifier> getIdentifiers()
{
if(mIdentifiers == null)
{
mIdentifiers = new ArrayList<>();
mIdentifiers.add(getUniqueID());
}
return mIdentifiers;
}
}

View File

@@ -0,0 +1,65 @@
/*
* ******************************************************************************
* 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.ltrnet.message.isw;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.module.decode.ltrnet.LtrNetMessageType;
import java.util.Collections;
import java.util.List;
/**
* ISW Unknown Message.
*/
public class IswUnknown extends LtrNetIswMessage
{
/**
* Constructs a message
*/
public IswUnknown(CorrectedBinaryMessage message, long timestamp)
{
super(message, timestamp);
}
@Override
public LtrNetMessageType getLtrNetMessageType()
{
return LtrNetMessageType.ISW_UNKNOWN;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("ISW UNKNOWN MESSAGE - AREA:").append(getArea(getMessage()));
sb.append(" LCN:").append(getChannel(getMessage()));
sb.append(" HOME:").append(getHomeRepeater(getMessage()));
sb.append(" GROUP").append(getGroup(getMessage()));
sb.append(" FREE:").append(getFree(getMessage()));
return sb.toString();
}
@Override
public List<Identifier> getIdentifiers()
{
return Collections.EMPTY_LIST;
}
}

View File

@@ -0,0 +1,93 @@
/*
* ******************************************************************************
* 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.ltrnet.message.isw;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.edac.CRC;
import io.github.dsheirer.edac.CRCLTR;
import io.github.dsheirer.message.MessageDirection;
import io.github.dsheirer.module.decode.ltrnet.LtrNetMessageType;
import io.github.dsheirer.module.decode.ltrnet.message.LtrNetMessage;
public abstract class LtrNetIswMessage extends LtrNetMessage
{
/**
* LTR-Net Inbound (mobile - to tower) Message
*/
public LtrNetIswMessage(CorrectedBinaryMessage message, long timestamp)
{
super(message, MessageDirection.ISW, timestamp);
/**
* If the CRC fails, test for a transmitted CRC of 127 and then check
* the Free field for special messages
*/
if(mCRC == CRC.FAILED_CRC && CRCLTR.getTransmittedChecksum(mMessage) == 127)
{
int free = getFree(getMessage());
if(free == 31 || free == 23)
{
mCRC = CRC.PASSED;
}
}
}
/**
* Determines the ISW message type
*/
public static LtrNetMessageType getMessageType(CorrectedBinaryMessage message)
{
int channel = getChannel(message);
if(channel == 31)
{
return LtrNetMessageType.ISW_CALL_END;
}
else if(channel > 20)
{
switch(channel)
{
case 24:
return LtrNetMessageType.ISW_UNIQUE_ID;
case 27:
return LtrNetMessageType.ISW_REGISTRATION_REQUEST_ESN_LOW;
case 29:
return LtrNetMessageType.ISW_REGISTRATION_REQUEST_ESN_HIGH;
}
}
else if(channel > 0)
{
int free = getFree(message);
switch(free)
{
case 21:
return LtrNetMessageType.ISW_CALL_START;
case 23:
return LtrNetMessageType.ISW_CALL_END;
case 31:
return LtrNetMessageType.ISW_REQUEST_ACCESS;
}
}
return LtrNetMessageType.ISW_UNKNOWN;
}
}

View File

@@ -0,0 +1,113 @@
/*
* ******************************************************************************
* 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.ltrnet.message.isw;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.esn.ESNIdentifier;
import io.github.dsheirer.module.decode.ltrnet.LtrNetMessageType;
import io.github.dsheirer.protocol.Protocol;
import java.util.ArrayList;
import java.util.List;
/**
* ESN High Message. ESN is transmitted over two messages with the ESNHigh message containing the high-order 16 bits
* and the ESNLow message containing the low-order 16 bits.
*/
public class RegistrationRequestEsnHigh extends LtrNetIswMessage
{
private RegistrationRequestEsnLow mRegistrationRequestEsnLow;
private ESNIdentifier mESNIdentifier;
private List<Identifier> mIdentifiers;
/**
* Constructs an ESN-High message
*/
public RegistrationRequestEsnHigh(CorrectedBinaryMessage message, long timestamp)
{
super(message, timestamp);
}
@Override
public LtrNetMessageType getLtrNetMessageType()
{
return LtrNetMessageType.ISW_REGISTRATION_REQUEST_ESN_HIGH;
}
/**
* Sets the corresponding ESN low message that can be used to create the full ESN value
*/
public void setEsnLowMessage(RegistrationRequestEsnLow message)
{
if(message != null)
{
mRegistrationRequestEsnLow = message;
}
}
public boolean isCompleteEsn()
{
return mRegistrationRequestEsnLow != null;
}
/**
* ESN Identifier with at least the high-order 16-bits specified and optionally includes the low-order 16 bits.
*/
public ESNIdentifier getESN()
{
if(mESNIdentifier == null)
{
mESNIdentifier = ESNIdentifier.create(getESNHigh() +
(mRegistrationRequestEsnLow != null ? mRegistrationRequestEsnLow.getESNLow() : "xxxx"),
Protocol.LTR_NET, Role.FROM);
}
return mESNIdentifier;
}
public String getESNHigh()
{
int esnHigh = getMessage().getInt(SIXTEEN_BITS);
return String.format("%04X", esnHigh & 0xFFFF);
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("ESN HIGH: ").append(getESN());
return sb.toString();
}
@Override
public List<Identifier> getIdentifiers()
{
if(mIdentifiers == null)
{
mIdentifiers = new ArrayList<>();
mIdentifiers.add(getESN());
}
return mIdentifiers;
}
}

View File

@@ -0,0 +1,112 @@
/*
* ******************************************************************************
* 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.ltrnet.message.isw;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.esn.ESNIdentifier;
import io.github.dsheirer.module.decode.ltrnet.LtrNetMessageType;
import io.github.dsheirer.protocol.Protocol;
import java.util.ArrayList;
import java.util.List;
/**
* ESN Low Message. ESN is transmitted over two messages with the ESNHigh message containing the high-order 16 bits
* and the ESNLow message containing the low-order 16 bits.
*/
public class RegistrationRequestEsnLow extends LtrNetIswMessage
{
private RegistrationRequestEsnHigh mRegistrationRequestEsnHigh;
private ESNIdentifier mESNIdentifier;
private List<Identifier> mIdentifiers;
/**
* Constructs an ESN-High message
*/
public RegistrationRequestEsnLow(CorrectedBinaryMessage message, long timestamp)
{
super(message, timestamp);
}
@Override
public LtrNetMessageType getLtrNetMessageType()
{
return LtrNetMessageType.ISW_REGISTRATION_REQUEST_ESN_LOW;
}
/**
* Sets the corresponding ESN high message that can be used to create the full ESN value
*/
public void setESNHighMessage(RegistrationRequestEsnHigh message)
{
if(message != null)
{
mRegistrationRequestEsnHigh = message;
}
}
public boolean isCompleteEsn()
{
return mRegistrationRequestEsnHigh != null;
}
/**
* ESN Identifier with at least the high-order 16-bits specified and optionally includes the low-order 16 bits.
*/
public ESNIdentifier getESN()
{
if(mESNIdentifier == null)
{
mESNIdentifier = ESNIdentifier.create((mRegistrationRequestEsnHigh != null ? mRegistrationRequestEsnHigh.getESNHigh() : "xxxx") + getESNLow(),
Protocol.LTR_NET, Role.FROM);
}
return mESNIdentifier;
}
public String getESNLow()
{
int esnLow = getMessage().getInt(SIXTEEN_BITS);
return String.format("%04X", esnLow & 0xFFFF);
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("ESN LOW: ").append(getESN());
return sb.toString();
}
@Override
public List<Identifier> getIdentifiers()
{
if(mIdentifiers == null)
{
mIdentifiers = new ArrayList<>();
mIdentifiers.add(getESN());
}
return mIdentifiers;
}
}

View File

@@ -0,0 +1,72 @@
/*
* ******************************************************************************
* 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.ltrnet.message.isw;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.module.decode.ltrnet.LtrNetMessageType;
import java.util.ArrayList;
import java.util.List;
/**
* Request access Message.
*/
public class RequestAccess extends LtrNetIswMessage
{
private List<Identifier> mIdentifiers;
/**
* Constructs a message
*/
public RequestAccess(CorrectedBinaryMessage message, long timestamp)
{
super(message, timestamp);
}
@Override
public LtrNetMessageType getLtrNetMessageType()
{
return LtrNetMessageType.ISW_REQUEST_ACCESS;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("REQUEST ACCESS TALKGROUP:").append(getTalkgroup());
sb.append(" AREA:").append(getArea(getMessage()));
sb.append(" LCN:").append(getChannel(getMessage()));
sb.append(" FREE:").append(getFree(getMessage()));
return sb.toString();
}
@Override
public List<Identifier> getIdentifiers()
{
if(mIdentifiers == null)
{
mIdentifiers = new ArrayList<>();
mIdentifiers.add(getTalkgroup());
}
return mIdentifiers;
}
}

View File

@@ -0,0 +1,77 @@
/*
* ******************************************************************************
* 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.ltrnet.message.osw;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.module.decode.ltrnet.LtrNetMessageType;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Channel Map - High Channels (11 - 20).
*/
public class ChannelMapHigh extends LtrNetOswMessage
{
/**
* Constructs a message
*/
public ChannelMapHigh(CorrectedBinaryMessage message, long timestamp)
{
super(message, timestamp);
}
@Override
public LtrNetMessageType getLtrNetMessageType()
{
return LtrNetMessageType.OSW_CHANNEL_MAP_HIGH;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("CHANNEL MAP HIGH ").append(getChannels());
return sb.toString();
}
public List<Integer> getChannels()
{
List<Integer> retVal = new ArrayList<>();
for(int x = 27; x >= 18; x--)
{
if(getMessage().get(x))
{
retVal.add(38 - x);
}
}
return retVal;
}
@Override
public List<Identifier> getIdentifiers()
{
return Collections.EMPTY_LIST;
}
}

View File

@@ -0,0 +1,77 @@
/*
* ******************************************************************************
* 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.ltrnet.message.osw;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.module.decode.ltrnet.LtrNetMessageType;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Channel Map - Low Channels (1 - 10).
*/
public class ChannelMapLow extends LtrNetOswMessage
{
/**
* Constructs a message
*/
public ChannelMapLow(CorrectedBinaryMessage message, long timestamp)
{
super(message, timestamp);
}
@Override
public LtrNetMessageType getLtrNetMessageType()
{
return LtrNetMessageType.OSW_CHANNEL_MAP_LOW;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("CHANNEL MAP LOW ").append(getChannels());
return sb.toString();
}
public List<Integer> getChannels()
{
List<Integer> retVal = new ArrayList<>();
for(int x = 27; x >= 18; x--)
{
if(getMessage().get(x))
{
retVal.add(28 - x);
}
}
return retVal;
}
@Override
public List<Identifier> getIdentifiers()
{
return Collections.EMPTY_LIST;
}
}

View File

@@ -0,0 +1,63 @@
/*
* ******************************************************************************
* 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.ltrnet.message.osw;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
/**
* Base frequency message
*/
public abstract class Frequency extends LtrNetOswMessage
{
/**
* Constructs a message
*/
public Frequency(CorrectedBinaryMessage message, long timestamp)
{
super(message, timestamp);
}
protected abstract FrequencyHigh getFrequencyHigh();
protected abstract FrequencyLow getFrequencyLow();
protected abstract boolean hasFrequencyHigh();
protected abstract boolean hasFrequencyLow();
/**
* Channel number for the frequency
*/
public int getChannel()
{
return getHomeRepeater(getMessage());
}
/**
* Frequency for the channel when both the high and low frequency messages are available
*/
public long getFrequency()
{
if(hasFrequencyHigh() && hasFrequencyLow())
{
return 150000000 + ((getFrequencyHigh().getHighChannelUnits() + getFrequencyLow().getLowChannelUnits()) * 1250);
}
return 0;
}
}

View File

@@ -0,0 +1,80 @@
/*
* ******************************************************************************
* 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.ltrnet.message.osw;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
/**
* Base frequency message
*/
public abstract class FrequencyHigh extends Frequency
{
private FrequencyLow mFrequencyLow;
/**
* Constructs a message
*/
public FrequencyHigh(CorrectedBinaryMessage message, long timestamp)
{
super(message, timestamp);
}
/**
* Sets the corresponding low frequency message so that the correct frequency can be calculated
*/
public void setFrequencyLow(FrequencyLow frequencyLow)
{
mFrequencyLow = frequencyLow;
}
/**
* Returns the value of the high order (15 - 12) frequency bits which are
* the lower 4 bits of the Free field, left shifted by 12, representing the
* frequency value in units of .00125 MHz
*/
public int getHighChannelUnits()
{
return Integer.rotateLeft(getMessage().getInt(29, 32), 12);
}
@Override
protected FrequencyHigh getFrequencyHigh()
{
return this;
}
@Override
protected FrequencyLow getFrequencyLow()
{
return mFrequencyLow;
}
@Override
protected boolean hasFrequencyHigh()
{
return true;
}
@Override
protected boolean hasFrequencyLow()
{
return mFrequencyLow != null;
}
}

View File

@@ -0,0 +1,77 @@
/*
* ******************************************************************************
* 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.ltrnet.message.osw;
import io.github.dsheirer.bits.CorrectedBinaryMessage;
/**
* Base frequency message
*/
public abstract class FrequencyLow extends Frequency
{
private FrequencyHigh mFrequencyHigh;
/**
* Constructs a message
*/
public FrequencyLow(CorrectedBinaryMessage message, long timestamp)
{
super(message, timestamp);
}
public void setFrequencyHigh(FrequencyHigh frequencyHigh)
{
mFrequencyHigh = frequencyHigh;
}
/**
* Returns the value of the low order (11 - 0) frequency bits which are
* contained in the Group and Free fields representing the frequency value
* units of .00125 MHz
*/
public int getLowChannelUnits()
{
return getMessage().getInt(21, 32);
}
@Override
protected FrequencyHigh getFrequencyHigh()
{
return mFrequencyHigh;
}
@Override
protected FrequencyLow getFrequencyLow()
{
return this;
}
@Override
protected boolean hasFrequencyHigh()
{
return mFrequencyHigh != null;
}
@Override
protected boolean hasFrequencyLow()
{
return true;
}
}

Some files were not shown because too many files have changed in this diff Show More