unknown BLE error sending notifications to a client out of reach

Jjens*
Posts: 4
Joined: Fri Jul 05, 2019 10:06 am

unknown BLE error sending notifications to a client out of reach

Postby Jjens* » Wed Nov 06, 2019 9:48 am

Hi guys,

I am using Neil Kolban's cpp_utils from his esp32-snippets github repository for BLE (with esp-idf). In my project the esp32 acts as a server, sending notifications to an central device. It is based on Kolbans BLE example "SampleNotify" using the "pCharacteristic->notify()" method.

The program works fine as long as the client is near by the ESP32, but when it is going to get out of reach, then I got an error massage "esp_ble_gatts_send_ notify: rc=-1 Unknown ESP_ERR error". This seems to be due to the method "esp_ble_gatts_send_indicate" in "esp_gatts_api.h".

I still wonder about this, because I thought using notifications the server doesn't care about whether a client is listening or not. And what is more, I do not have any idea how to handle this error massage. Is there any method to detect if the client is "connected" or nearby? This error only occur when I send more then 10-20 notifications in a second (I want to submit an ECG with 125-250 samples per second ;-).

Does anyone have an idea how to proceed with this error?

Thanks, JJens

chegewara
Posts: 2210
Joined: Wed Jun 14, 2017 9:00 pm

Re: unknown BLE error sending notifications to a client out of reach

Postby chegewara » Fri Nov 08, 2019 8:27 pm

I still wonder about this, because I thought using notifications the server doesn't care about whether a client is listening or not.
Thats true, but if peer device is too long out of range then connection is closed, when it is closed stack will try to send notification to NULL.

Try to increase timeout in esp_ble_gap_set_prefer_conn_params:
https://github.com/espressif/arduino-esp32/issues/1913

Jjens*
Posts: 4
Joined: Fri Jul 05, 2019 10:06 am

Re: unknown BLE error sending notifications to a client out of reach

Postby Jjens* » Mon Nov 11, 2019 1:46 pm

Thanks!

Increasing the timeout doesn't seem to make any difference. According to your explanation, I have to prevent the server from sending notifications to NULL. I assume that my task still pushes notification to a stack before the callback function (onDisconnect) deletes the task. That might be due to the high sample rate which generates notifications every 4ms.

Do you know any direct function to check the connection status before sending a notification. (I have tried "BLEServer::getConnectedCount()", but there are still roughly 20 notifications on stack before the function detects that there is no connected client...)

chegewara
Posts: 2210
Joined: Wed Jun 14, 2017 9:00 pm

Re: unknown BLE error sending notifications to a client out of reach

Postby chegewara » Tue Nov 12, 2019 7:50 am

As long as it doesn't crash app I wouldn't care about it and treat it as info/warnings.

Who is online

Users browsing this forum: No registered users and 216 guests