Keep live BlueZ discovery client alive for real scans
The previous Bluetooth fix only proved parser behavior with a synthetic stream. Real BlueZ discovery needs one interactive client to stay alive while unpaired Device1 objects exist. Add a bluetoothctl wrapper and bananarchy-bt-scan.sh PTY session that powers on, sets auto/duplicate-data filters, queries devices during discovery, and stops discovery cleanly. Add util-linux-misc, host test, docs and rebuild guards. Deployed to the live phone; a physical peripheral in pairing mode is still needed for final confirmation.
This commit is contained in:
1 parent
f892531df6
commit
77127c7844
10 files changed
+232
-4
No files matched your search
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/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
|
||||
|
||||
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 on' \
|
||||
'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
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
# Route bluetoothctl discovery through one live interactive BlueZ client.
|
||||
# All other bluetoothctl calls go to the real package binary unchanged.
|
||||
REAL="${BANANARCHY_REAL_BLUETOOTHCTL:-/usr/bin/bluetoothctl}"
|
||||
HELPER="${BANANARCHY_BT_SCAN_HELPER:-/usr/bin/bananarchy-bt-scan.sh}"
|
||||
export BANANARCHY_REAL_BLUETOOTHCTL="$REAL"
|
||||
|
||||
case " $* " in
|
||||
*" scan on "*|*" scan bredr "*|*" scan le "*)
|
||||
"$HELPER" || true
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
exec "$REAL" "$@"
|
||||
;;
|
||||
esac
|
||||
Reference in new issue
Block a user