Data Structures | |
struct | zb_zdo_signal_leave_params_s |
Leave parameters. More... | |
struct | zb_zdo_signal_leave_indication_params_s |
Leave Indication parameters. More... | |
struct | zb_zgp_signal_commissioning_params_s |
ZGP commissioning parameters. More... | |
struct | zb_nwk_signal_device_associated_params_s |
Association parameters. More... | |
struct | zb_zdo_signal_device_annce_params_s |
Association parameters. More... | |
struct | zb_bdb_signal_touchlink_nwk_started_params_s |
struct | zb_bdb_signal_touchlink_nwk_joined_router_s |
struct | zb_zdo_signal_can_sleep_params_s |
Sleep signal parameters. More... | |
struct | zb_zdo_app_signal_hdr_s |
Macros | |
#define | ZB_ZDO_SIGNAL_GET_PARAMS(sg_p, type) ((type *)(((zb_uint8_t *)sg_p) + sizeof(zb_zdo_app_signal_hdr_t))) |
#define | ZB_GET_APP_SIGNAL_STATUS(param) (ZB_BUF_FROM_REF(param)->u.hdr.status) |
Functions | |
zb_void_t | zboss_signal_handler (zb_uint8_t param) |
zb_zdo_app_signal_type_t | zb_get_app_signal (zb_uint8_t param, zb_zdo_app_signal_hdr_t **sg_p) |
There are tools that allow an application to handle Zigbee events like network formation, association status, leave indication, and others. Due to its nature, different Zigbee events appear asynchronously and ZBOSS informs the application about it through application signals. The application may handle or ignore a received signal. All application signals are processed in the application with a predefined callback function zboss_signal_handler(). It is mandatory for each application to implement this function, even if there is no need to process a signal.
There are policies that should be taken into account while implementing zboss_signal_handler() function:
#define ZB_GET_APP_SIGNAL_STATUS | ( | param | ) | (ZB_BUF_FROM_REF(param)->u.hdr.status) |
#define ZB_ZDO_SIGNAL_GET_PARAMS | ( | sg_p, | |
type | |||
) | ((type *)(((zb_uint8_t *)sg_p) + sizeof(zb_zdo_app_signal_hdr_t))) |
Obtains pointer to parameters passed with application signal.
sg_p | - pointer to application signal |
type | - parameter type |
Example
Association parameters.
Stack passes this parameter to application when some device associates to us.
typedef struct zb_zdo_app_signal_hdr_s zb_zdo_app_signal_hdr_t |
Application signal header
typedef enum zb_zdo_app_signal_type_e zb_zdo_app_signal_type_t |
Signals passed to zboss_signal_handler()
typedef struct zb_zdo_signal_can_sleep_params_s zb_zdo_signal_can_sleep_params_t |
Sleep signal parameters.
Stack passes this parameter to application when device ready to sleep.
Association parameters.
Stack passes this parameter to application when some device joins/rejoins to network.
Leave Indication parameters.
Stack passes this parameter to application upon receipt leave.indication primitive.
typedef struct zb_zdo_signal_leave_params_s zb_zdo_signal_leave_params_t |
Leave parameters.
Stack passes this parameter to application when device itself lefts network.
ZGP commissioning parameters.
Stack passes this parameter to application to notify about GPD commissioning result.
Signals passed to zboss_signal_handler()
Enumerator | |
---|---|
ZB_ZDO_SIGNAL_DEFAULT_START |
Default signal, for pre-R21 ZBOSS API compatibility. The signal has Code+statusonly. |
ZB_ZDO_SIGNAL_SKIP_STARTUP |
Notifies the application that ZBOSS framework (scheduler, buffer pool, etc.) started, but no join/rejoin/formation/BDB initialization is done yet. That signal is generated if application called zb_zdo_start_no_autostart() instead of zboss_start() before zboss_main_loop(). Useful, for instance, when some HW (like, sensor connected via UART etc) must be initialized before ZigBee commissioning, but having ZBOSS scheduler running. The signal has Code+statusonly. {
zb_zdo_app_signal_hdr_t *sg_p = NULL;
zb_zdo_app_signal_t sig = zb_get_app_signal(param, &sg_p);
TRACE_MSG(TRACE_APP1, "zboss_signal_handler: status %hd signal %hd",
(FMT__H_H, ZB_GET_APP_SIGNAL_STATUS(param), sig));
if (ZB_GET_APP_SIGNAL_STATUS(param) == 0)
{
switch(sig)
{
TRACE_MSG(TRACE_APP1, "ZB_ZDO_SIGNAL_SKIP_STARTUP: start commissioning", (FMT__0));
/* NVRAM is loaded, init relay state */
{
sp_relay_on_off((zb_bool_t )ZB_ZCL_GET_ATTRIBUTE_VAL_8(attr_desc_on_off));
}
/* Have zb_bdb_is_factory_new() check inside */
ZB_SCHEDULE_CALLBACK(sp_start_join, SP_FIRST_JOIN_ATTEMPT);
break;
|
ZB_ZDO_SIGNAL_DEVICE_ANNCE |
Inform App about receiving device_annce. The even has additional data of zb_zdo_signal_device_annce_params_t type. @snippet simple_gw.c signal_device_annce |
ZB_ZDO_SIGNAL_LEAVE |
The device itself has left the network. The evemnt has an additional data of type zb_zdo_signal_leave_params_t. @snippet application/light_sample/light_control/light_control.c signal_leave |
ZB_ZDO_SIGNAL_ERROR |
some mess in the buffer |
ZB_BDB_SIGNAL_DEVICE_FIRST_START |
Device started and commissioned first time after NVRAM erase. The signal has Code + Status only. TRACE_MSG(TRACE_APP1, "Device STARTED OK", (FMT__0));
#ifdef TEST_APS_FRAGMENTATION
ZB_SCHEDULE_ALARM(send_frag_data, 0, ZB_TIME_ONE_SECOND / 2);
#endif
buf = ZB_GET_OUT_BUF();
if (!buf)
{
TRACE_MSG(TRACE_APP1, "no buffer available", (FMT__0));
break;
}
/* Example: send permit join request to close network */
/** [zb_zdo_mgmt_permit_joining_req] */
req_param = ZB_GET_BUF_PARAM(buf, zb_zdo_mgmt_permit_joining_req_param_t);
req_param->dest_addr = 0xfffc;
req_param->permit_duration = 0;
req_param->tc_significance = 1;
zb_zdo_mgmt_permit_joining_req(ZB_REF_FROM_BUF(buf), permit_joining_cb);
/** [zb_zdo_mgmt_permit_joining_req] */
break;
|
ZB_BDB_SIGNAL_DEVICE_REBOOT |
BDB initialization completed after device reboot, use NVRAM contents during initialization. Device joined/rejoined and started. The signal has Code + Status only. TRACE_MSG(TRACE_APP1, "Device RESTARTED OK", (FMT__0));
#ifndef ZB_USE_BUTTONS
/* Do not have buttons in simulator - just start periodic on/off sending */
cmd_in_progress = ZB_FALSE;
ZB_SCHEDULE_ALARM_CANCEL(button_press_handler, ZB_ALARM_ANY_PARAM);
ZB_SCHEDULE_ALARM(button_press_handler, 0, 7 * ZB_TIME_ONE_SECOND);
#endif
break;
|
ZB_BDB_SIGNAL_TOUCHLINK_NWK_STARTED |
Inform the Touchlink initiator that the new Zigbee network created. {
zb_bdb_signal_touchlink_nwk_started_params_t *sig_params = ZB_ZDO_SIGNAL_GET_PARAMS(sg_p, zb_bdb_signal_touchlink_nwk_started_params_t);
light_control_led_on_off(BULB_LED_NEW_DEV_JOINED, 1);
ZB_IEEE_ADDR_COPY(g_device_ctx.pending_dev_addr, sig_params->device_ieee_addr);
g_device_ctx.pending_dev_ep = sig_params->endpoint;
TRACE_MSG(TRACE_APP1, "ZB_BDB_SIGNAL_TOUCHLINK_NWK_STARTED: remember dev "TRACE_FORMAT_64, (FMT__A, TRACE_ARG_64(g_device_ctx.pending_dev_addr)));
TRACE_MSG(TRACE_APP1, "profile 0x%x ep %hd", (FMT__D_H, sig_params->profile_id, sig_params->endpoint));
}
break;
|
ZB_BDB_SIGNAL_TOUCHLINK_NWK_JOINED_ROUTER |
Inform the Touchlink initiator that the new router joined the network. {
zb_bdb_signal_touchlink_nwk_joined_router_t *sig_params = ZB_ZDO_SIGNAL_GET_PARAMS(sg_p, zb_bdb_signal_touchlink_nwk_joined_router_t);
light_control_led_on_off(BULB_LED_NEW_DEV_JOINED, 1);
ZB_IEEE_ADDR_COPY(g_device_ctx.pending_dev_addr, sig_params->device_ieee_addr);
g_device_ctx.pending_dev_ep = sig_params->endpoint;
TRACE_MSG(TRACE_APP1, "ZB_BDB_SIGNAL_TOUCHLINK_NWK_JOINED_ROUTER: remember dev "TRACE_FORMAT_64, (FMT__A, TRACE_ARG_64(g_device_ctx.pending_dev_addr)));
TRACE_MSG(TRACE_APP1, "profile 0x%x ep %hd", (FMT__D_H, sig_params->profile_id, sig_params->endpoint));
}
break;
|
ZB_BDB_SIGNAL_TOUCHLINK |
Touchlink commissioning done. |
ZB_BDB_SIGNAL_STEERING |
BDB steering completed. |
ZB_BDB_SIGNAL_FORMATION |
BDB formation completed. |
ZB_BDB_SIGNAL_FINDING_AND_BINDING_TARGET_FINISHED |
BDB finding and binding target completed. |
ZB_BDB_SIGNAL_FINDING_AND_BINDING_INITIATOR_FINISHED |
BDB finding and binding initiator completed. |
ZB_BDB_SIGNAL_TOUCHLINK_TARGET |
Touchlink Target started. |
ZB_BDB_SIGNAL_TOUCHLINK_NWK |
Touchlink Target Network started. |
ZB_NWK_SIGNAL_DEVICE_ASSOCIATED |
New device associated to ZigBee Coordinator or router. Note: that signal exists due to historical reasons. Its usage is not recommented. Base your logic on ZB_ZDO_SIGNAL_DEVICE_ANNCE instead. |
ZB_ZDO_SIGNAL_LEAVE_INDICATION |
NWK leave indication from the child received Has additional data of type zb_zdo_signal_leave_indication_params_t. {
zb_zdo_signal_leave_indication_params_t *leave_ind_params = ZB_ZDO_SIGNAL_GET_PARAMS(sg_p, zb_zdo_signal_leave_indication_params_t);
if (!leave_ind_params->rejoin)
{
simple_gw_leave_indication(leave_ind_params->device_addr);
}
}
break;
|
ZB_ZGP_SIGNAL_COMMISSIONING |
ZGP commissioning complete signal Called when GPCB is leaving commissioning mode.
{
zb_zdo_app_signal_hdr_t *sg_p = NULL;
zb_zdo_app_signal_type_t sig = zb_get_app_signal(param, &sg_p);
TRACE_MSG(TRACE_ZCL1, "> zboss_signal_handler %hd", (FMT__H, param));
if (ZB_GET_APP_SIGNAL_STATUS(param) == 0)
{
switch(sig)
{
TRACE_MSG(TRACE_APP1, "Device STARTED OK", (FMT__0));
#ifndef ZB_USE_BUTTONS
/* if we do not have buttons, use alarm */
ZB_SCHEDULE_ALARM(start_comm, 0,
ZB_MILLISECONDS_TO_BEACON_INTERVAL(12000));
#endif
break;
{
zb_zgp_signal_commissioning_params_t *comm_params = ZB_ZDO_SIGNAL_GET_PARAMS(sg_p, zb_zgp_signal_commissioning_params_t);
}
break;
{
TRACE_MSG(TRACE_APP1, "Loading application production config", (FMT__0));
break;
}
|
ZB_COMMON_SIGNAL_CAN_SLEEP |
Notifies application that MCU can go to sleep. Passed up with parameter @ref zb_zdo_signal_can_sleep_params_t |
ZB_ZDO_SIGNAL_PRODUCTION_CONFIG_READY |
Notifies application that application specific part of production configuration can be applied Passed up with application specific data from production configuration. |
zb_zdo_app_signal_type_t zb_get_app_signal | ( | zb_uint8_t | param, |
zb_zdo_app_signal_hdr_t ** | sg_p | ||
) |
If any parameters are needed to be passed to the zboss_signal_handler, it will be better to inherit zb_zdo_app_signal_t and introduce the structure something like this:
typedef struct zb_zdo_app_my_custom_signal_s { zb_zdo_app_signal_t super; zb_my_custom_data_type_t my_custom_data; } Unpack application signal buffer in zboss_signal_handler()
param | - parameter of zboss_signal_handler() |
sg_p | - pointer to the extended signal info, if application wants it. Can be NULL. |
zb_void_t zboss_signal_handler | ( | zb_uint8_t | param | ) |
ZBOSS application signal handler.
Mandatory for all applications implemented on the top of ZBOSS stack. See zb_zdo_app_signal_type_e.
param | - reference to the buffer which contains signal. See zb_get_app_signal. |