File tree Expand file tree Collapse file tree 2 files changed +15
-25
lines changed
Expand file tree Collapse file tree 2 files changed +15
-25
lines changed Original file line number Diff line number Diff line change 33set timeout 120
44
55set prompt " #"
6- set address [lindex $argv 0]
76
87spawn sudo bluetoothctl -a
98expect -re $prompt
@@ -34,6 +33,9 @@ expect -re $prompt
3433send " pairable on\r"
3534sleep 1
3635
36+ expect -re " [NEW] Device\w(.+)\w"
37+ set address $expect_out (1,string)
38+
3739expect -re " Enter PIN code: "
3840send " 3434\r"
3941
@@ -43,8 +45,15 @@ send "trust $address\r"
4345sleep 2
4446
4547expect -re " trust succeeded"
46- sleep 3
48+ sleep 1
49+
50+ expect -re $prompt
51+ send " discoverable off\r"
52+ sleep 1
53+
54+ expect -re $prompt
55+ send " pairable off\r"
56+ sleep 1
4757
48- send_user " \nShould be paired now.\r"
4958send " quit\r"
5059expect eof
Original file line number Diff line number Diff line change @@ -26,36 +26,17 @@ echo "Activating bluetooth pairing mode"
2626
2727sudo hciconfig hci0 sspmode 0
2828
29- sudo btmgmt connectable yes
30- sudo btmgmt discov yes
31- sudo btmgmt pairable yes
32-
33- sudo killall -9 bt-agent
34-
35- echo " Bluetooth device is now discoverable"
36- echo
3729echo " Open ${bold} bluetooth settings${normal} on your phone to search for and ${bold} pair${normal} with this device"
3830echo " If you have already paired it on your phone, please unpair it first, then pair again"
3931echo
40- printf " Waiting for connection.."
41-
42- btdevice=
43- while [[ -z " $btdevice " ]]
44- do
45- printf " ."
46- sleep 1
47- btdevice=` sudo bt-device -l | grep -e \( .* \) `
48- done
49-
50- mac=` echo $btdevice | cut -d' (' -f2 | cut -d' )' -f1`
5132
5233/usr/bin/expect -f /home/pi/omnipy/bt-expect.sh
5334
54- sudo btmgmt discov no
55- sudo btmgmt pairable no
56-
5735sudo hciconfig hci0 sspmode 1
5836
37+ btdevice=` sudo bt-device -l | grep -e \( .* \) `
38+ mac=` echo $btdevice | cut -d' (' -f2 | cut -d' )' -f1`
39+
5940echo
6041
6142echo " ${bold} Paired with $btdevice .${normal} "
You can’t perform that action at this time.
0 commit comments