同步移动端工程、设备控制改进与发布资料
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
# Enable the existing WalnutPi vendor controller, without changing WiFi rfkill.
|
||||
set -eu
|
||||
test "$(id -u)" = 0 || { echo 'root is required' >&2; exit 1; }
|
||||
test -x /usr/bin/hciattach
|
||||
test -x /usr/sbin/rfkill
|
||||
test -f /lib/systemd/system/aw859-bluetooth.service
|
||||
install -d -m 0755 /etc/systemd/system/aw859-bluetooth.service.d
|
||||
cat > /etc/systemd/system/aw859-bluetooth.service.d/50-matrix-mobile.conf <<'EOF'
|
||||
[Service]
|
||||
ExecStartPre=
|
||||
ExecStartPre=/usr/sbin/modprobe hci_uart
|
||||
ExecStartPre=/usr/sbin/rfkill unblock bluetooth
|
||||
ExecStart=
|
||||
ExecStart=/usr/bin/hciattach -n -s 1500000 /dev/ttyBT0 sprd
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
EOF
|
||||
install -d -m 0755 /etc/systemd/system/bluetooth.service.d
|
||||
cat > /etc/systemd/system/bluetooth.service.d/50-matrix-mobile.conf <<'EOF'
|
||||
[Unit]
|
||||
After=aw859-bluetooth.service
|
||||
Wants=aw859-bluetooth.service
|
||||
EOF
|
||||
python3 - <<'PY'
|
||||
from pathlib import Path
|
||||
import re
|
||||
p = Path('/etc/bluetooth/main.conf')
|
||||
text = p.read_text(encoding='utf-8')
|
||||
backup = p.with_name('main.conf.matrix-mobile-original')
|
||||
if not backup.exists():
|
||||
with backup.open('x', encoding='utf-8') as stream:
|
||||
stream.write(text)
|
||||
for key, value in [('ControllerMode', 'le'), ('AlwaysPairable', 'false')]:
|
||||
pattern = r'(?m)^\s*' + key + r'\s*=.*$'
|
||||
if re.search(pattern, text):
|
||||
text = re.sub(pattern, key + '=' + value, text)
|
||||
else:
|
||||
text = text.replace('[General]', '[General]\n' + key + '=' + value, 1)
|
||||
p.write_text(text, encoding='utf-8')
|
||||
PY
|
||||
systemctl unmask bluetooth.service aw859-bluetooth.service
|
||||
systemctl daemon-reload
|
||||
systemctl enable bluetooth.service aw859-bluetooth.service
|
||||
if [ "${DEFER_SERVICE_START:-0}" != 1 ]; then
|
||||
# Bluetooth failure must not prevent deploying or running the display service.
|
||||
systemctl start aw859-bluetooth.service bluetooth.service || echo 'Bluetooth unavailable; inspect mobile status' >&2
|
||||
fi
|
||||
Reference in New Issue
Block a user