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

Fstorage Queue Runs Full when Bluetooth Connected

I'm trying to store some values with fstorage. The store operations seem to be queued successfully, but never executed. I currently have this to test the behavior:

FS_REGISTER_CFG(fs_config_t fs_config) =
{
    .callback  = fs_evt_handler, // Function for event callbacks.
    .num_pages = 1,      // Number of physical flash pages required.
    .priority  = 0xFE            // Priority for flash usage.
};

// ...

static void fs_evt_handler(fs_evt_t const * const evt, fs_ret_t result)
{
    nrf_drv_gpiote_out_toggle(LED_PIN_3);
    if (result != FS_SUCCESS)
    {
        APP_ERROR_HANDLER(result);
    }
}

// ...

fs_ret_t ret = fs_init();
if (ret != FS_SUCCESS)
{
    APP_ERROR_HANDLER(ret);
}

// ...

const uint32_t * storage_loc = fs_config.p_start_addr;
fs_ret_t ret;
ret = fs_erase(&fs_config, storage_loc, 1, NULL);
if (ret != FS_SUCCESS)
{
    APP_ERROR_HANDLER(ret);
}
nrf_drv_gpiote_out_toggle(LED_PIN_1);
ret = fs_store(&fs_config, storage_loc, (uint32_t *)data, 1, NULL);
if (ret != FS_SUCCESS)
{
    APP_ERROR_HANDLER(ret);
}
nrf_drv_gpiote_out_toggle(LED_PIN_2);

Both fs_erase and fs_store return FS_SUCCESS, but the fs_evt_handler is never called.

Original question: I have an application that records sensor measurements as soon as a characteristic is set via BLE. I'm using fstorage to save these values. I noticed that the fstorage queue runs full when I stay connected via BLE after setting the characteristic. I tried fiddling with the FS_QUEUE_SIZE and FS_MAX_WRITE_SIZE_WORDS parameters, but the problem persists. I don't want to assume that the user of the device disconnects after any given period, so my question is: is there a way to support writes while BLE is connected? (Maybe fiddling with the BLE connection parameters?)

Related