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();
...
Copyright © 2006 Sun Microsystems, Inc. All Rights Reserved.