まんま!の備忘録

ソフトウェア・ファームウェア・ハードウェア関連の備忘録

Raspberry PiのBluetooth設定

Bluetoothのステータスを確認するとエラーが出ているので、それを解消する。
[2023/12/14] こちらに対処スクリプト追加しました。
github.com

taogya@taogya-pi0:~ $ sudo systemctl status bluetooth.service
:
Apr 30 22:19:44 taogya-pi0 bluetoothd[886]: profiles/sap/server.c:sap_server_register() Sap driver initialization failed.
Apr 30 22:19:44 taogya-pi0 bluetoothd[886]: sap-server: Operation not permitted (1)
Apr 30 22:19:44 taogya-pi0 bluetoothd[886]: Failed to set privacy: Rejected (0x0b)


SAP系エラーは以下を参考。
raspberrypi.stackexchange.com

# バックアップ
root@taogya-pi0:~ $ mv /lib/systemd/system/bluetooth.service /lib/systemd/system/bluetooth.service.org
# 設定値作成
taogya@taogya-pi0:~ $ sudo su -
root@taogya-pi0:~ $ mkdir -p /root/services/bluetooth
root@taogya-pi0:~ $ cp /lib/systemd/system/bluetooth.service.org /root/services/bluetooth/bluetooth.service
root@taogya-pi0:~ $ sed -i 's|ExecStart=/usr/libexec/bluetooth/bluetoothd|ExecStart=/usr/libexec/bluetooth/bluetoothd --noplugin=sap|g' /root/services/bluetooth/bluetooth.service
root@taogya-pi0:~ $ chmod -R 600 /root/services
# シンボリックリンク作成
root@taogya-pi0:~ $ ln -s /root/services/bluetooth/bluetooth.service /lib/systemd/system/bluetooth.service
# 再起動
root@taogya-pi0:~ $ systemctl daemon-reload
root@taogya-pi0:~ $ systemctl restart bluetooth.service
root@taogya-pi0:~ $ systemctl status bluetooth.service
:
Apr 30 22:22:55 taogya-pi0 bluetoothd[415]: Failed to set privacy: Rejected (0x0b)


残りは以下参考。
stackoverflow.com

root@taogya-pi0:~ $ mkdir -p  /root/configs/bluetooth/bthelper@.service.d
root@taogya-pi0:~ $ echo -n '
[Unit]
After=hciuart.service bluetooth.service
Before=
 
[Service]
ExecStartPre=/bin/sleep 5
' > /root/configs/bluetooth/bthelper@.service.d/override.conf
root@taogya-pi0:~ $ chmod -R 600 /root/configs
root@taogya-pi0:~ $ mkdir /etc/systemd/system/bthelper@.service.d/
root@taogya-pi0:~ $ ln -s /root/configs/bluetooth/bthelper@.service.d/override.conf /etc/systemd/system/bthelper@.service.d/override.conf 
root@taogya-pi0:~ $ reboot now