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

Ernesto
Posts: 4
Joined: Sat Dec 23, 2017 3:48 am

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

Postby Ernesto » Sat Dec 30, 2017 4:14 pm

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?

Ernesto
Posts: 4
Joined: Sat Dec 23, 2017 3:48 am

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

Postby Ernesto » Sat Dec 30, 2017 4:47 pm

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.

Alexis81
Posts: 3
Joined: Thu Jun 04, 2020 7:04 am

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

Postby Alexis81 » Thu Jun 04, 2020 7:13 am

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 ...
Attachments
Télécomande Noire.png
Example
Télécomande Noire.png (48.96 KiB) Viewed 5540 times

brazoayeye
Posts: 41
Joined: Sun May 03, 2020 2:37 pm

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

Postby brazoayeye » Fri Jun 05, 2020 7:31 am

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

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

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

Postby chegewara » Fri Jun 05, 2020 10:01 am

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.

Alexis81
Posts: 3
Joined: Thu Jun 04, 2020 7:04 am

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

Postby Alexis81 » Fri Jun 05, 2020 2:13 pm

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

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

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

Postby chegewara » Tue Jun 09, 2020 1:21 am

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.

Who is online

Users browsing this forum: No registered users and 181 guests