Disable open thread in ble_thread_dyn_proximity example

Hello.

I have a problem with disabling Open Thread in ble_thread_dyn_proximity example.
By default, the example uses the following function

thread_soft_deinit();

But i would like to use the function.

thread_deinit();

I think that this function can solve my high consumption problem when thread is not needed (For example in deep sleep mode).

But this function causes crash.

Also I have another question:

- Can I dynamically change THREAD_RADIO_MODE_RX_ON_WHEN_IDLE to THREAD_RADIO_MODE_RX_OFF_WHEN_IDLE for optimising my current? And how can I do this?

Parents
  • Hello,

    What SDK version are you using? Did you check the return values from thread_soft_deinit() and thread_deinit()? What did they return?

    I think that this function can solve my high consumption problem when thread is not needed

    What current are we looking at? Is the current consumption higher than before the thread stack was initialized?

    Best regards,

    Edvin

Reply
  • Hello,

    What SDK version are you using? Did you check the return values from thread_soft_deinit() and thread_deinit()? What did they return?

    I think that this function can solve my high consumption problem when thread is not needed

    What current are we looking at? Is the current consumption higher than before the thread stack was initialized?

    Best regards,

    Edvin

Children
  • NRF5 SDK for thread and zigbee v4.2.0.


    Before the thread stack initialized current consumption was under 0.05mA.
    After thread initialization current is:
    - 20mA in router mode.
    - 9mA in sleepy end device mode.

    If I call function:

    thread_soft_deinit();

    current becomes 8mA, too high current (Before thread stack initialization current was under 0.05mA).

    After these measurements, I thought that I need to use the thread_deinit(); function instead of thread_soft_deinit();

    And about return value:

    void thread_deinit(void)
    {
        ASSERT(mp_ot_instance != NULL);
    
        otInstanceFinalize(mp_ot_instance);
        otSysDeinit();
        mp_ot_instance = NULL;
    }
    
    void thread_soft_deinit(void)
    {
        ASSERT(mp_ot_instance != NULL);
    
        otInstanceFinalize(mp_ot_instance);
        mp_ot_instance = NULL;
    }

    These functions are void type. And all functions they call are void type too. Maybe I misunderstood your question about return value of these functions?

  • HTRRA said:
    Maybe I misunderstood your question about return value of these functions?

    No, I didn't look them up. They do not have any return values. Neither does the functions inside (otInstanceFinalize() or otSysDeinit(). 

    So you are saying that thread_deinit() doesn't return (but crashes)? How do you trigger this call? Do you trigger it from a button press, or did you trigger it in another way?

    Best regards,

    Edvin

  • static bool deinit_flag = false;
    
    static void gpiote_callback(void)
    {
        deinit_flag = true;
    }
    
    int main()
    {
        while(1){
            if(deinit_flag)
            {
                thread_deinit();
                deinit_flag = false;
            }
        }
    }

    Gpio interrupt swithces deinit flag. 

    In main loop i check this flag

  • Is that your entire main() function? (probably not, but I don't know what else you have). I see that the example that you refer to almost looks like it is already handling what you are trying to do. 

    int main(void)
    {
        ...
        // Enter main loop.
        while (true)
        {
            thread_instance_init();
            thread_coap_init();
    
            while (!thread_soft_reset_was_requested())
            {
                thread_process();
                app_sched_execute();
    
                if (NRF_LOG_PROCESS() == false)
                {
                    thread_sleep();
                }
            }
    
            thread_coap_deinit();
            thread_instance_finalize();
        }
    }

    Did you test that?

    Or simply try to just call the last part of the while loop when your gpiote triggers?

    BR,
    Edvin

  • Yes, this is exactly what my main function looks like, only with the addition of what I wrote above with checking the flag and thread_deinit() and calling the sd_power_system_off function after. In this main by default used thread_instance_finalize()

    if you look at realization of thread_instance_finalize() you can see that this function calls thread_soft_deinit()

    thread_soft_deinit works fine, but consumption after thread_soft_deinit() is - 8mA
    but consumption before thread init is 0.05mA, thats why i tried to use thread_deinit() but in this case app crashes

Related