Package org.ka2ddo.aprs
Class MessageMessage
java.lang.Object
org.ka2ddo.ax25.AX25Message
org.ka2ddo.aprs.Message
org.ka2ddo.aprs.MessageMessage
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<AX25Message>
,AprsSignableMessage
,CommentedMessage
,LimitedSendableMessage
,SendableMessage
,SignableMessage
This class encodes an addressed Message APRS message (APRS protocol specification chapter 14).
Note that one form of Message can be a directed query (APRS protocol specification chapter 15).
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.ka2ddo.ax25.AX25Message
AX25Message.Precedence
Nested classes/interfaces inherited from interface org.ka2ddo.ax25.SignableMessage
SignableMessage.SignatureState
-
Field Summary
Modifier and TypeFieldDescriptionboolean
Flag indicating if a locally-originated message has been acknowledged.Addressee of the message.int
Number of times the message should be transmitted before giving up.Sequence number of this message used for acknowledgment.Quality of the signature (if any) associated with this message.Fields inherited from class org.ka2ddo.aprs.Message
appendCR, APRS_AND_OPENTRAC_AND_RAW, APRS_AND_RAW, comment, msgType, S_PERMANENT, S_PERMANENT_UC, symbolCode, symTableId
Fields inherited from class org.ka2ddo.ax25.AX25Message
APRS_AND_OPENTRAC, ax25Frame, extensions, invalid, originatingCallsign, originatingDest, PERMANENT, rcptTime, thirdParty, timestamp, UTC
-
Constructor Summary
ConstructorDescriptionMessageMessage
(byte[] body, int offset, String tp, long rcvTimestamp) Decode a MessageMessage from a byte array.MessageMessage
(String addressee, String body) Create a new partially-initialized MessageMessage, suitable for transmission.MessageMessage
(String addressee, String body, String serialNum) Create a new partially-initialized MessageMessage, suitable for transmission. -
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.void
Specify that message should no longer be transmitted.Report the addressee of this message.byte[]
getBody
(boolean countTransmission, ProtocolFamily protocolId, AX25Frame frame) Get an instance of this message, suitable for transmitting.Get the alias for the key that should be used to sign this message at transmission time.getQuery()
Test whether this MessageMessage contains a directed query (APRS protocol specification chapter 15).Get the ASCII-encoded signature of this message.Report the status of the signature of this message.boolean
Test if message should still be transmitted.boolean
Indicate if this text message is self-addressed.Descriptive text about this message, to be included in the toString() method's response.void
setKeyAlias
(String alias) Set the alias for the key that should be used to sign this message at transmission time.void
setMaxTransmits
(int maxTransmits) Specify the maximum number of times this message should be transmitted.void
setSignature
(String signature) Set the ASCII-encoded signature of this message.void
writeToSigningBuf
(DataOutput dos, PrintWriter pw) Write the appropriate part of the body of this message to the signing buffer.Methods inherited from class org.ka2ddo.aprs.Message
decodeDatestamp, decodeHurricaneParams, decodeTimestamp, decodeWeatherParams, decodeWeatherParams, dup, encodeTimestamp, extractComment, extractComment, extractSymbol, formatBody, getComment, getExtensionString, getMsgType, getPrecedence, getProtocols, getSymbolCode, getSymTableId, hasWeather, inferSymbol, isAppendCR, isSymbolInferred, looksLikeLongFormatLatitude, setAppendCR, setComment, setSymbolCode, setSymTableId, toString
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
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.ka2ddo.ax25.SendableMessage
dup
Methods inherited from interface org.ka2ddo.ax25.SignableMessage
getOriginatingCallsign, getTimestamp
-
Field Details
-
addressee
Addressee of the message. May be a bulletin sequence number or a broadcast group (such as NWS_WARN). -
serialNumber
Sequence number of this message used for acknowledgment. May be null if no sequence number. -
acked
public boolean ackedFlag indicating if a locally-originated message has been acknowledged. Used to stop automatic retransmissions of messages with serial numbers. -
numTransmissions
public int numTransmissionsNumber of times the message should be transmitted before giving up. -
signatureState
Quality of the signature (if any) associated with this message.
-
-
Constructor Details
-
MessageMessage
Decode a MessageMessage from a byte array.- Parameters:
body
- byte array containing the messageoffset
- index into the array where the message startstp
- third-party routing String, or null if not routed from another networkrcvTimestamp
- time in Java milliseconds since 1 Jan 1970 UTC when the message was received
-
MessageMessage
Create a new partially-initialized MessageMessage, suitable for transmission.- Parameters:
addressee
- String addressee for the messagebody
- String body text of the message
-
MessageMessage
Create a new partially-initialized MessageMessage, suitable for transmission.- Parameters:
addressee
- String addressee for the messagebody
- String body text of the messageserialNum
- String serial number for the message (indicates it should be acknowledged)
-
-
Method Details
-
paramString
Descriptive text about this message, to be included in the toString() method's response.- Overrides:
paramString
in classMessage
- Returns:
- String describing the contents of this message
- See Also:
-
bodyEquals
Compare the contents of the body of the message, reporting if they match.- Overrides:
bodyEquals
in classMessage
- 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 classMessage
- 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.
-
getAddressee
Report the addressee of this message.- Returns:
- addressee String
-
getQuery
Test whether this MessageMessage contains a directed query (APRS protocol specification chapter 15).- Returns:
- query String if this is a query, or null if not
-
getBody
Get an instance of this message, suitable for transmitting.- Specified by:
getBody
in interfaceSendableMessage
- Parameters:
countTransmission
- number of times the message has been transmittedprotocolId
- ProtocolFamily for this messageframe
- AX25Frame into which the message will be placed, so any alternate AX25Message can be linked to it- Returns:
- byte array of message
- See Also:
-
isEnabled
public boolean isEnabled()Test if message should still be transmitted.- Specified by:
isEnabled
in interfaceSendableMessage
- Returns:
- boolean true if message should still be transmitted
-
disableForTransmit
public void disableForTransmit()Specify that message should no longer be transmitted.- Specified by:
disableForTransmit
in interfaceSendableMessage
-
setMaxTransmits
public void setMaxTransmits(int maxTransmits) Specify the maximum number of times this message should be transmitted.- Specified by:
setMaxTransmits
in interfaceLimitedSendableMessage
- Parameters:
maxTransmits
- non-negative number of transmits before this message should go idle
-
isSelfAddressed
public boolean isSelfAddressed()Indicate if this text message is self-addressed. This commonly occurs when a station is transmitting telemetry data and wants to specify how the telemetry should be interpreted.- Returns:
- boolean true if message was received from the same station that it is addressed to
-
getSignatureState
Report the status of the signature of this message.- Specified by:
getSignatureState
in interfaceSignableMessage
- Returns:
- signature state of this message
-
setKeyAlias
Set the alias for the key that should be used to sign this message at transmission time.- Specified by:
setKeyAlias
in interfaceSignableMessage
- Parameters:
alias
- String name that should match a secret key in the key manager
-
getKeyAlias
Get the alias for the key that should be used to sign this message at transmission time.- Specified by:
getKeyAlias
in interfaceSignableMessage
- Returns:
- String name of key alias, matching a secret key in the key manager, or null if message should not be signed
-
getSignature
Get the ASCII-encoded signature of this message.- Specified by:
getSignature
in interfaceAprsSignableMessage
- Returns:
- ASCII String of the signature, or null if not signed
-
setSignature
Set the ASCII-encoded signature of this message.- Specified by:
setSignature
in interfaceAprsSignableMessage
- Parameters:
signature
- String of the signature, or null to remove any pre-existing signature
-
writeToSigningBuf
Write the appropriate part of the body of this message to the signing buffer.- Specified by:
writeToSigningBuf
in interfaceSignableMessage
- Parameters:
dos
- DataOutput that will accept binary writes of the message datapw
- PrintWriter that will accept character writes of the message data
-