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 int
The 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_BYTE
Fields 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 TypeMethodDescriptionint
byte[]
The content of the message.int
Get the ANT message ID.void
readFromParcel
(android.os.Parcel source) Set values to those in the provided Parcelvoid
setMessageContent
(byte[] messageContent) Set the message content of the AntMessageParcel.void
setMessageId
(int messageId) Set the message ID of the AntMessageParcel.void
writeToParcel
(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
MessageFromAntType
as 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
AntMessageFromAnt
according 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:AntMessage
Get the ANT message ID.- Specified by:
getMessageId
in classAntMessage
- 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 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:
describeContents
in interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(android.os.Parcel dest, int flags) - Specified by:
writeToParcel
in 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
-