We are developping an application using an NRF52840, Based on nRF5 SDK for Thread and Zigbee V3.0.0
Running S140 softdevice
We are using BLE advertizements and Openthread communication.
In the main loop, there are 2 lines for OpenThread communication
thread_instance_init(); for init (once)
thread_process(); (in mainloop)
Monitoring the power consumption in sleep mode, the Openthread communication keeps the current around 590uA.
If I disable the init and process line for thread, the current drops to 90uA.
Is it possible to turn on and off Openthread in a controlled way?
How can this be done?
Using nRF5 SDK for Thread and Zigbee V3.0.0.
I haven't tested these myself, but try calling thread_deinit() or thread_soft_deinit() (both defined in thread_utils.c) before going to sleep, as I think these should deinit should effectively disable Thread and notably lower the current consumption.
I tried adding these calls in the mainloop, before going to sleep:
thread_soft_deinit() did not change the current consumption
thread_deinit() triggered a fatal error.
I tried various scenarios with these 2 calls, with no success.
Once the OpenThread is initialized, I can't turn it off dynamically.
Any further inputs or help?
Is there an example I could refer to for dynamically enabling/disabling OpenThread?
I also tried to get thread_sleep(), but that has no effect.
Reading that it is advised to use the thread utility calls to handle init, deinit and sleep, how can this be done?
Thank you for the help!
You can check out the Thread CLI Example for how to deinitialize the Thread stack using thread_soft_deinit(), and the BLE and Thread Template Example for how to deinitialize using thread_deinit(). I believe these also demonstrate how the utility calls are used as well.
Thank you for your inputs.
As a test case, I init a thread instance, immediatly followed by either a soft deinit of a real deinit
When I do this in the mainloop, nothing more on thread calls
The processor resets
In the second case, you would expect the thread instance getting initialized and deinitialized, but a reset is the result.
BLE stack is initialized, thread is initialized, but thread_deinit(); call crahses the system
How are you going to sleep mode by the way? You say that you also tried using thread_sleep(); but how have you been going to sleep in the other instances? I dug a bit in the code and found that thread_soft_deinit(); just disables the OpenThread library, and is generally used as part of a deinit function. For example like this (from examples\thread\CLI):
static void thread_instance_finalize(void)
Maybe try the sleep and deinit functions as described there to see if that helps.