How to define the free address in flash using ble mesh?

Hi guys,

I am using the nRF52832 board on which I run the LPN example from BLE Mesh directory. I put there the code for measuring the temperature and now I want to save that value in the flash. I am using the SoftDevice APIs for erasing and writing something in flash, but every time I get the same error: 

00> <t:     153193>, app_error_weak.c,  115, Mesh error 16 at 0x00000000 (:0) which suggests that I defined the bad memory address. Now I am defining the address in this way: 

uint32_t pg_size_counter = NRF_FICR->CODEPAGESIZE;
uint32_t pg_num_counter = NRF_FICR->CODESIZE-1;
uint32_t * pointer_counter = (uint32_t *)(pg_size_counter * pg_num_counter);

Can you please tell me is this the correct way of defining the address, or in Mesh SDK it works on quite different way.

Thank you very much in advance!

Best regards,

Adnan.

  • Hi Aduka, 

    If you are using mesh SDK we would suggest you to use the flash manager library instead of using the softdevice flash API directly as it may mess up the flash manager library. 

    Please have a look at the Enocean example we have in the nRF Mesh SDK as an example on how to store application data into flash. In the example we store the device address and the enocean pair key into m_enocean_switch_file. 


Related