This is an old revision of the document!
Bluetooth
Various Bluetooth device setup in Linux on RPi and similar devices.
There are two standards in use known as BT classic and BT low energy.
Anything other than BLE is considered obsolete now.
HCI / LMP | Version |
---|---|
0 | 1.0b |
1 | 1.1 |
2 | 1.2 |
3 | 2.0+EDR |
4 | 2.1+EDR |
5 | 3.0+HS |
6 | 4.0 |
7 | 4.1 |
8 | 4.2 |
9 | 5.0 |
10 | 5.1 |
11 | 5.2 |
12 | 5.3 |
BT 3.0+HS utilises WiFi. BT 4.0 onward is BLE, anything prior is BDR/EDR.
Hardware
RPi
The Raspberry Pi3/4 have built in BT BLE 5.0 but it can be awkward to setup the UART configuration. UART can be /dev/ttyS0 or /dev/ttyAMA0 depending on how you configure it in /boot/config.txt
If the device needs to be attached to a specific the UART it can be done like this.
btattach -B /dev/ttyAMA0 -P bcm -S 3000000
Alternatively, Kernel attachment requires the following entry in /boot/config.txt on both the Pi3 and Pi4.
dtparam=krnbt=on
Pi400
Raspberry Pi 400 Rev 1.0
hci0: Type: Primary Bus: UART BD Address: DC:A6:32:DC:5A:E8 ACL MTU: 1021:8 SCO MTU: 64:1 UP RUNNING RX bytes:6038 acl:0 sco:0 events:400 errors:0 TX bytes:52632 acl:0 sco:0 commands:356 errors:0 Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH SNIFF Link mode: SLAVE ACCEPT Name: 'BlueZ 5.55' Class: 0x000000 Service Classes: Unspecified Device Class: Miscellaneous, HCI Version: 5.0 (0x9) Revision: 0x36 LMP Version: 5.0 (0x9) Subversion: 0x6606 Manufacturer: Broadcom Corporation (15)
Pi3
Raspberry Pi 3 Model B Plus Rev 1.3
hci0: Type: Primary Bus: UART BD Address: 43:45:C0:00:1F:AC ACL MTU: 1021:8 SCO MTU: 64:1 UP RUNNING RX bytes:4726 acl:0 sco:0 events:398 errors:0 TX bytes:60451 acl:0 sco:0 commands:398 errors:0 Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH SNIFF Link mode: SLAVE ACCEPT Name: 'BlueZ 5.50' Class: 0x000000 Service Classes: Unspecified Device Class: Miscellaneous, HCI Version: 5.0 (0x9) Revision: 0x156 LMP Version: 5.0 (0x9) Subversion: 0x6119 Manufacturer: Cypress Semiconductor Corporation (305)
Pi4
Raspberry Pi 4 Model B Rev 1.1
hci0: Type: Primary Bus: UART BD Address: DC:A6:32:03:03:0E ACL MTU: 1021:8 SCO MTU: 64:1 UP RUNNING RX bytes:3680 acl:0 sco:0 events:385 errors:0 TX bytes:66436 acl:0 sco:0 commands:385 errors:0 Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH SNIFF Link mode: SLAVE ACCEPT Name: 'BlueZ 5.55' Class: 0x000000 Service Classes: Unspecified Device Class: Miscellaneous, HCI Version: 5.0 (0x9) Revision: 0x17e LMP Version: 5.0 (0x9) Subversion: 0x6119 Manufacturer: Cypress Semiconductor (305)
USB
Here is a list of obsolete BT USB adapters all of which are either BT 2.0 or 1.2.
BARROT
BT 2.0 CSR clones which are very cheap from pound stores.
usb 2-1: new full-speed USB device number 44 using ohci-platform usb 2-1: device descriptor read/all, error -62 usb 2-1: new full-speed USB device number 45 using ohci-platform usb 2-1: New USB device found, idVendor=0a12, idProduct=0001, bcdDevice= 1.34 usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 Bluetooth: hci0: CSR: Setting up dongle with HCI ver=3 rev=0c5c; LMP ver=3 subver=0c5c; manufacturer=10 Bluetooth: hci0: CSR: Unbranded CSR clone detected; adding workarounds and force-suspending once... Bluetooth: hci0: CSR: Couldn't suspend the device for our Barrot 8041a02 receive-issue workaround Bluetooth: hci0: HCI Delete Stored Link Key command is advertised, but not supported. Bluetooth: hci0: HCI Read Default Erroneous Data Reporting command is advertised, but not supported. Bluetooth: hci0: HCI Set Event Filter command not supported. hci0: Type: Primary Bus: USB BD Address: 00:15:83:0C:BF:EB ACL MTU: 339:8 SCO MTU: 128:2 UP RUNNING RX bytes:966 acl:0 sco:0 events:41 errors:0 TX bytes:913 acl:0 sco:0 commands:41 errors:0 Features: 0xff 0x3e 0x85 0x30 0x18 0x18 0x00 0x00 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF Link mode: PERIPHERAL ACCEPT Name: 'Pi6' Class: 0x000104 Service Classes: Unspecified Device Class: Computer, Desktop workstation HCI Version: 2.0 (0x3) Revision: 0xc5c LMP Version: 2.0 (0x3) Subversion: 0xc5c Manufacturer: Cambridge Silicon Radio (10)
Silicon Wave
A very old BT 1.2 interface
usb 2-1: new full-speed USB device number 46 using ohci-platform usb 2-1: New USB device found, idVendor=0c10, idProduct=0000, bcdDevice=20.05 usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 usb 2-1: Product: Bluetooth Device usb 2-1: Manufacturer: Bluetooth Device usb 2-1: SerialNumber: D9BF16940A00 Bluetooth: hci0: HCI Read Local Supported Commands not supported Bluetooth: MGMT ver 1.22 hci0: Type: Primary Bus: USB BD Address: 00:0A:94:16:BF:D9 ACL MTU: 120:20 SCO MTU: 50:0 UP RUNNING RX bytes:399 acl:0 sco:0 events:17 errors:0 TX bytes:563 acl:0 sco:0 commands:17 errors:0 Features: 0xff 0xff 0x8d 0x78 0x18 0x18 0x00 0x80 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: Link mode: PERIPHERAL ACCEPT Name: 'Pi6' Class: 0x000000 Service Classes: Unspecified Device Class: Miscellaneous, HCI Version: 1.2 (0x2) Revision: 0x0 LMP Version: 1.2 (0x2) Subversion: 0x8a9 Manufacturer: Silicon Wave (11)
Broadcom
BT 2.0
usb 2-1: new full-speed USB device number 47 using ohci-platform usb 2-1: New USB device found, idVendor=050d, idProduct=0012, bcdDevice= 0.00 usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 usb 2-1: Product: BCM92045DG Non-UHE usb 2-1: Manufacturer: Broadcom Corp Bluetooth: MGMT ver 1.22 hci0: Type: Primary Bus: USB BD Address: 00:0A:3A:6D:86:E1 ACL MTU: 1017:8 SCO MTU: 64:8 UP RUNNING RX bytes:492 acl:0 sco:0 events:21 errors:0 TX bytes:574 acl:0 sco:0 commands:21 errors:0 Features: 0xff 0xff 0x8d 0xfe 0x9b 0xf9 0x00 0x80 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF PARK Link mode: PERIPHERAL ACCEPT Name: 'Pi6' Class: 0x000000 Service Classes: Unspecified Device Class: Miscellaneous, HCI Version: 2.0 (0x3) Revision: 0x2000 LMP Version: 2.0 (0x3) Subversion: 0x4127 Manufacturer: Broadcom Corporation (15)
BT 2.0 + EDR
usb 2-1: new full-speed USB device number 48 using ohci-platform usb 2-1: New USB device found, idVendor=0a5c, idProduct=2121, bcdDevice= 1.00 usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 usb 2-1: Product: Bluetooth Dongle V2.0+EDR usb 2-1: Manufacturer: Broadcom Corp Bluetooth: MGMT ver 1.22 hci0: Type: Primary Bus: USB BD Address: 00:19:86:00:01:B6 ACL MTU: 1017:8 SCO MTU: 64:0 UP RUNNING RX bytes:500 acl:0 sco:0 events:22 errors:0 TX bytes:584 acl:0 sco:0 commands:22 errors:0 Features: 0xff 0xff 0x8d 0xfe 0x9b 0xf9 0x00 0x80 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF PARK Link mode: PERIPHERAL ACCEPT Name: 'Pi6' Class: 0x000000 Service Classes: Unspecified Device Class: Miscellaneous, HCI Version: 2.0 (0x3) Revision: 0x411a LMP Version: 2.0 (0x3) Subversion: 0x430e Manufacturer: Broadcom Corporation (15)
Services
DBUS
I normally disable dbus with systemd and here is how to enable this service with `runit' if preferred.
#!/bin/bash sleep 1 #LOG exec 2>&1 ulimit -aH #RUN export TZ="UTC" rm -Rf /var/run/dbus mkdir -p /var/run/dbus exec dbus-daemon --syslog --syslog-only --nofork --config-file=/usr/share/dbus-1/system.conf
BLUETOOTHD
Install bluez and various tools if not already installed
apt install bluez bluez-test-tools bluez-hcidump
I prefer to run Bluetoothd from `runit'
This run file can work but it should wait until dbus is ready before starting.
See the wait method of runit to detect /var/run/dbus/pid.
#!/bin/bash sleep 5 #LOG exec 2>&1 ulimit -aH #RUN export TZ="UTC" exec /usr/sbin/bluetoothd -n