P25 work in progress - final commit of TSBK message parsers

This commit is contained in:
dennis.sheirer
2014-11-23 23:13:58 +00:00
parent 1660f13633
commit 23901c7a2f
29 changed files with 1630 additions and 184 deletions

View File

@@ -6,7 +6,7 @@ import decode.p25.message.tsbk.TSBKMessage;
import decode.p25.reference.DataUnitID;
import decode.p25.reference.Opcode;
public class AdjacentStatusBroadcast extends TSBKMessage
public class AdjacentStatusBroadcast extends TSBKMessage implements IdentifierUpdateReceiver
{
public static final int[] LOCATION_REGISTRATION_AREA = { 80,81,82,83,84,85,
86,87 };
@@ -18,14 +18,17 @@ public class AdjacentStatusBroadcast extends TSBKMessage
102,103 };
public static final int[] RFSS_ID = { 104,105,106,107,108,109,110,111 };
public static final int[] SITE_ID = { 112,113,114,115,116,117,118,119 };
public static final int[] CHANNEL = { 120,121,122,123,124,125,126,127,
128,129,130,131,132,133,134,135 };
public static final int[] IDENTIFIER = { 120,121,122,123 };
public static final int[] CHANNEL = { 124,125,126,127,128,129,130,131,132,
133,134,135 };
public static final int[] SYSTEM_SERVICE_CLASS = { 136,137,138,139,140,141,
142,143 };
private IdentifierUpdate mIdentifierUpdate;
public AdjacentStatusBroadcast( BitSetBuffer message,
DataUnitID duid,
AliasList aliasList )
DataUnitID duid,
AliasList aliasList )
{
super( message, duid, aliasList );
}
@@ -50,7 +53,11 @@ public class AdjacentStatusBroadcast extends TSBKMessage
sb.append( " SITE:" + getSiteID() );
sb.append( " CHAN:" + getChannel() );
sb.append( " CHAN:" + getIdentifier() + "-" + getChannel() );
sb.append( " DN:" + getDownlinkFrequency() );
sb.append( " UP:" + getUplinkFrequency() );
if( isConventionalChannel() )
{
@@ -122,8 +129,39 @@ public class AdjacentStatusBroadcast extends TSBKMessage
return mMessage.getInt( CHANNEL );
}
public int getIdentifier()
{
return mMessage.getInt( IDENTIFIER );
}
public int getSystemServiceClass()
{
return mMessage.getInt( SYSTEM_SERVICE_CLASS );
}
public long getDownlinkFrequency()
{
return calculateDownlink( mIdentifierUpdate, getChannel() );
}
public long getUplinkFrequency()
{
return calculateUplink( mIdentifierUpdate, getChannel() );
}
@Override
public void setIdentifierMessage( int identifier, IdentifierUpdate message )
{
/* we're only expecting 1 identifier, so use whatever is received */
mIdentifierUpdate = message;
}
public int[] getIdentifiers()
{
int[] idens = new int[ 1 ];
idens[ 0 ] = getIdentifier();
return idens;
}
}

View File

