|
Sun SPOT API |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
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".
| Method Summary | |
|---|---|
String |
getName()
|
void |
processIncomingRadioPacket(RadioPacket rp)
Called whenever a RadioPacket is received that is addressed to this IProtocolManager. |
| Method Detail |
|---|
void processIncomingRadioPacket(RadioPacket rp)
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.
rp - -- a RadioPacket to be filled inString getName()
|
Sun SPOT API |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||