Topic

FAQ
Login Register
Zigbee - save/restore attributes
Jul 04, 2022 09:41

/

A

/A

I am using modified sampleLight example. I am using TLSR8258.

To the example I have added another light endpoint - so I have to endpoints 1 and 2.

I have modified the simpleSwitch example to add another endpoint as well.

So I can turn On/Off each of the light with buttons on "simpleSwitch".


The question is, how to save/restore the status of each of the lights?

There is a function to save attribute nv_sts_t zcl_onOffAttr_save(void), which uses the following function to read saved data:

st = nv_flashReadNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_ON_OFF, sizeof(zcl_nv_onOff_t), (u8*)&zcl_nv_onOff);

And to save data:

st = nv_flashWriteNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_ON_OFF, sizeof(zcl_nv_onOff_t), (u8*)&zcl_nv_onOff);


I have g_zcl_onOffAttrs1 for light number 1 and g_zcl_onOffAttrs2 for light number 2.

I can't see anything in those function that would allow me to save status for both lights.

So, how can I save/restore the status of both lights?

Should I add another item (for example NV_ITEM_ZCL_ON_OFF2)  to typedef enum{{ }nv_item_t in drv_nv.h?


2 replies
TL_Soyo Jul 04, 2022 15:00
0
/A

Hi,

    You can add new another Item as you said,and you also can save 2 endpionts' onoff1 ,onoff2 data into one buffer,then save to one Item,like below example.


u8 data[4];

data[0] = onoff_1;

data[2] = onoff_2;

st =nv_flashWriteNew(1, NV_MODULE_ZCL, NV_ITEM_ZCL_ON_OFF, sizeof(data), (u8*)data);

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

Hi Soyo,

Thanks for your help.

Your solution seems better.