Sun SPOT API
Green Release  


com.sun.spot.peripheral.radio.proxy
Class ProxyPBPM

java.lang.Object
  extended by com.sun.spot.peripheral.radio.proxy.ProxyPBPM
All Implemented Interfaces:
IPortBasedProtocolManager

public class ProxyPBPM
extends Object
implements IPortBasedProtocolManager


Field Summary
static String RADIO_SERVER
           
 
Fields inherited from interface com.sun.spot.peripheral.radio.IPortBasedProtocolManager
BROADCAST, CTRL_OFFSET, DATA_OFFSET, INPUT, OUTPUT, PORT_OFFSET, SEQ_OFFSET, SERVER
 
Constructor Summary
ProxyPBPM(byte protocolNum, String name)
           
 
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 cid)
          Deregister a handler.
 boolean packetsAvailable(ConnectionID connectionID)
          Answer whether one or more radio packets have been received and are queued for the given ConnectionID.
 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
 

Field Detail

RADIO_SERVER

public static final String RADIO_SERVER
See Also:
Constant Field Values
Constructor Detail

ProxyPBPM

public ProxyPBPM(byte protocolNum,
                 String name)
Method Detail

closeConnection

public void closeConnection(ConnectionID cid)
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:
cid - - the ConnectionID to deregister

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

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

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

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.

Sun SPOT API
Green Release  


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