Hi All,
I am trying to emulate a bluetooth keyboard on my Raspberry Pi zero W. I encounter an error where when I attempt to pair to a device (or use the bluetooth socket) I get an error: “Socket is already in use”. From preious experience with stock raspberry buster I have found tis only happens on headed raspberry pi software with a desktop and not on the headless or lite versions. I believe this is because there is already another service using the bluetooth socket. Is there any way to list which services or applications are using the bluetooth socket? Even better is there any way to stop these services from running altogether?
I used the tutorial on : https://github.com/yaptb/BlogCode
Libraries installed: wiringpi, bluez, bluez-tools,bluez-firmware, python-bluez, python-dev, python-pip, python-dbus and libkf5bluezqt6 (Listed these just in case adding one of these libraries on the headed version is what caused the issue)
Please let me know if there is any extra information needed.
Did assure that the UART device /dev/ttyAMA0 is enabled but the serial console on it disabled? Check dietpi-config > Advanced Options > Serial/UART.
The two related Bluetooth services are running without errors?
systemctl status hciuart bluetooth
bluetoothctl and btmon should be able to tell you able to show you something about device connection states. But I am also not Bluetooth expert, probably someone who actively uses it can jump in
.
Hi MichaIng.
Yes, I assured ttyAMA0 is enabled and there is no serial console running on it. I’m not sure which two Bluetooth services you are referring to. I currently have my Bluetooth server script that I am attempting to run, but that cannot run because of a Bluetooth error 98 (Address already in use). bluetoothctl shows me what I am paired and connected to, but I want to know which service is handling that in the first place since I want only my server script to handle pairing and connection.
Thank you for the suggestion though!
I mean those two services hciuart.service and bluetooth.service, hence the command
:
systemctl status hciuart bluetooth
The first is required to enable/configure the RPi onboard Bluetooth adapter, that is connected via UART internally. bluetooth.service/bluetoothd AFAIK are responsible to handle the socket. So both should be essential for any Bluetooth connection, but they do not establish/pair with anything. But the question is where your scripts starts at, probably it aims to setup the Bluetooth socket itself, so that bluetooth.service must not run?
Some search result: https://bbs.archlinux.org/viewtopic.php?id=244935
At least worth to give it a try:
rfkill block bluetooth
rfkill unblock bluetooth
systemctl restart bluetooth
If rfkill is not installed yet: apt install rfkill