SunSPOT API V5.0


com.sun.spot.peripheral.radio
Interface IRadioProtocolManager

All Known Subinterfaces:
IRadiogramProtocolManager, IRadiostreamProtocolManager
All Known Implementing Classes:
ProxyRadiogramProtocolManager, ProxyRadioProtocolManager, ProxyRadiostreamProtocolManager, RadiogramProtocolManager, RadioProtocolManager, RadiostreamProtocolManager

public interface IRadioProtocolManager

A general purpose IProtocolManager designed to separate incoming radio packets into separate queues based on a unique identifying port number in the range 0-255.

Currently underpins com.sun.squawk.io.j2me.radiogram.RadiogramConnection and com.sun.squawk.io.j2me.radio.RadioConnection.


Field Summary
static byte FIRST_USER_PORT
          The first port free for user use
static int INPUT
           
static int OUTPUT
           
static int PORT_OFFSET
           
 
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.
 

Field Detail

FIRST_USER_PORT

static final byte FIRST_USER_PORT
The first port free for user use

See Also:
Constant Field Values

OUTPUT

static final int OUTPUT
See Also:
Constant Field Values

INPUT

static final int INPUT
See Also:
Constant Field Values

PORT_OFFSET

static final int PORT_OFFSET
See Also:
Constant Field Values
Method Detail

closeConnection

void closeConnection(ConnectionID cid)
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.

Parameters:
cid - - the ConnectionID to deregister

addOutputConnection

ConnectionID addOutputConnection(long macAddress,
                                 byte portNo)
Register a point-to-point connection on which packets can be sent

Parameters:
macAddress - - address of the other device
portNo - - port number to communicate over
Returns:
resultant ConnectionID

addInputConnection

ConnectionID addInputConnection(long macAddress,
                                byte portNo)
Register a point-to-point connection on which packets can be received

Parameters:
macAddress - - address of the other device
portNo - - port number to communicate over
Returns:
resultant ConnectionID

send

long send(ConnectionID cid,
          long toAddress,
          byte[] payload,
          int length)
          throws NoAckException,
                 ChannelBusyException,
                 NoRouteException,
                 NoMeshLayerAckException
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.

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
NoRouteException
NoMeshLayerAckException

receivePacket

IncomingData receivePacket(ConnectionID cid)
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.

Parameters:
cid - the ConnectionID over which to receive data
Returns:
the received data

receivePacket

IncomingData receivePacket(ConnectionID cid,
                           long timeout)
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.

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

boolean packetsAvailable(ConnectionID connectionID)
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.

Parameters:
connectionID -
Returns:
whether packets are available.

SunSPOT API V5.0


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