Sun SPOT API
Green Release  


com.sun.spot.peripheral.radio
Interface ILowPanPacketDispatcher

All Known Implementing Classes:
LowPanPacketDispatcher

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.

Author:
Syntropy

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

DEFAULT_PAN_ID

static final short DEFAULT_PAN_ID
Default PAN id to use.

See Also:
Constant Field Values

LOWPAN_DATA_OFFSET

static final byte LOWPAN_DATA_OFFSET
The offset into RadioPackets at which data starts. Clients should start writing and reading RadioPackets with code like this: myRadioPacket.setMACPayloadAt(LOWPAN_DATA_OFFSET, someValue);

See Also:
Constant Field Values
Method Detail

addProtocol

void addProtocol(byte protocolNum,
                 IProtocolManager protocolMan)
Register a protocol to send and receive radio packets.

Parameters:
protocolNum - - the unique number to identify the protocol (0..255)
protocolMan - - the object that will receive incoming radio packets associated with the protocol
Throws:
IllegalArgumentException - if the protocolNumber is already being handled by another IProtocolManager

removeProtocol

void removeProtocol(byte protocolNum)
Deregister an existing protocol so that it no longer receives radio packets

Parameters:
protocolNum - - the unique number to identify the protocol to deregister.
Throws:
IllegalArgumentException - if protocolNum isn't currently being handled

sendPacket

void sendPacket(byte protocolNum,
                RadioPacket rp)
                throws NoAckException,
                       ChannelBusyException
Send a radio packet on a given protocol. The caller is responsible for ensuring that the radio packet is addressed correctly and has the correct content. The caller should write content to the packet within the MAC payload area at or after the LOWPAN_DATA_OFFSET:

...
rp.setMACPayloadAt(ILowPanPacketDispatcher.LOWPAN_DATA_OFFSET, aVal);
...

Parameters:
protocolNum - - the protocl number associated with the outgoing packet
rp - - the radio packet to send
Throws:
NoAckException
ChannelBusyException

getChannelNumber

int getChannelNumber()
Answer the current channel number (between 11 and 26).

Returns:
current channel number

setChannelNumber

void setChannelNumber(int channel)
Set the current channel number (between 11 and 26).

Parameters:
channel - - the new channel number

getPanId

short getPanId()
Answer the current pan ID.

Returns:
current pan ID

setPanId

void setPanId(short pid)
Set the pan ID (should not be -1 or -2, which are reserved in the I802.15.4 standard).

Parameters:
pid - - the new pan ID

startMAC

void startMAC()
Start the MAC layer device, if it's not already started.


setOutputPower

void setOutputPower(int power)
Set the radio output power in decibels (between -32 and +31). NB. The range given is the I802.15.4 standard range. In practice, for the CC2420 radio, this will mean maximum power for all values from 0 to 31 db.

Parameters:
power - - new power setting in decibels.

getOutputPower

int getOutputPower()
Answer the radio output power in decibels.

Returns:
- radio output power

turnOffReceiver

void turnOffReceiver()
Turn off the radio receiver


turnOnReceiver

void turnOnReceiver()
Turn on the radio receiver


getIEEEAddress

long getIEEEAddress()
Returns:
the 64-bit IEEE address of this device

turnOnReceiver

void turnOnReceiver(int period)
Turn on the radio receiver for a fixed period

Parameters:
period - in milliseconds

initBaseStation

void initBaseStation()
Used in the host to initialize the base station - a no-op if called on a Spot


closeBaseStation

void closeBaseStation()
Used in the host to close down the base station - a no-op if called on a Spot


isLoggingConnections

boolean isLoggingConnections()
Returns:
true if connection addition and removal is being logged to System.out

setLogConnections

void setLogConnections(boolean logConnections)
Select whether connection addition and removal is being logged to System.out

Parameters:
logConnections - true if connnections should be logged

Sun SPOT API
Green Release  


Copyright © 2006 Sun Microsystems, Inc. All Rights Reserved.