Android手機Nexus One串連Apple Bluetooth Keyboard
Posted on August 20, 2010 by henry
首先所有帶藍芽的android手機理論上都是可以串連藍芽鍵盤滑鼠的(Human Interface Device),不幸地是官方的藍芽profile中預設不包括HID profile。所以只有採用第三方的ROM如Cyanogen(CM6版本以上)或在官方的rom上搭配bluez utility來實現藍芽鍵鼠的串連。
這裡我們僅討論第二種在官方ROM上添加工具的方案。手機必須取得root許可權,或者是ADP (Android Dev Phone),並且需要安裝busybox。
1. 先下載需要的工具。
$ wget http://androidobex.googlecode.com/files/hciconfig
$ wget http://androidobex.googlecode.com/files/hcitool
$ wget http://androidobex.googlecode.com/files/hidd
2. 提升到root許可權,並且將/system掛載成可讀寫,預設為read-only
$ su
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
# chmod 777 /system/xbin
3. 從本地複製第一步下載的檔案到手機
$ adb push hidd /system/xbin
$ adb push hcitool /system/xbin
$ adb push hciconfig /system/xbin
4. 如果你的手機不是ADP的話,可能無法直接從本地電腦複製檔案到手機。這樣你可以先用usb線串連手機,把以上三個檔案複製到sdcard根目錄上,然後執行。
# cp /sdcard/hidd /system/xbin/
# cp /sdcard/hcitool /system/xbin/
# cp /sdcard/hciconfig /system/xbin/
5. 開啟手機藍芽,在Settings -> Wireless & network settings -> Bluetooth settings中找到鍵盤並且配對。pin code可以填寫0000,配對成功後會發現該裝置顯示為’paried but not connected’,這是因為缺少HID profile。
6. 現在要用到之前拷入手機的三個檔案。實際情況中裝置的Mac地址會與下面的例子有所不同,根據實際情況輸入。
# 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
9. 至此,Apple Bluetooth Keyboard串連成功。開啟任意程式,藍芽鍵盤敲擊的鍵將出現在輸入欄。經過測試,Google中文法也可以正常使用並且可以用數字鍵選擇候選字。
10. 剩下的問題就是蘋果的鍵盤的多功能鍵(調節音量,螢幕亮度)暫時還不能在手機裡使用,有待進一步研究如何修改這幾個鍵位。
轉載:http://hi.baidu.com/fanrifei/blog/item/5a79607a0bf25fe22e73b3dc.html