diff options
Diffstat (limited to 'board/bluetooth.sh')
-rw-r--r-- | board/bluetooth.sh | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/board/bluetooth.sh b/board/bluetooth.sh index 960468a..c1af995 100644 --- a/board/bluetooth.sh +++ b/board/bluetooth.sh @@ -16,7 +16,10 @@ PairableTimeout = 0 AutoEnable=true __EOF__ +# Accept any code from any connexion +echo "* *" > "${TARGET_DIR}/etc/bluetooth/pins" +# Run the Bluetooth agent cat << __EOF__ > "${TARGET_DIR}/etc/systemd/system/bt-agent.service" [Unit] Description=Bluetooth Agent @@ -26,18 +29,62 @@ Requires=bluetooth.service [Service] Type=simple ExecStartPre=bt-adapter --set Discoverable 1 -# see https://github.com/RPi-Distro/repo/issues/291 #ExecStart=bt-agent -c NoInputNoOutput -ExecStart=/bin/sh -c '/usr/bin/yes | /usr/bin/bt-agent --capability=DisplayOnly' -# Restart the service each 60s -WatchdogSec=60 -RestartSec=60 -Restart=always +ExecStart=bt-agent -p /etc/bluetooth/pins +## Restart the service each 60s +#WatchdogSec=60 +#RestartSec=60 +#Restart=always [Install] WantedBy=multi-user.target __EOF__ +enable_service "bt-agent.service" + +create_missing_dir "/etc/dbus-1/system.d/" +cat << __EOF__ > "${TARGET_DIR}/etc/dbus-1/system.d/bluetooth.conf" +<!-- This configuration file specifies the required security policies + for Bluetooth core daemon to work. --> + +<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" + "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> +<busconfig> + + <!-- ../system.conf have denied everything, so we just punch some holes --> + + <policy user="root"> + <allow own="org.bluez"/> + <allow send_destination="org.bluez"/> + <allow send_interface="org.bluez.AdvertisementMonitor1"/> + <allow send_interface="org.bluez.Agent1"/> + <allow send_interface="org.bluez.MediaEndpoint1"/> + <allow send_interface="org.bluez.MediaPlayer1"/> + <allow send_interface="org.bluez.Profile1"/> + <allow send_interface="org.bluez.GattCharacteristic1"/> + <allow send_interface="org.bluez.GattDescriptor1"/> + <allow send_interface="org.bluez.LEAdvertisement1"/> + <allow send_interface="org.freedesktop.DBus.ObjectManager"/> + <allow send_interface="org.freedesktop.DBus.Properties"/> + <allow send_interface="org.mpris.MediaPlayer2.Player"/> + </policy> + + <!-- allow users of bluetooth group to communicate --> + <policy group="bluetooth"> + <allow send_destination="org.bluez"/> + </policy> + + <policy context="default"> + <allow send_destination="org.bluez"/> + </policy> + +</busconfig> +__EOF__ + +# Set permission to 755 in the directory /var/lib/bluetooth/ (prevent a +# permission error) +sed --in-place "s/0555/0755/" ${TARGET_DIR}/usr/lib/systemd/system/bluetooth.service + ## The same for the bluetooth, as bluetoothd keep a track for each paired device create_missing_dir "/var/lib/bluetooth/" #if ! grep -qE '/var/lib/bluetooth' "${TARGET_DIR}/etc/fstab"; then |