Package com.dsi.ant.message.fromhost
Class SetNetworkKeyMessage
java.lang.Object
com.dsi.ant.message.AntMessage
com.dsi.ant.message.fromhost.AntMessageFromHost
com.dsi.ant.message.fromhost.SetNetworkKeyMessage
- Direct Known Subclasses:
SetLongNetworkKeyMessage,SetShortNetworkKeyMessage
Contains the common values and logic for constructing the different types of network
key messages.
- Since:
- 4.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe message content offset to the network keystatic final intThe message content offset to the network number.static final intThe size in bytes of the network numberFields inherited from class com.dsi.ant.message.AntMessage
BITMASK_CHANNEL_NUMBER, FILLER_BYTE, OFFSET_CHANNEL_NUMBER, RAW_OFFSET_MESSAGE_CONTENT_START, RAW_OFFSET_MESSAGE_ID, RAW_OFFSET_MESSAGE_SIZE, SIZE_CHANNEL_NUMBER, SIZE_FILLER_BYTE -
Constructor Summary
ConstructorsConstructorDescriptionSetNetworkKeyMessage(byte[] networkKey) Constructs the message with given network key byte array -
Method Summary
Modifier and TypeMethodDescriptionprotected static AntMessageFromHostcreateSetNetworkKeyMessage(MessageFromHostType messageType, byte[] messageContent) Creates a set network key message from the message content.byte[]getMessageContent(int channelNumber, int networkNumber) The content of the message with specified channel number and network number set if required.protected static byte[]getNetworkKey(byte[] messageContent, int networkKeyLength) Retrieves the network key of a specific length from the message content.protected abstract intGets the network key length supported by this message.byte[]Get the network key contained in this message.toString()Methods inherited from class com.dsi.ant.message.fromhost.AntMessageFromHost
createAntMessage, createAntMessage, getMessageContent, getMessageContent, getMessageId, getMessageType, getRawMessage, toStringHeaderMethods inherited from class com.dsi.ant.message.AntMessage
equals, getMessageContentString, getMessageIdString, hashCode, maskChannelNumber
-
Field Details
-
OFFSET_NETWORK_NUMBER
public static final int OFFSET_NETWORK_NUMBERThe message content offset to the network number.- Since:
- 4.3
- See Also:
-
OFFSET_NETWORK_KEY
public static final int OFFSET_NETWORK_KEYThe message content offset to the network key- Since:
- 4.3
- See Also:
-
SIZE_NETWORK_NUMBER
public static final int SIZE_NETWORK_NUMBERThe size in bytes of the network number- Since:
- 4.3
- See Also:
-
-
Constructor Details
-
SetNetworkKeyMessage
public SetNetworkKeyMessage(byte[] networkKey) Constructs the message with given network key byte array- Parameters:
networkKey- The byte array containing the network key.- Throws:
IllegalArgumentException- Occurs when received an invalid network key byte array (null or invalid length)- Since:
- 4.3
-
-
Method Details
-
getRawNetworkKey
public byte[] getRawNetworkKey()Get the network key contained in this message.- Since:
- 4.3
-
getMessageContent
public byte[] getMessageContent(int channelNumber, int networkNumber) Description copied from class:AntMessageFromHostThe content of the message with specified channel number and network number set if required.- Specified by:
getMessageContentin classAntMessageFromHost- Parameters:
channelNumber- Written to the channel number byte if requirednetworkNumber- Written to the network number byte if required- Returns:
- Message content raw byte array.
-
getNetworkKey
protected static byte[] getNetworkKey(byte[] messageContent, int networkKeyLength) Retrieves the network key of a specific length from the message content.- Parameters:
messageContent- The raw message content that contains the network key.networkKeyLength- The length of the network key contained within the message content- Returns:
- The network key byte array.
-
getNetworkKeyLengthBytes
protected abstract int getNetworkKeyLengthBytes()Gets the network key length supported by this message.- Returns:
- The length in bytes for the network key.
- Since:
- 4.3
-
createSetNetworkKeyMessage
protected static AntMessageFromHost createSetNetworkKeyMessage(MessageFromHostType messageType, byte[] messageContent) Creates a set network key message from the message content.- Parameters:
messageType- The type of message to create.messageContent- The raw message content the network key messages will be created from.- Returns:
- The created ANT message.
-
toString
- Overrides:
toStringin classAntMessageFromHost
-