@@ -4,22 +4,13 @@ import alias.AliasList;
import bits.BitSetBuffer;
import decode.p25.message.tsbk.TSBKMessage;
import decode.p25.reference.DataUnitID;
import decode.p25.reference.Opcode;
public class IdentifierUpdate extends TSBKMessage
public abstract class IdentifierUpdate extends TSBKMessage
{
public static final int[] CHANNEL_IDENTIFIER = { 80,81,82,83 };
public static final int[] IDENTIFIER = { 80,81,82,83 };
public static final int[] CHANNEL_SPACING = { 102,103,104,105,106,107,108,
109,110,111 };
public static final int[] BANDWIDTH = { 84,85,86,87,88,89,90,91,92 };
public static final int[] BANDWIDTH_VHF_UHF = { 84,85,86,87 };
public static final int[] TRANSMIT_OFFSET = { 93,94,95,96,97,98,99,100,101 };
public static final int TRANSMIT_OFFSET_VHF_UHF_SIGN = 88;
public static final int[] TRANSMIT_OFFSET_VHF_UHF = { 89,90,91,92,93,94,
95,96,97,98,99,100,101 };
109,110,111 };
public static final int[] BASE_FREQUENCY = { 112,113,114,115,116,117,118,
119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,
@@ -32,42 +23,20 @@ public class IdentifierUpdate extends TSBKMessage
super( message, duid, aliasList );
}
@Override
public String getEventType()
{
return getOpcode().getDescription();
}
public String getMessage()
{
StringBuilder sb = new StringBuilder();
sb.append( getMessageStub() );
sb.append( " CHAN:" + getIdentifier() );
sb.append( " DOWNLINK:" + getDownlinkFrequency() );
sb.append( " UPLINK:" + ( getUplinkFrequency() ) );
sb.append( " BW:" + getBandwidth() );
sb.append( " SPACING:" + getChannelSpacing() );
return sb.toString();
}
/**
* (Band) Identifier
*/
public int getIdentifier()
{
return mMessage.getInt( CHANNEL_IDENTIFIER );
return mMessage.getInt( IDENTIFIER );
}
/**
* Channel spacing in hertz
*/
public int getChannelSpacing()
public long getChannelSpacing()
{
return mMessage.getInt( CHANNEL_SPACING ) * 125; //Hertz
return mMessage.getLong( CHANNEL_SPACING ) * 125l;
}
/**
@@ -75,79 +44,8 @@ public class IdentifierUpdate extends TSBKMessage
*/
public long getBaseFrequency()
{
return mMessage.getLong( BASE_FREQUENCY ) * 5l; //Hertz
return mMessage.getLong( BASE_FREQUENCY ) * 5l;
}
public boolean isVHF_UHF()
{
long base = getBaseFrequency();
return ( ( 136000000 <= base && base <= 172000000 ) ||
( 380000000 <= base && base <= 512000000 ) );
}
/**
* Channel bandwidth in hertz
*/
public int getBandwidth()
{
int bandwidth = mMessage.getInt( BANDWIDTH );
if( isVHF_UHF() )
{
switch( bandwidth )
{
case 4:
return 6250;
case 5:
return 12500;
default:
return 0;
}
}
else
{
return bandwidth * 125;
}
}
/**
* Transmit offset in hertz
*/
public long getOffset()
{
if( isVHF_UHF() )
{
long offset = mMessage.getLong( TRANSMIT_OFFSET_VHF_UHF );
if( mMessage.get( TRANSMIT_OFFSET_VHF_UHF_SIGN ) )
{
return offset;
}
else
{
return -offset;
}
}
else
{
return mMessage.getLong( TRANSMIT_OFFSET ) * 250l;
}
}
/**
* Uplink ( radio to tower) frequency in hertz
*/
public long getUplinkFrequency()
{
return getBaseFrequency() - getOffset();
}
/**
* Downlink ( tower to radio ) frequency in hertz
*/
public long getDownlinkFrequency()
{
return getBaseFrequency();
}
public abstract long getTransmitOffset();
}

View File

