NRF_ERROR_BUSY from characteristics discovery due to MTU exchange

Rick1997 gravatar image

asked 2017-06-19 14:55:58 +0100

updated 2017-06-21 10:59:01 +0100

My problem seems to be related to this unsolved question.

I've making a central application to connect to my peripheral but I'm having a hard time getting the service discovery to work. My central code is based on the central ble_app_uart_c. Here is a log of what happens:

 0> APP:INFO:ADVPKT: ed:60:1c:91:f4:38 -62dBm Bluetooth demo
 0> APP:INFO:Name match send connect_request.
 0> APP:INFO:Connected
 0> BLE_DB_DISC:DEBUG:Starting discovery of service with UUID 0xc001 on connection handle 0x0.
 0> APP:INFO:ERRdbds:0
 0> nrf_ble_gatt:DEBUG:Requesting to update ATT MTU to 158 bytes on connection 0x0.
 0> nrf_ble_gatt:DEBUG:sd_ble_gattc_exchange_mtu_request() on connection 0x0 returned busy, will retry.
 0> nrf_ble_gatt:DEBUG:Requesting to update data length to 162 on connection 0x0.
 0> nrf_ble_gatt:DEBUG:Requesting to update ATT MTU to 158 bytes on connection 0x0 (retry).
 0> BLE_DB_DISC:DEBUG:Found service UUID 0xc001.
 0> APP:INFO:db_disc_handler
 0> APP:INFO:EVT:1 UUID:11 Type:0
 0> nrf_ble_gatt:DEBUG:Data length updated to 27 on connection 0x0.
 0> nrf_ble_gatt:DEBUG:max_rx_octets: 27
 0> nrf_ble_gatt:DEBUG:max_tx_octets: 27
 0> nrf_ble_gatt:DEBUG:max_rx_time: 328
 0> nrf_ble_gatt:DEBUG:max_tx_time: 328
 0> nrf_ble_gatt:DEBUG:ATT MTU updated to 23 bytes on connection 0x0 (response).
 0> APP:INFO:ATT MTU exchange set to 23

What happens is that db_disc_handler() gets called which in turn calls the handler for my service, similar to what happens in ble_nus_c.h. The event that is passed is BLE_DB_DISCOVERY_ERROR and the error code in p_evt->params.err_code is 17 (NRF_ERROR_BUSY). The last thing logged before db_disc_handler is 'Found service UUID...'. Digging through the code of the discovery module I concluded the error must come from sd_ble_gattc_characteristics_discover().

I noticed some MTU exchange stuff in the log so I started messing with the MTU size in ble_stack_init(). I commented out the parts that set the ATT MTU size and updated the linker file. Now the service discovery works like it should but I get multiple errors like the one below here so I don't think this is a proper solution.

nrf_ble_gatt:ERROR:sd_ble_gattc_exchange_mtu_request() returned unexpected value 0x7.

I'm not sure what to change in order to get everything to work. I don't really care about the MTU size as I'm only making a demo and not dealing with large amounts of data. I included a zip of my code below. It's meant for the nRF52832 Dev Kit (PCA10040) using softdevice S130 and SDK 13.0.

Edit: Changing NRF_BLE_GATT_MAX_MTU_SIZE in sdk_config.h to 23 for both the peripheral and central has solve my issue as there is no MTU exchange anymore.

edit retag flag offensive close delete report spam

1 answer

Sort by » oldest newest most voted
Kristin gravatar image

answered 2017-06-19 15:41:32 +0100

This case deals with a similar problem, could you have a look at it and check if the latest update regarding configuration of the softdevice work in your case as well?

edit flag offensive delete publish link more


This didn't change anything for me, still the same issue.

Rick ( 2017-06-19 17:24:38 +0100 )editconvert to answer

Error code 0x7 is "Invalid parameter": Invalid Client RX MTU size supplied.

What is the client_rx_mtu value supplied to sd_ble_gattc_exchange_mtu_request()?

Kristin ( 2017-06-20 14:58:27 +0100 )editconvert to answer

I use the GATT module so I'm not calling that function myself. I'm using the NRF_BLE_GATT_MAX_MTU_SIZE macro which is set to 158 for the central side and 23 on the peripheral. The central code has a call to nrf_ble_gatt_att_mtu_central_set with the above mentioned macro after initializing the GATT module. I also set the MTU in ble_stack_init().

Changing the macro on the peripheral side to 158 doesn't change anything. Trying to configure the MTU in ble_statck_init() for the peripheral gives error code 0x7.

Edit: Changing both to 23 seems to fix my issue as there is no MTU exchange happening now. Strange that I couldn't get it to work with 158.

Rick ( 2017-06-20 15:27:20 +0100 )editconvert to answer

I just tested the bare ble_app_uarrt_c example with ble_app_uart, and it seems to work fine out-of-the box. Could you test unmodified versions of those examples?

Kristin ( 2017-06-21 13:20:53 +0100 )editconvert to answer

I tested the HRS example which works fine. I'm afraid I do not have more time to port the uart app to work on my custom board. I will just keep using 23 as the MTU size. Thanks for the help.

Rick ( 2017-06-21 17:23:02 +0100 )editconvert to answer

Hi, I'm facing similar error. Connection interval is 10ms. MTU size at the central and peripheral to be 23. event length is 8*1.25 = 10ms. data size is 20..Can someone help me!

Nivetha ( 2017-08-24 14:12:45 +0100 )editconvert to answer

Handled question from @nivethahere.

run_ar ( 2017-12-08 10:49:37 +0100 )editconvert to answer

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

User menu

    or sign up

Recent questions

Question Tools

1 follower


Asked: 2017-06-19 14:55:58 +0100

Seen: 379 times

Last updated: juni 21 '17