SunSPOT API V2.0


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

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

public interface RadiogramConnection
extends ITimeoutableConnection, DatagramConnection, IRadioControl

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.

Once the connection has been opened, each end can obtain streams to use to send and receive data, 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
 int getMaxBroadcastHops()
           
 boolean packetsAvailable()
           
 void setMaxBroadcastHops(int hops)
           
 
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
 

Method Detail

packetsAvailable

boolean packetsAvailable()

setMaxBroadcastHops

void setMaxBroadcastHops(int hops)

getMaxBroadcastHops

int getMaxBroadcastHops()

SunSPOT API V2.0


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