Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Join an existing mesh Network with a mesh provisioner (nrf mesh sdk)

Hi,

Is it possible to join an existing mesh network with a provisioner made on Nrf52840 (s140)  ?

I have used the provisioner example to make a provisioner which actually create a new mesh network. But after an "erase all" of the board, the provisioning data are lost and the board can't reconnect to the network because information are lost during the erase (logic).

Is there a way to extract the provisioning data and mesh network data from the board to use them later on an other board ?

My goal is to create a mesh network with a device, then store in a file all the information related to this network to be able later with another board to join this network and add new devices.

I have setup a serial connection to send data through the usb port to my computer so I could retrieve and return the data by this method.

I know that this is possible in the mobile application with the "export network" and "import network" functions but I can't reproduce the functionality with the mesh SDK.

Is this possible? If yes how?
Regards

Used sdk :

- nRF5_SDK_16.0.0_98a08e2

- nrf5_SDK_for_Mesh_v4.2.0_src

Board used :

- nrf52840 evaluation board

- nrf52832 evaluation board

Parents
  • Hi Neicureuil, 

    The easiest way of "exporting" the provisioner data to another board is to just do a hex dump of the flash content of the board (nrfjprog --readcode ). You can then use this hex file to flash on other board to access the network. 
    However doing that doesn't allow to have multiple provisioner at the same time and every time you provision a new node you would need to do a new hex dump. And that you would have only one firmware for all the provisioner. 

    A more advanced option is to only copy the specific data that need to be restored on a new board so that you can customized it to export and import. What you need to copy is : network key, application keys, device keys, the composition data of nodes.
    We don't have the code of doing that. You would need to study the code and send such data back to PC.

    I would suggest to go for option 1 if you don't need any extra requirement. If you don't want to clone the whole flash, you can think of only copy the flash area that the dsm store the database. This way you can customize the firmware, and only copy the database flash area. 

  • Hi,

    Thank for your response.

    Is there a way to copy the flash area without using "nrfjprog" because at the end, the goal is to put the code on a nrf52840 usb dongle which will be connected to a linux autonomous computer (maybe directly from the code).

  • Hi,

    Thanks for all.

    I want to check if its really  a IV Index issue, for that I want to debug it on the both side (provisioner and node) and see what's append.

    Can you say to me how can debug the IV Index (which variable I need to log) ?

    Regards

  • Hi Neicureuil, 

    The current IV Index is stored in m_net_state.iv_index in net_state.c .  If the device is provisioned the IV index is restored when the mesh config is loaded from flash (mesh_config_load). When net_state_enable() (restored_result_apply()) is called the IV index from flash will be applied to  m_net_state.iv_index. 

    The Secure Network Beacon is handled in net_beacon_packet_in inside beacon_packet_in() inside net_beacon.c . You can turn on logging at LOG_LEVEL_DBG1 level for LOG_SRC_NETWORK to get the info about the process on the log. 

    The actual update of the IV index is handled in incoming_data_received() in net_state.c .

    Note that if the difference between the current IV index in the node and the actual IV index in the network is above NETWORK_IV_RECOVERY_LIMIT (42) the node would need to be re-provisioned. 

  • Hi,

    I have realized some test :
    - I have set the NETWORK_IV_RECOVERY_LIMIT to 1000000000 to test if its an Iv Index issue but nothing change. On the network reload (from serial like the beginning) I got node alive event (from the node health model) but I need to wait between 5 minutes and infinity for the nodes to start receiving messages from the On/Off and config models of the provisioner.

    In the end does this look like an IV index problem or not ?

    Because if it is an index problem, the provisioner should not receive the alive events from the health model of the nodes.
    Unless the health model does not depend on the IV index?

    Regards

  • Hi,

    I have made a mistake.

    When I change the NETWORK_IV_RECOVERY_LIMIT, I only change it on the provisioner side.

    When I also change it in the node side, it seems to be faster (1 or 2 seconds).

    But why when the IV index is bad the health model messages are received both side ? Is the health model depends of the iv index or not ?

    EDIT :

    After a second test with more than one device (because the first test use only one node), its doesn't work. The node takes an average of 5 minutes to be sync (like before).

    Fake Hope ......

    EDIT 2 :

    Is the IV index the same for all the nodes in the network or each node as Its own IV index ?

    Regards

  • Hi,

    I don't think the Health Model Message is any different from other model. So it's pretty strange that you can receive the health model message but not the others. 

    I would suggest to test changing the IV Index of a single normal node, and observe how long it would take for the note to get updated to the current IV Index. 

Reply Children
  • Hi,

    Sorry for the late response.

    I made more tests and this what I got :

    1- I have tried to change the IV index tolerance (NETWORK_IV_RECOVERY_LIMIT ) of one node and the provisioner but nothing append because the tolerance is only for higher number : for example if the iv index is 30 and the tolerance is set to 10, the accepted incoming IV index are from 30 to 40 (and not 20 to 40). The issue is that when I reload the network, the provisioner index is set to 0, so its below the node index and nothing append.

    2- Considering that the health model used the iv index like other model and that I got instant alive event when I reload the network, I thought maybe it was my vendor model that had a problem.

    So I tried to launch a reconfiguration of the nodes when loading the network. For that I stored the devkey of my node and I reloaded it in memory when the network was loaded.

    I then waited for an alive event then I launched a configuration procedure from the provisioner for the node (node_setup_start) but nothing happened because the configuration model of the node did not respond. It ended up responding after 5 minutes like the other model.

    So I think that the event alive of the health model works differently from the rest and should potentially not use the iv index.

    3- I also noticed that if I reload my network on the provisioner and turn off and on my node, then all the models in the node respond instantly

    4- I would like to test the modification of the iv index of a node (as suggested in your message) but I can't find where to do it in the code. The incoming_data_received function that you give to me is only for check and update the iv index if needed but it runs if the message is valid, but when I reload my network and the models other than health don't respond, this function is never called (both on the node and the provisioner side).

    Regards

  • Hi Neicureuil,


    1. What you described is about right. That how it should work. You should have a way of communication between the old provisioner and the new provisioner to send the current IV Index, otherwise provisioning process is needed. 

    2. 3. I don't have an answer for this. I would need to study the code a little bit more. 

    4. Could you try what I suggested : 

    The current IV Index is stored in m_net_state.iv_index in net_state.c .  If the device is provisioned the IV index is restored when the mesh config is loaded from flash (mesh_config_load). When net_state_enable() (restored_result_apply()) is called the IV index from flash will be applied to  m_net_state.iv_index. 

  • Hi,

    I just tried to debug the iv index with "net_state_beacon_iv_index_get()" on both side. I'm surprised to see that its return 0 on the both side, even after model commands sending.

    Regards

  • Hi Neicureruil, 


    When did you call this function ? It's normal for a network to start with IV index = 0. 

  • Hi,

    I call it each time I received an alive event, and each time I received a model command acknowledgment. 

    I have tried to set a custom IV index just after the mesh init and start function with net_state_iv_index_set. But same thing append, each time I debug it (same places that before) its return the same index (the index that I previously set) and its never increase.

    Regards

Related