找回密码
 立即注册

微信扫码登录

查看: 4784|回复: 14

芯片主动上报level 状态, 这样是否可以?

[复制链接]

16

主题

36

回帖

202

积分

华贵铂金

积分
202
发表于 2024-12-23 10:26:53 | 显示全部楼层 |阅读模式 来自 广东深圳
information
说明:   建议参照本版块置顶帖内容输入必要信息
芯片型号:
SDK及版本:


使用samplight 例子,我自己添加的代码,芯片主动上报level 状态, 这样是否可以?

dstEpInfo 这个需要什么信息,没有API介绍这个?



void report_level_BY_handle(void)
{
        u8 u_v;

        u16 clusterID = 0xFFFF;
        epInfo_t dstEpInfo;
    TL_SETSTRUCTCONTENT(dstEpInfo, 0);

        dstEpInfo.dstAddrMode = APS_DSTADDR_EP_NOTPRESETNT;
        dstEpInfo.profileId = 0;


        u_v = 200;

        zcl_sendReportCmd(SAMPLE_LIGHT_ENDPOINT, &dstEpInfo,TRUE, ZCL_FRAME_SERVER_CLIENT_DIR,ZCL_CLUSTER_GEN_LEVEL_CONTROL,ZCL_ATTRID_LEVEL_CURRENT_LEVEL,ZCL_DATA_TYPE_UINT8,&u_v);
}


13

主题

61

回帖

363

积分

流光翡翠

积分
363
发表于 2024-12-23 13:22:21 | 显示全部楼层 来自 澳大利亚
Hi,
That's what I have in dstEpInfo
  1.         epInfo_t dstEpInfo;
  2.         memset((u8 *)&dstEpInfo, 0, sizeof(epInfo_t));
  3.         dstEpInfo.dstAddrMode = APS_SHORT_DSTADDR_WITHEP;
  4.         dstEpInfo.dstEp = 0x01
  5.         dstEpInfo.dstAddr.shortAddr = 0xffff;
  6.         dstEpInfo.profileId = HA_PROFILE_ID;
复制代码


You could set what level change you want to see before you send the report. And/Or use the timer to send report. at preset time intervals.

16

主题

36

回帖

202

积分

华贵铂金

积分
202
 楼主| 发表于 2024-12-23 22:30:34 | 显示全部楼层 来自 中国
hello , I'm wondering if the way I'm doing zcl_sendReportCmd(), is it mandatory for the chip to send out a level REPORT  ?

13

主题

61

回帖

363

积分

流光翡翠

积分
363
发表于 2024-12-24 04:18:57 | 显示全部楼层 来自 澳大利亚
本帖最后由 wes58 于 2024-12-24 04:23 编辑
fff 发表于 2024-12-23 22:30
hello , I'm wondering if the way I'm doing zcl_sendReportCmd(), is it mandatory for the chip to send ...

I am not sure if I understand you, but there are two ways the report is sent.
#1 in the function - report_handler()
The report will is only sent to devices that you bind to the device that sends report. The report is also sent when the value changes or the preset time elapses. For this to work you have to define it using
  1. bdb_defaultReportingCfg(LIGHT_ENDPOINT1, HA_PROFILE_ID, ZCL_CLUSTER_GEN_LEVEL_CONTROL, ZCL_ATTRID_LEVEL_CURRENT_LEVEL, 0x0000, 0x002a, (u8 *)&reportableChange);
复制代码
- and you have to bind the device. You can use ZGC_TOOL to do it from the Gateway.
The report will be sent every 0x002a second (you can change it to whatever value you want), or when the value changes.
  1. void report_handler(void){
  2.         if(zb_isDeviceJoinedNwk()){
  3.                 if(zcl_reportingEntryActiveNumGet()){
  4.                         u16 second = 1;//TODO: fix me

  5.                         reportNoMinLimit();
  6.                         //start report timer
  7.                         reportAttrTimerStart(second);
  8.                 }
  9.                 else{
  10.                         //stop report timer
  11.                         reportAttrTimerStop();
  12.                 }
  13.         }
  14. }
复制代码

#2. The second method is doing it manually, the way you do it. This way you send the report when you want and to the devices that you want. You don't have to worry about binding devices.

You should do it using ether method #1 or #2. There is no point doing it using both at the same time.
I hope this explanation helps you.

16

主题

36

回帖

202

积分

华贵铂金

积分
202
 楼主| 发表于 2024-12-24 08:30:23 | 显示全部楼层 来自 广东深圳
