Class SetNetworkKeyMessage

Direct Known Subclasses:
SetLongNetworkKeyMessage, SetShortNetworkKeyMessage

public abstract class SetNetworkKeyMessage extends AntMessageFromHost
Contains the common values and logic for constructing the different types of network key messages.
Since:
4.3
  • Field Details

    • OFFSET_NETWORK_NUMBER

      public static final int OFFSET_NETWORK_NUMBER
      The message content offset to the network number.
      Since:
      4.3
      See Also:
    • OFFSET_NETWORK_KEY

      public static final int OFFSET_NETWORK_KEY
      The message content offset to the network key
      Since:
      4.3
      See Also:
    • SIZE_NETWORK_NUMBER

      public static final int SIZE_NETWORK_NUMBER
      The 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: AntMessageFromHost
      The content of the message with specified channel number and network number set if required.
      Specified by:
      getMessageContent in class AntMessageFromHost
      Parameters:
      channelNumber - Written to the channel number byte if required
      networkNumber - 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

      public String toString()
      Overrides:
      toString in class AntMessageFromHost