Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bluetooth HCI snoop log not generated

I'm running Android 4.4.2 and I enabled the "Bluetooth HCI snoop log" as described here Sniffing/logging your own Android Bluetooth traffic

After turning bluetooth on and off I rebooted the phone. I could not find the log file in the expected location:

$ adb pull /sdcard/btsnoop_hci.log
remote object '/sdcard/btsnoop_hci.log' does not exist

How can I get to the btsnoop_hci.log?

like image 323
Jack Shultz Avatar asked Feb 11 '15 02:02

Jack Shultz


People also ask

Where is Bluetooth HCI snoop log?

These logs capture the Host Controller Interface (HCI) packets. For most Android devices, the logs are stored in data/misc/bluetooth/logs .

Is Bluetooth HCI snoop log?

Bluetooth HCI Snoop Log is a Bluetooth protocol log that keeps track of data sent and received by your Android device. In the USD root or SD storage of your device, you'll find the Btsnoop_hci. log file. For access to the file, you must use network protocol analysis software such as Wireshark.

What is BTSnoop file?

The BTSnoop file format is suitable for storing Bluetooth® HCI traffic. It closely resembles the snoop format, as documented in RFC 1761. File Format.


3 Answers

UPDATE: The btsnoop hci log seems to be getting phased out of the user-accessible areas on a lot of phones. Assuming you have hci logging enabled, you can get a bugreport

adb bugreport anewbugreportfolder

Then decompress the folder. If you're lucky there is an 'FS' folder that contains the btsnoop_hci.log log several layers down (not sure why some phones have this and some don't.) If you don`t have it, grab the bug report text file that looks like this

bugreport-2018-08-01-15-08-01.txt

Run btsnooz.py against it. Per Google`s instructions,

To extract snoop logs from the bug report, use the btsnooz script.

Get btsnooz.py.
Extract the text version of the bug report.
Run btsnooz.py on the text version of the bug report:

btsnooz.py BUG_REPORT.txt > BTSNOOP.log

As of 1/12/21 the link to btsnooz is here: https://android.googlesource.com/platform/packages/modules/Bluetooth/+/refs/heads/master/system/tools/scripts/btsnooz.py

LEGACY ANSWER:

You can see where your phone is storing the hci log by reading the bt_stack.conf file. Try

adb shell cat /etc/bluetooth/bt_stack.conf

You will see a line that looks like

# BtSnoop log output file
BtSnoopFileName =/sdcard/btsnoop_hci.log <--your file location

It is usually, but not always (depends on the phone) on the root of the sdcard. There is also a line in this configuration file which may reflect if hci logging is actually on or not

# EnableBtSnoop logging function
# valid value : true , false
BtSnoopLogOutput=false

Toggling the 'Enable Bluetooth HCI snoop log' option in the developer options should change it to

# EnableBtSnoop logging function
# valid value : true , false
BtSnoopLogOutput=true

I say "should" because for some phones this doesn't update this file. You should:

  1. Read the bt_stack.conf file. See where the HCI log should be and if bt snoop logging is actually enabled or not
  2. If developer options say btsnoop_hci logging is on but the bt_stack.conf file says it is off, try power cycling bluetooth and/or your phone.
  3. If your phone is rooted, manually set BtSnoopLogOutput=true

If none of the 3 options work, you're out of luck. BT Snoop hci logging is a bit inconsistent across different phones. I've seen a few phones where I just couldn't get it to work not matter what but for the most cases you should be able to get it going. A rooted phone is not a requirement.

like image 186
TwinPrimesAreEz Avatar answered Oct 19 '22 16:10

TwinPrimesAreEz


On Nexus 5X and Pixel C Android O you have to enable bluetooth, enable HCI snooping in developer settings, disable and reenable bluetooth and reboot.

After that you can get the log by going to developer settings and "take bug report" and get a full log.

The file bt_stack.conf is not changed and there is no new file on /sdcard as on other devices

like image 30
PaulFreund Avatar answered Oct 19 '22 18:10

PaulFreund


For a user version Pixel/Nexus, you may not have the permission to pull out /data/misc/bluetooth/logs/btsnoop_hci.log. You can get the hci log like this:

adb shell dumpsys bluetooth_manager
adb bugreport > BUG_REPORT.txt

You will get a BUG_REPORT.txt and zip file. HCI log will be found under FS\data\misc\bluetooth\logs of the zip file.

like image 11
Fukai Avatar answered Oct 19 '22 16:10

Fukai