Problem with fds module dont execute events after BLE connection SDK 16.

Hi everyone, i have working for a few days trying to implement the fds module, i have followed the "flash_fds" example but i am struggling a lot trying to make this work. Basically i want to have a program that store parameters that persist on restarts like the Advertising Name of the device, i have a data struct like the next:

typedef struct {
    char device_name[SETTINGS_DEVICE_NAME_MAX_SIZE];
    uint8_t led_color; 
} device_settings_t;

I init the settings with default settings and if the record doesn't exist it write it,and if exist i read it and update the settings, and i have a static buffer where i copy the settings and pass to the fds for making the update, this is the initialization of the settings:

device_settings_t g_device_settings __attribute__ ((aligned(4))) = {
    .device_name = DEFAULT_NAME,
    .led_color = DEFAULT_LED_COLOR
};

static device_settings_t settings_update_buffer; // Buffer for flash update


On the initialization eveything goes right, on the first boot the fds module write on flash the data struct, on the second boot it just read the flash and update the settings.

I am using the BLE nus service to send commands, and when i send a command for making a change on the device settings and update the record with "fds_record_update", i get the NRF_SUCCESS return code, but the fds event never execute, so when i restart the device i still getting the same settings of the first boot. I am thinking it some type of problem with BLE because when i first initialize the device the fds events execute without problem, but when i connect to the device and send the command over BLE for making a change on the settings and update it, it stop working. 

At the first time i think that the problem was the record_update command, so for saving the new settings i run a routine that delete the record, and write a new one with the commands "fds_record_delele" and "fds_record_write", but the same happen, the event of the record delete never execute even if the command return NRF_SUCCESS.

With SDK v12.3.0 i didnt have any problems at all using flash storage while a BLE connection is on, but now that i migrate to sdk v16.0.0 for a future compatibility with nrf52833 it stop working.

Please i need help about this, if someone have been through the same and solve it please post your solution.

  • Update: It seems clearly that is a conflict when the BLE is initialized, in the main routine of the program i first initialize the FDS module and then BLE module, and the fds initialization execute without problem, if i change the order and in first place i init the BLE, and then the FDS, the FDS initialization dont execute the event of write or update.

  • Update2: If i add the line "nrf_sdh_disable_request();" right before "fds_record_update", the update performs without problems, but the BLE connection shutdown, and then i have to restart the device to re-enable the BLE and confirm that the "device name" settings was changed with success. So what can i do? I dont want that my program have to disable softdevice and restart everytime i wanna storage some data on flash. Is this a known issue of SDK v16.0.0?  Maybe is there a way to dispatch this fds event manually like i did with SDK v12.3.0 with the SoftDevice system event handler?

  • Update3: The problem is directly related to enabling the soft device handling, this cause that fds events dont execute. I just start the sdh without advertising using the command nrf_sdh_enable_request();, and then initialize the fds and the events dont execute. Also trying initializing the ble_stack, (nrf_sdh_ble_enable(&ram_start);) and still dont work. Can annyone have an idea why FDS events only execute when SDH is not enable? Is there another way to store data on flash without FDS? I am ussing "NRF_SDH_DISPATCH_MODEL 0" i dont really know the correct way to use polling or appsh. Also in sdk_config.h i have #define FDS_BACKEND 2, so it should only work with SDH enable right? so it dont have much sense that only work with sdh disabled

  • Hi there,

    What FDS backend are you using?

    regards

    Jared 

Related