0% found this document useful (0 votes)
139 views

UART HCI Bluetooth Module For Linux v1 - 0

Uploaded by

Bill D
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views

UART HCI Bluetooth Module For Linux v1 - 0

Uploaded by

Bill D
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

A

UART HCI Bluetooth Module for Linux


BT860
Application Note v1.0

INTRODUCTION
BT860 is Laird’s latest UART HCI Bluetooth module based on the Cypress CYW20704 A2 chipset. This application
note describes how to use the BlueZ BCCMD tool to attach on the Linux platform. BlueZ and BlueZ-Utils
packages are required for this operation.

REQUIREMENTS
▪ BT860 development board
▪ BlueZ – Official Linux Bluetooth protocol stack

Notes: The BT860 development board uses the FTDI USB-UART chip. The testing platform used in this
application note has the driver installed automatically. The name of the serial port is
/dev/ttyUSB0.

Ubuntu 16.04 is used as the testing platform (Kernel version 4.4.0-31). The BlueZ stack (v 5.37) is
included.

PREPARATION
Before plugging the BT860 development board to the computer, type hciconfig to find out if there are any
existing Bluetooth radios. If you find one, close it by typing the following: hciconfig hciX down (Figure 1).
Typically, hci0 is the first Bluetooth device on the computer. Superuser permissions should be required.

Figure 1: Disable existing computer existing Bluetooth device

After plugging the BT860 development board to the computer, locate the USB UART port by typing the
following: dmesg | grep FTDI (Figure 2). The development board uses the FTDI USB-UART chip.
Embedded Wireless Solutions Support Center: Americas: +1-800-492-2320
http://ews-support.lairdtech.com 1 Europe: +44-1628-858-940
www.lairdtech.com/wireless © Copyright 2015 Laird. All Rights Reserved Hong Kong: +852 2923 0610
BT860 UART HCI Bluetooth Module for Linux
Application Note

Figure 2: Locate the FTDI USB-UART port

Attaching the HCI UART BT Module


In the recent release of BlueZ, the hciattach command was deprecated and is replaced with btattach. On this
test platform, both commands are supported. Your platform may have removed the hciattach command. This
document covers both commands.
With the hciattach command, BlueZ tries to load the new firmware if it is provided. Even it is not provided, it
continues to attach (Figure 3). The BT860 is loaded with HCI firmware at production (Figure 4).

Figure 3: hciattach /dev/ttyUSB0 bcm43xx 921600 attaches the BT860

Figure 4: btattach /dev/ttyUSB0 attaches the BT860

Launching the Bluetooth Stack with New Settings


To confirm that the BT860 is successfully attached, type hciconfig to see all recognized Bluetooth radios. To
enable the BT860, type hciconfig hci0 up if it is shown as DOWN (Figure 5).

Figure 5: BT860 is recognized and listed as UP and RUNNING


Embedded Wireless Solutions Support Center: Americas: +1-800-492-2320
http://ews-support.lairdtech.com 2 Europe: +44-1628-858-940
www.lairdtech.com/bluetooth © Copyright 2018 Laird. All Rights Reserved Hong Kong: +852 2923 0600
BT860 UART HCI Bluetooth Module for Linux
Application Note

CONNECTING THE BT860 VIA COMMAND LINE


Verify BT860 Connection
In Linux, you may configure and test the BT860 via terminal. The Linux utility to configure and identify Bluetooth
is hcitool. To verify that the BT860 is recognized by the operating system, run hcitool and check for devices by
doing the following:
1. Open the command terminal.
2. Enter the following command:

hcitool dev

This command displays local devices. If it finds one, it returns the following (Figure 6):

Figure 6: Command found a local device

Note: The hcitool command uses the first available Bluetooth device for its operations. If multiple
Bluetooth devices are found, all hcitool commands must specify which device to use, as follows:

hcitool [-i <hciX>] [command [command parameters]]

In this example, <hciX> must correspond to the HCI device number found using hcitool dev, e.g.
hci1.

Connecting with Classic Bluetooth


With the device initialized, you may test Bluetooth functionality from the command prompt. To test scanning,
you must have a nearby device (such as a tablet or smartphone) set to be discoverable.
The command to initialize a scan is:

hcitool scan

When a scan is initialized, the terminal returns found devices in the following format:

