Android 命令行控制蓝牙开关【转】

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值