Bluetooth Testing
The QuecPi Alpha single-board computer supports the QCA1023 HCI UART Bluetooth module for connecting Bluetooth peripherals. This document describes how to test Bluetooth keyboard and mouse connectivity.
Initialize Bluetooth Module
The Bluetooth module connects to the CPU via HCI UART using the HCI H4 protocol.
Power on the Bluetooth peripheral by writing to the device node with the following command. Power off the Bluetooth peripheral by writing to the device node with echo 0.
echo 1 > /sys/devices/platform/rfkill/bt_en
Initialize the Bluetooth module via UART with the hciattach command.
hciattach /dev/ttyHS1 qca 3000000 flow
Query and enable the HCI Bluetooth device with the hciconfig command:
hciconfig hci0 up
Verify HCI device status with hciconfig. When the status is UP RUNNING
, it indicates that the HCI Bluetooth device is enabled:
root@qcm6490-idp:~# hciconfig
hci0: Type: Primary Bus: UART
BD Address: 00:00:00:00:5A:AD ACL MTU: 1024:7 SCO MTU: 60:8
UP RUNNING
RX bytes:783665 acl:1106 sco:0 events:18678 errors:0
TX bytes:4072 acl:57 sco:0 commands:305 errors:0
Connect Bluetooth Peripherals
Execute bluetoothctl to enter Bluetooth configuration tool. When the command prompt changes to [bluetooth]#
, it indicates that the device enters Bluetooth control mode.
root@qcm6490-idp:~# bluetoothctl
[bluetooth]#
Execute scan on to start device discovery to display nearby Bluetooth devices. Please enable pairing mode on the target device.
[bluetooth]# scan on
After scanning for a while, execute scan off to stop scanning.
[bluetooth]# scan off
Execute devices to list discovered devices and find your Bluetooth device. Here is an example of a Bluetooth mouse.
[bluetooth]# devices
Device C3:3E:68:5E:E7:1F MX Master 2S
Execute the pair command to pair the device with your peripherals' address.
[bluetooth]# pair C3:3E:68:5E:E7:1F
If the pairing is successful, the CHG logs will be printed out. Then the mouse is registered to the input device such as input5 (Please refer to the actual registered address).
[CHG] Device C3:3E:68:5E:E7:1F Modalias: usb:v046DpB019d0006
[MX Master 2S]# [ 1157.381232][ T1737] input: MX Master 2S Keyboard as /devices/virtual/misc/uhid/0005:046D:B019.0001/input/input4
[ 1157.392409][ T1737] input: MX Master 2S Mouse as /devices/virtual/misc/uhid/0005:046D:B019.0001/input/input5
Add the device to trust and connect. (Optional if your device supports autoconnection.)
[MX Master 2S]# trust C3:3E:68:5E:E7:1F
Changing C3:3E:68:5E:E7:1F trust succeeded
[MX Master 2S]# connect C3:3E:68:5E:E7:1F
Attempting to connect to C3:3E:68:5E:E7:1F
Connection successful
Verify Peripheral
At this point, you can use the evtest tool to verify if the peripheral is functional. Enter evtest to view the list of available event devices. Then, select the device corresponding to your mouse (e.g., event 5).
root@qcm6490-idp:~# evtest
No device specified, scanning all /dev/input/event*
Available devices:
/dev/input/event0: pm8xxx_vib_ffmemless
/dev/input/event1: gpio-keys
/dev/input/event2: pmic_pwrkey
/dev/input/event3: pmic_resin
/dev/input/event4: MX Master 2S Keyboard
/dev/input/event5: MX Master 2S Mouse
Select the device event number [0-5]:
When the following information appears, the connection is completed. Mouse movements will generate real-time event reports.
Input driver version is 1.0.1
Input device ID: bus 0x5 vendor 0x46d product 0xb019 version 0x6
Input device name: "MX Master 2S Mouse"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 272 (BTN_LEFT)
Event code 273 (BTN_RIGHT)
Event code 274 (BTN_MIDDLE)
Event code 275 (BTN_SIDE)
Event code 276 (BTN_EXTRA)
Event code 277 (BTN_FORWARD)
Event code 278 (BTN_BACK)
Event code 279 (BTN_TASK)
Event code 280 (?)
Event code 281 (?)
Event code 282 (?)
Event code 283 (?)
Event code 284 (?)
Event code 285 (?)
Event code 286 (?)
Event code 287 (?)
Event type 2 (EV_REL)
Event code 0 (REL_X)
Event code 1 (REL_Y)
Event code 6 (REL_HWHEEL)
Event code 8 (REL_WHEEL)
Event code 11 (REL_WHEEL_HI_RES)
Event code 12 (REL_HWHEEL_HI_RES)
Event type 4 (EV_MSC)
Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)
Event: time 2618.445029, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 2618.445029, type 1 (EV_KEY), code 272 (BTN_LEFT), value 1
Event: time 2618.445029, -------------- SYN_REPORT ------------
Event: time 2618.610162, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 2618.610162, type 1 (EV_KEY), code 272 (BTN_LEFT), value 0
Event: time 2618.610162, -------------- SYN_REPORT ------------