zb_osif_sleep() return value

In the Zigbee framework, what is the purpose of the return variable from zb_osif_sleep() ? The "documentation" for Zigbee seems to implement a "guess and figure it out for yourself" model when it comes to parameters and return variables for many of its functions... Unfortunately, while I can guess that this is a success/failure type return, the meaning of those return values remains a mystery. (Documenting the parameter for zb_osif_sleep() would also be useful...)

Thanks.

Parents Reply Children
  • Hello Chris,

    It returns the duration that the device has slept in ms. You can find this in the implementation of the function here

    The sleep routine is roughly explained here. Application receives CAN_SLEEP signal when stack has nothing to for a given amount of time. Application can call zb_sleep_now() in this signal's handler to tell the stack to "go to sleep". As a result, stack invokes zb_osif_sleep() with the amount of time it can sleep for and this zb_osif_sleep() is responsible for switching device and/or its peripherals to low power mode, actually "sleeping" and returning the amount of time the device has slept for (note that the device can be waken up prematurely):

    In nRF5 SDK we actually called WFE/WFI to stop the CPU. In NCS we don't stop the CPU, Zigbee has its own independent thread and it is move to blocked state for the amount of time received in the zb_osif_sleep(), then the Zephyr scheduler decided when to enter IDLE state - basically when all other threads are suspended/blocked.

    Regards,

    Elfving

Related