How to get the Bluetooth Host Controller Interface logs from a modern Android phone
Most of the guidance floating around the internet for extracting the Bluetooth HCI logs from Android is grossly out of date. Here is how I managed to achieve it with a Samsung Galaxy S10 running Android version 10.
Things that don’t work on this version of android, for this phone at least, include:
- Live capture via Wireshark’s
androiddump
tool (https://stackoverflow.com/questions/53751028/live-capture-of-android-bluetooth-traffic-via-wireshark) - Copying the file directly from the filesystem using
adb pull
Here is what worked for me:
Step 1: Enable developer mode
Go to Settings, About phone, Software Information and tap the “Build Number” row 7 times. The phone will show a notification counting down once you’ve tapped it a few times, and will confirm that developer options have been enabled.
Step 2: Enable USB debugging and the Bluetooth logs
Go to the newly enabled “Developer options” section of the Settings menu, toggle “Enable Bluetooth HCI snoop log” to enable the logs, and “USB Debugging” to allow us to extract the logs over USB later.
Then toggle bluetooth on and off. The log is now enabled (although it doesn’t save to the user accessible part of the filesystem — read on for how to extract it). At this point you should use whatever app you want to capture the bluetooth traffic from to generate some logs.
Step 3: Download adb
, the Android Debug Bridge command line tool
Crucially, you don’t need the full Android development studio. The tools can be downloaded from https://developer.android.com/studio/releases/platform-tools.html, and will need to be placed somewhere in your PATH
so they can be called easily.
Step 4: Ensure your device is authorised and connected
Plug your device into you computer with a USB cable. Run adb devices
to see a list of devices adb
recognises. I had to unlock the phone and tap around in the USB Options section of the notification you get when the phone is plugged in to get a screen up asking me to authorise my computer before it would show as authorised:
Once authorised, adb
will show the device as attached:
$ adb devicesList of devices attachedRF8M55WFB4W device
Step 5: Generate a bug report
Use the adb bugreport filename
command to generate a bug report, which will create filename.zip
in the current directory. In this zip, in the FS/data/log/bt
directory there is the btsnoop_hci.log
file, which can be opened with Wireshark to examine the traffic.
Wrapping it all up
To make this process easier, I put together a small script to copy a timestamped log to the current directory:
#!/bin/bashOUTPUT_DIR=$(pwd)
pushd /tmp
echo "Getting Bug Report..."
adb bugreport bug
echo "Unzipping Bluetooth HCI Log..."
unzip bug.zip FS/data/log/bt/btsnoop_hci.log
echo "Copying btsnoop_hci.log to '$OUTPUT_DIR' ..."
cp FS/data/log/bt/btsnoop_hci.log $OUTPUT_DIR/$(date +"%Y%m%d_%H%M%S")_btsnoop_hci.log
echo "Cleaning up..."
rm FS/data/log/bt/btsnoop_hci.log
rm bug.zip
popd
Did this work for you? If you let me know the make and model of your device and the android version, I will update this article to list when it does (and doesn’t) work.