Class AntMessageParcel

java.lang.Object
com.dsi.ant.message.AntMessage
com.dsi.ant.message.ipc.AntMessageParcel
All Implemented Interfaces:
android.os.Parcelable

public class AntMessageParcel extends AntMessage implements android.os.Parcelable
An ANT message that has been packaged for communication between applications and the ANT Radio Service. A message parcel contains a simple representation of the serial ANT message received from, or to be written to, the ANT Adapter, split in to Message ID and Message Content.

Instead of parsing the raw message content yourself, you should create the appropriate Message object around this parcel. Received messages (from ANT) are defined in com.dsi.ant.message.fromant, and can be one of the MessageFromAntType types.

Since:
4.0
  • Field Details

    • mMessageId

      protected int mMessageId
      The ID (MessageId) identifies the contents and format of the message according to the specifications in the ANT Message Protocol and Usage document.

      Consider using MessageFromAntType as a convenient way to determine the message type without directly referencing this raw value.

    • mMessageContent

      protected byte[] mMessageContent
      The content of the message.

      For convenience in decoding this array use the type-specific offsets defined in AntMessageFromAnt according to the type given by AntMessageFromAnt.getMessageType().

      More details on the format of the contents of a message according to its message ID can be found in the ANT Message Protocol and Usage document.

    • CREATOR

      public static final android.os.Parcelable.Creator<AntMessageParcel> CREATOR
  • Constructor Details

    • AntMessageParcel

      public AntMessageParcel()
      Creates an ANT Message with no message type or content. Probably not what you want. Only exists to support Parcelable.
      Since:
      4.0
    • AntMessageParcel

      public AntMessageParcel(int messageId, byte[] messageContent)
      Constructs an AntMessageParcel from message ID and message content.
      Parameters:
      messageId - The message ID of the message.
      messageContent - The message content.
      Since:
      4.0
    • AntMessageParcel

      public AntMessageParcel(AntMessage antMessage)
      Constructs an AntMessageParcel from an AntMessage.
      Parameters:
      antMessage - The ant message.
      Since:
      4.0
    • AntMessageParcel

      public AntMessageParcel(android.os.Parcel source)
      Constructor to use when re-constructing object from a parcel
      Parameters:
      source - a parcel from which to read this object
      Since:
      4.0
  • 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
    • 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
    • setMessageId

      public void setMessageId(int messageId)
      Set the message ID of the AntMessageParcel.
      Parameters:
      messageId - The message ID to be set to.
      Since:
      4.0
    • setMessageContent

      public void setMessageContent(byte[] messageContent)
      Set the message content of the AntMessageParcel.
      Parameters:
      messageContent - The message content to be set to.
      Since:
      4.0
    • describeContents

      public int describeContents()
      Specified by:
      describeContents in interface android.os.Parcelable
    • writeToParcel

      public void writeToParcel(android.os.Parcel dest, int flags)
      Specified by:
      writeToParcel in interface android.os.Parcelable
    • readFromParcel

      public void readFromParcel(android.os.Parcel source)
      Set values to those in the provided Parcel
      Parameters:
      source - Parceled version of an AntMessageParcel.
      Since:
      4.0