アットウィキロゴ

Bluetooth

Bluetooth 関連

まだ、成功していないため覚え書き。動きませんので、これから対応に頑張る人向け
WLAN off で実験しています。

BoardConfig.mk の
BOARD_HAVE_BLUETOOTH := true
は true に指定。

通常ビルドして、実機に転送。


上記で bluez をビルドするが、bccmd がデフォルトでビルド対象になっていないのでビルドするようにする。

Froyo(2.2_r1.3)の場合は
$(ANDROID_SRC)/external/bluetooth/bluez/Android.mk
の最下部に下記を追加する。
#
# bccmd
#

include $(CLEAR_VARS)

LOCAL_SRC_FILES:= \
        bccmd.c \
        csr.c \
        csr_hci.c \
        csr_bcsp.c \
        csr_h4.c \
        csr_3wire.c \
        ubcsp.c

LOCAL_CFLAGS:= \
        -DVERSION=\"4.47\" \
        -D__BSD_VISIBLE=1

LOCAL_C_INCLUDES:=\
        $(LOCAL_PATH)/../include \
        $(LOCAL_PATH)/../common \

LOCAL_SHARED_LIBRARIES := \
        libbluetooth

LOCAL_STATIC_LIBRARIES := \
        libbluez-common-static

LOCAL_MODULE:=bccmd

include $(BUILD_EXECUTABLE)

それからビルドして、
$(TARGET)/system/bin/bccmd
を実機に転送

pskeys.psr を作成して、
/etc/bluetooth/pskeys.psr
に転送。中身は下記のような感じ。
// PSKEY_BDADDR
&0001 = 0044 5566 0033 1122
// PSKEY_UART_BAUDRATE - 921600
&01be = 0ebf
// PSKEY_ANA_FREQ
&01fe = 6590

実は、これが何者なのかいまいち分かっていない。
ドキュメントをしっかり読まないと…^^;
PSKEY_BDADDR とか明らかに適当だし。
bccmd 実行後に読まれるのかなぁ??


init.rc を書き換える。
init.qcom.rc のサービス名が同じ物はコメントアウトしておく。
下記のような感じ(書き換えても、Bluetoothはまだ動作しませんので、むしろ危険です)

service dbus /system/bin/dbus-daemon --system --nofork
    socket dbus stream 660 bluetooth bluetooth
    user bluetooth
    group bluetooth net_bt_admin

service hciattach /system/bin/logwrapper /system/bin/hciattach -n -s 115200 /dev/ttyHS0 bcsp 115200 flow
    user bluetooth
    group qcom_oncrpc bluetooth net_bt_admin system
    disabled
    oneshot

service bluetoothd /system/bin/logwrapper /system/bin/bluetoothd -n /system/etc/bluetooth/main.conf
    socket bluetooth stream 660 bluetooth bluetooth
    socket dbus_bluetooth stream 660 bluetooth bluetooth
    # init.rc does not yet support applying capabilities, so run as root and
    # let bluetoothd drop uid to bluetooth with the right linux capabilities
    group bluetooth net_bt_admin misc
    disabled

 service hfag /system/bin/sdptool add --channel=10 HFAG
    user bluetooth
    group bluetooth net_bt_admin
    disabled
    oneshot

 service hsag /system/bin/sdptool add --channel=11 HSAG
    user bluetooth
    group bluetooth net_bt_admin
    disabled
    oneshot

 service opush /system/bin/sdptool add --channel=12 OPUSH
    user bluetooth
    group bluetooth net_bt_admin
    disabled
    oneshot

service pbap /system/bin/sdptool add --channel=19 PBAP
    user bluetooth
    group bluetooth net_bt_admin
    disabled
    oneshot


さらに、init.rcを編集
これは、弊害が大きすぎるので何が起こってるか分かる人or許せる人向け。
特に、synergy_service との共存に問題がありそう(未調査)

じつは、私もよく分かっていない。。。。英語のドキュメント読みながら対応中。。。。
早い段階で、bccmd を起動する。

on property:persist.service.adb.enable=0
    stop adbd

service bccmd /system/bin/bccmd -t bcsp -d /dev/ttyHS0 psload -r /etc/bluetooth/pskeys.psr
    user bluetooth
    group bluetooth
    oneshot


shell 環境で bccmd を確認してみる。
早い段階で、bccmd を起動しておくと、再度、bccmd を下記の様な引数で実行しても結果が得られた。

# bccmd -t bcsp -d /dev/ttyHS0 psload -r /etc/bluetooth/pskeys.psr
Loading PSKEY_ANA_FREQ ... done
Loading PSKEY_UART_BAUDRATE ... done
Loading PSKEY_UART_SEQ_WINSIZE ... done
Loading PSKEY_BDADDR ... done
Loading PSKEY_PCM_CONFIG32 ... done
Loading PSKEY_PCM_FORMAT ... done
Loading PSKEY_HOSTIO_MAP_SCO_PCM ... done
Loading PSKEY_HOSTIO_MAP_SCO_CODEC ... done
Loading PSKEY_CODEC_PIO ... done

お?動いた???
いろいろ試してみる。

# bccmd -t bcsp -d /dev/ttyHS0 builddef
Build definitions:
0x0009 - TRANSPORT_BCSP
0x000a - TRANSPORT_H4
0x000d - MAX_CRYPT_KEY_LEN_128
0x0013 - RADIOTEST
0x0017 - INSTALL_COMBO_DOT11
0x0019 - TRANSPORT_TWUTL
0x001a - COMPILER_GCC
0x001d - CHIP_BASE_BC3
0x0020 - INSTALL_HCI_MODULE
0x002a - BT_VER_1_2
0x0030 - TRANSPORT_H4DS
0x0031 - CHIP_BASE_BC4

# bccmd -t bcsp -d /dev/ttyHS0 clock
Bluetooth clock: 0x0160 (352)

# bccmd -t bcsp -d /dev/ttyHS0 buildname
Build name: jem_6hci_rom_bt2.1_24_0904171732_encr128 2009-04-17

# bccmd -t BCSP -d /dev/ttyHS0 memtypes
psram (0x0008) = RAM (transient) (2)


# bccmd -t bcsp -d /dev/ttyHS0 psload -r /etc/bluetooth/pskeys.psr
実行後、
# hciattach -n -s 115200 /dev/ttyHS0 any 115200 flow &
Device setup complete
とすると、hci0 deviceが出来るらしいのだが、現在は未だ出来ていない。

dmesgで確認すると、
<3>[ 2897.943006] h4_recv: Unknown HCI packet type 00
<3>[ 2897.943013] h4_recv: Unknown HCI packet type 00
の様なのが大量に排出されてた。

海外の情報によると、bccmd 実行後の hciattach は、any ではなく、
# hciattach -n -s 115200 /dev/ttyHS0 any 115200 flow &
を指定しなければならないと思うんだが…。
あと、ボーレートは適当。

で、 h4_recv: Unknown HCI packet type 00 は kernel と bluez のバージョン整合性の問題だと、海外の掲示板にあったので要調査。

コメント
名前:
コメント:

すべてのコメントを見る


(2011/09/27 21:45 公開)
最終更新:2011年09月27日 23:07
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。