Integration Manual

JODY-W3 series - System integration manual
UBX-19011209 - R07 Software Page 51 of 71
C2-Restricted
3.8.8 Bluetooth usage
Once the Bluetooth drivers are loaded for the UART interface, it is necessary to bind the serial
interface to the Bluetooth stack. For this, use the hciattach tool in the
BlueZ
package.
The following code snippet shows how to attach to
BlueZ
through the /dev/ttyUSB0 serial device. In
the example below, Bluetooth is connected to the host using USB cable connected through FTDI.
$ hciattach /dev/ttyUSB0 any 3000000 flow
[ 442.667056] ps_init_work...
[ 442.675963] ps_init_timer...
[ 442.684716] ps_init...
[ 442.816845] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[ 442.825928] Bluetooth: BNEP socket layer initialized
[ 443.234456] Bluetooth: RFCOMM TTY layer initialized
[ 443.245865] Bluetooth: RFCOMM socket layer initialized
[ 443.254362] Bluetooth: RFCOMM ver 1.11
Device setup complete
An HCI interface (shown here as hci0) is then available for further transactions.
$ hciconfig a hci0 up
hci0: Type: Primary Bus: UART
BD Address: D4:CA:6E:00:1B:16 ACL MTU: 1021:7 SCO MTU: 120:6
UP RUNNING PSCAN
RX bytes:918 acl:0 sco:0 events:62 errors:0
TX bytes:1115 acl:0 sco:0 commands:62 errors:0
Features: 0xff 0xfe 0x8f 0xfe 0xdb 0xff 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH HOLD SNIFF
Link mode: SLAVE ACCEPT
Name: 'apalis-tk1'
Class: 0x200000
Service Classes: Audio
Device Class: Miscellaneous,
HCI Version: 5.0 (0x9) Revision: 0x8300
LMP Version: 5.0 (0x9) Subversion: 0x10bc
A Bluetooth inquiry can be issued to scan for remote devices and verify that Bluetooth is working.
L2CAP echo requests are used to ping the remote devices.
$ hcitool -i hci0 scan
Scanning ...
00:22:58:F8:86:BB ae-sho-bln-test
$ l2ping -i hci0 00:22:58:F8:86:BB
Ping: 00:22:58:F8:86:BB from 00:06:C6:46:DF:7B (data size 44) ...
4 bytes from 00:22:58:F8:86:BB id 0 time 69.75ms
4 bytes from 00:22:58:F8:86:BB id 1 time 56.76ms
[...]
3.8.8.1 Changing the UART baud rate
The vendor specific HCI command HCI_CMD_MARVELL_UART_BAUD can be used to switch to a
different baud rate, for example to 3 000 000 baud, as shown in the following example. The hciattach
tool needs to be restarted with the new baud rate.
$ hcitool i hci0 cmd 0x3F 0x0009 0xC0 0xC6 0x2D 0x00
< HCI Command: ogf 0x3f, ocf 0x0009, plen 4
C0 C6 2D 00
> HCI Event: 0x0e plen 4
01 7A 0C 00
$ killall hciattach
$ hciattach /dev/ttyUSB0 any 3000000 flow
$ hciconfig hci0 up
Commented [MZ86]: Change to 3000000 for ES
Commented [CT87R86]: ROLLOVER to later (ES)
release