- Switch bananarchy-bt-obex Agent1 from NoInputNoOutput to KeyboardDisplay with /run/bananarchy/bt-obex/pair_{prompt,decision}.tsv and op_done.tsv IPC, auto-confirming Classic Audio headsets while prompting user confirmation, PIN, passkey, or keyboard display codes.
- Enforce bredr on, ssp on, linksec on, bondable on, advertising off, class 2 3, and le on in bananarchy-bt-le-enable.sh alongside PairableTimeout = 0 in main.conf (keeping DiscoverableTimeout = 60 hidden by default) and boot hook sync in sxmo_hook_start.sh.
- Fix root/user daemon UID collisions and sticky-/tmp status/PID writes, separate phones from Classic Audio headsets, increase Pair timeout to 50 s, and add non-blocking --async-ui pairing/connect plus NetModal::BtPairingPrompt in networks.so.
- Extend scripts/test-bluetooth-obex.py, scripts/test-bluetooth-headset.py, scripts/check-rebuild.sh, docs, and rebuild/pin a1120 (cocojamboo) images and archives for nokia-argon, nokia-beatles, nokia-coconut, and nokia-sparkler.
98 lines
2.8 KiB
Bash
Executable File
98 lines
2.8 KiB
Bash
Executable File
#!/bin/sh
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
# Copyright 2022 Sxmo Contributors
|
|
|
|
if [ "$(id -u)" != "0" ]; then
|
|
exec doas -n /usr/bin/sxmo_bluetoothtoggle.sh "$@"
|
|
fi
|
|
|
|
. sxmo_common.sh
|
|
|
|
on() {
|
|
rfkill unblock bluetooth
|
|
modprobe -q uhid hidp uinput rfcomm bnep xpad af_alg algif_hash algif_skcipher algif_rng algif_aead 2>/dev/null || true
|
|
chgrp input /dev/uinput 2>/dev/null || true
|
|
chmod 0660 /dev/uinput 2>/dev/null || true
|
|
|
|
if [ -d /run/systemd/system ]; then
|
|
systemctl start bluetooth
|
|
systemctl enable bluetooth
|
|
else
|
|
rc-service bluetooth start
|
|
rc-update add bluetooth
|
|
fi
|
|
sleep 0.4
|
|
if [ -s /etc/bananarchy/bt_mac ] && [ -x /usr/bin/bananarchy-engmenu-ctl ]; then
|
|
/usr/bin/bananarchy-engmenu-ctl apply-boot >/dev/null 2>&1 || true
|
|
fi
|
|
/usr/bin/bananarchy-bt-le-enable.sh >/dev/null 2>&1 || true
|
|
timeout 2 /usr/bin/btmgmt -i hci0 class 2 3 >/dev/null 2>&1 || true
|
|
timeout 2 bluetoothctl power on >/dev/null 2>&1 || true
|
|
/usr/bin/bananarchy-bt-le-enable.sh >/dev/null 2>&1 || true
|
|
timeout 2 /usr/bin/btmgmt -i hci0 class 2 3 >/dev/null 2>&1 || true
|
|
|
|
bt_name=""
|
|
if [ -r /home/user/.config/sxmo/bt_name ]; then
|
|
IFS= read -r bt_name < /home/user/.config/sxmo/bt_name 2>/dev/null || true
|
|
fi
|
|
if [ -z "$bt_name" ]; then
|
|
bt_name="$(hostname 2>/dev/null || cat /etc/hostname 2>/dev/null || printf "Bananarchy")"
|
|
fi
|
|
if [ -n "$bt_name" ]; then
|
|
timeout 2 bluetoothctl system-alias "$bt_name" >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
bt_disc="0"
|
|
if [ -r /home/user/.config/sxmo/bt_discoverable ]; then
|
|
IFS= read -r bt_disc < /home/user/.config/sxmo/bt_discoverable 2>/dev/null || true
|
|
fi
|
|
timeout 2 bluetoothctl pairable-timeout 0 >/dev/null 2>&1 || true
|
|
timeout 2 bluetoothctl pairable on >/dev/null 2>&1 || true
|
|
timeout 2 bluetoothctl discoverable-timeout 60 >/dev/null 2>&1 || true
|
|
case "$bt_disc" in
|
|
1|on|ON|yes|YES|true|TRUE)
|
|
timeout 2 bluetoothctl discoverable on >/dev/null 2>&1 || true
|
|
;;
|
|
*)
|
|
timeout 2 bluetoothctl discoverable off >/dev/null 2>&1 || true
|
|
;;
|
|
esac
|
|
|
|
/usr/bin/bananarchy-bt-obex start >/dev/null 2>&1 || true
|
|
}
|
|
|
|
off() {
|
|
/usr/bin/bananarchy-bt-obex stop >/dev/null 2>&1 || true
|
|
if [ -d /run/systemd/system ]; then
|
|
systemctl stop bluetooth
|
|
systemctl disable bluetooth
|
|
else
|
|
rc-service bluetooth stop
|
|
rc-update del bluetooth
|
|
fi
|
|
rfkill block bluetooth
|
|
}
|
|
|
|
case "${1:-toggle}" in
|
|
on)
|
|
on
|
|
;;
|
|
off)
|
|
off
|
|
;;
|
|
status)
|
|
if rfkill list bluetooth -no ID,SOFT,HARD | grep -vq " blocked" && pidof -s bluetoothd >/dev/null 2>&1; then
|
|
echo "on"
|
|
else
|
|
echo "off"
|
|
fi
|
|
;;
|
|
*) # toggle
|
|
if rfkill list bluetooth -no ID,SOFT,HARD | grep -vq " blocked" && pidof -s bluetoothd >/dev/null 2>&1; then
|
|
off
|
|
else
|
|
on
|
|
fi
|
|
;;
|
|
esac
|