Page 2 of 2

Re: The BLE APIs and the concept of "handles" ...

Posted: Sat Dec 30, 2017 4:14 pm
by Ernesto
Cool, your lastest BT library containts a method setValue in BLERemoteService. I guess thats exactly what I am looking for.
What I realized is that the Arduino Core of esp32 (https://github.com/espressif/arduino-esp32.git) does not contain the esp_bt.h you use. How did you work around that? Do you use the Arduino IDE at all or how did you add the ESP BT library?

Re: The BLE APIs and the concept of "handles" ...

Posted: Sat Dec 30, 2017 4:47 pm
by Ernesto
Well, for the moment I just copied the missing header files to the ESP32_BLE library folder. But I get the following error:

Code: Select all

Documents/Arduino/libraries/ESP32_BLE/src/BLEExceptions.h:13:2: error: #error "C++ exception handling must be enabled within make menuconfig. See Compiler Options > Enable C++ Exceptions."
 #error "C++ exception handling must be enabled within make menuconfig. See Compiler Options > Enable C++ Exceptions."
 
so I guess you must integrate somehow the espressif IDF with you Arduino IDE. So I'd really be interested if you could shed some light how you are building.

Re: The BLE APIs and the concept of "handles" ...

Posted: Thu Jun 04, 2020 7:13 am
by Alexis81
Hello,

I am writing an application which simulates a Bluetooth remote control, but the receiver differentiates the commands according to the handle number. Do you know how I can give a handle style number 0x0030? See Attachment.

Thank you for your help.

Excuse my English, I'm French ...

Re: The BLE APIs and the concept of "handles" ...

Posted: Fri Jun 05, 2020 7:31 am
by brazoayeye
I have a related question, that's not strongly correlated with the main topic but always related to handles

In the example code (https://github.com/espressif/esp-idf/bl ... ain/peer.c) i found this usage of handles (schematized above)

Code: Select all

ble_gattc_disc_all_svcs (connHandle) 
               => connHandle,  ble_gatt_svc { start_handle, end_handle }
               
ble_gattc_disc_all_chrs ( connHandle, start_handle, end_handle ) 
               => connHandle, ble_gatt_chr { def_handle, val_handle }
               
ble_gattc_disc_all_dscs (connHandle, val_handle, isLastChr ? end_handle : def_handle_of_next_chr-1)
               => connHandle, chr_val_handle,  ble_gatt_dsc { handle }
I looked for explaination in the main documentation (http://mynewt.apache.org/latest/network ... gatts.html) finding nothing more than what I found in the example.

From my understanding services, chrs, dscs have one handles each, and they are not always contiguous. Is it wrong? If I receive more than 1 handle for service discovery CB, i expect they are related to the elements below (chrs or chrs+dscs?), but they could not fit a contiguous range.

And more, once I know i need the value given by the chr with connHandle yyyy->chr handle xxxx, what's the meaning of keeping all other datas acquired?

Thanks

Re: The BLE APIs and the concept of "handles" ...

Posted: Fri Jun 05, 2020 10:01 am
by chegewara
Alexis81 wrote: Hello,

I am writing an application which simulates a Bluetooth remote control, but the receiver differentiates the commands according to the handle number. Do you know how I can give a handle style number 0x0030? See Attachment.

Thank you for your help.

Excuse my English, I'm French ...
You dont have to copy handle number, because it is very uncommon that host device will use hardcoded handles.

brazoayeye wrote: From my understanding services, chrs, dscs have one handles each, and they are not always contiguous. Is it wrong? If I receive more than 1 handle for service discovery CB, i expect they are related to the elements below (chrs or chrs+dscs?), but they could not fit a contiguous range.
Characteristic needs 2 handles, one for characteristic and one for characteristic value. Service and descriptor only one handle each.
brazoayeye wrote: And more, once I know i need the value given by the chr with connHandle yyyy->chr handle xxxx, what's the meaning of keeping all other datas acquired?
No need to discover and keep other data. In fact you have this API to discover only part of handles and related characteristics and desriptors:

Code: Select all

ble_gattc_disc_all_chrs ( connHandle, start_handle, end_handle ) 
               => connHandle, ble_gatt_chr { def_handle, val_handle }
               
when you find characteristic you need then you can stop discovering, which will save time and power usage.

Re: The BLE APIs and the concept of "handles" ...

Posted: Fri Jun 05, 2020 2:13 pm
by Alexis81
Thank you for your reply,

But unfortunately the device that receives Bluetooth commands, relies on the Handle number, so I should be able to give the number 0x0030 to the Handle. Is it possible to do this?

Thank you

Re: The BLE APIs and the concept of "handles" ...

Posted: Tue Jun 09, 2020 1:21 am
by chegewara
There is few standard services and characteristics that are mandatory and are included by bluedroid stack. From here you can add services, characteristics and descriptors to reach handle 0x0030 using this formula:
Characteristic needs 2 handles, one for characteristic and one for characteristic value. Service and descriptor only one handle each.