This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problems with DLE on nRF52832DK, SDK12.2, S132v3

Hello Nordic developers,

I have been unsuccessfully trying to use the extended ATT_MTU / DLE sizes for increased throughput on a nRF52832DK board running the Nordic UART Service, using SDK 12.2.0 and S132v3.1.0. I am trying to increase data throughput on a UART over BLE connection with an Android device.

Of course, I followed the mini-guide, as well as these relevant posts on the forum - post 1, post 2, and post 3.

To summarize, here are the changes that I have made to the ble_peripheral/ble_app_uart example code:

  1. In main.c, changed FROM

    #define NRF_BLE_MAX_MTU_SIZE GATT_MTU_SIZE_DEFAULT
    TO
#define NRF_BLE_MAX_MTU_SIZE            247
  1. In ble_nus.h, ADDED

    #define NRF_BLE_MAX_MTU_SIZE 247

    and changed FROM

    #define BLE_NUS_MAX_DATA_LEN (GATT_MTU_SIZE_DEFAULT - 3)
    TO
    #define BLE_NUS_MAX_DATA_LEN (NRF_BLE_MAX_MTU_SIZE-3)
  2. In sdk_config.h, ADDED

    #ifndef NRF_BLE_GATT_MAX_MTU_SIZE
        #define NRF_BLE_GATT_MAX_MTU_SIZE 247
     #endif

    from ble_stack_handler_types.h

  3. In ble_stack_init.c, enable the softdevice, set DLE size and enable event extension:

    static void ble_stack_init(void)
    {
        uint32_t err_code;

        nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;

        // Initialize SoftDevice.
        SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);

        ble_enable_params_t ble_enable_params;
        err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT,
                                                    PERIPHERAL_LINK_COUNT,
                                                    &ble_enable_params);
        APP_ERROR_CHECK(err_code);

        //Check the ram settings against the used number of links
        CHECK_RAM_START_ADDR(CENTRAL_LINK_COUNT,PERIPHERAL_LINK_COUNT);

        // Enable BLE stack.
    #if (NRF_SD_BLE_API_VERSION == 3)
        ble_enable_params.gatt_enable_params.att_mtu = NRF_BLE_MAX_MTU_SIZE;
    #endif
        err_code = softdevice_enable(&ble_enable_params);
        APP_ERROR_CHECK(err_code);

        // Subscribe for BLE events.
        err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
        APP_ERROR_CHECK(err_code);

        /// ---- DLE stuf ----
    #if (NRF_SD_BLE_API_VERSION==3)
        //set DLE size
        ble_opt_t opt;
        opt.gap_opt.ext_len.rxtx_max_pdu_payload_size = NRF_BLE_MAX_MTU_SIZE+4;
        sd_ble_opt_set(BLE_GAP_OPT_EXT_LEN, &opt);

        //enable event extension
        opt.common_opt.conn_evt_ext.enable = 1;
        sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &opt);
        ///end of DLE stuff
    #endif
    }

I realize that all of this code is the same as the sample posted by Petter Myhre in post 2.

With my current setup, I am requesting MTU extension from the Android device as the connection is started. With the basic NUS example, I can receive 20B of data per packet, and when requesting MTU extension, receive 23B as the max MTU size (as expected).

Now, here comes the tricky part. When I make the above mentioned changes to code, I don't think the softdevice is initializing. On debugging, the device runs in loop between main() -> uart_init() -> buttons_led_init(&erase_bonds) -> ble_stack_init() -> main() ->........ And so I cannot seem to get it to work!

I suspect that I have not properly adjust the RAM for the soft device (and unsure of how to properly do so), or am making a mistake in changing the DLE settings with the softdevice. NOTE: I was also not able to run the sample code from post #2 and noticed the same issue.

Perhaps there is some way of initializing the soft device with the default ATT_MTU settings, and then modify the softdevice settings dynamically post-connection?

Any suggestions with this would be great!

Related