Developing with ZBOSS

Macros

#define ZB_SCHED_SLEEP_THRESHOLD_MS   20
 
#define ZB_MAXIMUM_SLEEP_THRESHOLD_MS   86400000
 

Functions

zb_ret_t zb_sleep_set_threshold (zb_uint32_t threshold_ms)
 
zb_uint32_t zb_get_sleep_threshold (void)
 
void zb_sleep_now (void)
 

Detailed Description

Power Saving for ZED
For sleepy end devices (RxOffWhenIdle = TRUE), ZBOSS provides a mechanism for power saving. ZBOSS scheduler tracks the callback queue and if there is no immediate callback for execution and there is no outgoing packet on the MAC level, a special signal ZB_COMMON_SIGNAL_CAN_SLEEP is sent to an application. The "can sleep" signal has a sleep time parameter that indicates allowed sleep duration in milliseconds.

Sleep duration value is based on the time remaining before the first alarm is called or it is set to 10 seconds if there are no alarms in the queue. Upon receiving ZB_COMMON_SIGNAL_CAN_SLEEP the application analyzes its internal state and decides whether to enter the sleep mode or not. To go to the sleep mode, the application should call the zb_sleep_now() function.

Macro Definition Documentation

◆ ZB_MAXIMUM_SLEEP_THRESHOLD_MS

#define ZB_MAXIMUM_SLEEP_THRESHOLD_MS   86400000

Maximum sleep threshold.

◆ ZB_SCHED_SLEEP_THRESHOLD_MS

#define ZB_SCHED_SLEEP_THRESHOLD_MS   20

Default sleep threshold. Do not sleep when it is less then 1 Beacon Interval to wake up.

Function Documentation

◆ zb_get_sleep_threshold()

zb_uint32_t zb_get_sleep_threshold ( void  )

Get sleep threshold value from stack.

Returns
threshold value in milliseconds

◆ zb_sleep_now()

void zb_sleep_now ( void  )

Blocking function responsible for putting device into sleep mode.

◆ zb_sleep_set_threshold()

zb_ret_t zb_sleep_set_threshold ( zb_uint32_t  threshold_ms)

Set sleep threshold on device; when scheduler detects that device can be put in sleep mode it will notify application with signal

See also
ZB_COMMON_SIGNAL_CAN_SLEEP. Device can not be put into sleep mode when sleep interval less than this threshold.
Parameters
threshold_ms- sleep threshold in milliseconds If threshold is 0, means zero threshold, application will be notified each time when stack is ready to sleep (no immediate callbacks in queue).
Returns
RET_OK if new threshold is valid and applied
RET_ERROR if user wants to set threshold greater that ZB_MAXIMUM_SLEEP_THRESHOLD_MS or lesser than ZB_SCHED_SLEEP_THRESHOLD_MS.