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

Large data transfer over ble.

Hi,

I would like to have a system such as follows:

  • Taking sensor data storing it locally till around 100 samples (Once per second)
  • Log this data to the SD with a time stamp
  • Then storing this data to an external SD card. (Utilising the fatfs example code in the SDK) Around  2 Mbytes
  • I then want a mobile device to request this data.

What therefore, is the best way of transferring the data from the SD card to BLE to be picked up by the mobile application.

Do I need to set up a GATT connection and wait on a notification change that I set in the Nordic board?

If so is there an example of this or a good starting point.

Would this post be a good starting point? : https://devzone.nordicsemi.com/f/nordic-q-a/553/dealing-large-data-packet-s-through-ble

If so what example is good to work from. Thanks

  • Hi Simon,

    Cheers for that, it makes perfect sense. So I have now changed, my ble_evt_handler with the disconnected case to:

    case BLE_GAP_EVT_DISCONNECTED:
                err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
                err_code = ble_advertising_restart_without_whitelist(&advertising_mod);
                    if (err_code != NRF_ERROR_INVALID_STATE)
                    {
                        APP_ERROR_CHECK(err_code);
                    }
                    GATT_CONNECTED = false;//Enable the live advertising
                break;

    This is similar to the UART example you suggested. However, I changed the parameter to advertising_mod from m_advertising. This was due to a compile error stating it was undefined and recommending advertising_mod.

    This still causes a fatal error on disconnect. This error comes from the uarte_evt_handler going to the fifo m_event_handler(&app_uart_event);

    This happens a few seconds after I press disconnect on the app.

    I have also tried using advertising_start();

    That functionality looks like below:

    static void advertising_start(void)
    {
        ret_code_t err_code;
    
        err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
        APP_ERROR_CHECK(err_code);
    }
    

    However, this does also not work.

  • Do you have any error code to go on this time around? I'm guessing that the UART events aren't handled properly since your project isn't using UART originally, but it's hard to say what exactly is going wrong without any error code or log.

    Best regards,

    Simon

  • I get an error code on sd_ble_gap_disconnect

    err_code 3002. Is there somewhere I can look up these error codes?

  • I also sometimes get an error from m_event_handler(&app_uart_event); within a uart event handler in app_uart_fifo.c. In the case of NRF_DRV_UART_EVT_TX_DONE.  This error code is 1.

    I am thinking this is due to data being sent to the uart and it not being processed until the main loop is restarted.

    This error run from the:

    • main: advertising_mod: err_code = sd_ble_gap_adv_stop(m_adv_handle);
    • ble_gap.h: SVCALL(SD_BLE_GAP_ADV_STOP, uint32_t, sd_ble_gap_adv_stop(uint8_t adv_handle));
    • nrfx_uarte.c: uarte_irq_handler : p_cb->handler(&event, p_cb->p_context); //This is aborting the transfer
    • nrfx_uarte.c: uarte_evt_handler : m_handlers[inst_idx](&event, m_contexts[inst_idx]);
    • app_uart_fifo.c : uart_event_handler: m_event_handler(&app_uart_event)
    • Then app error handler_bare

    I do however get some data out before this error runs:

  • Hi Thomas

    The error codes can be looked up using ble_err.h and nrf_error.h. Error 0x3002 is BLE_ERROR_INVALID_CONN_HANDLE and defined as being an invalid connect handle. NRF_ERROR_STK_BASE_NUM is defined as 0x3000 in nrf_error.h.

    Have you edited the ble_app_pwr_profiling example to be connectable or is it just advertising and not connecting to a central? I think it would be easier to avoid these connection errors if you based your project in an example that is already using connectable advertising by default.

    Best regards,

    Simon

Related