Files
bananarchy/overlay/rootfs/usr/bin/bananarchy-bt-scan.sh
T
Luxferre 1e7077e314 Fix bluetoothd CPU busy-loops, cache BT state, and refresh a1120 images
- Add /etc/conf.d/bluetooth (supervise-daemon, retry=TERM/3/KILL/1, --noplugin=hfp,bap,bass,mcp,vcp,micp,csip,ccp,tmap,gmap,asha,midi,neard) and drop gateway UUIDs (111f/1112/110a) from main.conf ReconnectUUIDs so Experimental = true keeps PreferredBearer without BlueZ hfp-hf/ATT EOF GMainLoop spins.

- Set duplicate-data off in bananarchy-bt-scan.sh and update sxmo_bluetoothtoggle.sh to disconnect, btmgmt power off, and clean state files on disable so adapter_stop() never busy-loops on dual-bearer links.

- Add single-shot BlueZ ObjectManager state caching (bt_state.tsv, dump-state, CTRL_READY_FILE, EPHEMERAL_DEV_PROPS filter) in bananarchy-bt-obex and consume it in networks.so instead of per-device bluetoothctl refresh storms.

- Extend Bluetooth host tests and check-rebuild.sh, update docs, and rebuild/pin a1120 (cocojamboo) images and release archives for nokia-argon, nokia-beatles, nokia-coconut, and nokia-sparkler.
2026-11-18 06:34:13 +02:00

58 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
# Keep one interactive bluetoothctl client alive for a full discovery window.
# BlueZ removes unpaired Device1 objects when the discovery client exits, and
# non-interactive "scan on" does not reliably print device events to a pipe.
# This helper drives bluetoothctl through a PTY via script(1), asks the same
# client for "devices" while discovery is active, then stops discovery cleanly.
REAL="${BANANARCHY_REAL_BLUETOOTHCTL:-/usr/bin/bluetoothctl}"
DURATION="${BANANARCHY_BT_SCAN_SECONDS:-13}"
case "$DURATION" in
''|*[!0-9]*)
DURATION=13
;;
esac
if [ "$DURATION" -lt 3 ]; then
DURATION=3
elif [ "$DURATION" -gt 13 ]; then
DURATION=13
fi
"$REAL" power on >/dev/null 2>&1 || true
doas -n /usr/bin/bananarchy-bt-le-enable.sh >/dev/null 2>&1 || true
q1=$((DURATION / 3))
q2=$((DURATION * 2 / 3))
q3=$((DURATION - 1))
if [ "$q1" -lt 1 ]; then
q1=1
fi
if [ "$q2" -le "$q1" ]; then
q2=$((q1 + 1))
fi
if [ "$q3" -le "$q2" ]; then
q3=$((q2 + 1))
fi
{
printf '%s\n' \
'menu scan' \
'transport auto' \
'duplicate-data off' \
'back' \
'power on'
sleep 1
printf '%s\n' 'scan on'
sleep "$q1"
printf '%s\n' 'devices'
sleep "$((q2 - q1))"
printf '%s\n' 'devices'
sleep "$((q3 - q2))"
printf '%s\n' 'devices' 'scan off'
sleep 1
printf '%s\n' 'quit'
} | timeout "$((DURATION + 2))" \
script -q -c "$REAL" /dev/null
exit 0