Can I change the priority of the main function in sensor server example of ble mesh?

Hi,

I am using the sensor server example available in nrf5 sdk for mesh to build my own application on top of it. And the SOC we are using is nRF52832. I am trying to erase the provisioning information stored in memory after provisioning the sensor server node after long press of a button. I am not able to erase the provisioning information from main function even after calling mesh_stack_config_clear() as the code gets hanged after calling that API. I am aware that the reason for this is that main function and softdevice are running in different priority levels and to solve it, both of them should be running in the same priority level. Is it  possible to change the priority of the main thread?

  • I am not able to erase the provisioning information from main function even after calling mesh_stack_config_clear() as the code gets hanged after calling that API. I am aware that the reason for this is that main function and softdevice are running in different priority levels and to solve it, both of them should be running in the same priority level. Is it  possible to change the priority of the main thread?

    First of all you need to find out what kind of fault you are getting when trying to erase the provisioning information and what API are you using?

    You cannot call SD API from interrupt handler which is higher in priority than the softdevice event interrupt. But you already know that, but main is in lower priority than SD events and it should have been fine to call softdevice API from main. I would suggest you to look at the call stack when you get the hardfault and see the context and interrupt priority in which you are trying to erase the provisioning data. It seems that you are not doing that from the main function.

  • I am doing it from the main function. I have attached the code for your reference. Sure will look as you suggested. Thanks

  • Actually, I am able to erase provisioning information before doing model configuration and the node returns to unprovisioned state. But after doing model configuration, am not able to unprovision the device after the long press of a button. The device resets after calling access_clear() api inside the mesh_stack_config_clear(). I have attached the log for the same too.

    The right side of the pic has the mesh_stack_config_clear() api and the left side of the pic shows the log in runtime after long press of a button (after model configuration). Code execution doesn't go after printing "2" and the device resets. Without doing model configuration, after long press of a button - "mesh stack configuration cleared" is printed in the terminal and after software reset, the device goes back to unprovisioned state (as shown in the second pic).  Please help me as to figure out why am not able to erase provisioning information after doing model configuration but able to before doing model configuration.

  • The device can only reset for certain reasons. Assuming that the power to your chip is stable, the chip only reset with a pin reset or soft reset. If you search for NVIC_SystemReset in whole of your project like below

    and put debug breakpoints in the one those appear in your search and run your application in the debugger, then you would eventually hit one of those breakpoints and know what is causing those resets.

Related