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.