Page 1 of 2

how to send BLE notification to client

Posted: Mon Dec 26, 2016 9:24 am
by mephistod2
I try to use "gatt_server " example to make connect to my ipad;

when I click Listen for notifications my ESP32 got a ESP_GATTS_WRITE_EVT on (read/write handle + 1);

but how can I send BLE notification , is there any api for this?

Re: how to send BLE notification to client

Posted: Mon Dec 26, 2016 12:55 pm
by mephistod2
I use "esp_ble_gatts_send_indicate" and get ESP32's notification.

Re: how to send BLE notification to client

Posted: Sun Jan 29, 2017 10:27 am
by innospiring
Hi,

I always get a stack overflow when sending the notification. Which attr_handle do you send it to? (46 is the CHAR_HANDLE...)

I (20776) GATTS_DEMO: SEND NOTIFICATION, gatts_if 5, conn_id 0, attr_handle 46, value len 1

***ERROR*** A stack overflow in task IDLE has been detected.

Re: how to send BLE notification to client

Posted: Sun Jan 29, 2017 11:48 pm
by kolban
It has been my experience that a stack overflow can be caused by not allocating enough stack space for the FreeRTOS task when either xTaskCreate() or xTaskCreatePinnedToCore() is called. You might want to look through the code and see if either of those are being called. If not, one can increase the amount of stack space allocated to the default task through the "make menuconfig" command.

Re: how to send BLE notification to client

Posted: Mon Jan 30, 2017 12:39 pm
by innospiring
hi Kolban, thanks for the answer.

unfortunately it did not help.

in addition to the stack overflow it reports this:
abort() was called at PC 0x4008615c
Guru Meditation Error: Core 0 panic'ed (abort)

does this indicate that the command is taking too long to finish?

the code line is:
esp_ble_gatts_send_indicate(gl_profile_tab[appID].gatts_if, gl_profile_tab[appID].conn_id,
gl_profile_tab[appID].char_handle, value_len, value, true);

proved that all values are valid...

Re: how to send BLE notification to client

Posted: Mon Jan 30, 2017 1:09 pm
by frax84
Hi,
i'm working on BLE notification too and i'm very interested in the problem. Actually i'm wondering how it works in detail. By protocol when you switch notification "on" you send a WRITE REQUEST on CHARACTERISTIC DESCRIPTOR (CCCD) where you set to 1 the bit field related to NOTIFY. Once this bit is set the server is able to take initiative and send notification. This explains why you get an "ESP_GATTS_WRITE_EVT": it's the gatt client that is trying to set the notification bit.
Actually you're using a "send_indicate" without managing the CCCD update. Maybe i'm wrong (can anyone confirm?) but you should use "set_attribute" function to manage the server status. Please just take this suggestions as a simple discussion. In fact i'm stuck with BLE notifications too, so i'm probably wrong somewhere.

By the way, what you tried triggers to me another question: what happens if client don't enable (on server) the notification bit and server use the server indicate API? Will the client read the characteristic update? Theorically it should not :)

Re: how to send BLE notification to client

Posted: Tue Jan 31, 2017 12:36 am
by ESP_Angus
You may need to increase the stack overhead in a different task. It's possible the abort is a symptom of the stack overflow, if it's sometimes crashing before stack overflow detection has a chance to kick in. (Or it's possible that both errors are a a symptom of some other memory corruption, unfortunately it can be hard to tell at this stage!)
innospiring wrote: abort() was called at PC 0x4008615c
Guru Meditation Error: Core 0 panic'ed (abort)
If you run "xtensa-esp32-elf-addr2line -fe build/APPNAME.elf 0x4008615c" then addr2line will print the line number where the abort occured.

There is also a "backtrace" in the dump, if you paste this onto the addr2line command line as well then you'll get a stack trace (stack return addresses) of function calls leading to the abort. Although if the stack is corrupt, this backtrace may be corrupt as well.

Re: how to send BLE notification to client

Posted: Sat Apr 22, 2017 7:50 pm
by m3th0d1c
Just wondering if you noticed that the "value" parameter is supposed to be a pointer, not the value itself.

Re: how to send BLE notification to client

Posted: Thu May 04, 2017 5:56 am
by joicetm
Hi frax84,

Did you rectified the problem? i am also facing the same issue. :|
when i try to send notification with esp_ble_gatts_send_indicate(), it shows ccd error in nrf app. i have also enabled notifications through nrf app.
also i couldn't understand the significance '#define GATTS_DESCR_UUID_TEST_A 0x3333' in the gatt server example.
:roll:

Re: how to send BLE notification to client

Posted: Fri May 05, 2017 6:01 pm
by frax84
Hi,
actually i've been working on a Labview application to make a BLE client on PC so that i can access the data at low level in a more familiar way (to me). I have been able (just today) to exchange a stream of data between an ADC channel of the esp and the client using BLE. Unfortunately, to make things simpler, i'm using read request/response. I'm hoping in a deeper documentation sooner or later for indicate/notify part sooner or later :)