0

##### PROBLEM #################################

I have a bluetooth device that was connecting fine with RPi4 with buster after the GUI has loaded but I am now having problems with the connection after boot and with reconnecting once disconnected. The error shows like the device is down but it is not.

pi@raspberrypi:~ $ systemctl status bluetooth
● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset
   Active: active (running) since Tue 2021-03-09 12:00:31 CET; 1h 18min ago
     Docs: man:bluetoothd(8)
 Main PID: 739 (bluetoothd)
   Status: "Running"
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/bluetooth.service
           └─739 /usr/lib/bluetooth/bluetoothd

mar 09 12:04:16 raspberrypi bluetoothd[739]: Can't get HIDP connection info
mar 09 12:04:21 raspberrypi bluetoothd[739]: connect error: Host is down (112)
mar 09 12:04:37 raspberrypi bluetoothd[739]: Can't get HIDP connection info
mar 09 12:04:43 raspberrypi bluetoothd[739]: connect error: Host is down (112)
mar 09 12:06:24 raspberrypi bluetoothd[739]: Can't get HIDP connection info
mar 09 12:06:29 raspberrypi bluetoothd[739]: connect error: Host is down (112)
mar 09 12:34:27 raspberrypi bluetoothd[739]: Can't get HIDP connection info
mar 09 12:34:32 raspberrypi bluetoothd[739]: connect error: Host is down (112)
mar 09 13:18:42 raspberrypi bluetoothd[739]: Can't get HIDP connection info
mar 09 13:18:47 raspberrypi bluetoothd[739]: connect error: Host is down (112)

pi@raspberrypi:~ $ bluetoothctl
Agent registered
[BLOW-BK105]# devices
Device 90:50:7B:87:90:02 powerSCANNDY07474838
Device A1:18:81:12:26:16 BLOW-BK105
Device 00:00:10:00:01:64 Trust-MS-01
[BLOW-BK105]# info 90:50:7B:87:90:02
Device 90:50:7B:87:90:02 (public)
    Name: powerSCANNDY07474838
    Alias: powerSCANNDY07474838
    Class: 0x00002540
    Icon: input-keyboard
    Paired: yes
    Trusted: yes
    Blocked: no
    Connected: no
    LegacyPairing: no
    UUID: Human Interface Device... (00001124-0000-1000-8000-00805f9b34fb)
[BLOW-BK105]# connect 90:50:7B:87:90:02
Attempting to connect to 90:50:7B:87:90:02
Failed to connect: org.bluez.Error.Failed
[BLOW-BK105]# 

Below is the content of the file /var/lib/bluetooth/<adapter mac>/<device mac>/info:

[General]
Name=powerSCANNDY07474838
Class=0x002540
SupportedTechnologies=BR/EDR;
Trusted=true
Blocked=false
Services=00001124-0000-1000-8000-00805f9b34fb;

[LinkKey]
Key=E121F0AE8C741F5D8F988F41CABB2200
Type=5
PINLength=0

##### QUESTION #################################

I have reinstalled the bundle bluez, bluez-firmware, pi-bluetooth but nothing changed. Any suggestions?

##### UPDATE n.1 ###############################

Below is the output of dmesg. I do not see anything particular going on with powerSCANNDY07474838 Keyboard. The output is the same as when working correctly.

