Skip to content

Commit 5dff90e

Browse files
authored
Merge pull request #2625 from psyke83/bluez_fixes
WIP: bluetooth: improve scan timeout functionality
2 parents 56bc17a + 6ce74e9 commit 5dff90e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

scriptmodules/supplementary/bluetooth.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ function bluez_cmd_bluetooth() {
6363
mkfifo "$fifo"
6464
exec 3<>"$fifo"
6565
local line
66-
while read -t "$2"; do
66+
while true; do
6767
_slowecho_bluetooth "$1" >&3
6868
# collect output for specified amount of time, then echo it
69-
while read -t "$2" -r line; do
69+
while read -r line; do
7070
printf '%s\n' "$line"
7171
# (slow) reply to any optional challenges
7272
if [[ -n "$3" && "$line" =~ $3 ]]; then
@@ -76,7 +76,7 @@ function bluez_cmd_bluetooth() {
7676
_slowecho_bluetooth "quit\n" >&3
7777
break
7878
# read from bluetoothctl buffered line by line
79-
done < <(stdbuf -oL bluetoothctl --agent=NoInputNoOutput <&3)
79+
done < <(timeout "$2" stdbuf -oL bluetoothctl --agent=NoInputNoOutput <&3)
8080
exec 3>&-
8181
}
8282

@@ -86,15 +86,15 @@ function list_available_bluetooth() {
8686
local info_text="\n\nSearching ..."
8787

8888
# sixaxis: add USB pairing information
89-
[[ -n "$(lsmod | grep hid_sony)" ]] && info_text="Searching ...\n\nDualShock registration: wait 3 seconds, then unplug and replug the controller (while this text is visible)."
89+
[[ -n "$(lsmod | grep hid_sony)" ]] && info_text="Searching ...\n\nDualShock registration: while this text is visible, unplug and replug the controller, then press the PS/SHARE button."
9090

9191
dialog --backtitle "$__backtitle" --infobox "$info_text" 7 60 >/dev/tty
9292
if hasPackage bluez 5; then
9393
# sixaxis: reply to authorization challenge on USB cable connect
9494
while read mac_address; read device_name; do
9595
echo "$mac_address"
9696
echo "$device_name"
97-
done < <(bluez_cmd_bluetooth "default-agent\nscan on" "20" "Authorize service$" "yes\ntrust\ndisconnect" >/dev/null; bluez_cmd_bluetooth "devices" "2" | grep "^Device " | cut -d" " -f2,3- | sed 's/ /\n/')
97+
done < <(bluez_cmd_bluetooth "default-agent\nscan on" "15" "Authorize service$" "yes\ntrust\ndisconnect" >/dev/null; bluez_cmd_bluetooth "devices" "3" | grep "^Device " | cut -d" " -f2,3- | sed 's/ /\n/')
9898
else
9999
while read; read mac_address; read device_name; do
100100
echo "$mac_address"

0 commit comments

Comments
 (0)