jamie/include/switch.h

76 lines
3.0 KiB
C

#ifndef SWITCH_H
#define SWITCH_H
#define ZB_DECLARE_INFO_EP(ep_name, ep_id, dev_ctx) \
\
ZB_ZCL_DECLARE_IDENTIFY_ATTRIB_LIST( \
ep_name ## _identify_attr_list, \
&dev_ctx.identify_attr.identify_time); \
\
ZB_ZCL_DECLARE_BASIC_ATTRIB_LIST_EXT( \
ep_name ## _basic_attr_list, \
&dev_ctx.basic_attr.zcl_version, \
&dev_ctx.basic_attr.app_version, \
&dev_ctx.basic_attr.stack_version, \
&dev_ctx.basic_attr.hw_version, \
dev_ctx.basic_attr.mf_name, \
dev_ctx.basic_attr.model_id, \
dev_ctx.basic_attr.date_code, \
&dev_ctx.basic_attr.power_source, \
dev_ctx.basic_attr.location_id, \
&dev_ctx.basic_attr.ph_env, \
dev_ctx.basic_attr.sw_ver); \
\
zb_zcl_cluster_desc_t ep_name ## _clusters[] = { \
ZB_ZCL_CLUSTER_DESC(ZB_ZCL_CLUSTER_ID_IDENTIFY, ZB_ZCL_ARRAY_SIZE(ep_name ## _identify_attr_list, zb_zcl_attr_t), (ep_name ## _identify_attr_list), ZB_ZCL_CLUSTER_SERVER_ROLE, ZB_ZCL_MANUF_CODE_INVALID), \
ZB_ZCL_CLUSTER_DESC(ZB_ZCL_CLUSTER_ID_BASIC, ZB_ZCL_ARRAY_SIZE(ep_name ## _basic_attr_list, zb_zcl_attr_t), (ep_name ## _basic_attr_list), ZB_ZCL_CLUSTER_SERVER_ROLE, ZB_ZCL_MANUF_CODE_INVALID), \
}; \
\
ZB_AF_SIMPLE_DESC_TYPE(2, 0) ep_name ## _desc = { \
ep_id, \
ZB_AF_HA_PROFILE_ID, \
0x0008, \
0, \
0, \
2, \
0, \
{ \
ZB_ZCL_CLUSTER_ID_BASIC, \
ZB_ZCL_CLUSTER_ID_IDENTIFY, \
} \
}; \
\
ZB_AF_DECLARE_ENDPOINT_DESC(ep_name, ep_id, ZB_AF_HA_PROFILE_ID, 0, NULL, ZB_ZCL_ARRAY_SIZE(ep_name ## _clusters, zb_zcl_cluster_desc_t), ep_name ## _clusters, (zb_af_simple_desc_1_1_t *)&ep_name ## _desc, 0, NULL, 0, NULL)
#define ZB_DECLARE_SW_EP(ep_name, ep_id, state, type, action) \
\
ZB_ZCL_DECLARE_ON_OFF_ATTRIB_LIST(ep_name ## _attribs, &state.on_off); \
ZB_ZCL_DECLARE_ON_OFF_CLIENT_ATTRIB_LIST(ep_name ## _client_attribs); \
ZB_ZCL_DECLARE_ON_OFF_SWITCH_CONFIGURATION_ATTRIB_LIST(ep_name ## _config_attribs, &type, &action); \
\
zb_zcl_cluster_desc_t ep_name ## _clusters[] = { \
ZB_ZCL_CLUSTER_DESC(ZB_ZCL_CLUSTER_ID_ON_OFF, ZB_ZCL_ARRAY_SIZE(ep_name ## _attribs, zb_zcl_attr_t), (ep_name ## _attribs), ZB_ZCL_CLUSTER_SERVER_ROLE, ZB_ZCL_MANUF_CODE_INVALID), \
ZB_ZCL_CLUSTER_DESC(ZB_ZCL_CLUSTER_ID_ON_OFF, ZB_ZCL_ARRAY_SIZE(ep_name ## _client_attribs, zb_zcl_attr_t), (ep_name ## _client_attribs), ZB_ZCL_CLUSTER_CLIENT_ROLE, ZB_ZCL_MANUF_CODE_INVALID), \
ZB_ZCL_CLUSTER_DESC(ZB_ZCL_CLUSTER_ID_ON_OFF_SWITCH_CONFIG, ZB_ZCL_ARRAY_SIZE(ep_name ## _config_attribs, zb_zcl_attr_t), (ep_name ## _config_attribs), ZB_ZCL_CLUSTER_SERVER_ROLE, ZB_ZCL_MANUF_CODE_INVALID), \
}; \
\
ZB_AF_SIMPLE_DESC_TYPE(2, 1) ep_name ## _desc = { \
ep_id, \
ZB_AF_HA_PROFILE_ID, \
0x0000, \
0, \
0, \
2, \
1, \
{ \
ZB_ZCL_CLUSTER_ID_ON_OFF, \
ZB_ZCL_CLUSTER_ID_ON_OFF, \
ZB_ZCL_CLUSTER_ID_ON_OFF_SWITCH_CONFIG, \
} \
}; \
\
ZBOSS_DEVICE_DECLARE_REPORTING_CTX(ep_name ## _rep_ctx, 3); \
ZB_AF_DECLARE_ENDPOINT_DESC(ep_name, ep_id, ZB_AF_HA_PROFILE_ID, 0, NULL, ZB_ZCL_ARRAY_SIZE(ep_name ## _clusters, zb_zcl_cluster_desc_t), ep_name ## _clusters, (zb_af_simple_desc_1_1_t *)&ep_name ## _desc, 1, ep_name ## _rep_ctx, 0, NULL)
#endif // SWITCH_H