Package com.dsi.ant.message.ipc
Class AntMessageParcel
java.lang.Object
com.dsi.ant.message.AntMessage
com.dsi.ant.message.ipc.AntMessageParcel
- All Implemented Interfaces:
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
-
Nested Class Summary
Nested classes/interfaces inherited from interface android.os.Parcelable
android.os.Parcelable.ClassLoaderCreator<T>, android.os.Parcelable.Creator<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final android.os.Parcelable.Creator<AntMessageParcel>protected byte[]The content of the message.protected intThe ID (MessageId) identifies the contents and format of the message according to the specifications in the ANT Message Protocol and Usage document.Fields 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_BYTEFields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE -
Constructor Summary
ConstructorsConstructorDescriptionCreates an ANT Message with no message type or content.AntMessageParcel(int messageId, byte[] messageContent) Constructs an AntMessageParcel from message ID and message content.AntMessageParcel(android.os.Parcel source) Constructor to use when re-constructing object from a parcelAntMessageParcel(AntMessage antMessage) Constructs an AntMessageParcel from an AntMessage. -
Method Summary
Modifier and TypeMethodDescriptionintbyte[]The content of the message.intGet the ANT message ID.voidreadFromParcel(android.os.Parcel source) Set values to those in the provided ParcelvoidsetMessageContent(byte[] messageContent) Set the message content of the AntMessageParcel.voidsetMessageId(int messageId) Set the message ID of the AntMessageParcel.voidwriteToParcel(android.os.Parcel dest, int flags) Methods inherited from class com.dsi.ant.message.AntMessage
equals, getMessageContentString, getMessageIdString, hashCode, maskChannelNumber, toString
-
Field Details
-
mMessageId
protected int mMessageIdThe ID (MessageId) identifies the contents and format of the message according to the specifications in the ANT Message Protocol and Usage document.Consider using
MessageFromAntTypeas a convenient way to determine the message type without directly referencing this raw value. -
mMessageContent
protected byte[] mMessageContentThe content of the message.For convenience in decoding this array use the type-specific offsets defined in
AntMessageFromAntaccording to the type given byAntMessageFromAnt.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
-
-
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
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:AntMessageGet the ANT message ID.- Specified by:
getMessageIdin classAntMessage- Returns:
- Raw value of this messages Message ID byte.
- Since:
- 4.0
-
getMessageContent
public byte[] getMessageContent()Description copied from class:AntMessageThe content of the message.- Specified by:
getMessageContentin classAntMessage- 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:
describeContentsin interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(android.os.Parcel dest, int flags) - Specified by:
writeToParcelin interfaceandroid.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
-