Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Problems with Provisioning and Configuring Nordic Development Kits using Python Script

I am utilizing two Nordic development kits as servers through the Light Switch Server example, and my task is to provision both devices using a Python script. To achieve this goal, I referred to the Using Serial Interface for Provisioning and Configuration document in the nrf5 SDK documentation. I compiled all the necessary provisioning commands into a script, which is displayed below.

After creating the provisioning script, I tested it and found that it worked well. The results of the script can be seen below.

Problem:

i found a problem in the above script and the problem is in this command (p.provision(name="Sensor server")) i will give you more explanation below.

Initially, when I ran the script without any interruptions, such as powering off a node, both the provisioning and configuration processes completed successfully for both server nodes.In another test, I interrupted one of the nodes during the provisioning command "p.provision()" by powering it off. This caused an error, and the compiler went to the "except" statement. Afterward, the compiler went to the second iteration and ran the provision command to provision the second node. However, the same error occurred again.

In another test, I once again interrupted one of the nodes by powering it off. However, this time I allowed the compiler to run the provision command and complete the provisioning process before powering off the node to generate an error during configuration. As expected, the error occurred during configuration, and the compiler went to the "except" statement. However, during the second iteration to provision the other node, there were no issues, and both the provisioning and configuration processes were successful for second node.

The overall testing results demonstrate that errors during node provisioning can cause the same problem for another node in the loop.

failed with error treated as unexpected error in above picture....sorry

Based on my extensive testing, I believe that the error occurred during the first iteration due to the "p.provision(name='')" command. In the second iteration, when the code provisioned the second node, the "p.provision()" command responded to the previous node that generated the error. I think if this command had responded to the second node, it would have worked.

My Question:

My primary inquiry is how to use the "p.provision(name="")" command so that it can be used for different nodes in the loop, where in the first iteration it responds to the first node and in the second iteration it responds to the second server node.

Thanks

Parents
  • Hello,

    As expected, the error occurred during configuration, and the compiler went to the "except" statement. However, during the second iteration to provision the other node, there were no issues, and both the provisioning and configuration processes were successful for second node.

    The overall testing results demonstrate that errors during node provisioning can cause the same problem for another node in the loop.

    I am not sure that I quite understand the issue described here, could you elaborate?
    From your description it seems that there was no problem during the second provisioning and configuration, but also that the tests demonstrate that the errors in one provisioning can carry over to another provisioning?

    failed with error treated as unexpected error in above picture....sorry

    The list index out of range is a common error in Python when you are trying to access a non-existing element in the list. For instance, in your code this could be if you attempt to read db.node[x] when x=1, but since the provisioning for node 1 failed the total length of db.node is just 1, making the attempted access of the [1] element invalid.
    Or, could it be that you are trying to access the element at [2], without accounting for the 0 index'd list. I.e that your device 1 is placed on db.node[0], and device 2 at db.node[1], and so there does not exist an element on [2], which you are trying to access in your for loop?
    This above examples might not be what is actually happening in your code, it is just a guess from briefly looking at the provided code. To see where it might be happening it would be great if you could include additional logs.

    My Question:

    My primary inquiry is how to use the "p.provision(name="")" command so that it can be used for different nodes in the loop, where in the first iteration it responds to the first node and in the second iteration it responds to the second server node.

    You can provide the name as a variable, so that each iteration will have a separate name, if that is what you are asking.
    One way to do this could be to have a list of names ready made, or you could just append the iteration variable on the back of a standard prefix to differentiate them.
    Please do not hesitate to let me know if this was not what you were asking about! :) 

    For future reference, please use the Insert -> Code option when sharing code or logs here on DevZone for increased readability.

    Best regards,
    Karl

Reply
  • Hello,

    As expected, the error occurred during configuration, and the compiler went to the "except" statement. However, during the second iteration to provision the other node, there were no issues, and both the provisioning and configuration processes were successful for second node.

    The overall testing results demonstrate that errors during node provisioning can cause the same problem for another node in the loop.

    I am not sure that I quite understand the issue described here, could you elaborate?
    From your description it seems that there was no problem during the second provisioning and configuration, but also that the tests demonstrate that the errors in one provisioning can carry over to another provisioning?

    failed with error treated as unexpected error in above picture....sorry

    The list index out of range is a common error in Python when you are trying to access a non-existing element in the list. For instance, in your code this could be if you attempt to read db.node[x] when x=1, but since the provisioning for node 1 failed the total length of db.node is just 1, making the attempted access of the [1] element invalid.
    Or, could it be that you are trying to access the element at [2], without accounting for the 0 index'd list. I.e that your device 1 is placed on db.node[0], and device 2 at db.node[1], and so there does not exist an element on [2], which you are trying to access in your for loop?
    This above examples might not be what is actually happening in your code, it is just a guess from briefly looking at the provided code. To see where it might be happening it would be great if you could include additional logs.

    My Question:

    My primary inquiry is how to use the "p.provision(name="")" command so that it can be used for different nodes in the loop, where in the first iteration it responds to the first node and in the second iteration it responds to the second server node.

    You can provide the name as a variable, so that each iteration will have a separate name, if that is what you are asking.
    One way to do this could be to have a list of names ready made, or you could just append the iteration variable on the back of a standard prefix to differentiate them.
    Please do not hesitate to let me know if this was not what you were asking about! :) 

    For future reference, please use the Insert -> Code option when sharing code or logs here on DevZone for increased readability.

    Best regards,
    Karl

Children
No Data
Related