This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

I want to recover control provisoned device, when I reopen the PyACI script and reset the 52840 DK

Dear friends,

When I reset 52840 DK and reopen the PyACI script , then, reloading the DB(database/example_database.json), I found the provsioned device can't be controled again.

I refrence this case ,however,  we can't get any data from the provsioned device, attach my test code:

db = MeshDB("database/example_database.json")
p = Provisioner(device, db)
device.send(cmd.DevkeyAdd(db.nodes[0].unicast_address, 0, db.nodes[0].device_key))
device.send(cmd.AddrPublicationAdd(db.nodes[0].unicast_address))
cc = ConfigurationClient(db)
device.model_add(cc)
cc.publish_set(8, 0)
cc.composition_data_get()

and the test log:

E:\bluemesh\fortest\nrf5_SDK_for_Mesh_v2.2.0_src\scripts\interactive_pyaci> C:\Users\admin\AppData\Local\Programs\Python\Python38\python.exe interactive_pyaci.py -d COM4

    To control your device, use d[x], where x is the device index.
    Devices are indexed based on the order of the COM ports specified by the -d option.
    The first device, d[0], can also be accessed using device.

    Type d[x]. and hit tab to see the available methods.

Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.23.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]:

In [2]: db = MeshDB("database/example_database.json")
   ...: p = Provisioner(device, db)

In [3]: 2021-07-02 17:32:31,468 - INFO - COM4: Success
2021-07-02 17:32:31,469 - INFO - COM4: Success
2021-07-02 17:32:31,473 - INFO - COM4: SubnetAdd: {'subnet_handle': 0}
2021-07-02 17:32:31,481 - INFO - COM4: AppkeyAdd: {'appkey_handle': 0}
2021-07-02 17:32:31,482 - INFO - COM4: AppkeyAdd: {'appkey_handle': 1}
In [3]:

In [3]: db.nodes[0].unicast_address
Out[3]: 0010

In [4]: device.send(cmd.DevkeyAdd(db.nodes[0].unicast_address, 0, db.nodes[0].device_key))
   ...: device.send(cmd.AddrPublicationAdd(db.nodes[0].unicast_address))

2021-07-02 17:32:46,728 - INFO - COM4: DevkeyAdd: {'devkey_handle': 8}
2021-07-02 17:32:46,729 - INFO - COM4: AddrPublicationAdd: {'address_handle': 0}In [5]:
In [5]:
In [5]: cc = ConfigurationClient(db)
   ...: device.model_add(cc)
   ...: cc.publish_set(8, 0)
   ...: cc.composition_data_get()

2021-07-02 17:32:56,990 - INFO - COM4: Success
In [6]:

In [6]:

In [6]:

In [6]: cc.composition_data_get()

In [7]: 2021-07-02 17:33:17,492 - INFO - COM4: Success
In [7]:

In [7]:

Could you give me some advice for realize this functionality?

Thank you in advance.

  • Hi Oplinux, 

    Please have a look at this discussion: https://devzone.nordicsemi.com/f/nordic-q-a/53613/some-questions-about-provisioning-with-pyaci

    Please ignore my initial information that "Devkey can't be readded" it's possible. 

    So, from what you can read in the case you pointed to and the case above, you can find that you need to restore the database on the nRF52 to make it work again after you reset. 
    I have some suggestions in the case with Wataru that you can refer to. We unfortunately still don't have any example to do the task yet. 

  • Thank you very much Hung,

    With the suggest "you need to restore the database on the nRF52 to make it work again after you reset", 

    a) I want to konw the format and content about the the database on the nRF52.

    b) Which parameters should I store in this database?

    c) How to create this database on 52840 Soc.

    d) Is there some APIs can achive this database?

    Best regards,

    Oplinux

  • Hi Oplinux, 

    Please note that we provided the PyACI only as an example of what you can do with the serial interface of the mesh stack. So if you want to develop a production tool you would need to study the serial interface and customize it on your needs. 


    As far as I know, what you need to restore the database is to call AddrPublicationAdd() to add the addresses of the provisioned node (so that you have address_handle added to the nRF52) and call DevkeyAdd ( so that you have the devkey_handle added to the nRF52)

    Basically you need to replay what you did when you provision the nodes in the first time. You need to call the 2 APIs above for each node in the correct order when they was provisioned. This way you can restore the same database on the NRF52. 

  • Hi Hung,

    Thanks for your reply.

    a) I used provisioner A provisioning 5 nodes,  IV Index of this mesh network is 287454020

    b)I prepared another provisioner B and flashed serial example to it, then, called AddrPublicationAdd() and DevkeyAdd(), I found the sequence number and IV Index of provisioner B begin from 0, however, the IV Index of the existed mesh network created before is 287454020

    c)Now, I want to update the IV Index of provisioner B to 287454020, Could you tell me that provisoner B how to scan the existed mesh network to get the IV index and then update IV Index of the provisoner to the newest value?

    Best regards

    Oplinux

  • Hi Oplinux, 

    By default if the new node doesn't have the correct IV Index (or it was inactive for too long), it should listen to the Secure Network Beacon. Please have al look at section 3.9.3.1 in the Mesh Profile Spec, especially Section 3.10.6 IV Index Recovery procedure.

    I believe all of these is performed transparently to the application as it should be handled by our mesh stack. 

    I would suggest to test with IV index = 0 first, just to make sure your new provisioner can talk to the mesh network. 

Related