Bluetooth : keyboard / mouse / ps4 controler pairing

Hello everyone.

I would like to set up all thoses bluetooth devices on my Dietpi.

I’m actualy running Dietpi’s LXDE and before to even start trying to make thoses devices works, i would like to ask you what is the best way to proceed on Dietpi.

Should i go through LXDE & install Blueman (as it seems that LXDE doesn’t have a build in graphical bluetooth’s tool) ?
Or should i focus on command line and “bluetoothctl” ?

I’ve tried last week on raspberry pi OS with some… issues…
https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=304000
And some people reply that i should just go through graphical tools. But that was for raspberry pi OS.

So, please, tell me what is the best way on Dietpi, as i can’t find answer on the Deitpi documentation and the only available things i’ve found in dietpi-config is to set bluetooth on/off.

Thanks =)

Hi,

if you use a Raspberry Pi SBC, you are still using Raspberry OS with DietPi scripts on top. Means, the graphic tool should work exactly same way :slight_smile:

Hello Joulinar.

Sorry i meant : I’ve removed Raspberry Pi OS and reflash / made a fresh new install of Dietpi on my RPi4.

But if it is the same, then my question is :
Raspberry Pi OS use a graphical bluetooth tool in Pixel (that i dont know the name of), and witch doesn’t seems available on lxde.

So :

  • should i install it on lxde ? (but what is the name of that tool).
  • should i install blueman ?
  • should i go with bluetoothctl

:wink:

We could check which GUI tool is pre-installed with Raspberry Pi OS. However, blueman should work just fine. Assure to enable Bluetooth through dietpi-config > Advanced Options so that the device tree part/modules and hciuart (to enable the internally UART-attached RPi onboard Bluetooth adapter) services are up. bluez/bluetoothctl are installed automatically then. If you need a GUI is then a personal preference/convenience question only, AFAIK blueman is just a bluez/bluetoothctl frontend for desktops, nothing more.

Hello Michalng.

Alright, thanks for your answer !
I will try with blueman and let you know if i have any issues i can’t solve alone.

So, i’ve managed to connect the keyboard and the ps4 controler, with blueman. It works fine.

But, i do have the same issue than with the raspberry pi official OS, it doesn’t work after a reboot.

After every reboot, i need to do :
systemctl daemon-reload
systemctl restart bluetooth
then devices can be connected.

I’ve already wrote about it here : https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=304000#p1820498

Could you tell me at witch github should i open a “issue” about it ?
Raspberry os ? BlueZ ?

Sorry, it’s not that much a Dietpi issue / subject.

If the issue happen on plain RPi OS, it should be fine to report back on their GitHub

We could with an effective bug report and check why it fails at boot. Could you check:

journalctl -u bluetooth -u hciuart

Hello Michalng.

Here is the log :

févr. 21 19:00:53 DietPi systemd[1]: Starting Configure Bluetooth Modems connected by UART…
févr. 21 19:01:00 DietPi btuart[221]: bcm43xx_init
févr. 21 19:01:00 DietPi btuart[221]: Flash firmware /lib/firmware/brcm/BCM4345C0.hcd
févr. 21 19:01:00 DietPi btuart[221]: Set Controller UART speed to 3000000 bit/s
févr. 21 19:01:00 DietPi btuart[221]: Device setup complete
févr. 21 19:01:00 DietPi systemd[1]: Started Configure Bluetooth Modems connected by UART.
févr. 21 19:01:01 DietPi systemd[1]: Starting Bluetooth service…
févr. 21 19:01:01 DietPi bluetoothd[402]: Bluetooth daemon 5.50
févr. 21 19:01:01 DietPi systemd[1]: Started Bluetooth service.
févr. 21 19:01:01 DietPi bluetoothd[402]: Starting SDP server
févr. 21 19:01:01 DietPi bluetoothd[402]: Bluetooth management interface 1.18 initialized
févr. 21 19:01:01 DietPi bluetoothd[402]: Sap driver initialization failed.
févr. 21 19:01:01 DietPi bluetoothd[402]: sap-server: Operation not permitted (1)
févr. 21 19:01:02 DietPi bluetoothd[402]: Failed to set privacy: Rejected (0x0b)
févr. 21 19:04:34 DietPi bluetoothd[402]: Terminating
févr. 21 19:04:34 DietPi systemd[1]: Stopping Bluetooth service…
févr. 21 19:04:34 DietPi bluetoothd[402]: Stopping SDP server
févr. 21 19:04:34 DietPi bluetoothd[402]: Exit
févr. 21 19:04:34 DietPi systemd[1]: bluetooth.service: Succeeded.
févr. 21 19:04:34 DietPi systemd[1]: Stopped Bluetooth service.
févr. 21 19:04:34 DietPi systemd[1]: Starting Bluetooth service…
févr. 21 19:04:34 DietPi bluetoothd[1062]: Bluetooth daemon 5.50
févr. 21 19:04:34 DietPi systemd[1]: Started Bluetooth service.
févr. 21 19:04:34 DietPi bluetoothd[1062]: Starting SDP server
févr. 21 19:04:34 DietPi bluetoothd[1062]: Bluetooth management interface 1.18 initialized
févr. 21 19:04:34 DietPi bluetoothd[1062]: Sap driver initialization failed.
févr. 21 19:04:34 DietPi bluetoothd[1062]: sap-server: Operation not permitted (1)
févr. 21 19:04:41 DietPi bluetoothd[1062]: Can’t get HIDP connection info
févr. 21 19:04:46 DietPi bluetoothd[1062]: connect error: Host is down (112)
févr. 21 19:04:55 DietPi bluetoothd[1062]: Can’t get HIDP connection info
févr. 21 19:05:00 DietPi bluetoothd[1062]: connect error: Host is down (112)

