Sun SPOT API
Green Release  


com.sun.spot.peripheral.radio
Class PortBasedProtocolManager

java.lang.Object
  extended by com.sun.spot.peripheral.radio.PortBasedProtocolManager
All Implemented Interfaces:
IPortBasedProtocolManager, IProtocolManager

public class PortBasedProtocolManager
extends Object
implements IProtocolManager, IPortBasedProtocolManager


Field Summary
 
Fields inherited from interface com.sun.spot.peripheral.radio.IPortBasedProtocolManager
BROADCAST, CTRL_OFFSET, DATA_OFFSET, INPUT, OUTPUT, PORT_OFFSET, SEQ_OFFSET, SERVER
 
Constructor Summary
PortBasedProtocolManager(byte protocolNum, String name)
          Construct an instance to manage the given protocol number.
PortBasedProtocolManager(byte protocolNum, String name, ILowPanPacketDispatcher lppd)
           
 
Method Summary
 ConnectionID addBroadcastConnection(byte portNo)
          Register a broadcast connection
 ConnectionID addInputConnection(long macAddress, byte portNo)
          Register a point-to-point connection on which packets can be received
 ConnectionID addOutputConnection(long macAddress, byte portNo)
          Register a point-to-point connection on which packets can be sent
 ConnectionID addServerConnection(byte portNo)
          Register a server connection
 void closeConnection(ConnectionID cidToClose)
          Deregister a handler.
 String getName()
           
 boolean packetsAvailable(ConnectionID connectionID)
          Answer whether one or more radio packets have been received and are queued for the given ConnectionID.
 void processIncomingRadioPacket(RadioPacket rp)
          Called whenever a RadioPacket is received that is addressed to this IProtocolManager.
 RadioPacket receivePacket(ConnectionID cid)
          Receive a radio packet over a Connection ID.
 RadioPacket receivePacket(ConnectionID cid, long timeout)
          Receive a radio packet over a Connection ID.
 void sendPacket(ConnectionID cid, RadioPacket rp)
          Send a radio packet using a ConnectionID.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PortBasedProtocolManager

public PortBasedProtocolManager(byte protocolNum,
                                String name,
                                ILowPanPacketDispatcher lppd)

PortBasedProtocolManager

public PortBasedProtocolManager(byte protocolNum,
                                String name)
Construct an instance to manage the given protocol number.

Parameters:
protocolNum - - the protocol number to be managed.
Method Detail

closeConnection

public void closeConnection(ConnectionID cidToClose)
Description copied from interface: IPortBasedProtocolManager
Deregister a handler. The ConnectionID supplied should be one that was created by a previous call to #addConnection. This call reverses the effect of the previous call.

Specified by:
closeConnection in interface IPortBasedProtocolManager
Parameters:
cidToClose - - the ConnectionID to deregister

sendPacket

public void sendPacket(ConnectionID cid,
                       RadioPacket rp)
                throws NoAckException,
                       ChannelBusyException
Description copied from interface: IPortBasedProtocolManager
Send a radio packet using a ConnectionID.

Specified by:
sendPacket in interface IPortBasedProtocolManager
Parameters:
cid - -- the ConnectionID to send the packet over.
rp - -- the RadioPacket to send.
Throws:
NoAckException
ChannelBusyException

processIncomingRadioPacket

public void processIncomingRadioPacket(RadioPacket rp)
Description copied from interface: IProtocolManager
Called whenever a RadioPacket is received that is addressed to this IProtocolManager. IProtocolManagers should do as little processing as possible inside this method, to avoid blocking other IProtocolManagers from receiving their packets. Typically an IProtocolManager will queue received packets for later dispatch to applications.

Specified by:
processIncomingRadioPacket in interface IProtocolManager
Parameters:
rp - -- a RadioPacket to be filled in

receivePacket

public RadioPacket receivePacket(ConnectionID cid)
Description copied from interface: IPortBasedProtocolManager
Receive a radio packet over a Connection ID. If the Connection ID is a server, this will be any packet received on the given protocol/port: if the Connection ID specifies a counterpart, it will be a packet received from that counterpart. It is an error to attempt to receive a packet over a broadcast Connection ID. This method blocks until a packet is received over the given Connection ID.

Specified by:
receivePacket in interface IPortBasedProtocolManager
Parameters:
cid - the ConnectionID over which to receive a packet
Returns:
the received packet

receivePacket

public RadioPacket receivePacket(ConnectionID cid,
                                 long timeout)
Description copied from interface: IPortBasedProtocolManager
Receive a radio packet over a Connection ID. If the Connection ID is a server, this will be any packet received on the given protocol/port: if the Connection ID specifies a counterpart, it will be a packet received from that counterpart. It is an error to attempt to receive a packet over a broadcast Connection ID. This method blocks until a packet is received over the given Connection ID, or until a timouet expires.

Specified by:
receivePacket in interface IPortBasedProtocolManager
Parameters:
cid - the ConnectionID over which to receive a packet
timeout - the maximum time to block in milliseconds
Returns:
the received packet or null if a timeout occurs

packetsAvailable

public boolean packetsAvailable(ConnectionID connectionID)
Description copied from interface: IPortBasedProtocolManager
Answer whether one or more radio packets have been received and are queued for the given ConnectionID. It is an error to call this method for a broadcast Connection ID.

Specified by:
packetsAvailable in interface IPortBasedProtocolManager
Returns:
whether packets are available.

getName

public String getName()
Specified by:
getName in interface IProtocolManager
Returns:
the name of this protocol manager

addOutputConnection

public ConnectionID addOutputConnection(long macAddress,
                                        byte portNo)
Description copied from interface: IPortBasedProtocolManager
Register a point-to-point connection on which packets can be sent

Specified by:
addOutputConnection in interface IPortBasedProtocolManager
Parameters:
macAddress - - address of the other device
portNo - - port number to communicate over
Returns:
resultant ConnectionID

addInputConnection

public ConnectionID addInputConnection(long macAddress,
                                       byte portNo)
Description copied from interface: IPortBasedProtocolManager
Register a point-to-point connection on which packets can be received

Specified by:
addInputConnection in interface IPortBasedProtocolManager
Parameters:
macAddress - - address of the other device
portNo - - port number to communicate over
Returns:
resultant ConnectionID

addServerConnection

public ConnectionID addServerConnection(byte portNo)
Description copied from interface: IPortBasedProtocolManager
Register a server connection

Specified by:
addServerConnection in interface IPortBasedProtocolManager
Parameters:
portNo - - port number to communicate over
Returns:
resultant ConnectionID

addBroadcastConnection

public ConnectionID addBroadcastConnection(byte portNo)
Description copied from interface: IPortBasedProtocolManager
Register a broadcast connection

Specified by:
addBroadcastConnection in interface IPortBasedProtocolManager
Parameters:
portNo - - port number to communicate over
Returns:
resultant ConnectionID

Sun SPOT API
Green Release  


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