Developing with ZBOSS SDK for Zigbee

Macros

#define ZB_SCHEDULE_APP_CALLBACK(func, param)   zb_schedule_app_callback(func, param)
 
#define ZB_SCHEDULE_APP_CALLBACK2(func, param, user_param)   zb_schedule_app_callback2(func, param, user_param)
 
#define ZB_SCHEDULE_APP_ALARM(func, param, timeout_bi)   zb_schedule_app_alarm(func, param, timeout_bi)
 
#define ZB_ALARM_ANY_PARAM   (zb_uint8_t)(-1)
 
#define ZB_ALARM_ALL_CB   (zb_uint8_t)(-2)
 
#define ZB_SCHEDULE_APP_ALARM_CANCEL(func, param)   zb_schedule_alarm_cancel((func), (param), NULL)
 
#define ZB_SCHEDULE_GET_ALARM_TIME(func, param, timeout_bi)   zb_schedule_get_alarm_time(func, param, timeout_bi)
 

Typedefs

typedef void(* zb_callback_t) (zb_uint8_t param)
 
typedef zb_ret_t(* zb_ret_callback_t) (zb_uint8_t param)
 
typedef void(* zb_callback_void_t) (void)
 
typedef void(* zb_callback2_t) (zb_uint8_t param, zb_uint16_t cb_param)
 

Detailed Description

The stack uses a cooperative multitasking model. The main component that provides multitasking capabilities is the scheduler.

There is no "task" abstraction in the schedule, it uses "callback" instead.

Running a task in the scheduler simply executes a callback function.

Each callback function can schedule one or more callback functions for execution through the scheduler. The scheduled callbacks are stored in the internal scheduler queue. This queue is handled in the scheduler ZBOSS main loop : the callbacks are executed one-by-one in the FIFO order with no priorities.

If there is currently no callback to execute, the scheduler can put the device into the sleep mode. See also Sleep API .

Before the scheduler main loop, call application-dependent initialization functions. They can schedule some callbacks. Callbacks will be called later, in the scheduler main loop.

More than one callback can be scheduled in succession. If there is no other callback in the queue, the scheduled callback is executed immediately after the current callback is finished.

Macro Definition Documentation

◆ ZB_ALARM_ALL_CB

#define ZB_ALARM_ALL_CB   (zb_uint8_t)(-2)

Special parameter for zb_schedule_alarm_cancel(): cancel alarm for all parameters

◆ ZB_ALARM_ANY_PARAM

#define ZB_ALARM_ANY_PARAM   (zb_uint8_t)(-1)

Special parameter for zb_schedule_alarm_cancel(): cancel alarm once without parameter check

Cancel only one alarm without check for parameter

◆ ZB_SCHEDULE_APP_ALARM

#define ZB_SCHEDULE_APP_ALARM (   func,
  param,
  timeout_bi 
)    zb_schedule_app_alarm(func, param, timeout_bi)

Schedule alarm - callback to be executed after timeout.

Function will be called via scheduler after timeout expired (maybe, plus some additional time). Timer resolution depends on implementation. Same callback can be scheduled for execution more then once.

Parameters
func- function to call via scheduler
param- parameter to pass to the function
timeout_bi- timeout, in beacon intervals
Returns
RET_OK or RET_OVERFLOW

See any sample

◆ ZB_SCHEDULE_APP_ALARM_CANCEL

#define ZB_SCHEDULE_APP_ALARM_CANCEL (   func,
  param 
)    zb_schedule_alarm_cancel((func), (param), NULL)

Cancel scheduled alarm.

This function cancel previously scheduled alarm. Function is identified by the pointer.

Parameters
func- function to cancel
param- parameter to cancel.
See also
ZB_ALARM_ANY_PARAM.
ZB_ALARM_ALL_CB
Returns
RET_OK or RET_OVERFLOW

See reporting_srv sample

◆ ZB_SCHEDULE_APP_CALLBACK

#define ZB_SCHEDULE_APP_CALLBACK (   func,
  param 
)    zb_schedule_app_callback(func, param)

Schedule single-param callback execution.

Schedule execution of function ‘func’ in the main scheduler loop.

Parameters
func- function to execute
param- callback parameter - usually, but not always ref to packet buffer
Returns
RET_OK or RET_OVERFLOW.

See sched sample

◆ ZB_SCHEDULE_APP_CALLBACK2

#define ZB_SCHEDULE_APP_CALLBACK2 (   func,
  param,
  user_param 
)    zb_schedule_app_callback2(func, param, user_param)

Schedule two-param callback execution. Schedule execution of function ‘func’ in the main scheduler loop.

Parameters
func- function to execute
param- zb_uint8_t callback parameter - usually, but not always ref to packet buffer
user_param- zb_uint16_t user parameter - usually, but not always short address
Returns
RET_OK or RET_OVERFLOW. See sched sample

◆ ZB_SCHEDULE_GET_ALARM_TIME

#define ZB_SCHEDULE_GET_ALARM_TIME (   func,
  param,
  timeout_bi 
)    zb_schedule_get_alarm_time(func, param, timeout_bi)

Get Schedule alarm time - seek alarm and return alarm time

Parameters
func- function to call via scheduler
param- parameter to pass to the function
timeout_bi- pointer on alarm timeout, in beacon intervals
Returns
RET_OK or error code

Typedef Documentation

◆ zb_callback2_t

typedef void( * zb_callback2_t) (zb_uint8_t param, zb_uint16_t cb_param)

Callback function with 2 parameters typedef. Callback is function planned to execute by another function.

Note
Callback must be declared as reentrant for sdcc.
Parameters
param- callback parameter - usually, but not always, ref to packet buf
cb_param- additional 2-byte callback parameter, user data.

See any sample

◆ zb_callback_t

typedef void( * zb_callback_t) (zb_uint8_t param)

Callback function typedef. Callback is function planned to execute by another function.

Note
Callback must be declared as reentrant for sdcc.
Parameters
param- callback parameter - usually, but not always, ref to packet buf

See any sample