[Info]: Low level bluetooth debugging

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

[Info]: Low level bluetooth debugging

Postby kolban » Tue Apr 18, 2017 11:32 pm

While studying Bluetooth (BLE) I found myself getting stuck. I couldn't follow the documentation and was getting errors I couldn't understand. I did some digging and found that the ESP32 Bluetooth stack is built on top of an existent bluetooth stack called "Bluedroid". That then took me into the world of Bluedroid (still swimming and looking around there) ... however very quickly I found that Bluedroid provides additional diagnostics that can be compiled (or enabled) into the environment. One way to achieve this is to edit the "component.mk" file found in the <ESP-IDF>/components/bt directory. This is the control file that describes how the bluetooth stack is compiled. If we then add the following:

Code: Select all

CFLAGS+= -DGATT_INITIAL_TRACE_LEVEL=6 \
	-DSMP_INITIAL_TRACE_LEVEL=6 \
	-DAPPL_INITIAL_TRACE_LEVEL=6 \
	-DHID_INITIAL_TRACE_LEVEL=6 \
	-DMCA_INITIAL_TRACE_LEVEL=6 \
	-DAVRC_INITIAL_TRACE_LEVEL=6 \
	-DAVCT_INITIAL_TRACE_LEVEL=6 \
	-DAVDT_INITIAL_TRACE_LEVEL=6 \
	-DA2D_INITIAL_TRACE_LEVEL=6 \
	-DPAN_INITIAL_TRACE_LEVEL=6 \
	-DBNEP_INITIAL_TRACE_LEVEL=6 \
	-DGAP_INITIAL_TRACE_LEVEL=6 \
	-DSDP_INITIAL_TRACE_LEVEL=6 \
	-DRFCOMM_INITIAL_TRACE_LEVEL=6 \
	-DL2CAP_INITIAL_TRACE_LEVEL=6 \
	-DBTM_INITIAL_TRACE_LEVEL=6 \
	-DHCI_INITIAL_TRACE_LEVEL=6 \
	-DRFCOMM_INITIAL_TRACE_LEVEL=6 \
	-DL2CAP_INITIAL_TRACE_LEVEL=6 \
	-DBTM_INITIAL_TRACE_LEVEL=6
and re-build, we will find that trace is enabled and we get a ton of new diagnostics from the insides of the Bluetooth stack. I'm still studying "what this means" ... but I wanted to share in case it is of use to others as we make progress in understanding what we have here.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

afrohl
Posts: 2
Joined: Tue Aug 15, 2017 9:56 pm

Re: [Info]: Low level bluetooth debugging

Postby afrohl » Mon Aug 21, 2017 5:53 pm

Did you ever find out more "what this means"? I'm trying to connect to devices with GATT to get the profile, disconnect, and repeat with the other devices in the area. This is intended to be a more verbose scan from just a GAP scan. My issue is that after a few connect/disconnect cycles the esp32 hangs without error or log output (usually). I've just started working with the esp32 and am looking for the best way to debug this issue. It seems like I need to go directly to the Bluedroid apis instead of using the esp32 api. Have you come across a setting to specify verbose logging from bludroid on the esp32? Thanks in advance.

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

Re: [Info]: Low level bluetooth debugging

Postby kolban » Tue Aug 22, 2017 10:06 pm

Unfortunately I don't have any skills or knowledge in Bluedroid. I may have just been lucky, but so far, ive gotten away with simply using the exposed ESP-IDF layers without any great issues and all has so far worked as desired.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Who is online

Users browsing this forum: Baidu [Spider], Majestic-12 [Bot], mikecarlos, zelenecul and 114 guests