Class AntMessageFromAnt

java.lang.Object
com.dsi.ant.message.AntMessage
com.dsi.ant.message.fromant.AntMessageFromAnt
Direct Known Subclasses:
AntVersionMessage, CapabilitiesMessage, ChannelEventMessage, ChannelIdMessage, ChannelResponseMessage, ChannelStatusMessage, DataMessage, SerialNumberMessage

public abstract class AntMessageFromAnt extends AntMessage
A message sent ANT -> Host. Takes a raw ANT message (single byte array) and sends it from the ANT Radio Service to an application, where it is constructed as the specific object that represents the message, and parses the information out.
Since:
4.0
  • Field Details

    • mMessageContent

      protected byte[] mMessageContent
      Saved copy so we do not have to re-process
  • Constructor Details

    • AntMessageFromAnt

      protected AntMessageFromAnt(byte[] messageContent)
  • Method Details

    • getMessageId

      public int getMessageId()
      Description copied from class: AntMessage
      Get the ANT message ID.
      Specified by:
      getMessageId in class AntMessage
      Returns:
      Raw value of this messages Message ID byte.
      Since:
      4.0
    • extractCorrectMessageContent

      protected static byte[] extractCorrectMessageContent(MessageFromAntType desiredType, AntMessageParcel messageParcel)
      If the parcel represents a message of the desired type, the message content is returned.
      Parameters:
      desiredType - The expected message type of the parcel.
      messageParcel - The parcel to extract the message content from.
      Returns:
      Raw ANT message content.
      Throws:
      IllegalArgumentException - If calculated and desired message types are not the same
    • getMessageContent

      public byte[] getMessageContent()
      Description copied from class: AntMessage
      The content of the message.
      Specified by:
      getMessageContent in class AntMessage
      Returns:
      Message content raw byte array.
      Since:
      4.0
    • getMessageType

      public abstract MessageFromAntType getMessageType()
      The type of this message based on its message id and contents.

      It is recommended to use this rather than the raw message ID.

      Returns:
      A message type corresponding to this message as defined in MessageFromAntType.
      Since:
      4.0
    • createAntMessage

      public static AntMessageFromAnt createAntMessage(byte[] rawMessage)
      Takes a message read from the chip and converts it to an AntMessageFromAnt object
      Parameters:
      rawMessage - The basic ANT message data received from the chip.
      Returns:
      A new specific com.dsi.ant.message.fromant message instance, or NULL if not a From ANT message or not a known MessageFromAntType.
      Since:
      4.0
    • createAntMessage

      public static AntMessageFromAnt createAntMessage(AntMessageParcel antParcel)
      Takes a message received over IPC and converts it to an AntMessageFromAnt object
      Parameters:
      antParcel - The basic ANT message data received over IPC.
      Returns:
      A new specific com.dsi.ant.message.fromant message instance, or NULL if not a From ANT message or not a known MessageFromAntType.
      Since:
      4.0
    • createAntMessage

      protected static AntMessageFromAnt createAntMessage(MessageFromAntType messageType, byte[] messageContent)
    • toStringHeader

      protected String toStringHeader()
    • toString

      public String toString()
      Overrides:
      toString in class AntMessage
      Since:
      4.0