SunSPOT API V3.0


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

java.lang.Object
  extended by com.sun.spot.peripheral.radio.proxy.ProxyRadioProtocolManager
All Implemented Interfaces:
IRadioProtocolManager
Direct Known Subclasses:
ProxyRadiogramProtocolManager, ProxyRadiostreamProtocolManager

public class ProxyRadioProtocolManager
extends Object
implements IRadioProtocolManager


Field Summary
protected  RequestSender requestSender
           
 
Fields inherited from interface com.sun.spot.peripheral.radio.IRadioProtocolManager
FIRST_USER_PORT, INPUT, OUTPUT, PORT_OFFSET
 
Constructor Summary
protected ProxyRadioProtocolManager(byte protocolNum, String name, String channelIdentifier)
           
 
Method Summary
 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
 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.
 IncomingData receivePacket(ConnectionID cid)
          Receive incoming data over a Connection ID.
 IncomingData receivePacket(ConnectionID cid, long timeout)
          Receive incoming data over a Connection ID.
 long send(ConnectionID cid, long toAddress, byte[] payload, int length)
          Send a byte array using a ConnectionID.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requestSender

protected RequestSender requestSender
Constructor Detail

ProxyRadioProtocolManager

protected ProxyRadioProtocolManager(byte protocolNum,
                                    String name,
                                    String channelIdentifier)
Method Detail

closeConnection

public void closeConnection(ConnectionID cid)
Description copied from interface: IRadioProtocolManager
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 IRadioProtocolManager
Parameters:
cid - - the ConnectionID to deregister

addOutputConnection

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

Specified by:
addOutputConnection in interface IRadioProtocolManager
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: IRadioProtocolManager
Register a point-to-point connection on which packets can be received

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

send

public long send(ConnectionID cid,
                 long toAddress,
                 byte[] payload,
                 int length)
          throws NoAckException,
                 ChannelBusyException,
                 NoRouteException
Description copied from interface: IRadioProtocolManager
Send a byte array using a ConnectionID. The client code should leave IPortBasedProtocolManager.DATA_OFFSET bytes free at the front of their payload as these will be overwritten.

Specified by:
send in interface IRadioProtocolManager
Parameters:
cid - the ConnectionID to send the packet over.
payload - the data
length - number of bytes to send, starting with index 0
Returns:
the time at which the data was sent
Throws:
NoAckException
ChannelBusyException
NoRouteException

receivePacket

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

Specified by:
receivePacket in interface IRadioProtocolManager
Parameters:
cid - the ConnectionID over which to receive data
Returns:
the received data

receivePacket

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

Specified by:
receivePacket in interface IRadioProtocolManager
Parameters:
cid - the ConnectionID over which to receive data
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: IRadioProtocolManager
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 IRadioProtocolManager
Returns:
whether packets are available.

SunSPOT API V3.0


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