Scanning ...
[MAC Address] Friendly_Name

If there are discoverable devices nearby, they appear in this list as they are discovered (Figure 7).

Embedded Wireless Solutions Support Center: Americas: +1-800-492-2320


http://ews-support.lairdtech.com 3 Europe: +44-1628-858-940
www.lairdtech.com/bluetooth © Copyright 2018 Laird. All Rights Reserved Hong Kong: +852 2923 0600
BT860 UART HCI Bluetooth Module for Linux
Application Note

Figure 7: Laird module is discovered

To demonstrate the RFcomm connection, a Laird module (already configured as discoverable and connectable),
is used. Simple secure mode must also be enabled (Figure 8).

Figure 8: RFconn connection to the module

Figure 9: Module shows it is connected

Connecting with Bluetooth Low Energy


The hcitool commands to scan Bluetooth Low Energy are distinct from those used in classic Bluetooth
connections. To initiate a BLE scan from the terminal, issue the following command:

#hcitool lescan

The terminal returns the following:

LE Scan ...
[MAC Address] – [BLE device]

Embedded Wireless Solutions Support Center: Americas: +1-800-492-2320


http://ews-support.lairdtech.com 4 Europe: +44-1628-858-940
www.lairdtech.com/bluetooth © Copyright 2018 Laird. All Rights Reserved Hong Kong: +852 2923 0600
BT860 UART HCI Bluetooth Module for Linux
Application Note

Figure 10: Scan for BLE devices

To demonstrate the BLE connection, a Laird module running the Laird vSP upass application is used (Figure 11).

Figure 11: Module running $autorun$.vsp.UART.bridge application

The Linux computer first scans for the Bluetooth device. Once the module displays, Press Ctrl-C to stop the
scanning. Send the following command:
gatttool –b <BT900_MAC> -t random –I
Once the prompt is returned, send the following:
Connect
The Linux computer returns Connection successful and the BT860 connected to UwTerminal reports the
connection as well (Figure 12).

Figure 12: Make a BLE connection to the module

To locate the handles for TX and RX, send the command characteristics to obtain the list of characteristics
(including the properties, handle value, and UUID). From the BL600 smartBASIC extension guide, the BL600 TX
characteristic UUID is 569a2000-b87f-490c-92cb-11ba5ea5167c and the Linux host must enable notification to
receive data from the BL600. The BL600 RX characteristic UUID is 569a2001-b87f-490c-92cb-11ba5ea5167c and
the Linux host writes to it (Figure 13).

Embedded Wireless Solutions Support Center: Americas: +1-800-492-2320


http://ews-support.lairdtech.com 5 Europe: +44-1628-858-940
www.lairdtech.com/bluetooth © Copyright 2018 Laird. All Rights Reserved Hong Kong: +852 2923 0600
BT860 UART HCI Bluetooth Module for Linux
Application Note

Figure 13: List of characteristics

To enable notification, send the following command:


char-write-req 0x001c 010

Figure 14: Enable notification for Modem-In and TX characteristics and written to Modem-Out characteristic to set the value to 1

From UwTerminal, you can enter ABCDEF into the terminal and press Enter. Data is received on the Linux
computer.

Figure 15: ABCDEF\n sent and received as notification

Embedded Wireless Solutions Support Center: Americas: +1-800-492-2320


http://ews-support.lairdtech.com 6 Europe: +44-1628-858-940
www.lairdtech.com/bluetooth © Copyright 2018 Laird. All Rights Reserved Hong Kong: +852 2923 0600
BT860 UART HCI Bluetooth Module for Linux
Application Note

To send from the BT860 side with ABCDEF as data, enter the following command:
char-write-cmd 0x001e 414243444546

Figure 16: Writing ABCDEF to the module

Figure 17: Data ABCDEF is received on the module side

REVISION HISTORY
Version Date Notes Contributors Approver
1.0 18 Jan 2018 Initial Release Raymond Au Jonathan Kaye

Embedded Wireless Solutions Support Center: Americas: +1-800-492-2320


http://ews-support.lairdtech.com 7 Europe: +44-1628-858-940
www.lairdtech.com/bluetooth © Copyright 2018 Laird. All Rights Reserved Hong Kong: +852 2923 0600

You might also like