Debugging Bluetooth on Android

It can feel like a black box when bluetooth isn't working on Android. The best tool I have found so far, is the hcilog. This is just a few notes about some useful commands for working with the hcilog.

First off here is how to enable the hci log on an attached device

$ adb shell settings put secure bluetooth_hci_log 1

Next run the scenario you want to test and then save a dump of the log with

$ adb dumpsys bluetooth_manager > btlog.snoop

Then download the pythonscript btsnooz.py and run it

$ python btsnooz.py btlog.snoop > btlog.log

I then you can finally look at it in wireshark

$ wireshark btlog.log

For my case I was debugging a firmware update via the SPP protocol. Unfortunately it seems that the data portion of the RFCOMM packages are stripped down to a few bytes and I haven't found a way to get a full log of all data.

Also remember to turn off the hci log again

$ adb shell settings put secure bluetooth_hci_log 0