Mar 11 12:45:22 raspberrypi kernel: [   15.581682] Bluetooth: Core ver 2.22
Mar 11 12:45:22 raspberrypi kernel: [   15.582520] NET: Registered protocol family 31
Mar 11 12:45:22 raspberrypi kernel: [   15.582533] Bluetooth: HCI device and connection manager initialized
Mar 11 12:45:23 raspberrypi kernel: [   15.583867] Bluetooth: HCI socket layer initialized
Mar 11 12:45:23 raspberrypi kernel: [   15.583879] Bluetooth: L2CAP socket layer initialized
Mar 11 12:45:23 raspberrypi kernel: [   15.583902] Bluetooth: SCO socket layer initialized
Mar 11 12:45:23 raspberrypi kernel: [   15.601064] Bluetooth: HCI UART driver ver 2.3
Mar 11 12:45:23 raspberrypi kernel: [   15.601075] Bluetooth: HCI UART protocol H4 registered
Mar 11 12:45:23 raspberrypi kernel: [   15.601137] Bluetooth: HCI UART protocol Three-wire (H5) registered
Mar 11 12:45:23 raspberrypi kernel: [   15.603740] Bluetooth: HCI UART protocol Broadcom registered
Mar 11 12:45:23 raspberrypi kernel: [   15.972292] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
Mar 11 12:45:23 raspberrypi kernel: [   15.972301] Bluetooth: BNEP filters: protocol multicast
Mar 11 12:45:23 raspberrypi kernel: [   15.972314] Bluetooth: BNEP socket layer initialized
Mar 11 12:45:40 raspberrypi kernel: [   32.901282] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
Mar 11 12:45:40 raspberrypi kernel: [   32.901297] Bluetooth: HIDP socket layer initialized
Mar 11 12:45:41 raspberrypi kernel: [   33.722906] hid-generic 0005:0000:0000.0001: unknown main item tag 0x0
Mar 11 12:45:41 raspberrypi kernel: [   33.724250] input: powerSCANNDY07474838 Keyboard as /devices/platform/soc/fe201000.serial/tty/ttyAMA0/hci0/hci0:12/0005:0000:0000.0001/input/input1
Mar 11 12:45:41 raspberrypi kernel: [   33.726134] input: powerSCANNDY07474838 Consumer Control as /devices/platform/soc/fe201000.serial/tty/ttyAMA0/hci0/hci0:12/0005:0000:0000.0001/input/input2
Mar 11 12:45:41 raspberrypi kernel: [   33.727233] hid-generic 0005:0000:0000.0001: input,hidraw0: BLUETOOTH HID v0.00 Keyboard [powerSCANNDY07474838] on dc:a6:32:bc:3d:49
Mar 11 13:10:19 raspberrypi kernel: [   63.229238] hid-generic 0005:046D:B016.0002: unknown main item tag 0x0
Mar 11 13:10:19 raspberrypi kernel: [   63.229481] input: Trust-MS-01 Mouse as /devices/platform/soc/fe201000.serial/tty/ttyAMA0/hci0/hci0:11/0005:046D:B016.0002/input/input3
Mar 11 13:10:19 raspberrypi kernel: [   63.237729] input: Trust-MS-01 Consumer Control as /devices/platform/soc/fe201000.serial/tty/ttyAMA0/hci0/hci0:11/0005:046D:B016.0002/input/input4
Mar 11 13:10:19 raspberrypi kernel: [   63.237940] hid-generic 0005:046D:B016.0002: input,hidraw0: BLUETOOTH HID v1.29 Mouse [Trust-MS-01] on dc:a6:32:bc:3d:49
Mar 11 13:11:00 raspberrypi kernel: [  104.221373] v3d fec00000.v3d: MMU error from client L2T (0) at 0x19c1000, pte invalid
Mar 11 13:13:17 raspberrypi kernel: [  241.429342] hid-generic 0005:05AC:0220.0003: unknown main item tag 0x0
Mar 11 13:13:17 raspberrypi kernel: [  241.429571] input: BLOW-BK105 Keyboard as /devices/platform/soc/fe201000.serial/tty/ttyAMA0/hci0/hci0:12/0005:05AC:0220.0003/input/input6
Mar 11 13:13:17 raspberrypi kernel: [  241.430065] input: BLOW-BK105 Consumer Control as /devices/platform/soc/fe201000.serial/tty/ttyAMA0/hci0/hci0:12/0005:05AC:0220.0003/input/input7
Mar 11 13:13:17 raspberrypi kernel: [  241.430223] hid-generic 0005:05AC:0220.0003: input,hidraw1: BLUETOOTH HID v0.01 Keyboard [BLOW-BK105] on dc:a6:32:bc:3d:49

Output of journalctl:

pi@raspberrypi:~ $ journalctl -f -u bluetooth.service
-- Logs begin at Thu 2021-03-11 17:06:55 CET. --
mar 11 17:07:06 raspberrypi systemd[1]: Started Bluetooth service.
mar 11 17:07:06 raspberrypi bluetoothd[826]: Starting SDP server
mar 11 17:07:06 raspberrypi bluetoothd[826]: Bluetooth management interface 1.18 initialized
mar 11 17:07:06 raspberrypi bluetoothd[826]: Sap driver initialization failed.
mar 11 17:07:06 raspberrypi bluetoothd[826]: sap-server: Operation not permitted (1)
mar 11 17:07:07 raspberrypi bluetoothd[826]: Endpoint registered: sender=:1.30 path=/MediaEndpoint/A2DPSource
mar 11 17:07:07 raspberrypi bluetoothd[826]: Endpoint registered: sender=:1.30 path=/MediaEndpoint/A2DPSink
mar 11 17:07:07 raspberrypi bluetoothd[826]: Failed to set privacy: Rejected (0x0b)
mar 11 17:07:23 raspberrypi bluetoothd[826]: Can't get HIDP connection info
mar 11 17:11:03 raspberrypi bluetoothd[826]: Can't get HIDP connection info

