Sun SPOT API
Green Release  


com.sun.spot.io.j2me.radio
Interface RadioConnection

All Superinterfaces:
Connection, InputConnection, ITimeoutableConnection, OutputConnection, StreamConnection
All Known Implementing Classes:
Protocol

public interface RadioConnection
extends ITimeoutableConnection, StreamConnection

This interface defines the "radio" protocol.

The radio protocol is a socket-like peer-to-peer protocol that provides reliable, buffered stream-based IO between two devices.

NOTE The current implementation is single-hop only: it can only be used to communicate between devices that are in direct radio range.

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 LowPanPacketDispatcher directly. See IProtocolManager for more information.

To open a connection do:

...
StreamConnection conn = (StreamConnection) Connector.open("radio://:");
...

where destinationAddr is the 64 bit IEEE Address of the radio at the far end, and portNo is a port number in the range 0 to 127 that identifies this particular connection. Note that 0 is not a valid IEEE address in this implementation.

To establish a bi-directional 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:

...
DataInputStream dis = conn.openDataInputStream();
DataOutputStream dos = conn.openDataOutputStream();
...


Method Summary
 
Methods inherited from interface com.sun.spot.peripheral.ITimeoutableConnection
getTimeout, setTimeout
 
Methods inherited from interface javax.microedition.io.InputConnection
openDataInputStream, openInputStream
 
Methods inherited from interface javax.microedition.io.Connection
close
 
Methods inherited from interface javax.microedition.io.OutputConnection
openDataOutputStream, openOutputStream
 
Methods inherited from interface javax.microedition.io.Connection
close
 


Sun SPOT API
Green Release  


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