(Four last lane are erreor because i tried to connect to the ps4 controler witch was off.)

The SAP (SIM Access Profile) plugin fails. Not sure why it is loaded when not connecting to a mobile phone, or why it does not skip gracefully on non-SIM devices. Please try the following:

mkdir /etc/systemd/system/bluetooth.service.d
echo -e '[Service]\nExecStart=\nExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=sap' > /etc/systemd/system/bluetooth.service.d/no-sap.conf
systemctl daemon-reload
systemctl restart bluetooth

Hello.

I’ve done it and rebooted.

Here is the log :

– Logs begin at Thu 2019-02-14 11:11:58 CET, end at Tue 2021-02-23 13:29:00 CET. –
févr. 23 13:27:27 DietPi systemd[1]: Starting Configure Bluetooth Modems connected by UART…
févr. 23 13:27:35 DietPi btuart[222]: bcm43xx_init
févr. 23 13:27:35 DietPi btuart[222]: Flash firmware /lib/firmware/brcm/BCM4345C0.hcd
févr. 23 13:27:35 DietPi btuart[222]: Set Controller UART speed to 3000000 bit/s
févr. 23 13:27:35 DietPi btuart[222]: Device setup complete
févr. 23 13:27:35 DietPi systemd[1]: Started Configure Bluetooth Modems connected by UART.
févr. 23 13:27:35 DietPi systemd[1]: Starting Bluetooth service…
févr. 23 13:27:47 DietPi bluetoothd[441]: Bluetooth daemon 5.50
févr. 23 13:27:47 DietPi systemd[1]: Started Bluetooth service.
févr. 23 13:27:47 DietPi bluetoothd[441]: Starting SDP server
févr. 23 13:27:47 DietPi bluetoothd[441]: Excluding (cli) sap
févr. 23 13:27:47 DietPi bluetoothd[441]: Bluetooth management interface 1.18 initialized
févr. 23 13:27:47 DietPi bluetoothd[441]: Failed to get connections: Not Powered (0x0f)

I can’t connect to devices.
Through blueman, the device are grey, i can’t connect to it.

I need to do systmctl daemon-reload / restart bluetooth to be able to connect the devices.

bluetoothd[441]: Failed to get connections: Not Powered (0x0f)

Hmm, probably it is starting somehow too early when some other hardware parts are not ready yet. Probably the kernel log dmesg reveals something.

Probably delaying the service start a bit is a workaround (for simplicity appending it to the some override config):

echo 'ExecStartPre=sleep 10' >> /etc/systemd/system/bluetooth.service.d/no-sap.conf

Thanks for taking some time on this =)

I’ve modified no-sap.conf and rebooted.
Here are the logs :

dmesg