Because the level cannot be reported for A zigbee gateway.  I don't understand why, so I want to use this method (zcl_sendReportCmd).     

16

主题

36

回帖

202

积分

华贵铂金

积分
202
 楼主| 发表于 2024-12-24 08:32:56 | 显示全部楼层 来自 广东深圳
image is RF data, after returning level data, the gateway did not send an ASP ACK confirmation. But to immediately send an inquiry about Onoff?
微信图片_20241224083015.png

16

主题

36

回帖

202

积分

华贵铂金

积分
202
 楼主| 发表于 2024-12-24 08:35:47 | 显示全部楼层 来自 广东深圳
I tested SDKs from other companies and did not encounter this issue.
微信图片_20241224083015.png

13

主题

61

回帖

363

积分

流光翡翠

积分
363
发表于 2024-12-24 13:17:57 | 显示全部楼层 来自 澳大利亚
本帖最后由 wes58 于 2024-12-24 13:55 编辑
fff 发表于 2024-12-24 08:30
Because the level cannot be reported for A zigbee gateway.  I don't understand why, so I want to use ...

Did you bind the Gateway to the device with the level cluster?
That's the only reason that I had in the past that the report is not send by the device to the Gateway.
You can have a look in zcl_reporting.c file to see how it works. You could add some code there to see if the report is treggered.

16

主题

36

回帖

202

积分

华贵铂金

积分
202
 楼主| 发表于 2024-12-24 13:55:19 | 显示全部楼层 来自 广东深圳
Haven't seen bind with gateway. so why?

13

主题

61

回帖

363

积分

流光翡翠

积分
363
发表于 2024-12-24 15:59:59 | 显示全部楼层 来自 澳大利亚
本帖最后由 wes58 于 2024-12-24 16:03 编辑
fff 发表于 2024-12-24 13:55
Haven't seen bind with gateway. so why?

Here is the function from zcl_reporting.c
  1. _CODE_ZCL_ void reportAttr(reportCfgInfo_t *pEntry)
  2. {
  3.         if(!zb_bindingTblSearched(pEntry->clusterID, pEntry->endPoint)){
  4.                 return;
  5.         }

  6.         epInfo_t dstEpInfo;
  7.         TL_SETSTRUCTCONTENT(dstEpInfo, 0);

  8.         dstEpInfo.dstAddrMode = APS_DSTADDR_EP_NOTPRESETNT;
  9.         dstEpInfo.profileId = pEntry->profileID;

  10.         zclAttrInfo_t *pAttrEntry = zcl_findAttribute(pEntry->endPoint, pEntry->clusterID, pEntry->attrID);
  11.         if(!pAttrEntry){
  12.                 //should not happen.
  13.                 ZB_EXCEPTION_POST(SYS_EXCEPTTION_ZB_ZCL_ENTRY);
  14.                 return;
  15.         }

  16.         u16 len = zcl_getAttrSize(pAttrEntry->type, pAttrEntry->data);

  17.         len = (len>8) ? (8):(len);

  18.         //store for next compare
  19.         memcpy(pEntry->prevData, pAttrEntry->data, len);

  20.         zcl_sendReportCmd(pEntry->endPoint, &dstEpInfo,  TRUE, ZCL_FRAME_SERVER_CLIENT_DIR,
  21.                                           pEntry->clusterID, pAttrEntry->id, pAttrEntry->type, pAttrEntry->data);
  22. }
复制代码

As you can see at the beginning of this function:
  1. if(!zb_bindingTblSearched(pEntry->clusterID, pEntry->endPoint)){
  2.                 return;
  3.         }
复制代码

If the entry for the device (for example gateway) and for a specified cluster is not in the binding table of the device that is sending the report won't be sent.

And this is from the Zigbee SDK Developer manual
5.2.6 bdb_defaultReportingCfg()
Configure the default reporting message, which takes effect after binding.
Prototype
status_t bdb_defaultReportingCfg(u8 endpoint, u16 profileID,
u16 clusterID, u16 attrID,
u16 minReportInt, u16 maxReportInt,
u8 *reportableChange)



您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Telink forum ( 沪ICP备17008231号-1 )

GMT+8, 2025-6-7 11:58 , Processed in 0.125320 second(s), 23 queries .

Powered by Telink 隐私政策

泰凌微电子版权所有 © 。保留所有权利。 2024

快速回复 返回顶部 返回列表