|
Sun SPOT API |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.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.
RadioPackets are managed - that is, they are reused rather than garbage collected - for
efficiency. For this reason, applications must free packets when done with them - see
#free().
To obtain RadioPackets, call one of getAckPacket(), getBroadcastPacket(),
getDataPacket().
| 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 |
checkSequenceNumber()
Checks the sequence number and throws a SequenceNumberException if it is incorrect (usually indicating missed packets). |
void |
copyFrom(RadioPacket otherRP)
Make this packet an exact copy of another |
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 |
getMACPayloadIntAt(int macPayloadOffset)
Answer the 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 long value corresponding to eight bytes at a given offset within the MAC payload. |
int |
getMACPayloadShortAt(int macPayloadOffset)
Answer the 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. |
boolean |
isAck()
Answer whether this packet is an ACK packet (i.e. |
boolean |
isData()
Answer whether this packet is a data packet (i.e. |
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(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 |
setMACPayloadIntAt(int macPayloadOffset,
int value)
Fill the four bytes at a given offset within the MAC payload with the 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 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. |
void |
writeOnto(DataOutputStream dataOutputStream)
|
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, 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
IOExceptionpublic int getLinkQuality()
public int getCorr()
getRssi(),
getLinkQuality()public int getRssi()
getCorr(),
getLinkQuality()public boolean isSeqOK()
public void setSeqOK(boolean dsnOK)
public void checkSequenceNumber()
throws SequenceNumberException
SequenceNumberExceptionpublic int getMACPayloadLength()
public void copyFrom(RadioPacket otherRP)
otherRP - the packet to copy from
public void writeOnto(DataOutputStream dataOutputStream)
throws IOException
IOException
public RadioPacket readFrom(DataInputStream dataInputStream)
throws IOException
IOExceptionpublic boolean isAck()
public boolean isData()
public boolean ackRequest()
public int getMACPayloadIntAt(int macPayloadOffset)
macPayloadOffset - -- the offset within the MAC payload
public long getMACPayloadLongAt(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 bytes
public void setMACPayloadLongAt(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 void setMACPayloadShortAt(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()
ObjecttoString 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
|
Sun SPOT API |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||