This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

zb_nvram_write_dataset writing application data zigbee

Is there any code example for storing application data using the zboss stack? I have only found this:

There are two predefined dataset IDs for a user application: ZB_NVRAM_APP_DATA1 and ZB_NVRAM_APP_DATA2. It's up to the application to decide what data to store in NVRAM. However, the total data size (all datasets) stored in the NVRAM storage should be less than one virtual page size. To start using NVRAM in the application, the following steps should be done in the application:

@li Define an application specific data structure to be stored in the NVRAM.
@li Register callbacks to write, read data and get size of data to store.
@li Once write application data callback is called, it gets a flash page number and a page offset value to store data. The callback must write data using an API zb_osif_nvram_write(). The data size must be the same as returned by a get data size callback.
@li Once get data size callback is called, it must return the size of the data being stored.
@li Once the read application data callback is called, it gets a flash page number, a page offset value, and a payload size of data to read. The callback reads the data using an API zb_osif_nvram_read() with the provided addressing information as input parameters.
@li At runtime trigger storing data to NVRAM with a call to zb_nvram_write_dataset().

I have not been able to successfully store data. Any code snippet? Could you help me with this?

thx

  • Hi Armand.

    Could you take a look here, at the bottom of this page is some examples.

    Best regards,

    Andreas

  • Hi Andreas,

    Thanks for pointing to the example. Somehow there is some doubts casting on my head:

    1. I am supposing that when the application code calls zb_nvram_write_dataset(ZB_NVRAM_APP_DATA1) the 

    write cb read_thc_app_data_cb is called back and the data is stored through zb_osif_nvram_write(page, pos, (zb_uint8_t*)&dssizeof(ds)). Is that correct?

    2. Now it is required to read the data back. I have defined the read_thc_app_data_cb. How is that function triggered? I cannot see any zb_nvram_read_dataset function declared.

    3. Finally. Let suppose I would like to read the data after a power cycle. Relevant info required to read the data from nvram will not be available on ram variables(page, pos) as they have been reset. Are we missing a zb_nvram_read_dataset that will will trigger the read_thc_app_data_cb and pass the correct (page, pos) data?

    Thanks

  • Hi.

    Do you really need to use the ZBOSS stack? If yes I will give you more details.

    But if you don't really need to use the ZBOSS stack to write to flash, I will recommend that you use the FDS module.

    It is an working example found in the multiprotocol example for the door lock (examples\multiprotocol\ble_zigbee\ble_zigbee_dynamic_door_lock_nus\) you can take a look at.

    And it is more documented than ZB_NVRAM:

    FDS moduleAPI reference, Usage.

    Best regards,

    Andreas

  • Thanks Andreas. Yes I would like to be able to use the ZBOSS stack as I am planning to use the nRF52811 device. I presume that future SDK releases will not bring the option of multiprotocol application to this device due to memory restrictions.

    Is is possible to use FDS module while running ZBOSS stack? Is there any risk of collision or data storage misshandling?

    Anyway I would also like to know how to read the nvram data using zb library. Is the current SDK version missing a  zb_nvram_read_dataset function?

  • Hi again.

    Ignacio said:
    I presume that future SDK releases will not bring the option of multiprotocol application to this device due to memory restrictions.

    I think it wouldn't be feasible to use multiprotocol in nRF52811 due to the FLASH and RAM size yes, but you can use FDS without using the SoftDevice.

    An example of FDS is found in <InstallFolder>\examples\peripheral\flash_fds

    FDS uses fstorage at the base, and neither require much code. The part that takes most space would be that you have to reserve two flash pages in order to use it.

    Ignacio said:
    Anyway I would also like to know how to read the nvram data using zb library. Is the current SDK version missing a  zb_nvram_read_dataset function?

     There is no zb_nvram_read_dataset function, reading is done by zb_osif_nvram_read() in the read_thc_app_data_cb().

    Best regards,

    Andreas

Related