[   11.200105] Bluetooth: Core ver 2.22
[   11.200184] NET: Registered protocol family 31
[   11.200191] Bluetooth: HCI device and connection manager initialized
[   11.200502] Bluetooth: HCI socket layer initialized
[   11.200514] Bluetooth: L2CAP socket layer initialized
[   11.200530] Bluetooth: SCO socket layer initialized
[   11.209220] Bluetooth: HCI UART driver ver 2.3
[   11.209229] Bluetooth: HCI UART protocol H4 registered
[   11.209283] Bluetooth: HCI UART protocol Three-wire (H5) registered
[   11.209871] Bluetooth: HCI UART protocol Broadcom registered
[   21.468057] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   21.468067] Bluetooth: BNEP filters: protocol multicast
[   21.468081] Bluetooth: BNEP socket layer initialized
[   21.601170] Bluetooth: hci0: unexpected event for opcode 0x0c52
[   33.138729] Bluetooth: RFCOMM TTY layer initialized
[   33.138750] Bluetooth: RFCOMM socket layer initialized
[   33.138771] Bluetooth: RFCOMM ver 1.11

and

root@DietPi:~# journalctl -u bluetooth -u hciuart
-- Logs begin at Thu 2019-02-14 11:11:58 CET, end at Wed 2021-02-24 11:46:06 CET. --
févr. 24 11:44:30 DietPi systemd[1]: Starting Configure Bluetooth Modems connected by UART...
févr. 24 11:44:38 DietPi btuart[233]: bcm43xx_init
févr. 24 11:44:38 DietPi btuart[233]: Flash firmware /lib/firmware/brcm/BCM4345C0.hcd
févr. 24 11:44:38 DietPi btuart[233]: Set Controller UART speed to 3000000 bit/s
févr. 24 11:44:38 DietPi btuart[233]: Device setup complete
févr. 24 11:44:38 DietPi systemd[1]: Started Configure Bluetooth Modems connected by UART.
févr. 24 11:44:38 DietPi systemd[1]: Starting Bluetooth service...
févr. 24 11:45:00 DietPi bluetoothd[670]: Bluetooth daemon 5.50
févr. 24 11:45:00 DietPi systemd[1]: Started Bluetooth service.
févr. 24 11:45:00 DietPi bluetoothd[670]: Starting SDP server
févr. 24 11:45:00 DietPi bluetoothd[670]: Excluding (cli) sap
févr. 24 11:45:00 DietPi bluetoothd[670]: Bluetooth management interface 1.18 initialized
févr. 24 11:45:00 DietPi bluetoothd[670]: Failed to set privacy: Rejected (0x0b)
févr. 24 11:45:00 DietPi bluetoothd[670]: Failed to set device class: Not Powered (0x0f)

Strange. You could try to further defer the start by e.g. 30 seconds instead of 10. When a restart solves it, at least a fresh service start at that time should work as well.

Ah one test could be:

systemctl disable bluetooth
reboot
systemctl start bluetooth

If this works, it is ruled out that one service stop or a second start is for whatever reason required to have it working.

Another thing we could try it a kernel downgrade. There were quite a few other issues reported that were solved by downgrading to Linux 5.4. Then we’d know that it’s something to report to the RPi kernel repository: https://github.com/raspberrypi/linux/issues

Ah there is a report already that looks at least similar: https://github.com/raspberrypi/linux/issues/4139
If you have a GitHub account, probably you could add your case and related logs.

so, i’ve tried with 30 sec.

 journalctl -u bluetooth -u hciuart
-- Logs begin at Thu 2019-02-14 11:11:58 CET, end at Fri 2021-02-26 10:34:11 CET. --
févr. 26 10:30:03 DietPi systemd[1]: Starting Configure Bluetooth Modems connected by UART...
févr. 26 10:30:11 DietPi btuart[228]: bcm43xx_init
févr. 26 10:30:11 DietPi btuart[228]: Flash firmware /lib/firmware/brcm/BCM4345C0.hcd
févr. 26 10:30:11 DietPi btuart[228]: Set Controller UART speed to 3000000 bit/s
févr. 26 10:30:11 DietPi btuart[228]: Device setup complete
févr. 26 10:30:11 DietPi systemd[1]: Started Configure Bluetooth Modems connected by UART.
févr. 26 10:30:11 DietPi systemd[1]: Starting Bluetooth service...
févr. 26 10:30:51 DietPi bluetoothd[920]: Bluetooth daemon 5.50
févr. 26 10:30:51 DietPi systemd[1]: Started Bluetooth service.
févr. 26 10:30:51 DietPi bluetoothd[920]: Starting SDP server
févr. 26 10:30:51 DietPi bluetoothd[920]: Excluding (cli) sap
févr. 26 10:30:51 DietPi bluetoothd[920]: Bluetooth management interface 1.18 initialized
févr. 26 10:30:52 DietPi bluetoothd[920]: Failed to set privacy: Rejected (0x0b)

There is no more “Not powered” error.
But, i still can’t connect device.
They are gray in blueman.

