Topic

FAQ
Login Register
ZigBee - Another issue with attribute restore
Jul 05, 2022 11:12

/

A

/A

I spent a lot of time trying to figure it out.

As per my previous post I use sampleLight modified example.

I add the second endpoint to control second light

I defined 2 endpoints:

#define LIGHT_ENDPOINT1 0x01

#define LIGHT_ENDPOINT2 0x02

I define OnOff Attributes:

zcl_onOffAttr_t g_zcl_onOffAttrs1;

zcl_onOffAttr_t g_zcl_onOffAttrs2;

and

const zclAttrInfo_t onOff_attrTbl1[]

const zclAttrInfo_t onOff_attrTbl2[]


Function user_init() has the following calls:

/* Initialize user application */

user_app_init();

/* Register except handler for test */

 sys_exceptHandlerRegister(LightSysException);

/* Adjust light state to default attributes*/

light_adjust();


In user_app_init() I have:

/* Register endPoint */

af_endpointRegister(LIGHT_ENDPOINT1, (af_simple_descriptor_t *)&Light_simpleDesc1, zcl_rx_handler, NULL);
af_endpointRegister(LIGHT_ENDPOINT2, (af_simple_descriptor_t *)&Light_simpleDesc2, zcl_rx_handler, NULL);


/* Initialize or restore attributes, this must before zcl_register() */

zcl_LightAttrsInit();

zcl_reportingTabInit();


/* Register ZCL specific cluster information */

zcl_register(LIGHT_ENDPOINT1, LIGHT_CB_CLUSTER_NUM, (zcl_specClusterInfo_t *)g_LightClusterList);
zcl_register(LIGHT_ENDPOINT2, LIGHT_CB_CLUSTER_NUM, (zcl_specClusterInfo_t *)g_LightClusterList);


In zcl_LightAttrsInit(), there is a call to function zcl_onOffAttr_restore();

Attributes for both lights are restored correctly.


But after the call to: light_adjust();, I can see that the attribute for light 1 is lost - OnOff attribute is always 1 (ON).


After a lot of time, I found out that the attribute is lost (changed to 1) after the first call: 

zcl_register(LIGHT_ENDPOINT1, LIGHT_CB_CLUSTER_NUM, (zcl_specClusterInfo_t *)g_LightClusterList);


When I changed and put zcl_LightAttrsInit();
after both calls to zcl_register(...), everything works fine.

zcl_register(LIGHT_ENDPOINT1, LIGHT_CB_CLUSTER_NUM, (zcl_specClusterInfo_t *)g_LightClusterList);
zcl_register(LIGHT_ENDPOINT2, LIGHT_CB_CLUSTER_NUM, (zcl_specClusterInfo_t *)g_LightClusterList);
zcl_LightAttrsInit();

Is it how I should be doing this?


So the question is why is it happening?

And this only happened for light 1, light 2 attribute was never lost?

Unless I was doing something wrong when registering 2 endpoints?







wes58 [Author] Jul 06, 2022 05:38
1
/A

Hi Soyo,

Thanks for this information.

How about bdb_defaultReportingCfg(...) and bdb_init(...)?

Do I have to do it for each endpoint

bdb_defaultReportingCfg(LIGHT_ENDPOINT1, HA_PROFILE_ID, ZCL_CLUSTER_GEN_ON_OFF, ZCL_ATTRID_ONOFF, 0x0000, 0x003c, (u8 *)&reportableChange);

bdb_defaultReportingCfg(LIGHT_ENDPOINT2, HA_PROFILE_ID, ZCL_CLUSTER_GEN_ON_OFF, ZCL_ATTRID_ONOFF, 0x0000, 0x003c, (u8 *)&reportableChange);

/* Initialize BDB */

bdb_init((af_simple_descriptor_t *)&Light_simpleDesc1, &g_bdbCommissionSetting, &g_zbDemoBdbCb, 1);

bdb_init((af_simple_descriptor_t *)&Light_simpleDesc2, &g_bdbCommissionSetting, &g_zbDemoBdbCb, 1);


But this doesn't really explain why the restored attribute is changed after the call to zcl_register?

7 replies
TL_Soyo Jul 05, 2022 13:49
0
/A

Hi,

   don't use same call back function : af_endpointRegister(LIGHT_ENDPOINT2, (af_simple_descriptor_t *)&Light_simpleDesc2, zcl_rx_handler_2, NULL);

   You can search AF_TEST_ENABLE in ZIgbee SDK ,it is a demo to add a new EP. 

wes58 [Author] Jul 06, 2022 05:38
1
/A

Hi Soyo,

Thanks for this information.

How about bdb_defaultReportingCfg(...) and bdb_init(...)?

Do I have to do it for each endpoint

bdb_defaultReportingCfg(LIGHT_ENDPOINT1, HA_PROFILE_ID, ZCL_CLUSTER_GEN_ON_OFF, ZCL_ATTRID_ONOFF, 0x0000, 0x003c, (u8 *)&reportableChange);

bdb_defaultReportingCfg(LIGHT_ENDPOINT2, HA_PROFILE_ID, ZCL_CLUSTER_GEN_ON_OFF, ZCL_ATTRID_ONOFF, 0x0000, 0x003c, (u8 *)&reportableChange);

/* Initialize BDB */

bdb_init((af_simple_descriptor_t *)&Light_simpleDesc1, &g_bdbCommissionSetting, &g_zbDemoBdbCb, 1);

bdb_init((af_simple_descriptor_t *)&Light_simpleDesc2, &g_bdbCommissionSetting, &g_zbDemoBdbCb, 1);


But this doesn't really explain why the restored attribute is changed after the call to zcl_register?

wes58 [Author] Jul 06, 2022 06:53
0
/A

Hi Soyo,

I still had doubts about zcl_register, so I looked in the SDK manual.

It reads:

The user registers the desired ports as well as clusters and attributes according to the specific product
features.
- Port registration:
af_endpoitRegister()
Register a port to specify the detailed function of the port (profileId, deviceId, port number, and supported
input clusters (server), output clusters (client).
- Cluster registration:
zcl_register()
Register the Clusters, Attributes related registration function and command callback processing functions
for a port.

So, I assume that "port" refers to the endpoint?


And in section 4.4.4.2 Data interaction using AF layer, it reads:

If not using zcl in sdk, there is no need to invoke zcl_register() and zcl_init().

Implementation method is as below.
1) Register the data reception processing callback function user_rx_handler and the send confirmation callback
function af_dataSentConfirm.
2) Invoke af_dataSend to send data.


Since in the SDK example, with AF_TEST_ENABLE,  zcl is not used for SAMPLE_TEST_ENDPOINT, there is no need to use zcl_register() for this endpoint. In zb_afTestcb.c, af_dataSend() function is used - as described in section 4.4.4.2 in the SDK manual.


So I think that if I am using zcl for all endpoints, I have to use zcl_register() for all of them.

What do you think?


minhlt8 Aug 26, 2023 14:17
0
/A

Hi Wes58,


Do you try your device (with multiple Lights) to join to Philips Hue Bridge? Can the Philips Hue Application show/handle multiple Lights? I also add 2nd endpoint but Philips Hue application only shows a light! :((

minhlt8 Aug 31, 2023 09:30
0
/A

I resolved!