现在的位置: 首页 > 综合 > 正文

命令行控制蓝牙开关

2018年04月17日 ⁄ 综合 ⁄ 共 1290字 ⁄ 字号 评论关闭

1. 命令行控制蓝牙开关

adb shell
cd /data/data/com.android.providers.settings/databases
sqlite3 settings.db
select * from secure where name="bluetooth_on"; (查看是否打开)
update secure set value=1 where name="bluetooth_on";  (这里的value=1是打开,0是关闭)
select * from secure where name="bluetooth_on"; (确认是否更改成功)
reboot <重启手机生效>

2. 命令行操作蓝牙

Android原生包括高通QRD用的是blueZ的蓝牙协议栈,有提供两个工具:hciconfig和hcitool用于调试蓝牙,开始调试前首先需要将这些工具Push到手机上:
adb remount
adb push hciconfig /system/xbin
adb push hcitool /system/xbin
adb shell
chmod -R 777 /system/xbin
要注意的是,这些工具只适用于blueZ,象MTK用的是bluetoothangel就不适用了

常用的一些命令:
hciconfig -a (查看蓝牙地址,芯片状态等等)
hcitool scan (进行蓝牙搜索,并列出搜索到的设备名称和设备地址)
hciconfig hciX piscan (开启Inquiry Scan和Page Scan,使手机处于可被搜索和可连接状态)
可以使用hciconfig --help以及hcitool --help来查询其它的功能,尤其要提的是hcitool cmd这个命令,通过这个命令可以发送任何的HCI Command,大部分蓝牙功能都可以通过发送HCI Command来实现,具体HCI Command格式可以查询蓝牙Spec

进入测试模式的命令:
hcitool cmd 0x06 0x0003 (Enter Test Mode)
hcitool cmd 0x03 0x0005 0x02 0x00 0x02 (Auto Accept All Connections)
hcitool cmd 0x03 0x001A 0x03 (Page Inquiry Scans)
hcitool cmd 0x03 0x0020 0x00 (Disable Authentication)
hcitool cmd 0x03 0x0022 0x00 (Disable Encryption)

Qualcomm bt test :

the follow commands to bring up bt through adb shell:

 #echo 1 > /sys/class/rfkill/rfkill0/state

#hci_qcomm_init -vvv -e

#hciattach /dev/ttyHS0 qualcomm-ibs 3000000

 #hciconfig hci0 up

#hcitool scan

The follow commands are used to enter test mode.

 #bttest disable

#bttest enable

#bttest enable_dut_mode

抱歉!评论已关闭.