6 Replies Latest reply on Oct 31, 2014 2:57 PM by jota_1939431

    how to work with persistence in wiced smart

      I have two characteristics which I would like to store in persistent memory. I am a little unclear on how this works. When data is written to the wiced smart the wizard generated "on_write_to" functions are called. In here I am passed a pointer to the string of data that was written in the attrPtr. So where the confusion comes in is writing a recalling from persistent memory at this point.


      My first confusion is with the idea of VsID. Under the Using NVRAM section of the Developing an Application for the BCM20732 it says that an application can specify any VsID between 0x10 and 0x6F with a maximum read or write block size of 255 bytes. My interpretation of this is that the VsID is an abstraction which is managed by some underlying framework that should allow me to write a chunk of data at 0x10 which is up to 255bytes, and then write another chunk of data to 0x11 which is also 255bytes without overwriting any of the data that was stored in 0x10. Is this correct? Or do I only have 0x6F - 0x10 = 0x5F bytes of total available contiguous non-volatile memory?


      My second confusion is the wizard generated comment above the "on_write_to" function which states that if any persistent memory is changed I should return TRUE. So does this mean that if I make a bleprofile_WriteNVRAM() function call that I need to return a true flag? Or does this imply that I can return a true flag and all the persistence for my characteristics will be handled for me behind the scenes somehow?


      Basically I am puzzled because in my "on_write_to" functions I am currently making a bleprofile_WriteNVRAM() function call, returning a TRUE flag to indicate that something has been changed in the persistent memory, and then on start-up during my "my_device_create" function making a bleprofile_ReadNVRAM() function call and storing that data into my characteristic using a "store_in_db_" function call. For some reason my wiced smart will never begin advertising. When I comment out the ReadNVRAM and store_in_db_ function calls everything works properly. So clearly I am missing something here.


      Am I maybe trying to read/store at the wrong point during startup? Or am I improperly working with the persistence feature?


      Thanks for any info in this regard.