Sun Microsystems V2.0 manual Program

Page 30

The radiogram protocol provides datagram-based communication between two devices. This protocol provides no guarantees about delivery or ordering. Datagrams sent over more than one hop could be silently lost, be delivered more than once, and be delivered out of sequence. Datagrams sent over a single hop will not be silently lost or delivered out of sequence, but they could be delivered more than once4.

The protocols are implemented on top of the MAC layer of the 802.15.4 implementation.

The radiostream protocol

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

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 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 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 now-closed connection: its packets will appear to be accepted because they were acknowledged, but they will not be processed by the destination SPOT. Thus connections working over a single hop have slightly different semantics to those operating over multiple hops; this is the result of an important performance optimisation for single hop connections.

30

Image 30
Contents Page Page Contents Http protocol support Introduction Building and deploying Sun Spot applications Deploying and running a sample applicationBuild Successful Total time 3 seconds \MyApplication Ant -Dport=COM2 info Total time 4 seconds \MyApplication Total time 0 seconds \MyApplication Deploying a pre-existing jar Incorporating utility classes into your applicationManifest and resources Excluding files from the compilationOther user properties Using the Basestation Built-in propertiesOverview Set up Base Station configuration Remote operationIntroduction Connect a Sun Spot base station Take suitable actions during over-the-air downloads Using short names for SPOTsManaging keys and sharing Sun SPOTs BackgroundChanging the owner of a Sun Spot Sharing Sun SPOTsGenerating a new key-pair What is protected?Deploying and running a host application LimitationsIncorporating pre-existing jars into your host application Configuring network featuresYour own host application Mesh routingHardware configurations and USB power Trace routeLogging Page Overview of an application ThreadsThread priorities Sun Spot device libraries Sun Spot device libraryDevice Interface Persistent properties Accessing flash memory Overriding the Ieee addressUsart Radio communication library Program Radiogram protocol Client end Server endYou can open server radiogram connections in a similar way Broadcasting Radio properties Turning the receiver off and on Conserving power using deep sleep mode Monitoring radio activityShallow Sleep Activating deep sleep mode Deep SleepDeep sleep behaviour of the standard drivers USB inhibits deep sleepPreconditions for deep sleeping Device Condition to permit deep sleepWriting a device driver Configuring the http protocol Http protocol supportConfiguring projects in an IDE Socket Proxy GUI modeClasspath configuration Javadoc/source configurationDebugging Ant selectapplication Configuring NetBeans as a debug client Configuring Eclipse as a debug clientUsing library suites Advanced topicsWith adderlib as your current directory, execute the command Use the command Using the spot client SpotSerialPortException other exception in serial port comms Reference Persistent system propertiesProperty name Meaning Memory usage Contents of the arm directoryContents of the lib directory Start address Space UseContents of the bin directory preverify.exe Contents of the upgrade directory Contents of the tests directory