This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

zcl_SendReportCmd使用咨询

    在sensortagapp例程里,发送16位温度给协调器的初始化如下,

   有几个疑问请教一下:

 1.pReportCmd->numAttr = 1;1是什么意思?代表数据的长度还是?

2.pReportCmd->attrList[0].attrID 是代表数据类型是温度数据?这个也可以随便设置的吧?

3.pReportCmd->attrList[0].dataType和pReportCmd->attrList[0].attrData是对应的吧?

4.这里是发送16位(2个字节)的数据,如果我要发送3个字节的数据,参数配置有什么不同?

// Fill in the single attribute information for the temperature reading
    pReportCmd->numAttr = 1;
    pReportCmd->attrList[0].attrID = ATTRID_MS_TEMPERATURE_MEASURED_VALUE;
    pReportCmd->attrList[0].dataType = ZCL_DATATYPE_INT16;
    pReportCmd->attrList[0].attrData = (void *) (&staTempMeasuredValue);

// Call ZCL function to send the report
    zcl_SendReportCmd(SENSORTAGAPP_TS_EP, &dstAddr,
                      ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT, pReportCmd,
                      ZCL_FRAME_SERVER_CLIENT_DIR, true, staTransID++);

  • 你可以去看看attrID 是代表的cluster 里面的ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT的attributeATTRID_MS_TEMPERATURE_MEASURED_VALUE
    不是随便写的。numAttr 代表了几个attribute的属性。
    我个人建议你去pReportCmd结构体的说明。
  • 1. 代表這個封包只有包含一組数据
    2. attrID 代表是量測温度数据类型,不能随便设置,必須遵照ZCL spec規範
    3. 是
    4. 遵照ZCL spec規範,量測温度数据类型只能是16位(2个字节)的数据,要发送3个字节的数据你要用私有的cluster ID/Attribute ID去作
  • 谢谢,我这边只是传私有协议的数据,不需要遵从ZCL规范,需要怎么传送?用什么函数?
  • 不需要遵从ZCL规范就直接用AF_DataRequest去传送
  • 直接用AF_DataRequest即可啊。
  • 请问ZCL的规范哪里可以下载?
  • cluster ID/Attribute ID,这个两个ID具体是什么意思?有啥区别?
  • 建议你去看ZCL specification,一个是cluster ,一个里面的支持的attribute。
  • cluster ID是传送数据類別,Attribute ID是传送数据類型
  • 温度传感器设备上报数据,在协调器里是进入下面的程序吗?
    我想把协调器收到的温度数据(int16)发到串口,请问下面的程序有没有问题?
    case ZCL_CMD_REPORT:
    if (pInMsg->clusterId == ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT)
    {
    uint8 str[2]={0};
    zclReportCmd_t *rpt_cmd;
    rpt_cmd= ((zclReportCmd_t *)pInMsg->attrCmd);
    str[0]=*(rpt_cmd->attrList->attrData);
    str[1]=*(rpt_cmd->attrList->attrData+1);
    HalUARTWrite(0,str,2 );
    }
  • 温度传感器设备上报数据,在协调器里是进入下面的程序吗?

    是的

    我想把协调器收到的温度数据(int16)发到串口,请问下面的程序有没有问题?

    看來沒什麼問題

  • ZCL规范里关于温度描述如下,正的可以理解,
    -273.15°C和0x954d 是怎么换算的?
    负的温度在数据上有什么标志位?
    Where -273.15°C <= temperature <= 327.67 ºC, corresponding to a MeasuredValue in the range 0x954d to
    0x7fff. The maximum resolution this format allows is 0.01 ºC.
  • 0x954d 的2's Complement轉換完就是-27315,0x7fff的2's Complement轉換完就是32767,ZCL這邊定義的溫度是放大100倍,所以就是對應到-273.15°C/327.67 ºC