Join A Network

This section refers to the following sample application(s):

  • 01-join


Joining a network consists of the following steps:

  • The mote listens for advertisement messages sent by the 

    SmartMesh manager

     or 

    SmartMesh mote

    s already in the network.
  • Once it hears such an advertisement, in synchronizes to the network, and starts the joining process with the 

    SmartMesh manager

    . Note that this can be done even when the 

    SmartMesh manager

     is multiple hops away from the joining 

    SmartMesh mote

    .
  • Once the joining process is finished, the 

    SmartMesh mote

     is Operational. It has been assigned some "base bandwidth" from the 

    SmartMesh manager

    , allowing it to send infrequent traffic to the 

    SmartMesh manager

    .

Refer to the SmartMesh IP User's Guide for a detailed description of the joining process.


The 

SmartMesh network stack

 sends events to the application to indicate the step of the joining process it is at. The DN_API_LOC_EV_OPERATIONAL event indicates that the 

SmartMesh mote

 has successfully joined the network.

To join a network, your application therefore needs to:

  • Configure the network identifier of the mote. This parameter is stored in non-volatile memory, so your application does not need to do this step every time the device boots. In particular, during development, you can set the network identifier through the mset netid CLI command, and reboot the part.
  • Optionally, configure the join duty cycle of the mote to the appropriate trade-off point between joining speed and average power consumption during the searching process.
  • Ask the 

    SmartMesh IP

     stack to search for a network and join, by calling the dnm_loc_joinCmd() function.
  • Monitor the events received from the the 

    SmartMesh IP

     stack. The mote is joined when your application receives the DN_API_LOC_EV_OPERATIONAL event.

The 01-join Sample Application

This application uses the loc_task helper module to join the network.

If you have a 

SmartMesh manager

 running, and your device is configured to its network identifier, the following messages print on the CLI:

SmartMeshIP stack, ver 1.2.1.3
 10154 : Joining
 11705 : Connected
 18015 : Active
Done joining!
packet sent
packet sent

The "Joining", "Connected" and "Active" messages are printed by the 

SmartMesh IP

 stack and can not be disabled. "Active" indicates the mote has successfully joined the network.

During the joining process, you can use the minfo CLI command to see the state of the 

SmartMesh mote

 change:

join app, ver 1.0.0.1
SmartMeshIP stack, ver 1.2.1.3
>
>
>
> minfo
Net stack  v1.2.1.3
state:     Search
mac:       00:17:0d:00:00:38:0f:47
moteid:    0
netid:     423
blSwVer:   13
ldrSwVer:  1.0.3.12
UTC time:  0:0
reset st:  200
>   4318 : Joining
minfo  6109 : Connected

Net stack  v1.2.1.3
state:     Conn
mac:       00:17:0d:00:00:38:0f:47
moteid:    2
netid:     423
blSwVer:   13
ldrSwVer:  1.0.3.12
UTC time:  0:0
reset st:  200
>  12418 : Active
Done joining!
minfo
Net stack  v1.2.1.3
state:     Oper
mac:       00:17:0d:00:00:38:0f:47
moteid:    2
netid:     423
blSwVer:   13
ldrSwVer:  1.0.3.12
UTC time:  1025665386:778198
reset st:  200

Once the device is joined, the 01-join sample application starts a task which sends a packet to the manager over the wireless network every 10s. You can connect the ApiExplorer application from the 

SmartMesh SDK

 to your 

SmartMesh manager

 and subscribe to data notifications to see the packets being received at the 

SmartMesh manager

:

Refer to the following documentation for the

SmartMesh SDK

:

You can also use the ApiExplorer application to send arbitrary data to the mote, using the sendData command:

The 01-join sample application prints details about the received data over CLI:

packet received:
 - sourceAddr: ff020000000000000000000000000002
 - sourcePort: 60000
 - data:       (4 bytes) aabbccdd

Implementation Details

The 01-join 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 and open a socket bound to UDP port 60000.

It uses a single task (sendTask) which:

  • waits for the loc_task helper module to have joined the network (by pending on the joinedSem semaphore);
  • every 10s, send a UDP packet to the IPv6 address of the manager.