android4.0.3 bluetooth
来源:互联网 发布:给淘宝商家供货 编辑:程序博客网 时间:2024/05/16 13:53
android:android4.0.3
kernel:linux3.0.8
五一放假之前,这个蓝牙可以收发数据了,身上一下子轻松了好多。kernel:linux3.0.8
1.kernel :
[*] Networking support --->
<*> Bluetooth subsystem support --->
[*] L2CAP protocol support
[*] SCO links support <*> RFCOMM protocol support
[*] RFCOMM TTY support
<*> BNEP protocol support
[ ] Multicast filter support
[ ] Protocol filter support
<*> HIDP protocol support
Bluetooth device drivers --->
<*> HCI USB driver
< > HCI SDIO driver
< > HCI UART driver
< > HCI BCM203x USB driver
< > HCI BPA10x USB driver
< > HCI BlueFRITZ! USB driver
< > HCI VHCI (Virtual HCI device) driver
< > Marvell Bluetooth driver support
<*> Atheros firmware download driver
<*> RF switch subsystem support --->
[*] Power off on suspend
[*] RF switch input support
<*> Generic rfkill regulator driver
<*> GPIO RFKILL driver
[*] RF switch input support
<*> Generic rfkill regulator driver
<*> GPIO RFKILL driver
2.android
a. init.smdkv210.rc 添加:
chown bluetooth bluetooth /sys/class/rfkill/rfkill0/type
chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state
chmod 0660 /sys/class/rfkill/rfkill0/state
b. 在init.rc中添加:
service hciattach /system/bin/hciattach -n -s 115200 /dev/ttySAC1 bcsp 115200
class main
disabled
oneshot
到了这里编译烧写后,蓝牙能正常使用了。
chown bluetooth bluetooth /sys/class/rfkill/rfkill0/type
chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state
chmod 0660 /sys/class/rfkill/rfkill0/state
b. 在init.rc中添加:
service hciattach /system/bin/hciattach -n -s 115200 /dev/ttySAC1 bcsp 115200
class main
disabled
oneshot
到了这里编译烧写后,蓝牙能正常使用了。
问题1:
打开蓝牙—系统休眠—唤醒—蓝牙自动关闭再也打不开。
但是在系统休眠或是USB蓝牙设备热插拔后蓝牙设备的节点名就会被重新分配,也就是驱动被重新加载了。这样驱动注册
时所创建的文件夹rfkill0就会变成rfkill1、rfkill2、rfkill3……这就会导致android上层找不到设备文件。
解决:
把设备名定死为rfkill0,这样设备起来的时候就不会因找不到设备了。
修改:
kernel\net\rfkill\core.c
在函数rfkill_register(struct rfkill *rfkill)中:
//rfkill_no=0; //方法1:强制置0
rfkill->idx = rfkill_no;
dev_set_name(dev, "rfkill%lu", rfkill_no);
//rfkill_no++; //方法2:注释掉设备名自加
问题2:
修改上述问题后,系统休眠后唤醒或者热插拔,设备名就一直是rfkill0了。
但是蓝牙还是打不开,提示对rfkill0/state没有写权限,logcat提示:
E/bluedroid( 161): open(/sys/class/rfkill/rfkill0/state) for write failed: Permission denied (13)
E/BluetoothAdapterStateMachine( 161): failed to prepare bluetooth, abort turning on
D/BluetoothAdapterStateMachine( 161): Bluetooth state 11 -> 10
解决:
给state权限。
在源码中给权限,即在注册时给设备节点读写权限:
kernel\net\rfkill\core.c
在rfkill_dev_attrs 结构体中将 state 中S_IWUSR改为S_IWUGO
__ATTR(state, S_IRUGO|S_IWUGO, rfkill_state_show, rfkill_state_store),//S_IWUSR, rfkill_state_show, rfkill_state_store),
说明:#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH)
S_IWUSR:用户写权限
S_IWGRP:用户组写权限
S_IWOTH:其他写权限
或者可先在终端给权限,chmod 0666 state
问题3:
修改权限后,唤醒后打开打开蓝牙—系统休眠—唤醒—android会重启,但是kernel没有重启,即屏幕上会回到android
闪动的那个画面,待系统起来后,bluetooth又能正常工作了。但过会系统休眠后又会重复上述情况。logcat提示:
D/BluetoothEventLoop( 2636): Property Changed: Pairable : true
D/BluetoothAdapterStateMachine( 2636): BluetoothOn process message: 54
E/BluetoothAdapterStateMachine( 2636): Get unexpected power on event, reset with: 1
D/BluetoothAdapterStateMachine( 2636): HotOff process message: 102
解决:追踪到android\frameworks\base\core\java\android\server\BluetoothA2dpService.java 550行
private class BluetoothOn extends State {中
case POWER_STATE_CHANGED:
if ((Boolean) message.obj) {
// reset the state machine and send it TURN_ON_CONTINUE message
// recoverStateMachine(USER_TURN_ON, false); //注释掉此句
}
break;
default:
编译烧写后,唤醒后打开打开蓝牙—系统休眠—唤醒,蓝牙还能继续正常工作,再关闭打开也正常。
- android4.0.3 bluetooth
- android4.0.3 bluetooth
- android4.0.3 bluetooth
- Android4.3 Bluetooth开篇
- Android4.3 Bluetooth开篇
- Android4.4 Bluetooth enble
- Android4.3 Bluetooth基本介绍
- Android4.3 Bluetooth基本介绍
- android4.2 bluetooth 文件位置
- Android4.4 之Bluetooth整理
- Android4.4 之Bluetooth整理
- android4.4 bluetooth 配置文件分析
- Android4.3 Bluetooth基本介绍
- android4.4 bluetooth 配置文件分析
- 和菜鸟一起学android4.0.3源码之bluetooth移植心得
- 和菜鸟一起学android4.0.3源码之bluetooth移植心得
- 和菜鸟一起学android4.0.3源码之bluetooth移植心得
- android4.2 bluetooth蓝牙HFP/HSP/A2DP
- beautifulsoup的简单用法
- My Internal training Doc on Sencha Touch build Mobile Web Applications
- Linux_Linux指令CP
- 1.11 自定义组合控件
- 杭电题目分类
- android4.0.3 bluetooth
- TEST
- 欧几里得算法、拓展欧几里得算法解青蛙约会问题
- JTextPane使用笔记
- ORA-01036: 非法的变量名/编号 解决方法
- 利用左右连接解决查询为空问题
- GridView中数据源中包含html标签显示问题的解决方法
- mysql 优化
- 根据模板参数生成派生类