how to send BLE notification to client

mephistod2
Posts: 6
Joined: Mon Dec 26, 2016 8:43 am

how to send BLE notification to client

Postby mephistod2 » Mon Dec 26, 2016 9:24 am

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?

mephistod2
Posts: 6
Joined: Mon Dec 26, 2016 8:43 am

Re: how to send BLE notification to client

Postby mephistod2 » Mon Dec 26, 2016 12:55 pm

I use "esp_ble_gatts_send_indicate" and get ESP32's notification.

innospiring
Posts: 3
Joined: Sun Jan 29, 2017 10:20 am

Re: how to send BLE notification to client

Postby innospiring » Sun Jan 29, 2017 10:27 am

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.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: how to send BLE notification to client

Postby kolban » Sun Jan 29, 2017 11:48 pm

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.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

innospiring
Posts: 3
Joined: Sun Jan 29, 2017 10:20 am

Re: how to send BLE notification to client

Postby innospiring » Mon Jan 30, 2017 12:39 pm

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...

frax84
Posts: 42
Joined: Thu Jan 07, 2016 11:26 am

Re: how to send BLE notification to client

Postby frax84 » Mon Jan 30, 2017 1:09 pm

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 :)

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: how to send BLE notification to client

Postby ESP_Angus » Tue Jan 31, 2017 12:36 am

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.

m3th0d1c
Posts: 2
Joined: Fri Apr 14, 2017 12:58 am

Re: how to send BLE notification to client

Postby m3th0d1c » Sat Apr 22, 2017 7:50 pm

Just wondering if you noticed that the "value" parameter is supposed to be a pointer, not the value itself.

joicetm
Posts: 15
Joined: Mon Apr 10, 2017 12:47 pm

Re: how to send BLE notification to client

Postby joicetm » Thu May 04, 2017 5:56 am

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:

frax84
Posts: 42
Joined: Thu Jan 07, 2016 11:26 am

Re: how to send BLE notification to client

Postby frax84 » Fri May 05, 2017 6:01 pm

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 :)

Who is online

Users browsing this forum: No registered users and 66 guests