5 years, 11 months ago.

BLE_STACK_BUSY error more frequent over time

I have a BLE application running Mbed 9.7.2 on an nRF52832 (softdevice 132). I have a connection interval (to the central) of 11.25 ms and specify a slave latency of 3. I have a custom service that houses 3 custom characteristics (notify). Each characteristic is 20 bytes in size and consists of 8 2-byte values and a single 4-byte value. The application will fill a single characteristic with new data every 10 ms; when all 3 characteristics are updated I call BLE::Instance().gattServer().write() to write the new data over BLE during the next connection interval.

My issue is as follows. When I attempt BLE::Instance().gattServer().write() I log the result. When the application first starts the result of this operation is BLE_ERROR_NONE - signifying that all is well. As time progresses the result of BLE::Instance().gattServer().write() more often becomes BLE_STACK_BUSY.

Any insights as to this are very welcome.

1 Answer

5 years, 10 months ago.

Hi Adam,

It looks like the tx buffers are full, so the stack is not able to take more data into the queue, and the reason might be the previous packet is under retransmission so the queue is still occupied. I would suggest two ways.

  • Increase GATTS tx queue size

You can use sd_ble_cfg_set(BLE_CONN_CFG_GATTS, &ble_gatts_conn_cfg, *ram_start) to increase GATTS_HVN_TX_QUEUE_SIZE, but it may just delay the busy scenario.

  • Check the data is sent

Or you can add a data send callback by GattServer::onDataSent(), the callback will be called when the notification is confirmed, and then you are good to send the next one.

Please feel free to ask me any questions!

Desmond, team Mbed

Hi Desmond,

Thanks for the response, this is very useful information. Is the <<sd_ble_cfg_set(BLE_CONN_CFG_GATTS, &ble_gatts_conn_cfg, *ram_start)>> function a part of the Nordic SoftDevice API? If so, is there anywhere that documents which parts of the API are exposed within mbedOS? I'd also like to look at increasing ATT MTU if at all possible.

Best regards, Adam

posted by Adam Mitchell 29 Jan 2019

Yes, sd_ble_cfg_set() is defined in Nordic SoftDevice API, which is used to configure SoftDevice before nrf_sdh_ble_enable(), you can refer btle_int() for the initializing procedure.

Mbed OS abstracts the BLE API so there is no documentation for what APIs are exposed within Mbed OS, I apologize for that.

To modify size of ATT MTU, you can change targets\TARGET_NORDIC\TARGET_NRF5x\TARGET_SDK14_2\TARGET_SOFTDEVICE_S132_FULL\mbed_lib.json, those definitions for BLE parameters are able to changed here.

Thank you for participating Mbed OS, please let me know for any questions.

Desmond, team Mbed

posted by Desmond Chen 01 Feb 2019