Hi,
I'm using nRF5_SDK_13.0 on nRF52840 based on ble_app_hrs_rscs_relay example. I use it to connect a bluetooth 4.0 device and it's ok now. Also I have a bluetooth 5.0 device which use long MTU packet. So I change the MTU to use long packet, but I found it returns 0x13 error when call sd_ble_gap_data_length_update on the data_length_update() function.Then it would reset. I do it as follow:
-
Change NRF_BLE_GATT_MAX_MTU_SIZE to 251 in the sdk_config.h and then configure the maximum ATT MTU in the ble_stack_init function.
-
Change the IRM1 size as the softdevice_enable function said.
3.Add initialization code in the gatt_init function:
static void data_len_ext_set(bool status){
uint8_t data_length = status ? (247 + LL_HEADER_LEN) : (23 + LL_HEADER_LEN);
(void) nrf_ble_gatt_data_length_set(&m_gatt, BLE_CONN_HANDLE_INVALID, data_length);}
static void gatt_mtu_set(uint16_t att_mtu){
ret_code_t err_code;
err_code = nrf_ble_gatt_att_mtu_periph_set(&m_gatt, att_mtu);
APP_ERROR_CHECK(err_code);
err_code = nrf_ble_gatt_att_mtu_central_set(&m_gatt, att_mtu);
APP_ERROR_CHECK(err_code);}
static void gatt_init(void){
ret_code_t err_code = nrf_ble_gatt_init(&m_gatt, NULL);
APP_ERROR_CHECK(err_code); gatt_mtu_set(NRF_BLE_GATT_MAX_MTU_SIZE);
data_len_ext_set(true);
preferred_phy_set(BLE_GAP_PHY_1MBPS);}
After that the application would run and then it could scan the device to connect. Is there anyother need to do? Thanks