|
Sun SPOT API |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface ILowPanPacketDispatcher
Multiplexes traffic for up to 255 protocols over the radio connection between two Spots or
between a host application and a spot. Implementations (named LowPanPacketDispatcher)
provide the platform-specific implementations.
Protocols (not to be confused with the use of the word "Protocol" in the GCF framework) are
identified by unique byte values. To implement a protocol, first pick a
protocol number not in conflict with other protocols. To send radio packets for that protocol,
route them via the LowPanPacketDispatcher on your platform:
...
LowPanPacketDispatcher.getInstance().sendPacket(MY_PROTOCOL_NUMBER, myRadioPacket);
...
To receive and manage the traffic associated with your protocol, you need to register an
IProtocolManager:
...
LowPanPacketDispatcher.getInstance().addProtocol(MY_PROTOCOL_NUMBER, myProtocolManager);
...
See IProtocolManager for more details.
ILowPanPacketDispatcher also provides a set of radio control facilities for application
developers such as controlling power output, channel and PAN ID.
| Field Summary | |
|---|---|
static short |
DEFAULT_PAN_ID
Default PAN id to use. |
static byte |
LOWPAN_DATA_OFFSET
The offset into RadioPackets at which data starts. |
| Method Summary | |
|---|---|
void |
addProtocol(byte protocolNum,
IProtocolManager protocolMan)
Register a protocol to send and receive radio packets. |
void |
closeBaseStation()
Used in the host to close down the base station - a no-op if called on a Spot |
int |
getChannelNumber()
Answer the current channel number (between 11 and 26). |
long |
getIEEEAddress()
|
int |
getOutputPower()
Answer the radio output power in decibels. |
short |
getPanId()
Answer the current pan ID. |
void |
initBaseStation()
Used in the host to initialize the base station - a no-op if called on a Spot |
boolean |
isLoggingConnections()
|
void |
removeProtocol(byte protocolNum)
Deregister an existing protocol so that it no longer receives radio packets |
void |
sendPacket(byte protocolNum,
RadioPacket rp)
Send a radio packet on a given protocol. |
void |
setChannelNumber(int channel)
Set the current channel number (between 11 and 26). |
void |
setLogConnections(boolean logConnections)
Select whether connection addition and removal is being logged to System.out |
void |
setOutputPower(int power)
Set the radio output power in decibels (between -32 and +31). |
void |
setPanId(short pid)
Set the pan ID (should not be -1 or -2, which are reserved in the I802.15.4 standard). |
void |
startMAC()
Start the MAC layer device, if it's not already started. |
void |
turnOffReceiver()
Turn off the radio receiver |
void |
turnOnReceiver()
Turn on the radio receiver |
void |
turnOnReceiver(int period)
Turn on the radio receiver for a fixed period |
| Field Detail |
|---|
static final short DEFAULT_PAN_ID
static final byte LOWPAN_DATA_OFFSET
myRadioPacket.setMACPayloadAt(LOWPAN_DATA_OFFSET, someValue);
| Method Detail |
|---|
void addProtocol(byte protocolNum,
IProtocolManager protocolMan)
protocolNum - - the unique number to identify the protocol (0..255)protocolMan - - the object that will receive incoming radio packets
associated with the protocol
IllegalArgumentException - if the protocolNumber is already being handled by
another IProtocolManagervoid removeProtocol(byte protocolNum)
protocolNum - - the unique number to identify the protocol to deregister.
IllegalArgumentException - if protocolNum isn't currently being handled
void sendPacket(byte protocolNum,
RadioPacket rp)
throws NoAckException,
ChannelBusyException
...
rp.setMACPayloadAt(ILowPanPacketDispatcher.LOWPAN_DATA_OFFSET, aVal);
...
protocolNum - - the protocl number associated with the outgoing packetrp - - the radio packet to send
NoAckException
ChannelBusyExceptionint getChannelNumber()
void setChannelNumber(int channel)
channel - - the new channel numbershort getPanId()
void setPanId(short pid)
pid - - the new pan IDvoid startMAC()
void setOutputPower(int power)
power - - new power setting in decibels.int getOutputPower()
void turnOffReceiver()
void turnOnReceiver()
long getIEEEAddress()
void turnOnReceiver(int period)
period - in millisecondsvoid initBaseStation()
void closeBaseStation()
boolean isLoggingConnections()
void setLogConnections(boolean logConnections)
logConnections - true if connnections should be logged
|
Sun SPOT API |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||