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?

  • 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

  • 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

Related