how to work with persistence in wiced smart

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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.



0 Likes
1 Solution
Anonymous
Not applicable

Hello m_stanbro,

Sorry for the late reply.

We are checking with the firmware guys.

These are other discussions you might find helpful.

Does NVRAM keep state after power is removed? (BCM20732S)

bleprofile_ReadNVRAM returns different value

Re: ble_profile_WriteNVRAM all work but bleprofile_ReadNVRAM all fail.

What does returning true in the "on_write" function do?

[JT] - This is what we need to check.

Are my characteristics able to be made persistent without the need for a WriteNVRam call?

Is it okay to make the ReadNVRam calls in the "create" function under the "// ToDo: Do your initialization on app startup" comment?

[JT] - This is OK to do.

Again, we will get back to you on the on-write function.

Thanks

JT

View solution in original post

0 Likes
6 Replies
Anonymous
Not applicable

Hello m_stanbro,

Let me know if this BLOG helps you: BCM20732 Memory Map Architecture

Thanks,

JT

0 Likes
Anonymous
Not applicable

Hello m_stanbro,

This is the better link:nvram: number of locations to write to

Thanks

JT

0 Likes
Anonymous
Not applicable

Okay, so this helps me to understand that the VsId's do work like I expected, and that they write in 32byte pages with 1024 total NVM bytes available. Great. This answers my first question about how the VsIds work.

I am still unclear about how to work with the persistence functions. What does returning true in the "on_write" function do? Are my characteristics able to be made persistent without the need for a WriteNVRam call? Is it okay to make the ReadNVRam calls in the "create" function under the "// ToDo: Do your initialization on app startup" comment? This seems like the most logical place but for some reason it is causing me problems.

0 Likes
Anonymous
Not applicable

Any word guys?

0 Likes
Anonymous
Not applicable

Hopefully Monday

Thanks

JT

0 Likes
Anonymous
Not applicable

Hello m_stanbro,

Sorry for the late reply.

We are checking with the firmware guys.

These are other discussions you might find helpful.

Does NVRAM keep state after power is removed? (BCM20732S)

bleprofile_ReadNVRAM returns different value

Re: ble_profile_WriteNVRAM all work but bleprofile_ReadNVRAM all fail.

What does returning true in the "on_write" function do?

[JT] - This is what we need to check.

Are my characteristics able to be made persistent without the need for a WriteNVRam call?

Is it okay to make the ReadNVRam calls in the "create" function under the "// ToDo: Do your initialization on app startup" comment?

[JT] - This is OK to do.

Again, we will get back to you on the on-write function.

Thanks

JT

0 Likes