@@ -0,0 +1,73 @@
package decode.p25.message.tsbk.osp.control;
import alias.AliasList;
import bits.BitSetBuffer;
import decode.p25.reference.DataUnitID;
import decode.p25.reference.Opcode;
public class IdentifierUpdateNonVUHF extends IdentifierUpdate
{
public static final int[] BANDWIDTH = { 84,85,86,87,88,89,90,91,92 };
public static final int TRANSMIT_OFFSET_VHF_UHF_SIGN = 93;
public static final int[] TRANSMIT_OFFSET = { 94,95,96,97,98,99,100,101 };
public IdentifierUpdateNonVUHF( BitSetBuffer message,
DataUnitID duid,
AliasList aliasList )
{
super( message, duid, aliasList );
}
@Override
public String getEventType()
{
return Opcode.IDENTIFIER_UPDATE_NON_VUHF.getDescription();
}
public String getMessage()
{
StringBuilder sb = new StringBuilder();
sb.append( getMessageStub() );
sb.append( " IDEN:" + getIdentifier() );
sb.append( " BASE:" + getBaseFrequency() );
sb.append( " BW:" + getBandwidth() );
sb.append( " SPACING:" + getChannelSpacing() );
sb.append( " OFFSET:" + getTransmitOffset() );
return sb.toString();
}
/**
* Channel bandwidth in hertz
*/
public int getBandwidth()
{
return mMessage.getInt( BANDWIDTH ) * 125;
}
/**
* Transmit offset in hertz
*/
@Override
public long getTransmitOffset()
{
long offset = mMessage.getLong( TRANSMIT_OFFSET ) * 250000l;
if( mMessage.get( TRANSMIT_OFFSET_VHF_UHF_SIGN ) )
{
return offset;
}
else
{
return -offset;
}
}
}

View File

@@ -0,0 +1,13 @@
package decode.p25.message.tsbk.osp.control;
/**
* Interface to allow messages to be augmented with IdentiferUpdateXXX type
* messages that provide the channel information necessary to calculate the
* uplink and downlink frequency for the channel.
*/
public interface IdentifierUpdateReceiver
{
public void setIdentifierMessage( int identifier, IdentifierUpdate message );
public int[] getIdentifiers();
}

View File

@@ -0,0 +1,85 @@
package decode.p25.message.tsbk.osp.control;
import alias.AliasList;
import bits.BitSetBuffer;
import decode.p25.reference.DataUnitID;
import decode.p25.reference.Opcode;
public class IdentifierUpdateVUHF extends IdentifierUpdate
{
public static final int[] BANDWIDTH = { 84,85,86,87 };
public static final int TRANSMIT_OFFSET_VHF_UHF_SIGN = 88;
public static final int[] TRANSMIT_OFFSET = { 89,90,91,92,93,94,95,96,97,98,
99,100,101 };
public IdentifierUpdateVUHF( BitSetBuffer message,
DataUnitID duid,
AliasList aliasList )
{
super( message, duid, aliasList );
}
@Override
public String getEventType()
{
return Opcode.IDENTIFIER_UPDATE_VHF_UHF_BANDS.getDescription();
}
public String getMessage()
{
StringBuilder sb = new StringBuilder();
sb.append( getMessageStub() );
sb.append( " IDEN:" + getIdentifier() );
sb.append( " BASE:" + getBaseFrequency() );
sb.append( " BW:" + getBandwidth() );
sb.append( " SPACING:" + getChannelSpacing() );
sb.append( " OFFSET:" + getTransmitOffset() );
return sb.toString();
}
/**
* Channel bandwidth in hertz
*/
public int getBandwidth()
{
int bandwidth = mMessage.getInt( BANDWIDTH );
switch( bandwidth )
{
case 4:
return 6250;
case 5:
return 12500;
default:
return 0;
}
}
/**
* Transmit offset in hertz
*/
@Override
public long getTransmitOffset()
{
long offset = mMessage.getLong( TRANSMIT_OFFSET ) *
getChannelSpacing();
if( mMessage.get( TRANSMIT_OFFSET_VHF_UHF_SIGN ) )
{
return offset;
}
else
{
return -offset;
}
}
}

View File

