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?