|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.spot.peripheral.radio.RadioPacket
public class RadioPacket
Represents an I802.15.4 radio packet.
Because the standard allows variable length and format packets according
to the purpose and data content of the packet, this class's apparent length
and contents varies also. For more details about the packet formats, see the first
reference below.
To obtain RadioPackets, call one of getAckPacket()
, getBroadcastPacket()
,
getDataPacket()
.
Once a packet has been received from the physical radio, clients - such as the MAC layer -
should call decodeFrameControl()
to decode the MAC header. Until this is done,
accessors for addresses, PAN id and other information will not return correct values.
Field Summary | |
---|---|
static int |
MIN_PAYLOAD_LENGTH
The maximum number of bytes of data that will fit into this packet after allowing for the MAC layer header. |
Method Summary | |
---|---|
boolean |
ackRequest()
Check whether this packet wants an acknowledgement |
void |
calculateAndSetFCS()
Calculate a frame check sequence for this packet -- not normally required for the CC2420 radio. |
void |
copyFrom(RadioPacket otherRP)
Make this packet an exact copy of another |
void |
decodeFrameControl()
|
static RadioPacket |
getAckPacket()
Answer a radio packet preformatted for sending ACKs. |
static RadioPacket |
getBroadcastPacket()
Answer a radio packet preformatted for broadcasting intra-PAN. |
int |
getCorr()
CORR measures the average correlation value of the first 4 bytes of the packet header. |
static RadioPacket |
getDataPacket()
Answer a radio packet preformatted for sending data. |
byte |
getDataSequenceNumber()
Answer the DSN (as defined by the I802.15.4 standard) of this packet. |
long |
getDestinationAddress()
Answer the destination address of this packet. |
int |
getDestinationPanID()
Answer the destination pan ID of this packet. |
short |
getFCS()
Answer the frame check sequence for this radio packet. |
int |
getFrameControl()
Answer the frame control field (16 bits) of this packet. |
int |
getLinkQuality()
Link Quality Indication (LQI) is a characterization of the quality of a received packet. |
byte |
getMACPayloadAt(int offset)
Get byte from MAC payload |
int |
getMACPayloadBigEndIntAt(int macPayloadOffset)
Answer the big end int value corresponding to four bytes at a given offset within the MAC payload. |
long |
getMACPayloadBigEndLongAt(int macPayloadOffset)
Answer the big end long value corresponding to eight bytes at a given offset within the MAC payload. |
int |
getMACPayloadBigEndShortAt(int macPayloadOffset)
Answer the big end short value corresponding to two bytes at a given offset within the MAC payload. |
int |
getMACPayloadIntAt(int macPayloadOffset)
Answer the little end int value corresponding to four bytes at a given offset within the MAC payload. |
int |
getMACPayloadLength()
Get length of MACPayload |
long |
getMACPayloadLongAt(int macPayloadOffset)
Answer the little end long value corresponding to eight bytes at a given offset within the MAC payload. |
int |
getMACPayloadShortAt(int macPayloadOffset)
Answer the little end short value corresponding to two bytes at a given offset within the MAC payload. |
int |
getMaxMacPayloadSize()
Answer the size of the payload in this packet. |
int |
getRssi()
RSSI (received signal strength indicator) measures the strength (power) of the signal for the packet. |
long |
getSourceAddress()
Answer the source address of this packet. |
int |
getSourcePanID()
Answer the source pan ID of this packet. |
long |
getTimestamp()
|
boolean |
isAck()
Answer whether this packet is an ACK packet (i.e. not data or broadcast) |
boolean |
isData()
Answer whether this packet is a data packet (i.e. not an ack packet) |
boolean |
isFCSValid()
Answer whether this packet was received with a correct FCS |
boolean |
isSeqOK()
Answer whether the DSN received implies that packets were missed |
RadioPacket |
readFrom(byte[] inputBuffer,
int startingOffset)
|
RadioPacket |
readFrom(DataInputStream dataInputStream)
|
RadioPacket |
readWithoutTimestampFrom(DataInputStream dataInputStream)
|
void |
setDestinationAddress(long addr)
Set the destination address for the packet. |
void |
setDestinationPanID(int id)
Set the destination pan ID of this packet. |
void |
setMACPayloadAt(int offset,
byte value)
Set byte in MAC payload |
void |
setMACPayloadBigEndIntAt(int macPayloadOffset,
int value)
Fill the four bytes at a given offset within the MAC payload with the big end int value provided. |
void |
setMACPayloadBigEndLongAt(int macPayloadOffset,
long value)
Fill the eight bytes at a given offset within the MAC payload with the big end long value provided. |
void |
setMACPayloadBigEndShortAt(int macPayloadOffset,
int value)
Fill the two bytes at a given offset within the MAC payload with the big end short value provided. |
void |
setMACPayloadIntAt(int macPayloadOffset,
int value)
Fill the four bytes at a given offset within the MAC payload with the little end int value provided. |
void |
setMACPayloadLength(int macPayloadLength)
Set length of MACPayload |
void |
setMACPayloadLongAt(int macPayloadOffset,
long value)
Fill the eight bytes at a given offset within the MAC payload with the little end long value provided. |
void |
setMACPayloadShortAt(int macPayloadOffset,
int value)
Fill the two bytes at a given offset within the MAC payload with the short value provided. |
void |
setSeqOK(boolean dsnOK)
|
void |
setSourceAddress(long addr)
Set the source address for the packet. |
String |
toString()
Returns a string representation of the object. |
int |
writeOnto(byte[] outputBuffer,
int startingOffset)
|
void |
writeOnto(DataOutputStream dataOutputStream)
|
int |
writeWithoutTimestampOnto(byte[] outputBuffer,
int startingOffset)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int MIN_PAYLOAD_LENGTH
Method Detail |
---|
public static RadioPacket getDataPacket()
public static RadioPacket getAckPacket()
public static RadioPacket getBroadcastPacket()
public long getDestinationAddress()
public void setDestinationAddress(long addr)
addr
- - the address to setpublic long getSourceAddress()
public void setSourceAddress(long addr)
addr
- - the address to setpublic int getSourcePanID()
public int getDestinationPanID()
public void setDestinationPanID(int id)
id
- the pan id to setpublic byte getDataSequenceNumber()
public int getFrameControl()
public byte getMACPayloadAt(int offset)
offset
- -- relative to bottom of MAC payload
public void setMACPayloadAt(int offset, byte value)
offset
- - relative to bottom of MAC payloadvalue
- the value to set in the payloadpublic void setMACPayloadLength(int macPayloadLength)
macPayloadLength
- - max 104 bytes
IOException
public int getLinkQuality()
public int getCorr()
getRssi()
,
getLinkQuality()
public int getRssi()
getCorr()
,
getLinkQuality()
public boolean isSeqOK()
public void setSeqOK(boolean dsnOK)
public int getMACPayloadLength()
public void decodeFrameControl()
public void copyFrom(RadioPacket otherRP)
otherRP
- the packet to copy frompublic void writeOnto(DataOutputStream dataOutputStream) throws IOException
IOException
public RadioPacket readFrom(DataInputStream dataInputStream) throws IOException
IOException
public RadioPacket readWithoutTimestampFrom(DataInputStream dataInputStream) throws IOException
IOException
public int writeOnto(byte[] outputBuffer, int startingOffset)
public int writeWithoutTimestampOnto(byte[] outputBuffer, int startingOffset)
public RadioPacket readFrom(byte[] inputBuffer, int startingOffset)
public boolean isAck()
public boolean isData()
public boolean ackRequest()
public int getMACPayloadIntAt(int macPayloadOffset)
macPayloadOffset
- -- the offset within the MAC payload
public int getMACPayloadBigEndIntAt(int macPayloadOffset)
macPayloadOffset
- -- the offset within the MAC payload
public long getMACPayloadLongAt(int macPayloadOffset)
macPayloadOffset
- -- the offset within the MAC payload
public long getMACPayloadBigEndLongAt(int macPayloadOffset)
macPayloadOffset
- -- the offset within the MAC payload
public void setMACPayloadIntAt(int macPayloadOffset, int value)
macPayloadOffset
- -- the offset within the MAC payloadvalue
- -- the int value to store in four bytespublic void setMACPayloadBigEndIntAt(int macPayloadOffset, int value)
macPayloadOffset
- -- the offset within the MAC payloadvalue
- -- the int value to store in four bytespublic void setMACPayloadLongAt(int macPayloadOffset, long value)
macPayloadOffset
- -- the offset within the MAC payloadvalue
- -- the long value to store in eight bytespublic void setMACPayloadBigEndLongAt(int macPayloadOffset, long value)
macPayloadOffset
- -- the offset within the MAC payloadvalue
- -- the long value to store in eight bytespublic int getMACPayloadShortAt(int macPayloadOffset)
macPayloadOffset
- -- the offset within the MAC payload
public int getMACPayloadBigEndShortAt(int macPayloadOffset)
macPayloadOffset
- -- the offset within the MAC payload
public void setMACPayloadShortAt(int macPayloadOffset, int value)
macPayloadOffset
- -- the offset within the MAC payloadvalue
- -- the short value to store in two bytespublic void setMACPayloadBigEndShortAt(int macPayloadOffset, int value)
macPayloadOffset
- -- the offset within the MAC payloadvalue
- -- the short value to store in two bytespublic short getFCS()
public void calculateAndSetFCS()
public boolean isFCSValid()
public int getMaxMacPayloadSize()
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
toString
in class Object
public long getTimestamp()
|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |