Sun Microsystems V2.0 manual Broadcasting

Page 34

There are some important points to note about using this operation:

If setting a timeout it must be set before opening streams or creating datagrams.

A TimeoutException is generated if the caller is blocked waiting for input for longer than the period specified.

Setting a timeout of 0 causes the exception to be generated immediately if data is not available.

Setting a timeout of -1 turns off timeouts, that is, wait forever.

Broadcasting

It is possible to broadcast datagrams. By default, broadcasts are transmitted over two hops, so they may be received by devices out of immediate radio range operating on the same PAN. The broadcast is not inter-PAN. Broadcasting is not reliable: datagrams sent might not be delivered. SPOTs ignore the echoes of broadcasts that they transmitted themselves or have already received.

To perform broadcasting first open a special radiogram connection:

DatagramConnection conn = (DatagramConnection)Connector.open("radiogram://broadcast:<portnum>");

where <portnum> is the port number you wish to use. Datagrams sent using this connection will be received by listening devices within the PAN.

Note that broadcast connections cannot be used to receive. If you want to receive replies to a broadcast then open a server connection, which can be on the same port.

If you wish broadcasts to travel for more or less than the default two hops, do

((RadiogramConnection)conn).setMaxBroadcastHops(3);

Broadcasting and basestations

As described in the section Using the Basestation, basestations may operate in either shared or dedicated mode. Imagine a remote SPOT, out of range of the basestation, which broadcasts a radiogram with the default two hops set. An intermediate SPOT that is in range of the basestation then picks up the radiogram, and relays it. Because the basestation receives the packet after two hops, it does not relay it.

In dedicated mode, the host application uses the basestation’s address and therefore receives this radiogram. In shared mode, the host application is still one more hop from the host process managing the basestation, and so does not receive the radiogram. Similar considerations apply to packets sent from host applications. For this reason, application developers using broadcast packets to communicate between remote SPOTs and host applications will need to consider the impact of basestation mode on the number of broadcast hops they set.

These considerations will also impact anyone that works directly with the I802.15.4 MAC layer or lower levels of the radio communications stack. At the MAC layer, all packets are sent single hop: using a dedicated basestation these will reach remote SPOTs, using a shared basestation they will not.

Port number usage

The valid range of port numbers for both the radio and radiogram protocols is 0 to 255. However, for each protocol, ports in the range 0 to 31 are reserved for system use; applications should not use port numbers in this range.

34

Image 34
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 applicationExcluding files from the compilation Manifest and resourcesOther user properties Built-in properties Using the BasestationOverview Set up Remote operation Base Station configurationIntroduction 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 routingTrace route Hardware configurations and USB powerLogging Page Threads Overview of an applicationThread priorities Sun Spot device library Sun Spot device librariesDevice 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 Monitoring radio activity Conserving power using deep sleep modeShallow 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 modeJavadoc/source configuration Classpath 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 Persistent system properties ReferenceProperty 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