Android 通过 adb 获取蓝牙 MAC 地址

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12197925/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 10:00:09  来源:igfitidea点击:

Get Bluetooth MAC Address via adb

androidbluetoothadbmac-address

提问by Antonio

Please help me to retrieve the Bluetooth MAC Addressof my Galaxy S3 phone connected via USB port. My device is rooted.

请帮助我检索通过 USB 端口连接的 Galaxy S3 手机的蓝牙 MAC 地址。我的设备已植根。

回答by Ted Mielczarek

Running netcfgwill show you all interfaces on the system along with their MAC addresses.

运行netcfg将显示系统上的所有接口及其 MAC 地址。

回答by jinzhaoyu

adb shell cat /sys/class/net/wlan0/address

adb shell cat /sys/class/net/wlan0/address

回答by Teocci

I usually get the mac addressof the WiFi interface of an Android device (that is connected to my PC through a USB port) by running these commands:

我通常通过运行以下命令来获取Android 设备(通过 USB 端口连接到我的 PC)的 WiFi 接口的mac 地址

  1. Find the device name using:

    adb devices
    

    Results usually looks like:

    List of devices attached 
    4e7354af    device
    1f97033e    device
    

    In this case we have two devices connected 4e7354afand 1f97033e. Let's work on the first one: 4e7354af

  2. Get the mac addressfor the first device:

    adb -s 4e7354af shell ip addr show wlan0  | grep 'link/ether '| cut -d' ' -f6
    

    In previous line, we used the -soption with the adbcommands to specify the serial number. Then shellindicate that is a linux command followed by the ip addr show wlan0 | grep 'link/ether '| cut -d' ' -f6this command can also be used in Linux if its interface has the same name as wlan0.

  1. 使用以下命令查找设备名称:

    adb devices
    

    结果通常如下所示:

    List of devices attached 
    4e7354af    device
    1f97033e    device
    

    在这种情况下,我们连接了两个设备,4e7354af并且1f97033e。让我们处理第一个:4e7354af

  2. 获取第一台设备的mac地址

    adb -s 4e7354af shell ip addr show wlan0  | grep 'link/ether '| cut -d' ' -f6
    

    在上一行中,我们使用-s带有adb命令的选项来指定序列号。然后shell表明是一个linux命令后跟ip addr show wlan0 | grep 'link/ether '| cut -d' ' -f6这个命令也可以在Linux中使用,如果它的接口与wlan0.

I generally use this approach because I have many devices connected to my testing environment. Good luck guys.

我通常使用这种方法,因为我有很多设备连接到我的测试环境。祝大家好运。

回答by vtuhtan

Isn't bluetooth MAC address available on every Android phone in Settings?

不是每部 Android 手机都可以在“设置”中使用蓝牙 MAC 地址吗?

Currently I have 2 devices near:

目前我附近有 2 台设备:

On Samsung Galaxy S2 - Settings > About Phone > Status

在三星 Galaxy S2 上 - 设置 > 关于手机 > 状态

On HTC Desire - Settings > About Phone > Hardware Information

在 HTC Desire 上 - 设置 > 关于手机 > 硬件信息

(Bluetooth must be turned on)

(必须开启蓝牙)