silicon lab ember zigbee学习杂谈 --------- 发送zcl command

Ember zigbee协议栈有专门提供发送zcl command 的API可调用,那么下面来看一下如何调用API发送zcl command。

1、先使用填充宏定义(fill macro)来构造你要发的zcl command,填充宏定义可在<install path>/app/builder/STM32/clientcommand-macro.h中找到,包括自定义的command也自动在此文件生成填充宏。如要发送一个identify command只需调用emberAfFillCommandIdentifyClusterIdentify(identifyTime)就能构造一个identify command。

2、确定command发送的源端点(source endpoint)和目标端点(target endpoint)来构造EmberApsFrame,直接调用void emberAfSetCommandEndpoints(int8u sourceEndpoint, int8u destinationEndpoint)函数。

3、发送指令,有三种发送方式,单播,组播和广播。分别调用以下函数:
组播:EmberStatus emberAfSendCommandMulticast(int16u multicastId);
单播:EmberStatus emberAfSendCommandUnicast(EmberOutgoingMessageType type,int16u indexOrDestination);
广播:EmberStatus emberAfSendCommandBroadcast(int16u destination);
具体用法参考请参考函数定义。

例如我需发送identify command给设备0x1234,识别时间10s,源端点和目标端点都为1,那么发送该指令的用法为:
emberAfFillCommandIdentifyClusterIdentify(10);
emberAfSetCommandEndpoints(1,1);
mberAfSendCommandUnicast(EMBER_OUTGOING_DIRECT,0x1234);
参考文档:UG102 - AppFrameworkDevGuide-10 Command Handling and Generation







猜你喜欢

转载自blog.csdn.net/wangchongttg/article/details/50389045