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

nRF51 persistant storage of characteristics data

What is the best way to store the values of my attribute data? With my current code, from the tutorials, the read, write and notify works fine. But I need to store the data in a more persistant way so the data is availble after a restart.

Have looked at some examples an how to use the PManager and Flash Manager but I don´t understand how to use it with my attribute data.

Kindly regards, Johan Dahlgren

Parents
  • Hi Johan,

    There are typically two ways:

    1. You will use some prepared library/module/filesystem like pstorage/fstorage/FDS. Then you need to understand how it works (= how it abstracts storage in terms of files or objects which you need to create/store/update/delete) and map your data on top of that. This is usual way but then we are done here, you will need to go deeper into SDK examples which are using these modules, their documentation in nRF5 SDK package on Nordic Infocenter and if you have specific questions to some of them then we can address them (but note that most of questions were already asked and answered on this forum so search first). This way should be relatively easy to implement and maintain/test (you have something done and used by many smart people before you) but maybe harder to understand.
    2. You prefer to build and manage your own simple "file system". Then you should be fine with understanding that you need to (typically hardcoded) reserve one or more flash pages and then you can use SD API (if Soft Device is running at that time) to write any data to any memory address and erase any page. "Business" logic on top of it is on you (= which data you store where, how much space you need to allocate, when to erase whole page and where to write next "record"). It is easy to understand but harder to design the solution, implement and test.

    In the end whatever way you choose your application need to know when you want to store the values (probably any time they change) and when you load them (probably only at restart). If you have hard requirements on atomicity/tear-safe character then you might need to even maintain two redundant instances of the same storage.

  • Well there is no event which will tell you "the data were read for you":) All storage systems work the same way as your hard drive on your PC: they are able to store "named" objects (blobs of data) which have either very abstracted names or just addresses. But you are responsible to store them and read them whenever you want and you are responsible to know what name means what;) So during your boot you need to init storage system and ask it to read certain "objects" which you then put as GATT handle values through normal SD BLE GATT API calls. I will try to look up which of SDK examples shows the closest sequence to your use case, which file/storage system you decided to use?:)

Reply
  • Well there is no event which will tell you "the data were read for you":) All storage systems work the same way as your hard drive on your PC: they are able to store "named" objects (blobs of data) which have either very abstracted names or just addresses. But you are responsible to store them and read them whenever you want and you are responsible to know what name means what;) So during your boot you need to init storage system and ask it to read certain "objects" which you then put as GATT handle values through normal SD BLE GATT API calls. I will try to look up which of SDK examples shows the closest sequence to your use case, which file/storage system you decided to use?:)

Children
No Data
Related