I’ve also tried

systemctl disable bluetooth
reboot
systemctl start bluetooth

without more succes.

Only

systemctl daemon-reload
systemctl restart bluetooth

after a reboot make it :confused:

I dont have github account for now but i will create one in order to post logs if that can help.

Could you tell me how can i downgrade the kernel on Dietpi please ? I dont know the process.
Thanks.

Could you tell me how can i downgrade the kernel on Dietpi please ? I dont know the process.

Well, DietPi is not providing any kernel. If I’m not mistaken you are on a Raspberry Pi. Therefore you would need to use Raspberry Foundation tools to perform this. It’s possible by using rpi-update.

https://github.com/Hexxeh/rpi-update#options

you can downgrade as follow to 5.4.79

sudo rpi-update 0642816ed05d31fb37fc8fbbba9e1774b475113f

So based on the test result it seems that the service must fail one and is then able to start. Probably on first failure it creates some environment or actives the BT hardware somehow so that the second start succeeds. systemctl daemon-reload should be obsolete since the systemd unit content does not change.

So as workaround, allowing one automated restart in case of failure via service options should work.

But let’s first see if a kernel downgrade helps.

Hello.

Sorry i’ve been afk for few days.

So i’ve downgrade to :

uname -a 
Linux DietPi 5.4.79-v7l+ #1373 SMP Mon Nov 23 13:27:40 GMT 2020 armv7l GNU/Linux

After a reboot, blueman just show wireless controler, not keyboard.
Turning on controler doesn’t make it connected automaticaly.

Here are logs :

dmesg 
[   11.007640] Bluetooth: Core ver 2.22
[   11.007689] NET: Registered protocol family 31
[   11.007694] Bluetooth: HCI device and connection manager initialized
[   11.007708] Bluetooth: HCI socket layer initialized
[   11.007718] Bluetooth: L2CAP socket layer initialized
[   11.007734] Bluetooth: SCO socket layer initialized
[   11.016180] Bluetooth: HCI UART driver ver 2.3
[   11.016190] Bluetooth: HCI UART protocol H4 registered
[   11.016227] Bluetooth: HCI UART protocol Three-wire (H5) registered
[   11.016352] Bluetooth: HCI UART protocol Broadcom registered
[   11.228847] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   11.228854] Bluetooth: BNEP filters: protocol multicast
[   11.228866] Bluetooth: BNEP socket layer initialized
[   12.924405] debugfs: File 'le_min_key_size' in directory 'hci0' already present!
[   12.924414] debugfs: File 'le_max_key_size' in directory 'hci0' already present!
[   60.668337] Bluetooth: RFCOMM TTY layer initialized
[   60.668353] Bluetooth: RFCOMM socket layer initialized
[   60.668372] Bluetooth: RFCOMM ver 1.11



 journalctl -u bluetooth -u hciuart
-- Logs begin at Thu 2019-02-14 11:11:58 CET, end at Mon 2021-03-01 15:37:28 CET. --
mars 01 15:31:54 DietPi systemd[1]: Starting Configure Bluetooth Modems connected by UART...
mars 01 15:32:02 DietPi btuart[221]: bcm43xx_init
mars 01 15:32:02 DietPi btuart[221]: Flash firmware /lib/firmware/brcm/BCM4345C0.hcd
mars 01 15:32:02 DietPi btuart[221]: Set Controller UART speed to 3000000 bit/s
mars 01 15:32:02 DietPi btuart[221]: Device setup complete
mars 01 15:32:02 DietPi systemd[1]: Started Configure Bluetooth Modems connected by UART.
mars 01 15:32:02 DietPi systemd[1]: Starting Bluetooth service...
mars 01 15:32:02 DietPi bluetoothd[399]: Bluetooth daemon 5.50
mars 01 15:32:02 DietPi systemd[1]: Started Bluetooth service.
mars 01 15:32:02 DietPi bluetoothd[399]: Starting SDP server
mars 01 15:32:02 DietPi bluetoothd[399]: Excluding (cli) sap
mars 01 15:32:02 DietPi bluetoothd[399]: Bluetooth management interface 1.14 initialized
mars 01 15:32:03 DietPi bluetoothd[399]: Failed to set privacy: Rejected (0x0b)

Now…

root@DietPi:~# systemctl daemon-reload
root@DietPi:~# systemctl restart bluetooth

Keyboard appear in the list of connectable device.
Wireless controler does connect after few try : Turning controler ON > Controler blink > Select connect to Human Interface Device Service in blueman > Some Data Activity indicator show up and down and controler turn off by him self.
After few try it does connect and stay stable.

