Developing with ZBOSS
|
Macros | |
#define | ZB_SCHEDULE_APP_CALLBACK(func, param) zb_schedule_app_callback(func, param, ZB_FALSE, 0, ZB_FALSE) |
#define | ZB_SCHEDULE_APP_CALLBACK2(func, param, user_param) zb_schedule_app_callback((zb_callback_t)(func), param, ZB_TRUE, user_param, ZB_FALSE) |
#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) |
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.
#define ZB_ALARM_ALL_CB (zb_uint8_t)(-2) |
Special parameter for zb_schedule_alarm_cancel(): cancel alarm for all parameters
#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
#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.
func | - function to call via scheduler |
param | - parameter to pass to the function |
timeout_bi | - timeout, in beacon intervals |
See any sample
#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.
func | - function to cancel |
param | - parameter to cancel. |
See reporting_srv sample
#define ZB_SCHEDULE_APP_CALLBACK | ( | func, | |
param | |||
) | zb_schedule_app_callback(func, param, ZB_FALSE, 0, ZB_FALSE) |
Schedule single-param callback execution.
Schedule execution of function ‘func’ in the main scheduler loop.
func | - function to execute |
param | - callback parameter - usually, but not always ref to packet buffer |
See sched sample
#define ZB_SCHEDULE_APP_CALLBACK2 | ( | func, | |
param, | |||
user_param | |||
) | zb_schedule_app_callback((zb_callback_t)(func), param, ZB_TRUE, user_param, ZB_FALSE) |
Schedule two-param callback execution. Schedule execution of function ‘func’ in the main scheduler loop.
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 |
#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
func | - function to call via scheduler |
param | - parameter to pass to the function |
timeout_bi | - pointer on alarm timeout, in beacon intervals |
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.
param | - callback parameter - usually, but not always, ref to packet buf |
cb_param | - additional 2-byte callback parameter, user data. |
See any sample
typedef void( * zb_callback_t) (zb_uint8_t param) |
Callback function typedef. Callback is function planned to execute by another function.
param | - callback parameter - usually, but not always, ref to packet buf |
See any sample