Sun SPOT API
Green Release  


com.sun.spot.peripheral.radio
Class LowPanPacketDispatcher

java.lang.Object
  extended by com.sun.spot.peripheral.radio.LowPanPacketDispatcher
All Implemented Interfaces:
ILowPanPacketDispatcher

public class LowPanPacketDispatcher
extends Object

Implements ILowPanPacketDispatcher for the Spot environment.


Field Summary
protected  int channelNumber
           
protected  I802_15_4_MAC macDevice
           
protected  boolean macStarted
           
protected  short panId
           
 
Fields inherited from interface com.sun.spot.peripheral.radio.ILowPanPacketDispatcher
DEFAULT_PAN_ID, LOWPAN_DATA_OFFSET
 
Constructor Summary
LowPanPacketDispatcher(I802_15_4_MAC macDevice)
          Do not use.
 
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()
           
static ILowPanPacketDispatcher getInstance()
          Return the singleton instance of LowPanPacketDispatcher.
protected  byte getLowPanProtocol(RadioPacket rp)
           
 int getOutputPower()
          Answer the radio output power in decibels.
 short getPanId()
          Answer the current pan ID.
protected  int getPLMETransmitPower()
           
protected  IProtocolManager getProtocolFor(byte protNum)
          Answer the protocol manager handling the given protocol number
 void initBaseStation()
          Used in the host to initialize the base station - a no-op if called on a Spot
protected  void initUsing(I802_15_4_MAC macDevice)
          Initialise on a particular MAC device.
 boolean isLoggingConnections()
           
static String logicalToPhysical(String ieeeAddressString)
          Attempt to lookup a SPOT name in the spot.names file - this works only on the host
protected  void processIncomingRP(RadioPacket rp)
          Process an incoming RadioPacket.
 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.
protected  void setAsDaemonThread(Thread dispatcherThread)
           
 void setChannelNumber(int channel)
          Set the current channel number (between 11 and 26).
static void setInstance(ILowPanPacketDispatcher lp)
          Set the singleton instance of LowPanPacketDispatcher.
 void setLogConnections(boolean logConnections)
          Select whether connection addition and removal is being logged to System.out
protected  void setLowPanProtocol(byte protocolNum, RadioPacket rp)
           
 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).
protected  void setPLMETransmitPower(int power)
           
 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
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

panId

protected short panId

channelNumber

protected int channelNumber

macStarted

protected boolean macStarted

macDevice

protected I802_15_4_MAC macDevice
Constructor Detail

LowPanPacketDispatcher

public LowPanPacketDispatcher(I802_15_4_MAC macDevice)
Do not use. Used in the base station to allow the construction of a LowPanPacketDispatcher for the serial MAC as well as for the radio MAC. TODO remove this constructor after base station refactored.

Parameters:
macDevice - The MAC layer to be used by this dispatcher
Method Detail

setChannelNumber

public void setChannelNumber(int channel)
Description copied from interface: ILowPanPacketDispatcher
Set the current channel number (between 11 and 26).

Specified by:
setChannelNumber in interface ILowPanPacketDispatcher
Parameters:
channel - - the new channel number

setPanId

public void setPanId(short pid)
Description copied from interface: ILowPanPacketDispatcher
Set the pan ID (should not be -1 or -2, which are reserved in the I802.15.4 standard).

Specified by:
setPanId in interface ILowPanPacketDispatcher
Parameters:
pid - - the new pan ID

startMAC

public void startMAC()
Description copied from interface: ILowPanPacketDispatcher
Start the MAC layer device, if it's not already started.

Specified by:
startMAC in interface ILowPanPacketDispatcher

setPLMETransmitPower

protected void setPLMETransmitPower(int power)

getPLMETransmitPower

protected int getPLMETransmitPower()

getIEEEAddress

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

turnOffReceiver

public void turnOffReceiver()
Description copied from interface: ILowPanPacketDispatcher
Turn off the radio receiver

Specified by:
turnOffReceiver in interface ILowPanPacketDispatcher

turnOnReceiver

public void turnOnReceiver()
Description copied from interface: ILowPanPacketDispatcher
Turn on the radio receiver

Specified by:
turnOnReceiver in interface ILowPanPacketDispatcher

turnOnReceiver

public void turnOnReceiver(int period)
Description copied from interface: ILowPanPacketDispatcher
Turn on the radio receiver for a fixed period

Specified by:
turnOnReceiver in interface ILowPanPacketDispatcher
Parameters:
period - in milliseconds

