Identifier Framework and Message/Event Processing Overhaul (#455)

* WIP on new P25 message framer.

* WIP on new P25 message framer.

* Adds new 1/2 and 3/4 rate trellis decoders.  Still trying to chase
down why there is a sync pattern mismatch in the NID buffer queue.

* WIP - new p25 message framer works correctly now.  PDU's are dectected
and decoded using the 1/2 and 3/4 rate trellis decoders.  Packet
Sequences are assembled.  Need to add a new packet sequence message
factory that can detect Motorola Auto Registration Service (ARS)
formatted UDP/ID packets and SNDCP command packets.

* WIP - removes nullify on channel results queue.

* WIP - updates message framer for TSBK 1/2/3 processing.

* WIP removing P25 sync pattern and nid bits from all message parsers.

* WIP - merges identifier framework branch changes into this branch.

* WIP on updating link control words to new format and identifier framework.

* WIP - implements rest of link control words for extended formats

* WIP - initial work on ISP/OSP TSBK message restructuring.

* WIP - adds more TSBK ISP and OSP messages

* WIP - finished updating most of the TSBK ISP and OSP messages.  Converted
all messages to no longer include the NID (nac + dataunitID) so that
each message can simply hold the parsed values.  Removed AliasList as
an argument to each message and updated all messges to use the new
IIdentifer and IAPCO25Channel interfaces.

Removed legacy TDU and LDU link control messages and replaced with a
single LinkControlWord class hierarchy.

P25 decoder state is not yet updated for the new message structure.

PDU message parsing is not fully implemented.

* WIP - adds some Multi-Block trunking control messages with Alternate
and Unconfirmed formats.

* WIP - Fully implements AMBTC and UMBTC PDU message parsers.

Some package restructuring.

* WIP - Resolves Link control parsing in LDU1 and 2 messages.

* WIP - finishes updating TSBK and Link Control messages.  Adds support
for moto link control messages for patch groups.

* WIP - finishes updating TSBK and Link Control messages.  Adds support
for moto link control messages for patch groups.  Adds support for moto
ARS service, IPV4 decoding, and UDP/IP packets.

* WIP - finishes SNDCP packet data with header parsing.  Compressed IP or
UDP headers are not yet supported, but are logged as such.

* WIP - converts all talkgroup identifiers to integers and updates
alias list to create a per-protocol map of talkgroup id's to alias.

Inserts a legacy talkgroup (ltr, p25, passport, mpt1327, mdc, etc.)
conversion utility to convert existing legacy (string) talkgroups to
new integer talkgroup format.

Creates an audio packet manager to insert metadata into audio packets
before streaming packets for playback, recording, and/or streaming.

Creates identifier collection to manage current identifiers in each of
the channel and decoder states.

Creates simplified channel metadata to maintain the now playing display.

Moves channel attributes (alias list, system, site, name) as configuration
identifiers in the channel state.

Many other refactoring and updates.

* WIP - numerous updates to push use of identifier collection throughout
the system.  Updates the channel metadata and audio packet processing
logic.  Implements a large portion of the P25 decode state processing.
Updates traffic channel management.  Adds user preferences for timestamp
and identifier formatting, however doesn't add a user interface yet.

* WIP - initial implementation of user preferences editor window.

* WIP - updates preferences editor window to close and dispose window but
retain javafx event thread running.

* WIP - fully updates p25 decoder state and traffic channel processing to
use the new identifier framework.

Cleans up channel event processing and removes channel model as the sole
broadcaster of channel events.  Channel processing manager now listens
for all start/stop events and requestors dispatch event directly to the
channel processing manager.

Resolves issue in airspy that was causing user interface to lock-up.  The
issue appears to occur when the dongle is plugged into a usb port that
can't fully support the data rate.  sdrtrunk now recognizes these errors
and warns the user that they should use another usb port.

* WIP - updates alias action manager and adds new talkgroup range alias identifier.

Updates playlist to incorporate a version number so that the playlist
updater only runs when needed, to update a playlist to the correct
version format.

Updates user preferences to use the google event bus to broadcast
preference update notifications to remove the need for listeners to
register directly on the user preferences instance.

* WIP - updates alias id editors to flag invalid values and moves legacy
alias ids to legacy package.

Updates event logging configuration to add traffic channel decode events
and decoded message logging.  Removes binary message logging since that
is now replaced with demodulated bitstream recording.

* Removes system properties from user preferences.  Preferences are stored
in the OS-dependent settings store (windows - registry)

* Updates MapService to use new PlottableDecodeEvent instead of monitoring
all of the decoded messages.

Updates Fleetsync decoder and related messages to identifier framework.

* Updates LTR-Net, Fleetsync and LJ1200 decoders to new identifier
framework and adds support for user preferences for formatting of
LTR-Net and fleetsync talkgroup identifiers.

Breaks LTR-Net messages into various message types and uses a new
message factory.

Removes alias list from message processing for ltr-net, fleetsync and
lj1200.

* Updates LTR-Standard messages to Identifier framework.

* Removes Plottable and IPlottable from codebase.

* wip

* WIP on MPT-1327 messages.

* Updates MPT1327 decoder to identifier framework and new traffic channel
manager.  This decoder still needs to be updated with a new message
parser factory and a sync detector like what is now used for P25.

* Updates MDC1200 decoder and message to identifier framework.

* Updates Tait1200 and Passport decoders to identifier framework.

* Merges changes from master branch.

* Removes legacy alias support classes.  Updates passport message processor
to only pass valid messages.  Adds support to playlist updater for
converting passport mobile ids to become passport talkgroup values.

* Updates P25 decoder state and channel state to better track allocated
traffic channels.  Resolves issue in timestamp manager for trackig
message timestamps. Resolves issue in airspy tuner that was causing
the tuner to stop sending samples to the application.

* Update P25 Decoder state to process SNDCP management messages and
PDU messages.

Updates P25 activity summary to display network and site details.

Resolves issue with overlay panel that prevented enabled channels from
rendering correctly when zoomed in.

* Creates a new FilePreferences as part of the user preferences to begin
the transition of SystemProperties over to user preferences and consolidate
file preferences in one location.

Updates playlist manager to use the new file preferences and to use
default.xml as the new default playlist name, following conversion of
a playlist_v2.xml format to the new format.

In the near future, the user will be able to edit file locations and to
create/use other playlists.

Resolved an issue with all decoder states where not all identifiers were
being included in decode events.
This commit is contained in:
Denny Sheirer
2018-12-24 09:08:34 -05:00
committed by GitHub
parent 735fca16d6
commit b67d4d92dc
869 changed files with 64776 additions and 45233 deletions

View File

@@ -1,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;
}
}