Sun Microsystems V2.0 manual Turning the receiver off and on

Page 36

DefaultChannelNumber

DefaultPanId

DefaultTransmitPower

Turning the receiver off and on

The radio receiver is initially turned off, but turns on automatically when either a radiogram connection capable of receiving is opened (that is, a non-broadcast radiogram connection) or when an input stream associated with a radio connection is opened. The receiver is turned off automatically when all such connections are closed.

Connections can be associated with one of three policies:

ON: the default policy, where the existence of the connection forces the radio receiver to be on.

OFF: where the connection does not require the radio receiver to be on.

WEAK_ON: where the connection is prepared to handle incoming radio traffic but is happy to acquiesce if another connection wants the radio off.

To set a connection’s policy, do, for example:

myRadiogramConnection.setRadioPolicy(RadioPolicy.OFF);

In the presence of multiple connections the radio is always kept on as long as one or more connections have set their policy to be RadioPolicy.ON. If no connections are set to ON and one or more connections are set to OFF then the radio is turned off, and if all the current connections are set to WEAK_ON the radio is turned on. If all connections are removed, the radio is turned off.

Note that all the above applies to the radio receiver. Even when the receiver is off, outgoing traffic can still be transmitted. When transmission happens, the receiver is turned on briefly, so that link- level acknowledgements can be received where necessary.

If your application does not use the radio, but has the OTA command server running, then because the OTA command server’s connection has its policy set to WEAK_ON, the radio will be on. So, if you want to turn the radio off to conserve power, or to allow deep sleep to happen, you should create a dummy connection and set its policy to off:

RadiogramConnection conn = (RadiogramConnection) Connector.open("radiogram://:42"); conn.setRadioPolicy(RadioPolicy.OFF);

This will overrule the OTA command server connection WEAK_ON policy. Note that if you close the dummy connection, then the radio will turn back on, in line with the OTA command server’s

WEAK_ON policy.

Allowing the radio stack to run

Some threads within the radio stack run at normal priority. So, if your application has threads that run continuously without blocking, you should ensure that these run at normal or lower priority to permit the radio stack to process incoming traffic.

Signal strength

When using the Radiogram protocol it is possible to obtain various measures of radio signal quality captured when the datagram is received.

36

Image 36
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 Using short names for SPOTs Managing keys and sharing Sun SPOTsTake suitable actions during over-the-air downloads BackgroundChanging the owner of a Sun Spot Sharing Sun SPOTsWhat is protected? Deploying and running a host applicationGenerating a new key-pair LimitationsConfiguring network features Your own host applicationIncorporating pre-existing jars into your 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 SleepUSB inhibits deep sleep Preconditions for deep sleepingDeep sleep behaviour of the standard drivers 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 Contents of the arm directory Contents of the lib directoryMemory usage Start address Space UseContents of the bin directory preverify.exe Contents of the upgrade directory Contents of the tests directory