The radiogram protocol provides
The protocols are implemented on top of the MAC layer of the 802.15.4 implementation.
The radiostream protocol
The radiostream protocol is a
To open a connection do:
RadiostreamConnection conn = (RadiostreamConnection)
Connector.open("radio://<destinationAddr>:<portNo>");
where destinationAddr is the 64bit IEEE Address of the radio at the far end, and portNo is a port number in the range 0 to 255 that identifies this particular connection. Note that 0 is not a valid IEEE address in this implementation. The connection is opened using the default radio channel and default PAN Id (currently channel 26, PAN 3). The section Radio properties shows how to override these defaults.
To establish a
Once the connection has been opened, each end can obtain streams to send and receive data, for example:
DataInputStream dis = conn.openDataInputStream();
DataOutputStream dos = conn.openDataOutputStream();
Here's a complete example:
Program 1
RadiostreamConnection conn = (RadiostreamConnection) Connector.open("radio://0014.4F01.0000.0006:100");
DataInputStream dis = conn.openDataInputStream(); DataOutputStream dos = conn.openDataOutputStream(); try {
dos.writeUTF("Hello up there"); dos.flush();
System.out.println ("Answer was: " + dis.readUTF()); } catch (NoRouteException e) {
System.out.println ("No route to 0014.4F01.0000.0006");
}finally { dis.close(); dos.close();
conn.close();
}
4One aspect of the current behaviour that can be confusing occurs if a SPOT that was communicating over a single hop closes its connection but then receives a packet addressed to it. In this case the packet will be acknowledged at the MAC level but then ignored. This can be confusing from the perspective of another SPOT sending to the
30