如何使用TI HomeAutomation 中的SampleLight和SampleSwitch添加closure中的shade功能
想在HomeAutomation中的SampleLight和SampleSwith加上窗帘shade的程序,一直无法成功,不知道是哪里的问题,switch中的修改如下: #define ZCLSAMPLESW_BINDINGLIST 2 static cId_t bindingOutClusters[ZCLSAMPLESW_BINDINGLIST] = { ZCL_CLUSTER_ID_GEN_ON_OFF, ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING }; 然后使用了串口回调函数,来数据就向绑定的终端发送函数(绑定用的原例程中的) zclClosures_SendUpOpen(SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr, false, 0); 终端中的修改如下: 添加cluster static cId_t bindingInClusters[ZCLSAMPLELIGHT_BINDINGLIST] = { ZCL_CLUSTER_ID_GEN_ON_OFF, ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING }; 命令回调函数 static zclClosures_AppCallbacks_t zclSampleShade_CmdCallbacks= { NULL, NULL, zclSampleShade_WindowCoveringSimple_t , //zclSampleShade_WindowCoveringSimple_t , //zclSampleShade_WindowCoveringSimple_t , NULL, NULL, NULL, NULL, NULL, NULL, NULL, }; 对回调进行注册 zclClosures_RegisterCmdCallbacks( SAMPLELIGHT_ENDPOINT, &zclSampleShade_CmdCallbacks ); 回调函数内容 static void zclSampleShade_WindowCoveringSimple_t (void) { HalUARTWrite(0,"Hello World\n",12); //(串口0,'字符',字符个数。) HalLedSet( HAL_LED_1, HAL_LED_MODE_OFF ); } 下载程序无法实现回调函数的内容 还有什么需要修改的吗? |
在appname.c中还应该添加cluster的吧,但是具体的东西却不知该如何添加
应该在appname.c中再添加cluster的,
不知道这么添加的是否正确
zclsampleswitch_data.c中修改
#define ZCLSAMPLESW_MAX_INCLUSTERS 2
const cId_t zclSampleSw_InClusterList[ZCLSAMPLESW_MAX_INCLUSTERS] =
{
ZCL_CLUSTER_ID_GEN_BASIC,
ZCL_CLUSTER_ID_CLOSURES_SHADE_CONFIG
};
#define ZCLSAMPLESW_MAX_OUTCLUSTERS 2
const cId_t zclSampleSw_OutClusterList[ZCLSAMPLESW_MAX_OUTCLUSTERS] =
{
ZCL_CLUSTER_ID_GEN_ON_OFF,
ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING
};
SimpleDescriptionFormat_t zclSampleSw_SimpleDesc =
{
SAMPLESW_ENDPOINT, // int Endpoint;
ZCL_HA_PROFILE_ID, // uint16 AppProfId[2];
ZCL_HA_DEVICEID_SHADE_CONTROLLER,//ZCL_HA_DEVICEID_ON_OFF_SWITCH, // uint16 AppDeviceId[2];
SAMPLESW_DEVICE_VERSION, // int AppDevVer:4;
SAMPLESW_FLAGS, // int AppFlags:4;
ZCLSAMPLESW_MAX_INCLUSTERS, // byte AppNumInClusters;
(cId_t *)zclSampleSw_InClusterList, // byte *pAppInClusterList;
ZCLSAMPLESW_MAX_OUTCLUSTERS, // byte AppNumInClusters;
(cId_t *)zclSampleSw_OutClusterList // byte *pAppInClusterList;
};
在CONST zclAttrRec_t zclSampleSw_Attrs[SAMPLESW_MAX_ATTRIBUTES]中添加:
{ ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING,
{
ATTRID_CLOSURES_WINDOW_COVERING_TYPE,
ZCL_DATATYPE_UINT8,
ACCESS_CONTROL_READ,
(void *)& zclSampleClosures_OpenCloseStop
}
},
ZCL_CLUSTER_ID_CLOSURES_SHADE_CONFIG,
{
ATTRID_CLOSURES_STATUS,
ZCL_DATATYPE_UINT8,
CLOSURES_STATUS_SHADE_IS_OPERATIONAL,
NULL
}
},
在zcl_samplelight_data.c中修改:
SimpleDescriptionFormat_t zclSampleLight_SimpleDesc =
{
SAMPLELIGHT_ENDPOINT, // int Endpoint;
ZCL_HA_PROFILE_ID, // uint16 AppProfId[2];
ZCL_HA_DEVICEID_SHADE,//ZCL_HA_DEVICEID_DIMMABLE_LIGHT, // uint16 AppDeviceId[2];
SAMPLELIGHT_DEVICE_VERSION, // int AppDevVer:4;
SAMPLELIGHT_FLAGS, // int AppFlags:4;
ZCLSAMPLELIGHT_MAX_INCLUSTERS, // byte AppNumInClusters;
(cId_t *)zclSampleLight_InClusterList, // byte *pAppInClusterList;
ZCLSAMPLELIGHT_MAX_OUTCLUSTERS, // byte AppNumInClusters;
(cId_t *)zclSampleLight_OutClusterList // byte *pAppInClusterList;
};
const cId_t zclSampleLight_InClusterList[ZCLSAMPLELIGHT_MAX_INCLUSTERS] =
{
ZCL_CLUSTER_ID_GEN_BASIC,
ZCL_CLUSTER_ID_GEN_SCENES,
ZCL_CLUSTER_ID_GEN_GROUPS,
ZCL_CLUSTER_ID_GEN_ON_OFF,
ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL,
ZCL_CLUSTER_ID_CLOSURES_SHADE_CONFIG,
ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING
};
#define ZCLSAMPLELIGHT_MAX_OUTCLUSTERS 2
const cId_t zclSampleLight_OutClusterList[ZCLSAMPLELIGHT_MAX_OUTCLUSTERS] =
{
ZCL_CLUSTER_ID_GEN_BASIC,
ZCL_CLUSTER_ID_CLOSURES_SHADE_CONFIG
};
在CONST zclAttrRec_t zclSampleSw_Attrs[SAMPLESW_MAX_ATTRIBUTES]中添加
ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING,
{
ATTRID_CLOSURES_WINDOW_COVERING_TYPE,
ZCL_DATATYPE_UINT8,
ACCESS_CONTROL_READ,
(void *)& zclSampleClosures_OpenCloseStop
}
},
{
ZCL_CLUSTER_ID_CLOSURES_SHADE_CONFIG,
{
ATTRID_CLOSURES_STATUS,
ZCL_DATATYPE_UINT8,
CLOSURES_STATUS_SHADE_IS_OPERATIONAL,
NULL
}
}
你好,你的做法是对的。
参考ZigBee Home Automation Specification中对Closure Devices需要支持的cluster有哪些,包括in cluster(server)和out cluster(client)是什么
然后对应cluster下面的attribute有哪些
最后注册相关的call back函数
像这个cluster:ZCL_CLUSTER_ID_CLOSURES_SHADE_CONFIG 下有好多attributes,这需要对每一个进行配置吗?
// Shade information attributes set
#define ATTRID_CLOSURES_PHYSICAL_CLOSED_LIMIT 0x0000
#define ATTRID_CLOSURES_MOTOR_STEP_SIZE 0x0001
#define ATTRID_CLOSURES_STATUS 0x0002
/*** Status attribute bit values ***/
#define CLOSURES_STATUS_SHADE_IS_OPERATIONAL 0x01
#define CLOSURES_STATUS_SHADE_IS_ADJUSTING 0x02
#define CLOSURES_STATUS_SHADE_DIRECTION 0x04
#define CLOSURES_STATUS_SHADE_MOTOR_FORWARD_DIRECTION 0x08
// Shade settings attributes set
#define ATTRID_CLOSURES_CLOSED_LIMIT 0x0010
#define ATTRID_CLOSURES_MODE 0x0012
/*** Mode attribute values ***/
#define CLOSURES_MODE_NORMAL_MODE 0x00
#define CLOSURES_MODE_CONFIGURE_MODE 0x01
我用的homeautomation版本较低,closures中只有两种设备ID
// Closures Device IDs
#define ZCL_HA_DEVICEID_SHADE 0x0200
#define ZCL_HA_DEVICEID_SHADE_CONTROLLER 0x0201
我查了一下文档,
这个只配置了shade configuration,这个只是当成了on/off设备来用 我想用ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING 这个cluster,那该如何配置?想用到这个里面的open/close/stop,求解!
Hi VV
我在ZIGBEE 的官方看到 TI 已经有 window convering 的 认证 example
请问 能否 共享 example 的code ?
谢谢!
@Mars, 没有完整的关于Window Covering的samecode。 但是关于Window Covering需要用的cluster,device,command,callback这些在zcl的文件里面都已经实现好了。 你只需要参考一个sampleDoorlock这个例子,然后根据标准文档的要求,就可以去做了,相当于搭积木一样。 等你学会一个产品的开发以后,以后其他的产品也是一样的过程。