Cannot get all characteristics of a service

james89
Posts: 3
Joined: Mon Apr 03, 2017 8:11 pm

Cannot get all characteristics of a service

Postby james89 » Mon Apr 03, 2017 8:21 pm

From what I understand the

Code: Select all

esp_ble_gattc_get_characteristic()
is called with

Code: Select all

start_char_id
= NULL to get the first characteristic, and then in the callback

Code: Select all

ESP_GATTC_GET_CHAR_EVT
,

Code: Select all

esp_ble_gattc_get_characteristic()
is called again with

Code: Select all

start_char_id
= char_id received to get the next characteristic.

When I do this however I keep getting:
E (12025) App: get_char.status: 0x85
E (12029) BT: btc_to_bta_uuid UUID len is invalid 0

This happens for both 16 bit UUIDs and 128 bit UUIDs.

Can anyone help?

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

Re: Cannot get all characteristics of a service

Postby kolban » Tue Apr 04, 2017 5:09 am

Your theory looks sound but the devil will undoubtedly be in the details. What I'd suggest is to create the smallest application possible that attempts to achieve what you want (i.e. remove all code unrelated to the problem area) and validate that you are still getting the error. Then, when done, attach it to this thread and let the community take a look in context. Ideally describe your thinking and for extra credit, post the whole solution ready to be compiled on Github under your respository so that others can download, compile and test on their devices.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

dave111
Posts: 45
Joined: Fri Mar 03, 2017 1:37 am

Re: Cannot get all characteristics of a service

Postby dave111 » Tue Apr 04, 2017 5:58 am

Hi james89, the exact same thing is happening to me, too. But it only happens in combination with certain peripherals. For instance, it never happens with Android (Bluedroid) based peripherals. Android peripherals always let my ESP32 fetch all characteristics. The problem occurs when I connect my ESP32 to a peripheral based on Bluez. Bluez-based peripherals give me this problem every the time. It is absolutely consistent.

Interestingly: If I use some other client (say, an Android client), the same Bluez-based peripheral lets me fetch all characteristics. So it is not simply an issue with Bluez. The problem seems to occur only in this combination: ESP32 as client, peripheral based on Bluez. What Bt stack does your peripheral use?

james89
Posts: 3
Joined: Mon Apr 03, 2017 8:11 pm

Re: Cannot get all characteristics of a service

Postby james89 » Tue Apr 04, 2017 3:48 pm

I am using the example gatt_client from the espressif github: https://github.com/espressif/esp-idf/tr ... att_client

I just modified the ESP_GAP_BLE_SCAN_RESULT_EVT() callback to look for my peripheral and connect to it, everything else is the same.

What is interesting is that I do get the first characteristic for each service, but I cannot get the rest of a service's characteristics.

Hi dave111, my peripheral is a BT module from Nordic Semiconductor so its their own BT stack. But I have tried it with many other types of peripherals like Apple TVs, Amazon Echos, and connectBlue devices and the result is the same.

james89
Posts: 3
Joined: Mon Apr 03, 2017 8:11 pm

Re: Cannot get all characteristics of a service

Postby james89 » Tue Apr 04, 2017 9:26 pm

I figured out the problem. In the call to esp_ble_gattc_get_characteristic() I was passing in p_data->search_res.srvc_id for the srvc_id param, the correct srvc_id to use is p_data->get_char.srvc_id.

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

Re: Cannot get all characteristics of a service

Postby kolban » Wed Apr 05, 2017 1:01 am

@james89,
Great find and glad it works. Thank you especially for taking the time to help future users and readers by posting the error and what you did to correct.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Who is online

Users browsing this forum: Basalt and 324 guests