@@ -6,7 +6,7 @@ import decode.p25.message.tsbk.TSBKMessage;
import decode.p25.reference.DataUnitID;
import decode.p25.reference.Opcode;
public class NetworkStatusBroadcast extends TSBKMessage
public class NetworkStatusBroadcast extends TSBKMessage implements IdentifierUpdateReceiver
{
public static final int[] LOCATION_REGISTRATION_AREA = { 80,81,82,83,84,85,
86,87 };
@@ -14,11 +14,14 @@ public class NetworkStatusBroadcast extends TSBKMessage
101,102,103,104,105,106,107 };
public static final int[] SYSTEM_ID = { 108,109,110,111,112,113,114,115,116,
117,118,119 };
public static final int[] CHANNEL = { 120,121,122,123,124,125,126,127,128,
129,130,131,132,133,134,135 };
public static final int[] IDENTIFIER = { 120,121,122,123 };
public static final int[] CHANNEL = { 124,125,126,127,128,129,130,131,132,
133,134,135 };
public static final int[] SYSTEM_SERVICE_CLASS = { 136,137,138,139,140,141,
142,143 };
private IdentifierUpdate mIdentifierUpdate;
public NetworkStatusBroadcast( BitSetBuffer message,
DataUnitID duid,
AliasList aliasList )
@@ -44,7 +47,11 @@ public class NetworkStatusBroadcast extends TSBKMessage
sb.append( " SYS:" + getSystemID() );
sb.append( " CNTRL CHAN:" + getChannel() );
sb.append( " CTRL CHAN:" + getIdentifier() + "-" + getChannel() );
sb.append( " DN:" + getDownlinkFrequency() );
sb.append( " UP:" + getUplinkFrequency() );
sb.append( " SYS SVC CLASS:" +
SystemService.toString( getSystemServiceClass() ) );
@@ -66,6 +73,11 @@ public class NetworkStatusBroadcast extends TSBKMessage
{
return mMessage.getHex( SYSTEM_ID, 3 );
}
public int getIdentifier()
{
return mMessage.getInt( IDENTIFIER );
}
public int getChannel()
{
@@ -76,4 +88,30 @@ public class NetworkStatusBroadcast extends TSBKMessage
{
return mMessage.getInt( SYSTEM_SERVICE_CLASS );
}
public long getDownlinkFrequency()
{
return calculateDownlink( mIdentifierUpdate, getChannel() );
}
public long getUplinkFrequency()
{
return calculateUplink( mIdentifierUpdate, getChannel() );
}
@Override
public void setIdentifierMessage( int identifier, IdentifierUpdate message )
{
/* we're only expecting 1 identifier, so use whatever is received */
mIdentifierUpdate = message;
}
public int[] getIdentifiers()
{
int[] idens = new int[ 1 ];
idens[ 0 ] = getIdentifier();
return idens;
}
}

View File