initBaseStation

public void initBaseStation()
Description copied from interface: ILowPanPacketDispatcher
Used in the host to initialize the base station - a no-op if called on a Spot


closeBaseStation

public void closeBaseStation()
Description copied from interface: ILowPanPacketDispatcher
Used in the host to close down the base station - a no-op if called on a Spot


logicalToPhysical

public static String logicalToPhysical(String ieeeAddressString)
Attempt to lookup a SPOT name in the spot.names file - this works only on the host

Parameters:
ieeeAddressString - the logical address string
Returns:
the phyical address string

setAsDaemonThread

protected void setAsDaemonThread(Thread dispatcherThread)

getInstance

public static ILowPanPacketDispatcher getInstance()
Return the singleton instance of LowPanPacketDispatcher.

Returns:
the instance

setInstance

public static void setInstance(ILowPanPacketDispatcher lp)
Set the singleton instance of LowPanPacketDispatcher. Only intended for test use.

Parameters:
lp - - the replacement ILowPanPacketDispatcher

initUsing

protected void initUsing(I802_15_4_MAC macDevice)
Initialise on a particular MAC device.

Parameters:
macDevice -

addProtocol

public void addProtocol(byte protocolNum,
                        IProtocolManager protocolMan)
Description copied from interface: ILowPanPacketDispatcher
Register a protocol to send and receive radio packets.

Specified by:
addProtocol in interface ILowPanPacketDispatcher
Parameters:
protocolNum - - the unique number to identify the protocol (0..255)
protocolMan - - the object that will receive incoming radio packets associated with the protocol

removeProtocol

public void removeProtocol(byte protocolNum)
Description copied from interface: ILowPanPacketDispatcher
Deregister an existing protocol so that it no longer receives radio packets

Specified by:
removeProtocol in interface ILowPanPacketDispatcher
Parameters:
protocolNum - - the unique number to identify the protocol to deregister.

sendPacket

public void sendPacket(byte protocolNum,
                       RadioPacket rp)
                throws NoAckException,
                       ChannelBusyException
Description copied from interface: ILowPanPacketDispatcher
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);
...

Specified by:
sendPacket in interface ILowPanPacketDispatcher
Parameters:
protocolNum - - the protocl number associated with the outgoing packet
rp - - the radio packet to send
Throws:
NoAckException
ChannelBusyException

getChannelNumber

public int getChannelNumber()
Description copied from interface: ILowPanPacketDispatcher
Answer the current channel number (between 11 and 26).

Specified by:
getChannelNumber in interface ILowPanPacketDispatcher
Returns:
current channel number

getPanId

public short getPanId()
Description copied from interface: ILowPanPacketDispatcher
Answer the current pan ID.

Specified by:
getPanId in interface ILowPanPacketDispatcher
Returns:
current pan ID

getProtocolFor

protected IProtocolManager getProtocolFor(byte protNum)
Answer the protocol manager handling the given protocol number

Parameters:
protNum - -- the protocol number
Returns:
the protocol manager

processIncomingRP

protected void processIncomingRP(RadioPacket rp)
Process an incoming RadioPacket. Called from the LowPanDispatcher's receive thread.

Parameters:
rp - -- the RadioPacket.

setLowPanProtocol

protected void setLowPanProtocol(byte protocolNum,
                                 RadioPacket rp)

getLowPanProtocol

protected byte getLowPanProtocol(RadioPacket rp)

setOutputPower

public void setOutputPower(int power)
Description copied from interface: ILowPanPacketDispatcher
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.

Specified by:
setOutputPower in interface ILowPanPacketDispatcher
Parameters:
power - - new power setting in decibels.

getOutputPower

public int getOutputPower()
Description copied from interface: ILowPanPacketDispatcher
Answer the radio output power in decibels.

Specified by:
getOutputPower in interface ILowPanPacketDispatcher
Returns:
- radio output power

isLoggingConnections

public boolean isLoggingConnections()
Specified by:
isLoggingConnections in interface ILowPanPacketDispatcher
Returns:
true if connection addition and removal is being logged to System.out

setLogConnections

public void setLogConnections(boolean logConnections)
Description copied from interface: ILowPanPacketDispatcher
Select whether connection addition and removal is being logged to System.out

Specified by:
setLogConnections in interface ILowPanPacketDispatcher
Parameters:
logConnections - true if connnections should be logged

Sun SPOT API
Green Release  


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