Find device bluetooth MAC address using adb

2019-02-04 16:15发布

Is there a way to look for a device's bluetooth MAC address using adb. I've tried using logcat to find it. It works right now, but logcat will get overwritten eventually. So I was wondering if there is a way where I can access the bluetooth MAC address anytime I want through adb. I've also tried 'netcfg' but I can't see the bluetooth interface there even when bluetooth is on.

I want to do this through adb.

Thanks

4条回答
干净又极端
2楼-- · 2019-02-04 16:25

cd /data/misc/bluetoothd

ls

BT address would be available

查看更多
干净又极端
3楼-- · 2019-02-04 16:27

adb shell settings get secure bluetooth_address

or

adb shell service call bluetooth_manager 10 for Android 4.4.4

adb shell service call bluetooth_manager 12 for Android 5.0+

查看更多
贼婆χ
4楼-- · 2019-02-04 16:32

You could use something like this:

adb shell cat /data/misc/bluetooth/bt_config.xml

And you will get an output:

<N1 Tag="Local">
    <N1 Tag="Adapter">
        <N1 Tag="BluezMigrationDone" Type="int">1</N1>
        <N2 Tag="Address" Type="string">5c:51:4f:0e:cc:92</N2>
        <N3 Tag="ScanMode" Type="int">0</N3>
        <N4 Tag="DiscoveryTimeout" Type="int">120</N4>
    </N1>

The Tag="Address" line has the MAC address for Bluettoth. On my device I used:

adb shell cat /data/misc/bluedroid/bt_config.xml

As an alternative you could pull the xml file using:

adb pull /data/misc/bluetooth/bt_config.xml local_folder

and parse the file locally.

查看更多
5楼-- · 2019-02-04 16:36

For samsung devices Android 7.0+ or API level 25+ try this:

 adb shell strings /data/misc/bluedroid/bt_config.conf | grep Address
查看更多
登录 后发表回答