Skip to content

Commit 74d8e50

Browse files
committed
Streamline Bluetooth scan
Eliminate separate BR/EDR and BR/EDR+LE scans because they return the same results in testing. Just go with the default "auto" which is what is set when no transport is explicitly set.
1 parent eb29b58 commit 74d8e50

File tree

2 files changed

+11
-62
lines changed

2 files changed

+11
-62
lines changed

www/blu-config.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,12 @@
120120
phpSession('close');
121121

122122
// Command list
123-
$_cmd['btcmd'] .= "<option value=\"-s\" " . (($cmd == '-s') ? "selected" : "") . ">SCAN (Standard)</option>\n";
124-
$_cmd['btcmd'] .= "<option value=\"-S\" " . (($cmd == '-S') ? "selected" : "") . ">SCAN (Plus LE devices)</option>\n";
123+
$_cmd['btcmd'] .= "<option value=\"-s\" " . (($cmd == '-s') ? "selected" : "") . ">SCAN (20 seconds)</option>\n";
125124
$_cmd['btcmd'] .= "<option value=\"-p\" " . (($cmd == '-p') ? "selected" : "") . ">LIST paired</option>\n";
126125
$_cmd['btcmd'] .= "<option value=\"-c\" " . (($cmd == '-c') ? "selected" : "") . ">LIST connected</option>\n";
127126
$_cmd['btcmd'] .= "<option value=\"-l\" " . (($cmd == '-l') ? "selected" : "") . ">LIST trusted</option>\n";
128127
$_cmd['btcmd'] .= "<option value=\"-D\" " . (($cmd == '-D') ? "selected" : "") . ">DISCONNECT all</option>\n";
129-
$_cmd['btcmd'] .= "<option value=\"-R\" " . (($cmd == '-R') ? "selected" : "") . ">REMOVE all devices</option>\n";
128+
$_cmd['btcmd'] .= "<option value=\"-R\" " . (($cmd == '-R') ? "selected" : "") . ">REMOVE all</option>\n";
130129
$_cmd['btcmd'] .= "<option value=\"-H\" " . (($cmd == '-H') ? "selected" : "") . ">HELP</option>\n";
131130

132131
// Initial control states
@@ -159,7 +158,7 @@
159158
$_select['audioout'] .= "<option value=\"Bluetooth\" " . (($_SESSION['audioout'] == 'Bluetooth') ? "selected" : "") . ">Bluetooth speaker</option>\n";
160159

161160
// Provide a select for removing, disconnecting, pairing or connecting a device
162-
$cmd_array = array('-p', '-c', '-l', '-s', '-S');
161+
$cmd_array = array('-p', '-c', '-l', '-s');
163162
if (in_array($cmd, $cmd_array)) {
164163
switch ($cmd) {
165164
case '-p':
@@ -170,7 +169,6 @@
170169
break;
171170
case '-l':
172171
case '-s':
173-
case '-S':
174172
$type = 'scanned_device';
175173
break;
176174
}

www/util/blu-control.sh

Lines changed: 8 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
# - show and kill active connections - "online"
1515
# - kill active connections before scanning
1616
# - TODO: How to avoid double source connection??
17+
# Rev 2.0 24-Nov-2025
18+
# - Update for moOde 10 Trixie
1719
#
1820
# This script is designed to work with bluez and bluez-alsa
1921
# It performs bluetooth controller initialization and provides management of bluetooth sources
2022
# All related data files will reside under /var/lib/bluetooth
2123
#
2224

23-
REV=1.6
25+
REV=2.0
2426

2527
# Check for sudo
2628
[[ $EUID -ne 0 ]] && { echo "Use sudo to run the script" ; exit 1 ; } ;
@@ -50,40 +52,9 @@ echo "**"
5052
echo "** Controller initialized"
5153
}
5254

53-
# Scan for only BR/EDR devices
54-
SCAN_BREDR() {
55-
echo "** Scanning for only BR/EDR devices (${SCAN_DURATION} seconds)"
56-
echo "**"
57-
expect <(cat <<EOF
58-
log_user 0
59-
set timeout -1
60-
match_max 100000
61-
spawn bluetoothctl
62-
expect "*> "
63-
send "menu scan\r"
64-
expect "*> "
65-
send "clear\r"
66-
expect "*> "
67-
send "transport bredr\r"
68-
expect "*> "
69-
send "back\r"
70-
expect "*> "
71-
send "scan on\r"
72-
expect "Discovery started\r"
73-
expect "*> "
74-
sleep $SCAN_DURATION
75-
send "scan off\r"
76-
expect "Discovery stopped\r"
77-
expect "*> "
78-
send "quit\r"
79-
expect eof
80-
EOF
81-
)
82-
}
83-
84-
# Scan for both BR/EDR and LE devices
85-
SCAN_DUAL() {
86-
echo "** Scanning for BR/EDR and LE devices (${SCAN_DURATION} seconds)"
55+
# Scan for devices
56+
SCAN() {
57+
echo "** Scanning for devices (${SCAN_DURATION} seconds)"
8758
echo "**"
8859
expect <(cat <<EOF
8960
log_user 0
@@ -258,8 +229,7 @@ HELP_TERM() {
258229
echo "** Usage: blu-control.sh [OPTION]"
259230
echo "**"
260231
echo "** -i Initialize/reset controller"
261-
echo "** -s Scan (BR/EDR only) and trust devices"
262-
echo "** -S Scan (LE and BR/EDR) and trust devices"
232+
echo "** -s Scan for and trust devices"
263233
echo "** -p List paired devices"
264234
echo "** -c List connected devices"
265235
echo "** -l List trusted devices"
@@ -272,16 +242,6 @@ HELP_TERM() {
272242
echo "** -h Help"
273243
}
274244

275-
# Format help for html presentation
276-
HELP_HTML() {
277-
echo "1) Put your device in discovery mode and wait until it discovers Moode Bluetooth. You may have to turn Bluetooth off/on on your device to accomplish this."
278-
echo
279-
echo -e "2) To send audio from your device to moOde:<br>First turn on the Pairing agent in Audio Config and then initiate the connection on your device. Your device should automatically pair and connect. You can verify that your device has been successfully paired and connected by submitting \"LIST paired\" or \"LIST connected\" commands."
280-
echo
281-
echo -e "3) To send audio from moOde to your device:<br>First submit a SCAN command and verify that your device appears in the scan results. The SCAN may have to be run multiple times. Next select the device in the dropdown list, PAIR it then select \"MPD audio output->Bluetooth\" from the dropdown then CONNECT."
282-
echo "<br>Note: Bluetooth has a range of around 30 feet (10 meters) but range will vary depending on obstacles (metal, wall, etc.), device signal strength and quality, and level of electromagnetic interferrence."
283-
}
284-
285245
#
286246
# Main
287247
#
@@ -291,14 +251,8 @@ case $1 in
291251
-i) INIT
292252
exit 0
293253
;;
294-
-s) SCAN_BREDR
295-
TRUST
296-
#echo "** Scan complete"
297-
exit 0
298-
;;
299-
-S) SCAN_DUAL
254+
-s) SCAN
300255
TRUST
301-
#echo "** Scan complete"
302256
exit 0
303257
;;
304258
-l) LIST_DISCOVERED
@@ -339,9 +293,6 @@ case $1 in
339293
-h) HELP_TERM
340294
exit 0
341295
;;
342-
-H) HELP_HTML
343-
exit 0
344-
;;
345296
*) HELP_TERM
346297
exit 0
347298
;;

0 commit comments

Comments
 (0)