Android手机Nexus One连接Apple Bluetooth Keyboard

首先所有带蓝牙的android手机理论上都是可以连接蓝牙键盘鼠标的(Human Interface Device),不幸地是官方的蓝牙profile中默认不包括HID profile。所以只有采用第三方的ROM如Cyanogen(CM6版本以上)或在官方的rom上搭配bluez utility来实现蓝牙键鼠的连接。

这里我们仅讨论第二种在官方ROM上添加工具的方案。手机必须取得root权限,或者是ADP (Android Dev Phone),并且需要安装busybox。

1. 先下载需要的工具。

\[code lang="bash"\]

$ wget http://androidobex.googlecode.com/files/hciconfig $ wget http://androidobex.googlecode.com/files/hcitool $ wget http://androidobex.googlecode.com/files/hidd

\[/code\]

2. 提升到root权限,并且将/system挂载成可读写,默认为read-only

\[code lang="bash"\]

$ su # mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system # chmod 777 /system/xbin

\[/code\]

3. 从本地复制第一步下载的文件到手机

\[code lang="bash"\]

$ adb push hidd /system/xbin $ adb push hcitool /system/xbin $ adb push hciconfig /system/xbin

\[/code\]

4. 如果你的手机不是ADP的话,可能无法直接从本地电脑复制文件到手机。这样你可以先用usb线连接手机,把以上三个文件复制到sdcard根目录上,然后执行。

\[code lang="bash"\]

# cp /sdcard/hidd /system/xbin/ # cp /sdcard/hcitool /system/xbin/ # cp /sdcard/hciconfig /system/xbin/

\[/code\]

5. 打开手机蓝牙,在Settings -> Wireless & network settings -> Bluetooth settings中找到键盘并且配对。pin code可以填写0000,配对成功后会发现该设备显示为’paried but not connected’,这是因为缺少HID profile。

6. 现在要用到之前拷入手机的三个文件。实际情况中设备的Mac地址会与下面的例子有所不同,根据实际情况输入。

\[code lang="bash"\]

# hciconfig hci0: Type: UART BD Address: 00:22:A5:B8:AD:65 ACL MTU: 1021:4 SCO MTU: 180:4 UP RUNNING PSCAN RX bytes:8672 acl:98 sco:0 events:285 errors:0 TX bytes:3336 acl:102 sco:0 commands:89 errors:0

# hcitool dev Devices: hci0 00:22:A5:B8:AD:65

# hcitool scan Scanning … 00:1D:4F:A7:9A:49 Apple Wireless Keyboard

# hidd –connect 00:1D:4F:A7:9A:49

# hcitool con Connections: < ACL 00:1D:4F:A7:9A:49 handle 1 state 1 lm MASTER

\[/code\]

9. 至此,Apple Bluetooth Keyboard连接成功。打开任意程序,蓝牙键盘敲击的键将出现在输入栏。经过测试,谷歌中文法也可以正常使用并且可以用数字键选择候选字。

10. 剩下的问题就是苹果的键盘的多功能键(调节音量,屏幕亮度)暂时还不能在手机里使用,有待进一步研究如何修改这几个键位。

使用 Hugo 构建
主题 StackJimmy 设计