mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
* P25 Phase 2 now supports control channel decoding and decoder was enhanced to improve decodes. * Radio reference site editor updated for phase 2 sites to allow user to select FDMA or TDMA control. * Decode events are now minimized and de-duplicated. * Fully parsing all phase 1/2 messages from the latest ICD. * Vendor specific messaging recoveries (Moto & Harris). * Patch group management enhancements with stale patch detection. * Tuner editor now fully resets the min/max frequency values * Default traffic channel count increased to 20 (from 3). * ISSI roaming radio and talkgroup values now displayed and aliasable as fully qualified values (e.g. 1234(123.456.7890) * Moto emergency alarm activation messaging support * Expanded list of P25 encryption algorithms * Message (bits) viewer enhanced for P25 phase 1 and phase 2 * IPV4 addresses and UDP ports no longer classified as user values - won't display in event views. * New framework for describing message binary fields that should reduce overall memory footprint and enhance code readability Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
191
src/main/java/io/github/dsheirer/message/AbstractMessage.java
Normal file
191
src/main/java/io/github/dsheirer/message/AbstractMessage.java
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2024 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.message;
|
||||
|
||||
import io.github.dsheirer.bits.CorrectedBinaryMessage;
|
||||
import io.github.dsheirer.bits.FragmentedIntField;
|
||||
import io.github.dsheirer.bits.IntField;
|
||||
import io.github.dsheirer.bits.LongField;
|
||||
|
||||
/**
|
||||
* Base message class with general utility methods for accessing fields in BinaryMessages.
|
||||
*/
|
||||
public abstract class AbstractMessage
|
||||
{
|
||||
private CorrectedBinaryMessage mMessage;
|
||||
private int mOffset = 0;
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param message containing the message bits.
|
||||
* @param offset to the start of the message within the corrected binary message.
|
||||
*/
|
||||
public AbstractMessage(CorrectedBinaryMessage message, int offset)
|
||||
{
|
||||
mMessage = message;
|
||||
mOffset = offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance.
|
||||
* @param message bits
|
||||
*/
|
||||
public AbstractMessage(CorrectedBinaryMessage message)
|
||||
{
|
||||
this(message, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this message is offset within the corrected binary message.
|
||||
* @return true of offset is non-zero.
|
||||
*/
|
||||
private boolean hasOffset()
|
||||
{
|
||||
return mOffset > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Offset to the start of the message (fragement) within the corrected binary message.
|
||||
*/
|
||||
public int getOffset()
|
||||
{
|
||||
return mOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Binary (bits) message for this message.
|
||||
* @return corrected binary message
|
||||
*/
|
||||
public CorrectedBinaryMessage getMessage()
|
||||
{
|
||||
return mMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the field has a non-zero value, meaning that any of the bits for the field are set to a one.
|
||||
* @param field to inspect.
|
||||
* @return true if the field has a non-zero value.
|
||||
*/
|
||||
public boolean hasInt(IntField field)
|
||||
{
|
||||
if(hasOffset())
|
||||
{
|
||||
return getMessage().hasInt(field, getOffset());
|
||||
}
|
||||
else
|
||||
{
|
||||
return getMessage().hasInt(field);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the integer field value and formats it as hexadecimal number
|
||||
* @param field to parse
|
||||
* @param places to format (ie 2 for a byte, 4 for 2-bytes, etc.)
|
||||
* @return formatted hex value.
|
||||
*/
|
||||
public String getIntAsHex(IntField field, int places)
|
||||
{
|
||||
int value = getInt(field);
|
||||
String hex = Integer.toHexString(value).toUpperCase();
|
||||
while(hex.length() < places)
|
||||
{
|
||||
hex = "0" + hex;
|
||||
}
|
||||
|
||||
return hex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the integer value for the specified field.
|
||||
* @param field to access
|
||||
* @return integer value for the field.
|
||||
*/
|
||||
public int getInt(IntField field)
|
||||
{
|
||||
if(hasOffset())
|
||||
{
|
||||
return getMessage().getInt(field, getOffset());
|
||||
}
|
||||
else
|
||||
{
|
||||
return getMessage().getInt(field);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the field has a non-zero value, meaning that any of the bits for the field are set to a one.
|
||||
* @param field to inspect.
|
||||
* @return true if the field has a non-zero value.
|
||||
*/
|
||||
public boolean hasInt(FragmentedIntField field)
|
||||
{
|
||||
if(hasOffset())
|
||||
{
|
||||
return getMessage().hasInt(field, getOffset());
|
||||
}
|
||||
else
|
||||
{
|
||||
return getMessage().hasInt(field);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the integer value for the specified field.
|
||||
* @param field to access
|
||||
* @return integer value for the field.
|
||||
*/
|
||||
public int getInt(FragmentedIntField field)
|
||||
{
|
||||
if(hasOffset())
|
||||
{
|
||||
return getMessage().getInt(field, getOffset());
|
||||
}
|
||||
else
|
||||
{
|
||||
return getMessage().getInt(field);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the long value for the specified field.
|
||||
* @param field to access
|
||||
* @return value for the field.
|
||||
*/
|
||||
public long getLong(LongField field)
|
||||
{
|
||||
if(hasOffset())
|
||||
{
|
||||
return getMessage().getLong(field, getOffset());
|
||||
}
|
||||
else
|
||||
{
|
||||
return getMessage().getLong(field);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to format an octet as hex.
|
||||
*/
|
||||
public static String formatOctetAsHex(int value)
|
||||
{
|
||||
return String.format("%02X", value);
|
||||
}
|
||||
}
|
||||
103
src/main/java/io/github/dsheirer/message/TimeslotMessage.java
Normal file
103
src/main/java/io/github/dsheirer/message/TimeslotMessage.java
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2024 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.message;
|
||||
|
||||
import io.github.dsheirer.bits.CorrectedBinaryMessage;
|
||||
|
||||
/**
|
||||
* Timeslot message base class.
|
||||
*/
|
||||
public abstract class TimeslotMessage extends AbstractMessage
|
||||
{
|
||||
public static final int TIMESLOT_0 = 0;
|
||||
public static final int TIMESLOT_1 = 1;
|
||||
public static final int TIMESLOT_2 = 2;
|
||||
private long mTimestamp;
|
||||
private int mTimeslot;
|
||||
private boolean mValid = true;
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param message containing binary fields that may contain fields outside of the scope of this class and thus
|
||||
* requires an offset value that points to the start of this message structure within the larger message context.
|
||||
* @param offset in the binary message to the start of this chunk of the message.
|
||||
* @param timeslot for this message
|
||||
* @param timestamp for this message
|
||||
*/
|
||||
public TimeslotMessage(CorrectedBinaryMessage message, int offset, int timeslot, long timestamp)
|
||||
{
|
||||
super(message, offset);
|
||||
mTimeslot = timeslot;
|
||||
mTimestamp = timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param message containing binary fields.
|
||||
* @param timeslot for this message
|
||||
* @param timestamp for this message
|
||||
*/
|
||||
public TimeslotMessage(CorrectedBinaryMessage message, int timeslot, long timestamp)
|
||||
{
|
||||
super(message);
|
||||
mTimeslot = timeslot;
|
||||
mTimestamp = timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Timeslot for this message.
|
||||
* @return timeslot, default of 0 for no timeslot.
|
||||
*/
|
||||
public int getTimeslot()
|
||||
{
|
||||
return mTimeslot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Timestamp when the message was received or processed. This timestamp should be as close to
|
||||
* accurate as possible.
|
||||
*/
|
||||
public long getTimestamp()
|
||||
{
|
||||
return mTimestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decoded textual representation of the message
|
||||
*/
|
||||
public abstract String toString();
|
||||
|
||||
/**
|
||||
* Indicates if the message is valid and has passed crc/integrity checks
|
||||
*/
|
||||
public boolean isValid()
|
||||
{
|
||||
return mValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the validity flag to indicate if the message is valid and passed any CRC or integrity checks.
|
||||
* @param valid flag
|
||||
*/
|
||||
public void setValid(boolean valid)
|
||||
{
|
||||
mValid = valid;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user