Hi,
I'm using BLE on nrf52832 and softdevice s132. It seems that when I send too many packets (around 45), the ble crashes. Is there a way to increase that number or at least make it not crash?
Thanks
Hi,
I'm using BLE on nrf52832 and softdevice s132. It seems that when I send too many packets (around 45), the ble crashes. Is there a way to increase that number or at least make it not crash?
Thanks
What BLE profile are you using - eg, NUS?
You should get an error status telling you when the SD can't accept more packets - are you paying attention to that?
NUS profile (uart).
To clarify, the crash happens when I send data from microcontroller STM32 to the nordic nrf52 that's connected to it via uart, and then send the data to a smartphone by BLE.
What error should I get? I looked through the error codes (0 to 19) and I can't find anything related to accepting packets.
Also, if I get this error, what can I do?
Here's some of the code inside uart_event_handle() under the case APP_UART_DATA_READY:
do
{
uint16_t length = (uint16_t)index;
err_code = ble_nus_string_send(&m_nus, data_array, &length);
if ( (err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_RESOURCES) )
{
APP_ERROR_CHECK(err_code);
}
} while (err_code == NRF_ERROR_RESOURCES);
Or should I be looking somewhere else?
Thanks
You need to investigate to see what happens immediately before the crash.
Maybe you're getting NRF_ERROR_RESOURCES - that sounds a likely candidate, doesn't it?
Instrument your code to see what's happening.
if I get this error, what can I do?
The link has a finite capacity - you can't just keep chucking data at it over that capacity.
Only you can decide what's appropriate for your application in this situation
Thanks for the response,
I verified that the error that I'm getting is NRF_ERROR_RESOURCES.
Regarding the capacity, let's say maximum packets is 40 of size 20. Does that mean that if I send, say 40 packets of size 20, then wait some time, and then continue sending, it will work successfully? How much should the waiting time be?
Thank you
Thanks for the response,
I verified that the error that I'm getting is NRF_ERROR_RESOURCES.
Regarding the capacity, let's say maximum packets is 40 of size 20. Does that mean that if I send, say 40 packets of size 20, then wait some time, and then continue sending, it will work successfully? How much should the waiting time be?
Thank you
Arbitrary delays are never a good idea.
Better to look for a specific indication that the link again has capacity.
If you are constantly hitting this, it indicates that you need to re-evaluate something - either send less data, or adjust the link parameters to increase throughput
Can you tell me what parameters to adjust?
I just tried adding a 500 ms delay after roughly 40 packets, and I'm not getting the error anymore.
Connection interval
MTU size
Use the 2Mbps PHY (BLE 5 High troughput mode)
https://www.nordicsemi.com/Products/Low-power-short-range-wireless/Bluetooth-5
But remember that your Central (especially if it's a phone or tablet) may impose limits ...