@@ -6,7 +6,7 @@ import decode.p25.message.tsbk.TSBKMessage;
import decode.p25.reference.DataUnitID;
import decode.p25.reference.Opcode;
public class RFSSStatusBroadcast extends TSBKMessage
public class RFSSStatusBroadcast extends TSBKMessage implements IdentifierUpdateReceiver
{
public static final int[] LOCATION_REGISTRATION_AREA = { 80,81,82,83,84,85,
86,87 };
@@ -15,11 +15,14 @@ public class RFSSStatusBroadcast extends TSBKMessage
102,103 };
public static final int[] RFSS_ID = { 104,105,106,107,108,109,110,111 };
public static final int[] SITE_ID = { 112,113,114,115,116,117,118,119 };
public static final int[] CHANNEL = { 120,121,122,123,124,125,126,127,
128,129,130,131,132,133,134,135 };
public static final int[] IDENTIFIER = { 120,121,122,123 };
public static final int[] CHANNEL = { 124,125,126,127,128,129,130,131,132,
133,134,135 };
public static final int[] SYSTEM_SERVICE_CLASS = { 136,137,138,139,140,141,
142,143 };
private IdentifierUpdate mIdentifierUpdate;
public RFSSStatusBroadcast( BitSetBuffer message,
DataUnitID duid,
AliasList aliasList )
@@ -47,8 +50,12 @@ public class RFSSStatusBroadcast extends TSBKMessage
sb.append( " SITE:" + getSiteID() );
sb.append( " CHAN:" + getChannel() );
sb.append( " CHAN:" + getIdentifier() + "-" + getChannel() );
sb.append( " DN:" + getDownlinkFrequency() );
sb.append( " UP:" + getUplinkFrequency() );
if( hasActiveNetworkConnection() )
{
sb.append( " ACTIVE-NETWORK-CONN" );
@@ -83,6 +90,11 @@ public class RFSSStatusBroadcast extends TSBKMessage
{
return mMessage.getHex( SITE_ID, 2 );
}
public int getIdentifier()
{
return mMessage.getInt( IDENTIFIER );
}
public int getChannel()
{
@@ -93,4 +105,30 @@ public class RFSSStatusBroadcast extends TSBKMessage
{
return mMessage.getInt( SYSTEM_SERVICE_CLASS );
}
public long getDownlinkFrequency()
{
return calculateDownlink( mIdentifierUpdate, getChannel() );
}
public long getUplinkFrequency()
{
return calculateUplink( mIdentifierUpdate, getChannel() );
}
@Override
public void setIdentifierMessage( int identifier, IdentifierUpdate message )
{
/* we're only expecting 1 identifier, so use whatever is received */
mIdentifierUpdate = message;
}
public int[] getIdentifiers()
{
int[] idens = new int[ 1 ];
idens[ 0 ] = getIdentifier();
return idens;
}
}

View File

@@ -1,24 +1,36 @@
package decode.p25.message.tsbk.osp.control;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import alias.AliasList;
import bits.BitSetBuffer;
import decode.p25.message.tsbk.TSBKMessage;
import decode.p25.reference.DataUnitID;
import decode.p25.reference.Opcode;
public class SecondaryControlChannelBroadcast extends TSBKMessage
public class SecondaryControlChannelBroadcast extends TSBKMessage
implements IdentifierUpdateReceiver
{
public static final int[] RFSS_ID = { 80,81,82,83,84,85,86,87 };
private final static Logger mLog =
LoggerFactory.getLogger( SecondaryControlChannelBroadcast.class );
public static final int[] RFSS_ID = { 80,81,82,83,84,85,86,87 };
public static final int[] SITE_ID = { 88,89,90,91,92,93,94,95 };
public static final int[] CHANNEL_1 = { 96,97,98,99,100,101,102,103,104,105,
106,107,108,109,110,111 };
public static final int[] IDENTIFIER_1 = { 96,97,98,99 };
public static final int[] CHANNEL_1 = { 100,101,102,103,104,105,106,107,108,
109,110,111 };
public static final int[] SYSTEM_SERVICE_CLASS_1 = { 112,113,114,115,116,
117,118,119 };
public static final int[] CHANNEL_2 = { 120,121,122,123,124,125,126,127,
128,129,130,131,132,133,134,135 };
public static final int[] IDENTIFIER_2 = { 120,121,122,123 };
public static final int[] CHANNEL_2 = { 124,125,126,127,128,129,130,131,132,
133,134,135 };
public static final int[] SYSTEM_SERVICE_CLASS_2 = { 136,137,138,139,140,
141,142,143 };
private IdentifierUpdate mIdentifierUpdate1;
private IdentifierUpdate mIdentifierUpdate2;
public SecondaryControlChannelBroadcast( BitSetBuffer message,
DataUnitID duid,
AliasList aliasList )
@@ -42,22 +54,27 @@ public class SecondaryControlChannelBroadcast extends TSBKMessage
sb.append( " SITE:" + getSiteID() );
sb.append( " CHAN 1:" + getChannel1() );
sb.append( " CHAN1:" + getIdentifier1() + "-" + getChannel1() );
sb.append( " SVC CLASS 1:" +
sb.append( " DN1:" + getDownlinkFrequency1() );
sb.append( " UP1:" + getUplinkFrequency1() );
sb.append( " SVC1:" +
SystemService.toString( getSystemServiceClass1() ) );
if( hasChannel2() )
{
sb.append( " CHAN 2:" + getChannel2() );
sb.append( " CHAN2:" + getIdentifier2() + "-" + getChannel2() );
sb.append( " SVC CLASS 2:" +
sb.append( " DN2:" + getDownlinkFrequency2() );
sb.append( " UP2:" + getUplinkFrequency2() );
sb.append( " SVC2:" +
SystemService.toString( getSystemServiceClass2() ) );
}
else
{
sb.append( " CHAN 2: empty" );
}
return sb.toString();
}
@@ -71,6 +88,11 @@ public class SecondaryControlChannelBroadcast extends TSBKMessage
return mMessage.getHex( SITE_ID, 2 );
}
public int getIdentifier1()
{
return mMessage.getInt( IDENTIFIER_1 );
}
public int getChannel1()
{
return mMessage.getInt( CHANNEL_1 );
@@ -80,6 +102,11 @@ public class SecondaryControlChannelBroadcast extends TSBKMessage
{
return mMessage.getInt( SYSTEM_SERVICE_CLASS_1 );
}
public int getIdentifier2()
{
return mMessage.getInt( IDENTIFIER_2 );
}
public int getChannel2()
{
@@ -95,4 +122,64 @@ public class SecondaryControlChannelBroadcast extends TSBKMessage
{
return getSystemServiceClass2() != 0;
}
public long getDownlinkFrequency1()
{
return calculateDownlink( mIdentifierUpdate1, getChannel1() );
}
public long getUplinkFrequency1()
{
return calculateUplink( mIdentifierUpdate1, getChannel1() );
}
public long getDownlinkFrequency2()
{
return calculateDownlink( mIdentifierUpdate2, getChannel2() );
}
public long getUplinkFrequency2()
{
return calculateUplink( mIdentifierUpdate2, getChannel2() );
}
@Override
public void setIdentifierMessage( int identifier, IdentifierUpdate message )
{
if( identifier == getIdentifier1() )
{
mIdentifierUpdate1 = message;
}
else if( identifier == getIdentifier2() )
{
mIdentifierUpdate2 = message;
}
else
{
throw new IllegalArgumentException( "Unexpected identifier update "
+ "message for identifier [" + identifier + "]" );
}
}
public int[] getIdentifiers()
{
int[] idens;
if( hasChannel2() )
{
idens = new int[ 2 ];
idens[ 0 ] = getIdentifier1();
idens[ 1 ] = getIdentifier2();
}
else
{
idens = new int[ 1 ];
idens[ 0 ] = getIdentifier1();
}
return idens;
}
}

View File

@@ -0,0 +1,60 @@
package decode.p25.message.tsbk.osp.control;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import alias.AliasList;
import bits.BitSetBuffer;
import decode.p25.reference.DataUnitID;
import decode.p25.reference.Opcode;
public class SecondaryControlChannelBroadcastExplicit
extends SecondaryControlChannelBroadcast
{
private final static Logger mLog = LoggerFactory.getLogger(
SecondaryControlChannelBroadcastExplicit.class );
public SecondaryControlChannelBroadcastExplicit( BitSetBuffer message,
DataUnitID duid, AliasList aliasList )
{
super( message, duid, aliasList );
}
@Override
public String getEventType()
{
return Opcode.SECONDARY_CONTROL_CHANNEL_BROADCAST_EXPLICIT.getDescription();
}
public String getMessage()
{
StringBuilder sb = new StringBuilder();
sb.append( getMessageStub() );
sb.append( " RFSS:" + getRFSS() );
sb.append( " SITE:" + getSiteID() );
sb.append( " DOWNLINK:" + getIdentifier1() + "-" + getChannel1() );
sb.append( " " + getDownlinkFrequency1() );
sb.append( " SVC1:" +
SystemService.toString( getSystemServiceClass1() ) );
if( hasChannel2() )
{
sb.append( " UPLINK:" + getIdentifier2() + "-" + getChannel2() );
sb.append( " " + getUplinkFrequency1() );
sb.append( " SVC2:" +
SystemService.toString( getSystemServiceClass2() ) );
}
return sb.toString();
}
}

View File

@@ -0,0 +1,155 @@
package decode.p25.message.tsbk.osp.control;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import alias.AliasList;
import bits.BitSetBuffer;
import decode.p25.message.tsbk.TSBKMessage;
import decode.p25.reference.DataUnitID;
import decode.p25.reference.Opcode;
public class TimeAndDateAnnouncement extends TSBKMessage
{
public static final int VALID_DATE_INDICATOR = 80;
public static final int VALID_TIME_INDICATOR = 81;
public static final int VALID_LOCAL_TIME_OFFSET_INDICATOR = 82;
public static final int LOCAL_TIME_OFFSET_SIGN = 84;
public static final int[] LOCAL_TIME_OFFSET = { 85,86,87,88,89,90,91,92,
93,94,95 };
public static final int[] MONTH = { 96,97,98,99 };
public static final int[] DAY = { 100,101,102,103 };
public static final int[] YEAR = { 105,106,107,108,109,110,111,112,113,114,
115,116,117 };
public static final int[] HOURS = { 120,121,122,123,124 };
public static final int[] MINUTES = { 125,126,127,128,129,130 };
public static final int[] SECONDS = { 131,132,133,134,135,136 };
private SimpleDateFormat mTimeFormatter =
new SimpleDateFormat( "EEE, d MMM yyyy HH:mm:ss Z" );
public TimeAndDateAnnouncement( BitSetBuffer message, DataUnitID duid,
AliasList aliasList )
{
super( message, duid, aliasList );
}
@Override
public String getEventType()
{
return Opcode.TIME_DATE_ANNOUNCEMENT.getDescription();
}
public String getMessage()
{
StringBuilder sb = new StringBuilder();
sb.append( getMessageStub() );
if( hasValidDate() )
{
sb.append( " DATE-TIME:" );
}
sb.append( mTimeFormatter.format( new Date( getDateTimestamp() ) ) );
return sb.toString();
}
public long getDateTimestamp()
{
Calendar cal = new GregorianCalendar( getTimeZone() );
if( hasValidDate() )
{
cal.set( Calendar.YEAR, getYear() );
cal.set( Calendar.MONTH, getMonth() );
cal.set( Calendar.DAY_OF_MONTH, getDay() );
}
if( hasValidTime() )
{
cal.set( Calendar.HOUR, getHour() );
cal.set( Calendar.MINUTE, getMinute() );
cal.set( Calendar.SECOND, getSecond() );
}
return cal.getTimeInMillis();
}
public boolean hasValidDate()
{
return mMessage.get( VALID_DATE_INDICATOR );
}
public boolean hasValidTime()
{
return mMessage.get( VALID_TIME_INDICATOR );
}
public TimeZone getTimeZone()
{
StringBuilder sb = new StringBuilder();
sb.append( "GMT " );
sb.append( mMessage.get( LOCAL_TIME_OFFSET_SIGN ) ? "-" : "+" );
int offsetMinutes = getLocalTimeOffset();
sb.append( (int)( offsetMinutes / 60 ) );
sb.append( " : " );
sb.append( offsetMinutes % 60 );
return TimeZone.getTimeZone( sb.toString() );
}
public boolean hasValidLocalTimeOffset()
{
return mMessage.get( VALID_LOCAL_TIME_OFFSET_INDICATOR );
}
/**
* Local Time Offset in minutes
*/
public int getLocalTimeOffset()
{
return mMessage.getInt( LOCAL_TIME_OFFSET );
}
public int getMonth()
{
return mMessage.getInt( MONTH );
}
public int getDay()
{
return mMessage.getInt( DAY );
}
public int getYear()
{
return mMessage.getInt( YEAR );
}
public int getHour()
{
return mMessage.getInt( HOURS );
}
public int getMinute()
{
return mMessage.getInt( MINUTES );
}
public int getSecond()
{
return mMessage.getInt( SECONDS );
}
}