SunSPOT API V5.0


com.sun.spot.peripheral.radio
Class RadioProtocolManager

java.lang.Object
  extended by com.sun.spot.peripheral.radio.RadioProtocolManager
All Implemented Interfaces:
IRadioProtocolManager
Direct Known Subclasses:
RadiogramProtocolManager, RadiostreamProtocolManager

public abstract class RadioProtocolManager
extends Object
implements IRadioProtocolManager


Field Summary
 
Fields inherited from interface com.sun.spot.peripheral.radio.IRadioProtocolManager
FIRST_USER_PORT, INPUT, OUTPUT, PORT_OFFSET
 
Method Summary
protected  ConnectionID addConnection(boolean canReceive, ConnectionID cid)
           
 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 cidToClose)
          Deregister a handler.
protected  com.sun.spot.peripheral.radio.ConnectionState getConnectionState(long macAddress, int connectionType, byte portNumber)
           
protected abstract  String getName()
           
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.spot.peripheral.radio.IRadioProtocolManager
send
 

Method Detail

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.

closeConnection

public void closeConnection(ConnectionID cidToClose)
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:
cidToClose - - 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

addConnection

protected ConnectionID addConnection(boolean canReceive,
                                     ConnectionID cid)

getConnectionState

protected com.sun.spot.peripheral.radio.ConnectionState getConnectionState(long macAddress,
                                                                           int connectionType,
                                                                           byte portNumber)

getName

protected abstract String getName()

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

SunSPOT API V5.0


Copyright � 2006-2008 Sun Microsystems, Inc. All Rights Reserved.