##### UPDATE n.2 ###############################

It does not solve the issue deactivating the SIM Access Profile (SAP) by editing /etc/systemd/system/bluetooth.target.wants/bluetooth.service and changing ExecStart=/usr/lib/bluetooth/bluetoothd into ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=sap

##### UPDATE n.3 ###############################

I gave a try to bluez 5.55, 5.56 and 5.48 and it did not help. Neither did putting systemctl start bluetooth in a bash file and run it before my app.

##### UPDATE n.4 ###############################

Updated the bt SPP config but it did not helped:

pi@raspberrypi:~ $ bluetoothctl
Agent registered
[BLOW-BK105]# connect  90:50:7B:87:90:02
Attempting to connect to 90:50:7B:87:90:02
[CHG] Device 90:50:7B:87:90:02 Connected: yes
Failed to connect: org.bluez.Error.Failed
[CHG] Device 90:50:7B:87:90:02 Connected: no
[BLOW-BK105]# exit
pi@raspberrypi:~ $ journalctl -f -u bluetooth.service 
-- Logs begin at Mon 2021-03-15 10:40:29 CET. --
mar 15 10:40:41 raspberrypi systemd[1]: Starting Bluetooth service...
mar 15 10:40:41 raspberrypi bluetoothd[709]: Bluetooth daemon 5.56
mar 15 10:40:41 raspberrypi systemd[1]: Started Bluetooth service.
mar 15 10:40:41 raspberrypi bluetoothd[709]: Starting SDP server
mar 15 10:40:41 raspberrypi bluetoothd[709]: Bluetooth management interface 1.18 initialized
mar 15 10:40:41 raspberrypi bluetoothd[709]: Failed to set privacy: Rejected (0x0b)
mar 15 10:40:59 raspberrypi bluetoothd[709]: profiles/input/device.c:ioctl_is_connected() Can't get HIDP connection info
mar 15 10:41:00 raspberrypi bluetoothd[709]: profiles/input/device.c:control_connect_cb() connect to 90:50:7B:87:90:02: Connection refused (111)
mar 15 10:41:28 raspberrypi bluetoothd[709]: profiles/input/device.c:ioctl_is_connected() Can't get HIDP connection info
mar 15 10:41:29 raspberrypi bluetoothd[709]: profiles/input/device.c:control_connect_cb() connect to 90:50:7B:87:90:02: Connection refused (111)
^C
pi@raspberrypi:~ $ bluetoothctl
Agent registered
[BLOW-BK105]# info  90:50:7B:87:90:02
Device 90:50:7B:87:90:02 (public)
    Name: powerSCANNDY07474838
    Alias: powerSCANNDY07474838
    Class: 0x00002540
    Icon: input-keyboard
    Paired: yes
    Trusted: yes
    Blocked: no
    Connected: no
    WakeAllowed: yes
    LegacyPairing: no
    UUID: Human Interface Device... (00001124-0000-1000-8000-00805f9b34fb)
[BLOW-BK105]# 

3 Answers 3

1

You should run diagnostic tools like btmon (and perhaps dmesg) in a terminal, reproduce the disconnect problem and analyse the logs to narrow the problem down.

Without the logs, one thing you can try is to disable power management for the bluetooth device. Try running something like

echo on > /sys/class/bluetooth/hci*/power/control
1
  • I have updated the answer with the dmesg output during the faulty operation of the scanner. The output is the same as when working correctly.
    – parovelb
    Mar 11, 2021 at 13:35
0

This btferret program works like bluetoothctl but bypasses the Pi Bluetooth service, and it will often connect when bluez fails as above.

https://github.com/petzval/btferret

0

After logging the errors during the operation of my app I found out the problem was not bluetooth related. It was a matter of the full path name when calling the bluetooth reading subprocess. After booting the app launched fine but the paths were not complete. This is also the reason why the bluetooth reading worked when I launched the app in the terminal from the right location. This is how I learned to always use full path names in the script.

1
  • This answer gave me enough ideas. I had an issue with a BT mouse, so there's no application involved per see, but exhibiting the same behaviour. Turns out, I forgot the cardinal rule of tech support, but rather than turning it off and on, I had to remove the device, then re-pair and trust. Those errors in the logs are highly misleading. Somehow, the Bluetooth service broke the state of that particular paired device and returning I/O errors is unhelpful.
    – SaltwaterC
    Sep 4, 2021 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.