aboutsummaryrefslogtreecommitdiff
path: root/board/bluetooth.sh
blob: 405d061f8f3591a9a507657d2a1822b5d1077c5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#############################
#                           #
#  Bluetooth configuration  #
#                           #
#############################

create_missing_dir "/etc/bluetooth/"
cat << __EOF__ > "${TARGET_DIR}/etc/bluetooth/main.conf"
[General]

Class = 200428
DiscoverableTimeout = 0
PairableTimeout = 0

[Policy]
AutoEnable=true
__EOF__


cat << __EOF__ > "${TARGET_DIR}/etc/systemd/system/bt-agent.service"
[Unit]
Description=Bluetooth Agent
After=bluetooth.service
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 10s
WatchdogSec=10
RestartSec=30
Restart=always

[Install]
WantedBy=multi-user.target
__EOF__

## 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
#    cat << __EOF__ >> "${TARGET_DIR}/etc/fstab"
#tmpfs /var/lib/bluetooth tmpfs rw 0 0
#__EOF__
#fi