android 蓝牙接口_如何从现代的android手机获取蓝牙主机控制器接口日志

android 蓝牙接口

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.

互联网上流传的大多数有关从Android提取Bluetooth HCI日志的指南都已过时。 这是我通过运行Android版本10的Samsung Galaxy S10设法实现的。

Things that don’t work on this version of android, for this phone at least, include:

至少对于此手机而言,在此版本的android上不起作用的事情包括:

  1. Live capture via Wireshark’s androiddump tool (https://stackoverflow.com/questions/53751028/live-capture-of-android-bluetooth-traffic-via-wireshark)

    通过Wireshark的androiddump工具进行实时捕获( https://stackoverflow.com/questions/53751028/live-capture-of-android-bluetooth-traffic-via-wireshark )

  2. Copying the file directly from the filesystem using adb pull

    使用adb pull直接从文件系统复制文件

Here is what worked for me:

这是对我有用的东西:

Image for post
Press “Build number” 10 times
按“内部编号”十次

步骤1:启用开发人员模式 (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.

转到“设置”,“关于手机”,“软件信息”,然后点击“内部版本号”行7次。 轻按几次后,电话将显示倒数的通知,并确认已启用开发人员选项。

步骤2:启用USB调试和蓝牙日志 (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.

转到“设置”菜单中新启用的“开发人员选项”部分,切换“启用蓝牙HCI监听日志”以启用日志,并切换“ USB调试”以允许我们稍后通过USB提取日志。

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.

然后打开和关闭蓝牙。 日志现已启用(尽管它不会保存到文件系统的用户可访问部分,请继续阅读以了解如何提取日志)。 此时,您应该使用想要捕获蓝牙流量的任何应用程序生成一些日志。

第3步:下载adb的款A ndroid B在UG大桥命令行工具 (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.

至关重要的是,您不需要完整的Android开发工作室。 这些工具可以从https://developer.android.com/studio/releases/platform-tools.html下载,并且需要将其放置在PATH某个位置,以便可以轻松调用它们。

步骤4:确保您的设备已授权并已连接 (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:

使用USB电缆将设备插入计算机。 运行adb devices以查看adb识别的设备列表。 我必须解锁手机,然后在插入手机时收到的通知的“ USB选项”部分中点按以显示一个屏幕,要求我对计算机进行授权,然后才能显示为已授权:

Image for post
Tap the USB for file transfer notification to authorise debugging
点击USB以进行文件传输通知以授权调试

Once authorised, adb will show the device as attached:

授权后, adb将显示该设备已连接:

$ adb devicesList of devices attachedRF8M55WFB4W     device

步骤5:产生错误报告 (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.

使用adb bugreport filename命令生成一个错误报告,该报告将在当前目录中创建filename.zip 。 在此zip文件中, FS/data/log/bt目录中有btsnoop_hci.log文件,可以使用Wireshark打开该文件来检查流量。

包装全部 (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.

它能为您提供帮助吗? 如果您让我知道您设备的品牌和型号以及android版本,那么我将更新本文以列出其起作用(和不起作用)的时间。

翻译自: https://medium.com/@charlie.d.anderson/how-to-get-the-bluetooth-host-controller-interface-logs-from-a-modern-android-phone-d23bde00b9fa

android 蓝牙接口

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值