Sun SPOT API
Green Release  


com.sun.spot.peripheral.radio
Interface IProtocolManager

All Known Implementing Classes:
PortBasedProtocolManager

public interface IProtocolManager

Implementors of this interface handle traffic relating to a particular protocol.

The separate class LowPanPacketDispatcher multiplexes traffic for up to 255 protocols over the radio connection between two Spots or between a host application and a Spot. For more information about the overall framework for implementing protocols, see that class.

To handle incoming traffic for a protocol you need an object that implements IProtocolManager. This object can be registered to receive traffic:

...
LowPanPacketDispatcher.getInstance().addProtocol(MY_PROTOCOL_NUMBER, pm);
...

and similarly deregistered

...
LowPanPacketDispatcher.getInstance().removeProtocol(MY_PROTOCOL_NUMBER);
...

There should only be one registered protocol manager for each unique protocol number.

The ILowPanPacketDispatcher will then repeatedly call processIncomingRadioPacket(RadioPacket) when packets are received for the protocol.

PortBasedProtocolManager is an example implementation that supports the "radio:" and "radiogram:" implementations supplied as part of the Spot base library. Note that although these protocols are implemented as Protocols in the sense implied by the GCF framework, this is not required. The word protocol in "IProtocolManager" has a different meaning to that in "GCF Protocol".

Author:
Syntropy, 2005

Method Summary
 String getName()
           
 void processIncomingRadioPacket(RadioPacket rp)
          Called whenever a RadioPacket is received that is addressed to this IProtocolManager.
 

Method Detail

processIncomingRadioPacket

void processIncomingRadioPacket(RadioPacket rp)
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.

Parameters:
rp - -- a RadioPacket to be filled in

getName

String getName()
Returns:
the name of this protocol manager

Sun SPOT API
Green Release  


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