Package org.ka2ddo.aprs
Class Message
java.lang.Object
org.ka2ddo.ax25.AX25Message
org.ka2ddo.aprs.Message
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<AX25Message>
,CommentedMessage
- Direct Known Subclasses:
DefaultMessage
,MessageMessage
,PositionlessWeatherReport
,PositionMessage
,Query
,StationCapabilities
,StatusMessage
,TelemetryMessage
,UltimeterRawMessage
This abstract class defines the common parts of one APRS message. Subclasses handle the details
of specific message types.
- Author:
- Andrew Pavlin, KA2DDO
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.ka2ddo.ax25.AX25Message
AX25Message.Precedence
-
Field Summary
Modifier and TypeFieldDescriptionprotected static boolean
Flag for APRS message generators as to whether a trailing carriage return (CR or \\r character) should be appended to APRS packets.protected static final Set<ProtocolFamily>
ProtocolFamily set providing all protocols.protected static final Set<ProtocolFamily>
Set of ProtocolFamily values for both APRS and raw AX.25.protected String
Free-text comment in this message.protected byte
APRS message type code (prefix character in the message text).static final String
Reserved APRS timestamp string for permanent Objects.static final String
Reserved APRS timestamp string for permanent Objects, with uppercase timezone letter.protected char
The APRS symbol code within the specified table for the station originating this message.protected char
The APRS symbol table ID (or overlay character) for the station originating this message.Fields inherited from class org.ka2ddo.ax25.AX25Message
APRS_AND_OPENTRAC, ax25Frame, extensions, invalid, originatingCallsign, originatingDest, PERMANENT, rcptTime, thirdParty, timestamp, UTC
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Compare the contents of the body of the message, reporting if they match.int
Compares this object with the specified object for order.protected int
decodeDatestamp
(byte[] body, int pos) Extract an APRS-standard 8-digit date/timestamp from a byte array presumably containing a timestamped APRS message and store it in the timestamp field of this Message object.protected int
decodeHurricaneParams
(byte[] body, int offset) Extract APRS-standard hurricane/tropical storm information from a message body.protected int
decodeTimestamp
(byte[] body, int pos, long rcvTimestamp) Extract an APRS-standard 6-digit timestamp from a byte array presumably containing a timestamped APRS message and store it in the timestamp field of this Message object.protected int
decodeWeatherParams
(byte[] body, int offset) Extract APRS-standard weather information from a message body.protected int
decodeWeatherParams
(String body, int offset) Extract APRS-standard weather information from a message body.dup()
Creates and returns a deep copy of this Message.protected static String
encodeTimestamp
(Date date, long now) Produce a APRS-standard 6-digit timestamp string for the specified date/time, using the most precise format possible relative to the current time.protected void
extractComment
(byte[] body, int offset) Extract the remaining text in the byte buffer as the free-text comment of this message.protected void
extractComment
(byte[] body, int startPos, int endPos) Extract the remaining text in the byte buffer as the free-text comment of this message.static String
extractSymbol
(String dest) Decode a symbol from the destination tocall (handling the case of old hardware and/or software whose limited message set does not include messages with symbol codes in the message body).static String
formatBody
(byte[] body, int offset) Convert a byte array into a UTF_8 printable string.Get the free-text comment of this message,Build a formatted string of the weather data known to this message,int
Get the APRS message type code for this message.Report the traffic-handling precedence for this message instance.Get the protocol family or families that this message corresponds to, so ports that don't support all protocols will not forward inappropriate packets.final char
Get the APRS symbol code for this Message.final char
Get the APRS symbol table ID or overlay character for this Message.boolean
Report if this Message contains weather information.protected void
inferSymbol
(AX25Callsign src, AX25Callsign dst) Decode a symbol from the destination AX25Callsign (handling the case of old hardware and/or software whose limited message set does not include messages with symbol codes in the message body).static boolean
Indicate whether trailing CR should be appended to generated APRS packets.boolean
Report whether the non-null APRS symbol reported by this message is explicit or inferred from destination or source callsign.protected static boolean
looksLikeLongFormatLatitude
(byte[] body, int pos, int len) Test the byte array to see if it looks like it contains a APRS text-format (long) position indicator.Descriptive text about this message, to be included in the toString() method's response.static void
setAppendCR
(boolean appendCR) Specify whether trailing CR should be appended to generated APRS packets.void
setComment
(String comment) Set the free-text comment for this Message.void
setSymbolCode
(char symbolCode) Set the APRS symbol code for this Message.void
setSymTableId
(char symTableId) Set the APRS symbol table ID or overlay character for this Message.toString()
Returns a string representation of the object.Methods inherited from class org.ka2ddo.ax25.AX25Message
equals, extractSource, getAx25Frame, getExtension, getFirstDigipeat, getLastDigipeat, getNthDigipeat, getOriginalDestination, getOriginalSource, getOriginatingCallsign, getOriginatingDest, getRcptTime, getReadOnlyExtensionMap, getTimestamp, hashCode, hasPosition, hasThisFirstDigi, indexOf, indexOf, isDirect, isInvalid, isRf, onlyDigits, onlyDigits, onlyDigitsOrMinus, onlyDigitsOrPeriod, onlyDigitsOrSpace, onlyDigitsPlus, onlyPeriods, setAx25Frame, setInvalid, setOriginatingCallsign, setRcptTime, setTimestamp, split, storeExtension
-
Field Details
-
S_PERMANENT
Reserved APRS timestamp string for permanent Objects.- See Also:
-
S_PERMANENT_UC
Reserved APRS timestamp string for permanent Objects, with uppercase timezone letter.- See Also:
-
APRS_AND_OPENTRAC_AND_RAW
ProtocolFamily set providing all protocols. -
appendCR
protected static boolean appendCRFlag for APRS message generators as to whether a trailing carriage return (CR or \\r character) should be appended to APRS packets. -
symTableId
protected char symTableIdThe APRS symbol table ID (or overlay character) for the station originating this message. May be zero if no symbol defined by this message.- See Also:
-
symbolCode
protected char symbolCodeThe APRS symbol code within the specified table for the station originating this message. May be zero if no symbol defined by this message.- See Also:
-
comment
Free-text comment in this message. -
msgType
protected byte msgTypeAPRS message type code (prefix character in the message text). -
APRS_AND_RAW
Set of ProtocolFamily values for both APRS and raw AX.25.
-
-
Constructor Details
-
Message
protected Message()Create an uninitialized message. -
Message
Set up this superclass's infrastructure for a particular message type at a particular receive time with the specified third-party routing.- Parameters:
msgType
- printable ASCII character identifying the APRS message typethirdParty
- String of third-party network routing data (may be null)rcptTime
- time in milliseconds since Jan 1 1970 UTC that message was received or created
-
-
Method Details
-
bodyEquals
Compare the contents of the body of the message, reporting if they match.- Specified by:
bodyEquals
in classAX25Message
- Parameters:
o
- another AX25Message to compare against- Returns:
- boolean true if the body values are equivalent
-
compareTo
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.- Specified by:
compareTo
in interfaceComparable<AX25Message>
- Overrides:
compareTo
in classAX25Message
- Parameters:
o
- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Throws:
ClassCastException
- if the specified object's type prevents it from being compared to this object.
-
toString
Returns a string representation of the object.- Overrides:
toString
in classAX25Message
- Returns:
- a string representation of the object.
-
getMsgType
public int getMsgType()Get the APRS message type code for this message.- Returns:
- the ASCII character identifying the type of this APRS message
-
decodeTimestamp
protected int decodeTimestamp(byte[] body, int pos, long rcvTimestamp) Extract an APRS-standard 6-digit timestamp from a byte array presumably containing a timestamped APRS message and store it in the timestamp field of this Message object.- Parameters:
body
- byte array containing the messagepos
- index into the array where the timestamp is supposed to startrcvTimestamp
- default time (in Java milliseconds since Jan 1 1970 UTC) to use if timestamp field is all period characters- Returns:
- index into the byte array immediately following the decoded timestamp
- See Also:
-
decodeDatestamp
protected int decodeDatestamp(byte[] body, int pos) Extract an APRS-standard 8-digit date/timestamp from a byte array presumably containing a timestamped APRS message and store it in the timestamp field of this Message object.- Parameters:
body
- byte array containing the messagepos
- index into the array where the timestamp is supposed to start- Returns:
- index into the byte array immediately following the decoded timestamp
- See Also:
-
encodeTimestamp
Produce a APRS-standard 6-digit timestamp string for the specified date/time, using the most precise format possible relative to the current time.- Parameters:
date
- Data object of the time to formatnow
- current time in Java milliseconds since 1970 UTC, to determine if 'date' is so far away from current time that a format with the day in it is necessary- Returns:
- 7 character String of APRS representation of timestamp
-
looksLikeLongFormatLatitude
protected static boolean looksLikeLongFormatLatitude(byte[] body, int pos, int len) Test the byte array to see if it looks like it contains a APRS text-format (long) position indicator.- Parameters:
body
- byte array containing the APRS messagepos
- index into the byte array where lat/lon values are supposed to startlen
- remaining length of valid message bytes in the array- Returns:
- boolean true if a long-format text lat/lon appears to be in the buffer
-
extractComment
protected void extractComment(byte[] body, int offset) Extract the remaining text in the byte buffer as the free-text comment of this message.- Parameters:
body
- byte array containing the APRS messageoffset
- index into the byte array where the free-text comment begins
-
extractComment
protected void extractComment(byte[] body, int startPos, int endPos) Extract the remaining text in the byte buffer as the free-text comment of this message.- Parameters:
body
- byte array containing the APRS messagestartPos
- index into the byte array where the free-text comment beginsendPos
- index into the byte array after the free-text comment ends
-
paramString
Descriptive text about this message, to be included in the toString() method's response. This method may be overridden, and the override may concatenate the results of the superclass's paramString) method with additional text of its own. This default implementation returns the free-text comment of this APRS message.- Overrides:
paramString
in classAX25Message
- Returns:
- String describing the contents of this message
- See Also:
-
formatBody
Convert a byte array into a UTF_8 printable string.- Parameters:
body
- byte arrayoffset
- start index into the array- Returns:
- String decoded from the trailing part of the byte array
-
getSymbolCode
public final char getSymbolCode()Get the APRS symbol code for this Message.- Returns:
- char of the symbol code, or '\0' if this Message does not include a symbol
-
getSymTableId
public final char getSymTableId()Get the APRS symbol table ID or overlay character for this Message.- Returns:
- char of the symbol table ID or overlay, or '\0' if this Message does not include a symbol
-
setSymbolCode
public void setSymbolCode(char symbolCode) Set the APRS symbol code for this Message. Generally only meaningful for SendableMessages.- Parameters:
symbolCode
- char of the symbol code, or '\0' if this Message should not include a symbol
-
setSymTableId
public void setSymTableId(char symTableId) Set the APRS symbol table ID or overlay character for this Message.- Parameters:
symTableId
- char of the symbol table ID or overlay, or '\0' if this Message should not include a symbol
-
decodeWeatherParams
protected int decodeWeatherParams(byte[] body, int offset) Extract APRS-standard weather information from a message body.- Parameters:
body
- byte array of message bodyoffset
- starting position for parsing weather data- Returns:
- end position in message body after weather data
-
decodeHurricaneParams
protected int decodeHurricaneParams(byte[] body, int offset) Extract APRS-standard hurricane/tropical storm information from a message body.- Parameters:
body
- byte array of message bodyoffset
- starting position for parsing weather data- Returns:
- end position in message body after weather data
-
decodeWeatherParams
Extract APRS-standard weather information from a message body.- Parameters:
body
- String of message bodyoffset
- starting position for parsing weather data- Returns:
- end position in message body after weather data
-
hasWeather
public boolean hasWeather()Report if this Message contains weather information.- Specified by:
hasWeather
in classAX25Message
- Returns:
- boolean true if weather information in this Message
-
getPrecedence
Report the traffic-handling precedence for this message instance. Expected to be overridden by subclasses that have precedence fields.- Overrides:
getPrecedence
in classAX25Message
- Returns:
- Precedence level for this AX25Message
-
getExtensionString
Build a formatted string of the weather data known to this message,- Returns:
- String in weather comment format
-
getComment
Get the free-text comment of this message,- Specified by:
getComment
in interfaceCommentedMessage
- Returns:
- free-text comment String
-
setComment
Set the free-text comment for this Message. Note this is only meaningful for SendableMessages.- Specified by:
setComment
in interfaceCommentedMessage
- Parameters:
comment
- String free-text comment to associate with this Message
-
isSymbolInferred
public boolean isSymbolInferred()Report whether the non-null APRS symbol reported by this message is explicit or inferred from destination or source callsign. Intended to be overridden by message types which can infer a symbol but can't explicitly specify the symbol.- Returns:
- boolean true if symbol is inferred
-
inferSymbol
Decode a symbol from the destination AX25Callsign (handling the case of old hardware and/or software whose limited message set does not include messages with symbol codes in the message body). This handles the GPSxyz, GPSCnn, GPSEnn, SPCxyz, and SYMxyz tocalls, per chapter 20 of the APRS Protocol Reference, V1.0.1.- Parameters:
src
- source AX25Callsign to parse (assuming this Message was not relayed through a third-party network), or null to not use source SSID as final fallbackdst
- destination AX25Callsign to parse (assuming this Message was not relayed through a third-party network)
-
extractSymbol
Decode a symbol from the destination tocall (handling the case of old hardware and/or software whose limited message set does not include messages with symbol codes in the message body). This handles the GPSxyz, GPSCnn, GPSEnn, SPCxyz, and SYMxyz tocalls, per chapter 20 of the APRS Protocol Reference, V1.0.1.- Parameters:
dest
- destination String to parse- Returns:
- APRS symbol table and code for the specified destination, or null if not determinable
-
dup
Creates and returns a deep copy of this Message.- Overrides:
dup
in classAX25Message
- Returns:
- a clone of this instance.
- See Also:
-
getProtocols
Get the protocol family or families that this message corresponds to, so ports that don't support all protocols will not forward inappropriate packets.- Overrides:
getProtocols
in classAX25Message
- Returns:
- array of supported ProtocolFamily enums
-
isAppendCR
public static boolean isAppendCR()Indicate whether trailing CR should be appended to generated APRS packets.- Returns:
- boolean true if CR control character should be appended, false if not
-
setAppendCR
public static void setAppendCR(boolean appendCR) Specify whether trailing CR should be appended to generated APRS packets.- Parameters:
appendCR
- boolean true if CR control character should be appended, false if not
-