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

Problem with BLE payload size larger than 23

I've tried to use UART samples to test large BLE payload size with SDK 12 and SoftDevice 3.0

What I did is modifying UART central and peripheral code:

  • In both project c/c++ options,

#define NRF_BLE_MAX_MTU_SIZE to a value larger than GATT_MTU_SIZE_DEFAULT

  • For UART peripheral, in ble_nus.h,

#define BLE_NUS_MAX_DATA_LEN (NRF_BLE_MAX_MTU_SIZE - 3); originally it is (GATT_MTU_SIZE_DEFAULT - 3). For UART central, it is done in ble_nus_c.h

  • In both UART central and peripheral, add the following code in ble_stack_init() after calling softdevice_enable()

    #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);

    #endif

This is based on this post.

  • Change app_ram_base and ram size accordingly.

The problem I am facing is: for peripheral node, I can send string with more than 20 chars; but the central node seems to receive them int two packets; for the central node, sending string with more than 20 chars will make it hang.

After studying the two app, peripheral code has functions rx_char_add() and tx_char_add() whereby tx and rx max_len are set to BLE_NUS_MAX_RX_CHAR_LEN. I cannot find anything similar in central code. I can only guess that may be the reason central code hangs.

Any comments?

Parents
  • You also have to initiate the ATT MTU Exchange procedure first.

    This is done by calling sd_ble_gattc_exchange_mtu_request(conn_handle, NRF_BLE_MAX_MTU_SIZE))

    and generates an BLE_GATTC_EVT_EXCHANGE_MTU_RSP once the peer responds.

    If the peer is initiating, you will only receive a BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST and need to respond with sd_ble_gatts_exchange_mtu_reply(conn_handle, NRF_BLE_MAX_MTU_SIZE).

    Note: The stack will use the smallest of the two proposed numbers. If you send 247, but the peer responds with 27, then you are stuck on 27.

Reply
  • You also have to initiate the ATT MTU Exchange procedure first.

    This is done by calling sd_ble_gattc_exchange_mtu_request(conn_handle, NRF_BLE_MAX_MTU_SIZE))

    and generates an BLE_GATTC_EVT_EXCHANGE_MTU_RSP once the peer responds.

    If the peer is initiating, you will only receive a BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST and need to respond with sd_ble_gatts_exchange_mtu_reply(conn_handle, NRF_BLE_MAX_MTU_SIZE).

    Note: The stack will use the smallest of the two proposed numbers. If you send 247, but the peer responds with 27, then you are stuck on 27.

Children
No Data
Related