ZigBee 3.0 EmberZNet EFR32MG 学习笔记-6-Report Attribute

本文深入解析ZigBee3.0中使用EmberZNetEFR32MG进行ReportAttribute操作的方法,详细介绍了如何在Windows10环境下,通过SimplicityStudio4和EmberZNetSDK6.4.0.0实现属性报告,包括buff填充、底层填充、endpoint设置及单播到Coordinator的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转载请注明出处,谢谢!

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

工程:新建

  1. 填充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。

  2. 将buff填充到底层 :
    emberAfFillCommandGlobalServerToClientReportAttributes(ZCL_TEMP_MEASUREMENT_CLUSTER_ID, (uint8_t *) buff, 10);

  3. 填写endpoint:emberAfSetCommandEndpoints(1, 1);

  4. 单播到Coordinator:emberAfSendCommandUnicast(EMBER_OUTGOING_DIRECT, 0x0000);

  5. 常驻:NewBit Studio

更新

更好的方法

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);
  }

}
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值