Ga naar de inhoud
Home » Bluetooth en Raspberry Pi

Bluetooth en Raspberry Pi

Raspberry Pi Blog Header

Ten eerste Dongles van Cambridge Silicon Radio Ltd. (CSR) blijken na heel wat Googlen dubies te zijn … dat je het weet … output bij lsusb

Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

Installeren via terminal. Dit doe je als je een oude Pi zonder bluetooth hebt. Je moe er natuurlijk wel een bluetooth dongle in stoppen …

sudo apt update

sudo apt upgrade

sudo apt install bluetooth pi-bluetooth bluez

Reboot het systeem

sudo systemctl reboot

Start bluetooth control

sudo bluetoothctl

Om te zoeken naar lokale devices type je

scan on

Om connectie te maken met een device type je

pair XX:XX:XX:XX:XX:XX

als alles goed gegaan is krijg je de melding pairing successful

Als je vaak wilt verbinden met dit device moet je haar “vertrouwen”

trust XX:XX:XX:XX:XX:XX

Als alles goed gaat krijge je de melgine trust succeeded

Type

quit

Om terug in de shell te komen

Meer detail: https://howchoo.com/pi/bluetooth-raspberry-pi

 

Bluetooth valt weg of de dongle wordt niet gezien …

pi@solar:~ $ sudo systemctl status bluetooth
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2023-07-01 09:08:10 CEST; 14min ago
Docs: man:bluetoothd(8)
Main PID: 10783 (bluetoothd)
Status: "Running"
Tasks: 1 (limit: 2059)
CGroup: /system.slice/bluetooth.service
└─10783 /usr/lib/bluetooth/bluetoothd

Jul 01 09:17:42 solar bluetoothd[10783]: Sap driver initialization failed.
Jul 01 09:17:42 solar bluetoothd[10783]: sap-server: Operation not permitted (1)
Jul 01 09:18:02 solar bluetoothd[10783]: Sap driver initialization failed.
Jul 01 09:18:02 solar bluetoothd[10783]: sap-server: Operation not permitted (1)
Jul 01 09:20:30 solar bluetoothd[10783]: Sap driver initialization failed.
Jul 01 09:20:30 solar bluetoothd[10783]: sap-server: Operation not permitted (1)
Jul 01 09:21:02 solar bluetoothd[10783]: Sap driver initialization failed.
Jul 01 09:21:02 solar bluetoothd[10783]: sap-server: Operation not permitted (1)
Jul 01 09:22:02 solar bluetoothd[10783]: Sap driver initialization failed.
Jul 01 09:22:02 solar bluetoothd[10783]: sap-server: Operation not permitted (1)
pi@solar:~ $ bluetoothd -n -d
bluetoothd[11998]: Bluetooth daemon 5.50
bluetoothd[11998]: src/main.c:parse_config() parsing /etc/bluetooth/main.conf
bluetoothd[11998]: src/main.c:parse_config() Key file does not have key “DiscoverableTimeout” in group “General”
bluetoothd[11998]: src/main.c:parse_config() Key file does not have key “PairableTimeout” in group “General”
bluetoothd[11998]: src/main.c:parse_config() Key file does not have key “Privacy” in group “General”
bluetoothd[11998]: src/main.c:parse_config() Key file does not have key “Name” in group “General”
bluetoothd[11998]: src/main.c:parse_config() Key file does not have key “Class” in group “General”
bluetoothd[11998]: src/main.c:parse_config() Key file does not have key “DeviceID” in group “General”
bluetoothd[11998]: src/main.c:parse_config() Key file does not have key “ReverseServiceDiscovery” in group “General”
bluetoothd[11998]: src/main.c:parse_config() Key file does not have key “MinEncKeySize” in group “GATT”
D-Bus setup failed: Connection ":1.32" is not allowed to own the service "org.bluez" due to security policies in the configuration file
bluetoothd[11998]: Unable to get on D-Bus
pi@solar:~ $

De oplossing: start bluetooth op met de optie –noplugin=sap dit doe je in /usr/lib/systemd/system/bluetooth.service:

pi@solar:/usr/lib/systemd/system $ cat bluetooth.service
[Unit]
Description=Bluetooth service
Documentation=man:bluetoothd(8)
ConditionPathIsDirectory=/sys/class/bluetooth

[Service]
Type=dbus
BusName=org.bluez
ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=sap
NotifyAccess=main
#WatchdogSec=10
#Restart=on-failure
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
LimitNPROC=1
ProtectHome=true
ProtectSystem=full

[Install]
WantedBy=bluetooth.target
Alias=dbus-org.bluez.service
pi@solar:/usr/lib/systemd/system $

Uit proberen:

pi@solar:/usr/lib/systemd/system $ sudo systemctl daemon-reload
pi@solar:/usr/lib/systemd/system $ sudo systemctl stop bluetooth
pi@solar:/usr/lib/systemd/system $ sudo systemctl start bluetooth
pi@solar:/usr/lib/systemd/system $ sudo systemctl status bluetooth
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2023-07-01 09:28:47 CEST; 5s ago
Docs: man:bluetoothd(8)
Main PID: 12492 (bluetoothd)
Status: "Running"
Tasks: 1 (limit: 2059)
CGroup: /system.slice/bluetooth.service
└─12492 /usr/lib/bluetooth/bluetoothd --noplugin=sap

Jul 01 09:28:47 solar systemd[1]: Starting Bluetooth service...
Jul 01 09:28:47 solar bluetoothd[12492]: Bluetooth daemon 5.50
Jul 01 09:28:47 solar systemd[1]: Started Bluetooth service.
Jul 01 09:28:47 solar bluetoothd[12492]: Starting SDP server
Jul 01 09:28:47 solar bluetoothd[12492]: Excluding (cli) sap
Jul 01 09:28:47 solar bluetoothd[12492]: Bluetooth management interface 1.18 initialized
pi@solar:/usr/lib/systemd/system $ lsusb
Bus 001 Device 127: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 001 Device 123: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
Bus 001 Device 122: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 121: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@solar:/usr/lib/systemd/system $ hcitool scan
Scanning ...
90:56:82:5F:EE:41 n/a
00:80:25:A4:F7:72 SMA001d SN: 2130076542 SN2130076542
pi@solar:/usr/lib/systemd/system $

Doet het weer ..