how to send BLE notification to client
-
- Posts: 6
- Joined: Mon Dec 26, 2016 8:43 am
how to send BLE notification to client
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?
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?
-
- Posts: 6
- Joined: Mon Dec 26, 2016 8:43 am
Re: how to send BLE notification to client
I use "esp_ble_gatts_send_indicate" and get ESP32's notification.
-
- Posts: 3
- Joined: Sun Jan 29, 2017 10:20 am
Re: how to send BLE notification to client
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.
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
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
-
- Posts: 3
- Joined: Sun Jan 29, 2017 10:20 am
Re: how to send BLE notification to client
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...
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
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
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
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!)
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.
If you run "xtensa-esp32-elf-addr2line -fe build/APPNAME.elf 0x4008615c" then addr2line will print the line number where the abort occured.innospiring wrote: abort() was called at PC 0x4008615c
Guru Meditation Error: Core 0 panic'ed (abort)
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
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
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.
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.
Re: how to send BLE notification to client
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
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 110 guests