Sun SPOT API
Green Release  


com.sun.spot.peripheral.radio
Interface IPortBasedProtocolManager

All Known Implementing Classes:
PortBasedProtocolManager, ProxyPBPM

public interface IPortBasedProtocolManager

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 int BROADCAST
           
static int CTRL_OFFSET
           
static int DATA_OFFSET
          The offset into RadioPackets at which data starts.
static int INPUT
           
static int OUTPUT
           
static int PORT_OFFSET
           
static int SEQ_OFFSET
           
static int SERVER
           
 
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.
 

Field Detail

OUTPUT

static final int OUTPUT
See Also:
Constant Field Values

INPUT

static final int INPUT
See Also:
Constant Field Values

SERVER

static final int SERVER
See Also:
Constant Field Values

BROADCAST

static final int BROADCAST
See Also:
Constant Field Values

PORT_OFFSET

static final int PORT_OFFSET
See Also:
Constant Field Values

SEQ_OFFSET

static final int SEQ_OFFSET
See Also:
Constant Field Values

CTRL_OFFSET

static final int CTRL_OFFSET
See Also:
Constant Field Values

DATA_OFFSET

static final int DATA_OFFSET
The offset into RadioPackets at which data starts. Clients should start writing and reading RadioPackets with code like this: myRadioPacket.setMACPayloadAt(DATA_OFFSET, someValue);

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

addServerConnection

ConnectionID addServerConnection(byte portNo)
Register a server connection

Parameters:
portNo - - port number to communicate over
Returns:
resultant ConnectionID

addBroadcastConnection

ConnectionID addBroadcastConnection(byte portNo)
Register a broadcast connection

Parameters:
portNo - - port number to communicate over
Returns:
resultant ConnectionID

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

sendPacket

void sendPacket(ConnectionID cid,
                RadioPacket rp)
                throws NoAckException,
                       ChannelBusyException
Send a radio packet using a ConnectionID.

Parameters:
cid - -- the ConnectionID to send the packet over.
rp - -- the RadioPacket to send.
Throws:
NoAckException
ChannelBusyException

receivePacket

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

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

receivePacket

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

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

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.

Sun SPOT API
Green Release  


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