Large data transfer over ble.


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? :

If so what example is good to work from. Thanks

  • Hi Simon,

    I've used my project as I feel it is more complex and, too a long time to set up.

    However, I have just debugged my program stepping through the main when it gets to ble_stack_init.

    It runs the line of code nrf_sdh_ble_enable. Running through this gives

    NRF_LOG_WARNING("Insufficient RAM allocated for the SoftDevice.");
            NRF_LOG_WARNING("Change the RAM start location from 0x%x to 0x%x.",
                            app_ram_start_link, *p_app_ram_start);
            NRF_LOG_WARNING("Maximum RAM size for application is 0x%x.",
                            ram_end_address_get() - (*p_app_ram_start));

    Which I presume means the ram allocated is not large enough.

    How do I resolve this?



    Edit note : I am using Segger error code is 0x00000004

  • Hi

    In this case, SEGGER should give you an indication of what you should allocate your RAM to in the error message. To see how you do change the RAM and Flash memory start addresses and sizes, please check out this guide on the matter.

    Best regards,


  • Thanks SImon,

    I've resolved that issue now thanks.

    Another question. As my project previously advertises data how do I add the connect-ability functionality too this?

    This is my present advertisement init routine.

    static void live_advertising_init(void)
        uint32_t      err_code;
        ble_advdata_t advdata;
        uint8_t       flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
        ble_advdata_manuf_data_t manuf_specific_data;
        manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER; = (uint8_t *) m_beacon_info;   = APP_BEACON_INFO_LENGTH;
        // Build and set advertising data.
        memset(&advdata, 0, sizeof(advdata));
        //Advertisement information
        advdata.name_type             = BLE_ADVDATA_NO_NAME;
        advdata.flags                 = flags;
        advdata.p_manuf_specific_data = &manuf_specific_data;
        /*Old setup
        advdata.name_type             = BLE_ADVDATA_NO_NAME;
        advdata.flags                 = flags;
        advdata.p_manuf_specific_data = &manuf_specific_data;
        // Initialize advertising parameters (used when starting advertising).
        memset(&m_adv_params, 0, sizeof(m_adv_params));
        m_adv_params.p_peer_addr     = NULL;    // Undirected advertisement.
        m_adv_params.filter_policy   = BLE_GAP_ADV_FP_ANY;
        m_adv_params.interval        = NON_CONNECTABLE_ADV_INTERVAL;
        m_adv_params.duration        = 0;       // Never time out.
        err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
        err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);

    I want it so when I am connected I can connect to the Gatt services and then notifications after that.

    The advertising_init in the GATT example is

    void advertising_init(void)
        ret_code_t             err_code;
        ble_advertising_init_t init;
        memset(&init, 0, sizeof(init));
        init.advdata.name_type            = BLE_ADVDATA_FULL_NAME;
        init.advdata.include_appearance   = true;
        init.advdata.flags                = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
        init.config.ble_adv_fast_enabled  = true;
        init.config.ble_adv_fast_interval = ADV_INTERVAL;
        init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;
        init.evt_handler = on_adv_evt;
        err_code = ble_advertising_init(&m_advertising, &init);
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);

    But, when I make the basic change of making the name from BLE_ADVDATA_NO_NAME to BLE_ADVDATA_FULL_NAME it no longer advertises. As an error is thrown on ble_advdata_encode.

    I might therefore, start again with the GATT example and import my code over. But the underlying question is how do I have a dumb advertisement which broadcasts but, is connectable to the Gatt?

  • Hi

    You need to change the advertising params to make the device connectable and (usually) scannable by changing the to something like BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED.

    You can check out the ble_advertising_init function in ble_advertising.c to see the default advertising parameters used in most of the connectable examples in the SDK. Note that the gatts example uses the app_adv.c file to set up the advertising (where it again calls ble_advertising_init).

    Best regards,




    err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);

    To pass an error code 12.

    Also where is a look up table for error codes?

    Also is it possible to have a ble advert e.g. something that changes every second with data in it, whilst being connectable for other features?