Info |
---|
This section refers to the following sample application(s):
|
Table of Contents |
---|
The 01-join_control sample application relies on the local module to handle joining. It does this by passing the fJoin flag = JOIN_YES, and supplying a semaphore to notify the application when the mote has joined. Behind the scenes, the mote is using the joinDutyCycle Energy to join a network when it is present is roughly constant - joining is either faster but at higher current, or slower but at lower current. In some cases however, e.g. when there is the possibility that the network may not be present for long periods of time, it may be desirable to listen for a short period of time, then return to a low power mode for a longer period, waking periodically to listen for the network. Normally the mote uses the joinDutyCycle parameter stored in its persistent parameter settings (default = 64 or 25%), and will listen continuously at this duty cycle until it joins a network. The 01-join_control sample
An OCSDK application can control join behavior on its own by passing JOIN_NO and a NULL pointer for the join semaphore to the local module. The 01-join_control illustrates using the application to control join behavior:
- It changes a
control sample application relies on the local module to handle joining, but modifies the joinDutyCycle while the mote remains searching for the network.
The 01-join_control Sample Application
The application is best used with the manager initially turned off. The application cycles through listing at 100%, 5%, and sitting in idle (burning a few µA).
No Format |
---|
Join app, ver 1.2.0.1
SmartMeshIP stack, ver 1.4.1.6
Setting Join duty cycle to 100%
Setting Join Duty Cycle to 5%
Stop listening and return to idle state
Starting to try joining again...
Setting Join duty cycle to 100%
...
|
You can also turn on the mac trace to see the radio listening listening (and at what duty cycle) during active periods.
No Format |
---|
> mtrace mac on listen chan = 0, dc=100 listen chan = 6, dc=100 listen chan = 4, dc=100 Setting Join Duty Cycle to 5% listen chan = 5, dc=5 listen chan = 2, dc=5 listen chan = 9, dc=5 ... |
After a few cycles, turn on the manager and the mote will join. It will print the following once joined:
No Format |
---|
I finally joined! |
Implementation Details
The 01-join_control
sample application uses the Helper Modules to initialize the CLI Module and interaction with the local interface. In particular, it configures the loc_task
helper module to join the network - it tells the local module to not open a socket by passing NULL in the port field.
It uses a single task (joinTask
) which:
...
, in a while(1)
loop:
- Sets the joinDutyCycle to 100% and pends on the
joinedSem
semaphore ); - waits for the
loc_task
helper module to be granted the requested service service (by pending on theserviceSem
semaphore); - every 10s, request the current service to the manager (by calling
dnm_loc_getAssignedServiceCmd()
), and print that over CLI. - It with a timeout HI_TIMEOUT
- If the timeout is reached, it sets the joinDutyCycle to 5% and pends on the
joinedSem
semaphore with a timeout LOW_TIMEOUT - If the timeout is reached, it issues the
dn_loc_stopSearchCmd()
and waits for IDLE_TIMEOUT - It then issues
dnm_loc_joinCmd()
to start the mote listening for a network and repeats the loop - If the mote successfully joins, it prints a success message and doesn't modify the join duty cycle further