82

I recently bought chinesse device that connects via bluetooth with android phone / tablet. Since there is no application availible for windows / linux I want to create one for personal usage.

Usually phone connects to the device and exchanges some data. I connected PC to the device and looked into serial debugger and menaged to discover the protocol (one way only). Phone sends only one command to the device. But this time I'm not able to find out what it containts.

Is there any software that will allow me to look into data sent via bluetooth? I tried decompiling the app, but it looks really unfriendly.

Thanks.

1
  • 2
    it is laser rangefinder. Data you receive from it is simply d5 f0 ... ... milimiters_as_uint32 0d
    – peku33
    May 27, 2014 at 19:59

4 Answers 4

86

Android 4.4 (Kit Kat) does have a new sniffing capability for Bluetooth. You should give it a try.

If you don’t own a sniffing device however, you aren’t necessarily out of luck. In many cases we can obtain positive results with a new feature introduced in Android 4.4: the ability to capture all Bluetooth HCI packets and save them to a file.

When the Analyst has finished populating the capture file by running the application being tested, he can pull the file generated by Android into the external storage of the device and analyze it (with Wireshark, for example).

Once this setting is activated, Android will save the packet capture to /sdcard/btsnoop_hci.log to be pulled by the analyst and inspected.

Type the following in case /sdcard/ is not the right path on your particular device:

adb shell echo \$EXTERNAL_STORAGE

We can then open a shell and pull the file: $adb pull /sdcard/btsnoop_hci.log and inspect it with Wireshark, just like a PCAP collected by sniffing WiFi traffic for example, so it is very simple and well supported:

screenshot of wireshark capture using Android HCI Snoop

[source]

You can enable this by going to Settings->Developer Options, then checking the box next to "Bluetooth HCI Snoop Log."

15
  • 10
    @JackShultz If you don't see btsnoop_hci.log created, open /etc/bluetooth/bt_stack.conf in a text editor, it contains the path to the file on your device. For me it was stored in /sdcard/Android/data/btsnoop_hci.log.
    – Mr. Bungle
    Mar 9, 2015 at 13:14
  • 1
    I get an error: adb: error: remote object '/sdcard/btsnoop_hci.log' does not exist Apr 14, 2017 at 14:35
  • 1
    @IgorGanapolsky adb shell echo \$EXTERNAL_STORAGE Apr 25, 2017 at 15:41
  • 3
    @StephanBranczyk That way of pulling hci.log may be obsolete on the newer devices (especially Nexus and Pixel). One now has to enable bug report shortcut from developer settings to obtain this log manually. Apr 25, 2017 at 15:43
  • 1
    Did you have any luck retrieving logs in a Pixel device using the Bug Report feature? I can't seem to adb pull the .log file or receive it via email. Also, switching the dev option on and off, doesn't have any effect on bt_stack.conf contents. Has this feature been disabled in latest Android versions? Jun 6, 2017 at 15:49
8

Also, this might help finding the actual location the btsnoop_hci.log is being saved:

adb shell "cat /etc/bluetooth/bt_stack.conf | grep FileName"
2
  • When I try to pull this file, I get an error: adb: error: remote object '/data/misc/bluetooth/logs/btsnoop_hci.log' does not exist Apr 14, 2017 at 14:39
  • This configuration file can also be found in a few other places such as /system/etc/ and /vendor/etc/
    – DearVolt
    Jul 11, 2017 at 20:26
2

On a Xiaomi phone with Android 11, after enabling "Bluetooth HCI Snoop log" in developer settings the file seems to be written to

/data/misc/bluetooth/logs/btsnoop_hci.log (only accessible with root)

/sdcard/MIUI/debug_log/common/com.android.bluetooth/btsnoop_hci.log

In addition, it's possible to get the log by running adb bugreport zipname from the computer, as written here.

Note that the logging only turned on after a reboot for me.

1
  • The adb bugreport zipname did it for me, the log was in /data/misc where non-root adb does not have access to. Jan 11 at 18:51
0

On Xiaomi Redmi Note 9s This configuration file can also be found /storage/emulated/0/MIUI/debug_log/common named as hci_snoop20210210214303.cfa hci_snoop20210211095126.cfa

With enabled 'Settings->Developer Options, then checking the box next to "Bluetooth HCI Snoop Log." '

I was used Total Commander for taking file from Internal storage

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.