This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

use "zb_sleep_now()" in main loop

I use the "zb_sleep_now()" function in the main loop, which greatly reduces the start current. The device wakes up apparently due to the RTC2 interrupt used by the zigbee stack in sleep mode. When connecting USB, I do not use sleep and, accordingly, I block the call to the "zb_sleep_now()" function. Is it possible to somehow configure the stack so that the  "zb_sleep_now()" call is processed in the ZB_COMMON_SIGNAL_CAN_SLEEP callback. If you set the sleep time to 0 ("zb_sleep_set_threshold (0)"), then the device still goes to sleep only after connecting to the network. Or is the solution using "zb_sleep_now()" in the main loop ok?

    while(1)
    { 
     nrfx_wdt_channel_feed(m_channel_id);
     zboss_main_loop_iteration();
        if (m_usb_connected==true)
        {
        
          while (app_usbd_event_queue_process())
            {
             /* Nothing to do */
            }
        }
        else
        {
        zb_sleep_now();
        }     
    UNUSED_RETURN_VALUE(NRF_LOG_PROCESS());
    }

  • I don't think that is the correct use of zb_sleep_now(). According to the documentation it can be called when the signal handler receives ZB_COMMON_SIGNAL_CAN_SLEEP.

    For application processing you should use ZB_SCHEDULE_APP_CALLBACK and let this be you "main" loop, and not reschedule when you do not have anything more to process. 

    in the main loop you should only call:

    zboss_main_loop_iteration();
    app_sched_execute();
    UNUSED_RETURN_VALUE(NRF_LOG_PROCESS());
     

    I have applications using both BLE and ZigBee and ZigBee only, and it works for both of them and the power saving is good.  

Related