base cluster添加额外的属性

Zigbee 子设备开发


Post Reply
yezhipeng
Posts: 42

Dear All,


Code: Select all

环境:EFR32MG21A020_TuyaOS-3.6.1

这边需要在base cluster添加product code属性,需要怎么处理。我添加如下会启动失败。

uint8_t productCode[] = {4, 'b', 'u', 'l', 'l', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

#ifndef GET_ARRAY_LEN
#define GET_ARRAY_LEN(x) (sizeof(x) / sizeof(x[0]))
#endif

#define BASE_ATTR_LIST \
{0x000A, ATTR_OCTET_STRING_ATTRIBUTE_TYPE, 17, (ATTR_MASK_READABLE),0, {(UINT8_T )&productCode[0]}}, / 12 / base / product code*/

// application attribute
const TAL_ATTR_T base_attr_list[] = {
BASE_ATTR_LIST};

// server cluster
const TAL_CLUSTER_T app_server_cluster_list[] = {
DEF_BASE_CLUSTER_ID(base_attr_list)
DEF_CLUSTER_IDENTIFY_CLUSTER_ID(identify_attr_list)
DEF_CLUSTER_GROUPS_CLUSTER_ID(group_attr_list)
DEF_CLUSTER_SCENES_CLUSTER_ID(scene_attr_list)
DEF_CLUSTER_ON_OFF_CLUSTER_ID(onoff_attr_list)
DEF_CLUSTER_LEVEL_CONTROL_CLUSTER_ID(level_attr_list)
DEF_CLUSTER_COLOR_CONTROL_CLUSTER_ID(color_attr_list)
DEF_CLUSTER_ZLL_COMMISSIONING_CLUSTER_ID(zll_attr_list)};

BRS
Ye.Zhi-Peng

huanghuan
Posts: 244

Re: base cluster添加额外的属性

1.这个问题是因为按照你的配置basic cluster下只会注册这一个attr,zigbee 3.0 spec中规定basic下是有要强制注册的attr的,sdk内部会检测是否有注册这些强制要求注册的attr list。
2.下面的sdk内部的basic attr list,你可以在这个基础在加上你要求的attr,其中 0xFFXX 是涂鸦私有attr,不过为了保证sdk功能完整,在不影响你需求的情况下建议保留这些私有属性。

Code: Select all

#ifdef TUYA_ZG_ROUTER
CONST TAL_ATTR_T g_base_server_attr_list[] = {
    { 0x0000, ATTR_INT8U_ATTRIBUTE_TYPE, 1, (ATTR_MASK_READABLE),  0, (UINT8_T*)0x03 }, /* 0 / Basic / ZCL version*/\
    { 0x0001, ATTR_INT8U_ATTRIBUTE_TYPE, 1, (ATTR_MASK_READABLE),  0, (UINT8_T*)0x41  }, /* 1 / Basic / application version*/\
    { 0x0002, ATTR_INT8U_ATTRIBUTE_TYPE, 1, (ATTR_MASK_READABLE),  0, (UINT8_T*)0x01  }, /* 2 / Basic / stack version*/\
    { 0x0003, ATTR_INT8U_ATTRIBUTE_TYPE, 1, (ATTR_MASK_READABLE),  0, (UINT8_T*)0x02  }, /* 3 / Basic / hardware version*/\
    { 0x0004, ATTR_CHAR_STRING_ATTRIBUTE_TYPE, 33, (ATTR_MASK_TOKEN_FAST), 0, NULL  }, /* 4 / Basic / manufacturer name*/\
    { 0x0005, ATTR_CHAR_STRING_ATTRIBUTE_TYPE, 33, (ATTR_MASK_READABLE),  0, NULL  }, /* 5 / Basic / model identifier*/\
    { 0x0006, ATTR_CHAR_STRING_ATTRIBUTE_TYPE, 17, (ATTR_MASK_READABLE),  0, NULL  }, /* 6 / Basic / date code*/\
    { 0x0007, ATTR_ENUM8_ATTRIBUTE_TYPE, 1, (ATTR_MASK_READABLE),  0, (UINT8_T*)0x01  }, /* 7 / Basic / power source*/\
    { 0xFFC0, ATTR_CHAR_STRING_ATTRIBUTE_TYPE, 33, (ATTR_MASK_TOKEN_FAST), 0, NULL },/*14 / tuya private Basic /reserverd*/\
    { 0xFFCF, ATTR_INT16U_ATTRIBUTE_TYPE, 2, (ATTR_MASK_READABLE), 0, (UINT8_T*)0x00B4},/*default heartbeat 3*60s*/
    { 0xFFDE, ATTR_INT8U_ATTRIBUTE_TYPE, 1, (ATTR_MASK_WRITABLE),  0, (UINT8_T*)0x0D  }, /* 8 / basic / tx power cfg*/\
    { 0xFFFD, ATTR_INT16U_ATTRIBUTE_TYPE, 2, (ATTR_MASK_READABLE), 0, (UINT8_T*)0x0002  }, /* 8 / Basic / cluster revision*/\
    { 0xFFFE, ATTR_ENUM8_ATTRIBUTE_TYPE, 1, (ATTR_MASK_READABLE),  0, (UINT8_T*)0x00  },/*9*/\
    { 0xFFE0, ATTR_ARRAY_ATTRIBUTE_TYPE, 41, (ATTR_MASK_READABLE), 0, (UINT8_T*)0x00 },/*10 / tuya private Basic /pub key*/\
    { 0xFFE1, ATTR_ARRAY_ATTRIBUTE_TYPE, 41, (ATTR_MASK_READABLE), 0, (UINT8_T*)0x00 },/*11 / tuya private Basic /sign info*/\
    { 0xFFE2, ATTR_INT8U_ATTRIBUTE_TYPE, 1, (ATTR_MASK_READABLE),  0, (UINT8_T*)TUYA_ZIGBEE_SDK_VER },/*12 / tuya private Basic /sdk ver*/\
    { 0xFFE3, ATTR_CHAR_STRING_ATTRIBUTE_TYPE, 41, (ATTR_MASK_READABLE), 0, NULL },/*13 / tuya private Basic /reserverd*/\
};
#else
CONST TAL_ATTR_T g_base_server_attr_list[] = {
    { 0x0000, ATTR_INT8U_ATTRIBUTE_TYPE, 1, (ATTR_MASK_READABLE),  0, (UINT8_T*)0x03 }, /* 0 / Basic / ZCL version*/\
    { 0x0001, ATTR_INT8U_ATTRIBUTE_TYPE, 1, (ATTR_MASK_READABLE),  0, (UINT8_T*)0x41  }, /* 1 / Basic / application version*/\
    { 0x0002, ATTR_INT8U_ATTRIBUTE_TYPE, 1, (ATTR_MASK_READABLE),  0, (UINT8_T*)0x01  }, /* 2 / Basic / stack version*/\
    { 0x0003, ATTR_INT8U_ATTRIBUTE_TYPE, 1, (ATTR_MASK_READABLE),  0, (UINT8_T*)0x02  }, /* 3 / Basic / hardware version*/\
    { 0x0004, ATTR_CHAR_STRING_ATTRIBUTE_TYPE, 33, (ATTR_MASK_TOKEN_FAST), 0, NULL  }, /* 4 / Basic / manufacturer name*/\
    { 0x0005, ATTR_CHAR_STRING_ATTRIBUTE_TYPE, 33, (ATTR_MASK_READABLE),  0, NULL  }, /* 5 / Basic / model identifier*/\
    { 0x0006, ATTR_CHAR_STRING_ATTRIBUTE_TYPE, 17, (ATTR_MASK_READABLE),  0, NULL  }, /* 6 / Basic / date code*/\
    { 0x0007, ATTR_ENUM8_ATTRIBUTE_TYPE, 1, (ATTR_MASK_READABLE),  0, (UINT8_T*)0x01  }, /* 7 / Basic / power source*/\
    { 0xFFC0, ATTR_CHAR_STRING_ATTRIBUTE_TYPE, 33, (ATTR_MASK_TOKEN_FAST), 0, NULL },/*14 / tuya private Basic /reserverd*/\
    { 0xFFCF, ATTR_INT16U_ATTRIBUTE_TYPE, 2, (ATTR_MASK_READABLE), 0, (UINT8_T*)0x3840},/*default heartbeat 4*3600s*/
    { 0xFFDE, ATTR_INT8U_ATTRIBUTE_TYPE, 1, (ATTR_MASK_WRITABLE),  0, (UINT8_T*)0x0D  }, /* 8 / basic / tx power cfg*/\
    { 0xFFFD, ATTR_INT16U_ATTRIBUTE_TYPE, 2, (ATTR_MASK_READABLE), 0, (UINT8_T*)0x0002  }, /* 8 / Basic / cluster revision*/\
    { 0xFFFE, ATTR_ENUM8_ATTRIBUTE_TYPE, 1, (ATTR_MASK_READABLE),  0, (UINT8_T*)0x00  },/*9*/\
    { 0xFFE0, ATTR_ARRAY_ATTRIBUTE_TYPE, 41, (ATTR_MASK_READABLE), 0, (UINT8_T*)0x00 },/*10 / tuya private Basic /pub key*/\
    { 0xFFE1, ATTR_ARRAY_ATTRIBUTE_TYPE, 41, (ATTR_MASK_READABLE), 0, (UINT8_T*)0x00 },/*11 / tuya private Basic /sign info*/\
    { 0xFFE2, ATTR_INT8U_ATTRIBUTE_TYPE, 1, (ATTR_MASK_READABLE),  0, (UINT8_T*)TUYA_ZIGBEE_SDK_VER },/*12 / tuya private Basic /sdk ver*/\
    { 0xFFE3, ATTR_CHAR_STRING_ATTRIBUTE_TYPE, 41, (ATTR_MASK_READABLE), 0, NULL },/*13 / tuya private Basic /reserverd*/\
};
#endif
Post Reply