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

problem with pstorage and bonding..........?

hai

i am working with nrf51822 and mbed.

in my application i have requested one page in flash for data store using pstorage.

        pstorage_module_param_t param;
        param.block_size  = 1024;
        param.block_count = 1;
        param.cb = cb_handler;
        retval = pstorage_register(&param, &base_handle);

then i stored a value using

 retval = pstorage_store(&base_handle, source_data, sizeof(source_data),0)

noe the starting address of my page is 0x0003f800 and the data is stored successfully.

image description

after that i have initialised bonding using security manager

 ble.init();
 ble.securityManager().init(enableBonding, requireMITM,   SecurityManager::IO_CAPS_DISPLAY_ONLY,PASS_KEY);
 ble.securityManager().onPasskeyDisplay(passkeyDisplayCallback);
 ble.securityManager().onSecuritySetupCompleted(securitySetupCompletedCallback);

and i bonded my phone with my nrf51822. the security bonding is successfully established. now the data i have stored is overwritten by the bonding information. that is the bonding information are stored at the beginning of my page.

image description

after that i have changed PSTORAGE_MAX_APPLICATIONS = 4 in pstorage_platform.h then requested 4 pages for data storage in flash

    pstorage_module_param_t param;
    param.block_size  = 1024;
    param.block_count = 4;
    param.cb = cb_handler;
    retval = pstorage_register(&param, &base_handle);

now the starting addresses are 0x000ec00 , 0x0003f00 ,0x0003f400 , 0x0003f800 respectively .

after that each time a new device is bonded, the bonding information are stored at the starting of each page.

so my question is can i allocate a separate memory block for bonding information so that i can prevent my data in flash from overwrite..?

edit:-

i have changed PSTORAGE_MAX_APPLICATIONS = 5 and requested only one block for my data.

    pstorage_module_param_t param;
    param.block_size  = 1024;
    param.block_count = 1;
    param.cb = cb_handler;
    retval = pstorage_register(&param, &base_handle);

and i stored my data at an offset of 0x220

retval = pstorage_store(&handle2, source_data, sizeof(source_data),0x220);

now the data is stored in flash with starting address 0x0003fa20. and the bonding information is again stored at the staring of my page.

image description

edit :-

i have tried bonding without pstorge but i cant bond more that two devices . and the bonding information is stored in same page . the staring address is 0x0003f800. the if a third device is bonded some times the system gets hang or the device is to be paired with each connection.

image description

Parents
  • i have requested 1 page first. that is shown in the attached images . first i stored my data in that page.that is shown in first image. but after bonding the data is overwritten by bonding information shown in second image.

    when four pages are requested. when one device bonded the data will store at the starting of first page just like the second image . after that if a second device is bonded that bonding information will store at the starting of second page and so on..

Reply
  • i have requested 1 page first. that is shown in the attached images . first i stored my data in that page.that is shown in first image. but after bonding the data is overwritten by bonding information shown in second image.

    when four pages are requested. when one device bonded the data will store at the starting of first page just like the second image . after that if a second device is bonded that bonding information will store at the starting of second page and so on..

Children
No Data
Related