Wednesday, May 27, 2009

few notes about android bluetooth

bluez version3.36 source code in Android git

start bluetooth manually
Pull high in BT power

#echo 1 > /sys/class/rfkill/rfkill0/state

Load BT firmware to hci stack
# hciattach -n -s 115200 /dev/ttyHS0 texas 4000000 flow

Texas module LMP version : 0X3
Texas module LMP sub-version : 0X1126
internal version freeze: 38
software version: 2
chip: brf6300 (4)
Setting speed to 4000000
Texas speed changed to 4000000.
Loading firmware from /etc/firmware/brf6300.bin...
Firmware load successful.

Start HCI device
# hciconfig hci0 up

Start HCI daemon
# hcid -s -n -f /etc/bluez/hcid.conf

hcid[307]: Bluetooth HCI daemon
hcid[307]: Device hci0 has been activated

Gettingthe current values from dbus:

# dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.GetMode
# dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.GetDiscoverableTimeout

Changing to discoverable mode and setting the timeout to 60 seconds

# dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.SetMode string:discoverable
# dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.SetDiscoverableTimeout uint32:60

check bluetooth is On or Off
# ps | grep hci

325 1002 744 S /system/bin/hciattach -n -s 115200 /dev/ttyHS0 texas
326 1002 1608 S /system/bin/hcid -s -n -f /etc/bluez/hcid.conf

bluetooth configuration file:

hcid.conf manual

check bluetooth device in detail
# hciconfig -a

hci0: Type: UART
BD Address: 00:22:A5:B8:AD:65 ACL MTU: 1021:4 SCO MTU: 180:4
RX bytes:2271 acl:18 sco:0 events:66 errors:0
TX bytes:1156 acl:16 sco:0 commands:39 errors:0
Features: 0xff 0xff 0x2d 0xfe 0x9b 0xf9 0x00 0x80
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Name: 'g1mokoko'
Class: 0x48010c
Service Classes: Capturing, Telephony
Device Class: Computer, Laptop
HCI Ver: 2.0 (0x3) HCI Rev: 0x0 LMP Ver: 2.0 (0x3) LMP Subver: 0x1126
Manufacturer: Texas Instruments Inc. (13)

# dmesg | grep Blue

[ 5.751220] Bluetooth: HCI UART driver ver 2.2
[ 5.751525] Bluetooth: HCI H4 protocol initialized
[ 5.751831] Bluetooth: HCILL protocol initialized
[ 5.767395] Bluetooth: L2CAP ver 2.11
[ 5.767669] Bluetooth: L2CAP socket layer initialized
[ 5.768005] Bluetooth: SCO (Voice Link) ver 0.6
[ 5.768524] Bluetooth: SCO socket layer initialized
[ 5.782531] Bluetooth: RFCOMM socket layer initialized
[ 5.782928] Bluetooth: RFCOMM TTY layer initialized
[ 5.783599] Bluetooth: RFCOMM ver 1.10
[ 5.783905] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[ 5.784210] Bluetooth: HIDP (Human Interface Emulation) ver 1.2

Scan nearby bluetooth devices
# hcitool scan

Scanning ...
00:22:43:C6:5B:B9 daydreamer-0
00:18:C5:42:18:78 Erin-Nokia N73
00:1E:52:6D:E8:E9 erin's keyboard
00:0F:79:08:D4:05 GgBlu
00:07:61:4B:20:3B Bluetooth Travel Mouse

Check what service it has: AVRCP,A2DP,HandsFree, Headset
# sdptool browse local

Browsing FF:FF:FF:00:00:00 ...
Service Name: Audio Source
Service RecHandle: 0x10000
Service Class ID List:
"Audio Source" (0x110a)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 25
"AVDTP" (0x0019)
uint16: 0x100
Profile Descriptor List:
"Advanced Audio" (0x110d)
Version: 0x0100

Service Name: AVRCP TG
Service RecHandle: 0x10001
Service Class ID List:
"AV Remote Target" (0x110c)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 23
"AVCTP" (0x0017)
uint16: 0x100
Profile Descriptor List:
"AV Remote" (0x110e)
Version: 0x0100

Service Name: Voice Gateway
Service RecHandle: 0x10002
Service Class ID List:
"Headset Audio Gateway" (0x1112)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 11
Profile Descriptor List:
"Headset" (0x1108)
Version: 0x0100

Service Name: Voice Gateway
Service RecHandle: 0x10003
Service Class ID List:
"Handsfree Audio Gateway" (0x111f)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 10
Profile Descriptor List:
"Handsfree" (0x111e)
Version: 0x0105

Connect to bluetooth keyboard
add these lines to /etc/bluez/hcid.conf
device 00:1E:52:6D:E8:E9 {
name “Bluetooth Keyboard”;
auth enable;
encrypt enable;
# hidd --connect 00:1E:52:6D:E8:E9

Connect to bluetooth mice
add these lines to /etc/bluez/hcid.conf
device 00:07:61:4B:20:3B {
name “Bluetooth Mouse”;
# hidd --connect 00:07:61:4B:20:3B

Confirm the connections
hidd --show

00:1E:52:6D:E8:E9 Bluetooth HID Boot Protocol Device [0000:0000] connected [boot-protocol]
00:07:61:4B:20:3B Bluetooth HID Boot Protocol Device [0000:0000] connected [boot-protocol]

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.