转载请注明出处,谢谢!
Newbit-Msming 2018-9-27
ZigBee 3.0 EmberZNet EFR32MG 学习笔记-目录
ZigBee 3.0 EmberZNet EFR32MG 学习笔记-6-Report Attribute
环境:Windows 10、Simplicity Studio 4
SDK: EmberZNet SDK 6.4.0.0
工程:新建
-
填充buff,如下:
uint8_t buff[10] = {0x00, 0x00, 0x29, 0x05, 0x06, 0x01, 0x00, 0x29, 0x07, 0x08};
可以看出buff的格式为:| Attribute ID | Data type | Attribute data |,低字节先传,
现在这个buff填充了两个attribute,分别是0x0000、0x0001,数据类型都是0x29,
Attribute 0x0000的数据为0x0605, Attribute 0x0001的数据为0x0807。 -
将buff填充到底层 :
emberAfFillCommandGlobalServerToClientReportAttributes(ZCL_TEMP_MEASUREMENT_CLUSTER_ID, (uint8_t *) buff, 10);
-
填写endpoint:
emberAfSetCommandEndpoints(1, 1);
-
单播到Coordinator:
emberAfSendCommandUnicast(EMBER_OUTGOING_DIRECT, 0x0000);
更新
更好的方法
void reportAttrbute(uint8_t sourceEndpoint, uint8_t destinationEndpoint, uint16_t clusterId, uint16_t attributeId)
{
EmberAfStatus status, emStatus;
uint8_t data[2 + 1 + ATTRIBUTE_LARGEST];
uint8_t bufIndex = 0;
//| Attribute ID | Data type | Attribute data |,LSB
status = emberAfAppendAttributeReportFields(sourceEndpoint, clusterId, attributeId, CLUSTER_MASK_SERVER, data, sizeof(data), &bufIndex);
if(EMBER_ZCL_STATUS_SUCCESS == status){
emberAfFillCommandGlobalServerToClientReportAttributes(clusterId, data, bufIndex);
emberAfSetCommandEndpoints(sourceEndpoint, destinationEndpoint);
emStatus = emberAfSendCommandUnicast(EMBER_OUTGOING_DIRECT, 0x0000);
Println("ToCoordinator: %d", emStatus);
}
}