SunSPOT API V3.0


com.sun.spot.io.j2me.radiogram
Interface RadiogramConnection

All Superinterfaces:
Connection, DatagramConnection, IMultipleHopConnection, IRadioControl, ITimeoutableConnection
All Known Implementing Classes:
RadiogramConnImpl

public interface RadiogramConnection
extends ITimeoutableConnection, DatagramConnection, IRadioControl, IMultipleHopConnection

This interface defines the "radiogram" protocol - the radiogram protocol is a datagram-based protocol that allows the exchange of packets between two devices.

IMPORTANT This protocol is provided for test purposes and to allow creation of simple demonstrations. It is NOT designed to be used as the base for higher level or more complex protocols. If you want to create something more sophisticated write a new protocol that calls the RadioPacketDispatcher or LowPan directly. See IProtocolManager for more information.

To establish a point-to-point connection both ends must open connections specifying the same portNo and corresponding IEEE addresses.
Port numbers between 0 and 31 are reserved for system services. Use by applications may result in conflicts.
Once the connection has been opened, each end can send and receive data using a datagram created on that connection, eg:

...
DatagramConnection conn = (DatagramConnection) Connector.open("radiogram://" + targetIEEEAddress + ":10");
Datagram dg = conn.newDatagram(conn.getMaximumLength());
dg.writeUTF("My message");
conn.send(dg);
...
conn.receive(dg);
String answer = dg.readUTF();
...


The radiogram protocol also supports broadcast mode, where radiograms are delivered to all listeners on the given port. Because broadcast mode does not use I802.15.4 ACKing, there are no delivery guarantees.


...
DatagramConnection sendConn = (DatagramConnection) Connector.open("radiogram://broadcast:10");
dg.writeUTF("My message");
sendConn.send(dg);
...
DatagramConnection recvConn = (DatagramConnection) Connector.open("radiogram://:10");
recvConn.receive(dg);
String answer = dg.readUTF();



Method Summary
 boolean packetsAvailable()
          determines whether there are radiograms that can be read from this connection
 
Methods inherited from interface com.sun.spot.peripheral.ITimeoutableConnection
getTimeout, setTimeout
 
Methods inherited from interface javax.microedition.io.DatagramConnection
getMaximumLength, getNominalLength, newDatagram, newDatagram, newDatagram, newDatagram, receive, send
 
Methods inherited from interface javax.microedition.io.Connection
close
 
Methods inherited from interface com.sun.spot.peripheral.IRadioControl
getLocalPort, setRadioPolicy
 
Methods inherited from interface com.sun.spot.peripheral.IMultipleHopConnection
getMaxBroadcastHops, setMaxBroadcastHops
 

Method Detail

packetsAvailable

boolean packetsAvailable()
determines whether there are radiograms that can be read from this connection

Returns:
true if there are packets that can be read from the connection

SunSPOT API V3.0


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