Here are the logs.

journalctl -u bluetooth -u hciuart

mars 01 15:40:56 DietPi bluetoothd[399]: Terminating
mars 01 15:40:56 DietPi systemd[1]: Stopping Bluetooth service...
mars 01 15:40:56 DietPi bluetoothd[399]: Stopping SDP server
mars 01 15:40:56 DietPi bluetoothd[399]: Exit
mars 01 15:40:56 DietPi systemd[1]: bluetooth.service: Succeeded.
mars 01 15:40:56 DietPi systemd[1]: Stopped Bluetooth service.
mars 01 15:40:56 DietPi systemd[1]: Starting Bluetooth service...
mars 01 15:40:56 DietPi bluetoothd[1019]: Bluetooth daemon 5.50
mars 01 15:40:56 DietPi systemd[1]: Started Bluetooth service.
mars 01 15:40:56 DietPi bluetoothd[1019]: Starting SDP server
mars 01 15:40:56 DietPi bluetoothd[1019]: Excluding (cli) sap
mars 01 15:40:56 DietPi bluetoothd[1019]: Bluetooth management interface 1.14 initialized
mars 01 15:41:54 DietPi bluetoothd[1019]: Authentication attempt without agent
mars 01 15:41:54 DietPi bluetoothd[1019]: Access denied: org.bluez.Error.Rejected
mars 01 15:42:02 DietPi bluetoothd[1019]: Can't get HIDP connection info
mars 01 15:42:07 DietPi bluetoothd[1019]: connect error: Host is down (112)
mars 01 15:42:15 DietPi bluetoothd[1019]: Can't get HIDP connection info
mars 01 15:42:16 DietPi bluetoothd[1019]: connect error: Operation already in progress (114)
mars 01 15:42:17 DietPi bluetoothd[1019]: Authentication attempt without agent
mars 01 15:42:17 DietPi bluetoothd[1019]: Access denied: org.bluez.Error.Rejected
mars 01 15:42:42 DietPi bluetoothd[1019]: Authentication attempt without agent
mars 01 15:42:42 DietPi bluetoothd[1019]: Access denied: org.bluez.Error.Rejected
mars 01 15:42:45 DietPi bluetoothd[1019]: Can't get HIDP connection info
mars 01 15:42:50 DietPi bluetoothd[1019]: connect error: Host is down (112)
mars 01 15:42:59 DietPi bluetoothd[1019]: Can't get HIDP connection info
mars 01 15:42:59 DietPi bluetoothd[1019]: Refusing input device connect: Operation already in progress (114)

dmesg

[  535.785363] debugfs: File 'le_min_key_size' in directory 'hci0' already present!
[  535.785373] debugfs: File 'le_max_key_size' in directory 'hci0' already present!
[  601.745742] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[  601.745757] Bluetooth: HIDP socket layer initialized
[  658.489213] sony 0005:054C:09CC.0001: unknown main item tag 0x0
[  658.513258] input: Wireless Controller Touchpad as /devices/platform/soc/fe201000.serial/tty/ttyAMA0/hci0/hci0:11/0005:054C:09CC.0001/input/input1
[  658.513575] input: Wireless Controller Motion Sensors as /devices/platform/soc/fe201000.serial/tty/ttyAMA0/hci0/hci0:11/0005:054C:09CC.0001/input/input2
[  658.514246] input: Wireless Controller as /devices/platform/soc/fe201000.serial/tty/ttyAMA0/hci0/hci0:11/0005:054C:09CC.0001/input/input0
[  658.514493] sony 0005:054C:09CC.0001: input,hidraw0: BLUETOOTH HID v81.00 Gamepad [Wireless Controller] on b8:27:eb:d6:4d:70

So, it doesn’t connect after reboot, so i’m not sure that it is a kernel issue.

Hmm: https://unix.stackexchange.com/questions/334386/how-to-set-up-automatic-connection-of-bluetooth-headset

bluetoothctl trust <MAC-address>
bluetoothctl disconnect <MAC-address>
bluetoothctl connect <MAC-address>

But shouldn’t it be possible, and automatically when pairing, that the device is trusted permanently?

On a similar report on Arch one stated that it was necessary to remove the device(s) once from trusted ones and re-scan/re-add it.

Hello
I’m definitely not an expert but I faced similar trouble and following this message solve it.

I didn’t either use blueman but only bluetoothctl
I think it would worth a change in a future release.
Have a nice day