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

Migrate the Persistent storage Manager to SDK MESH 4.0.0

I'm migrating my code from the MESH SDK 3.1.0 to 4.0.0
I'm using the following function to initialize a persistance storage controller

uint32_t pers_data_init(void)
{
  /* Adding custom data to flash for persistent storage */
  // 1) Flash manager is already initialized
  // 2) Add a new flash manager instance. NB: should not overlap (in region) the instance used by mesh.

  flash_manager_config_t custom_data_manager_config;
  custom_data_manager_config.write_complete_cb = write_complete_cb;
  custom_data_manager_config.invalidate_complete_cb = write_invalidate_cb;
  custom_data_manager_config.remove_complete_cb = remove_completed_cb;
  custom_data_manager_config.min_available_space = WORD_SIZE;

  // The new instance of flash manager should use an unused region of flash:
  custom_data_manager_config.p_area = (const flash_manager_page_t *)(((const uint8_t *)dsm_flash_area_get()) - (ACCESS_FLASH_PAGE_COUNT * PAGE_SIZE) - (NET_FLASH_PAGE_COUNT * PAGE_SIZE));

  custom_data_manager_config.page_count = APPLICATION_DATA_FLASH_PAGE_COUNT;

  uint32_t ret_code = flash_manager_add(&m_application_data_flash_manager, &custom_data_manager_config);

  if (NRF_SUCCESS != ret_code)
  {
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Flash error: no memory\n", ret_code);
  }

  return ret_code;
}

The new SDK doesn't use the ACCESS_FLASH_PAGE_COUNT and the NET_FLASH_PAGE_COUNT Macros.
It doesn't support morevoer the dsm_flash_area_get() function.

How can i manage my persistent data with the new SDK?

Thanks

Related