Skip to content

Instantly share code, notes, and snippets.

@KlausEverWalkingDev
Forked from RamonGilabert/bluetooth.sh
Created October 31, 2019 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KlausEverWalkingDev/8cf26b083af6220d309783085acdebf7 to your computer and use it in GitHub Desktop.
Save KlausEverWalkingDev/8cf26b083af6220d309783085acdebf7 to your computer and use it in GitHub Desktop.
Bluetoothctl automation
#!/usr/bin/expect -f
set prompt "#"
set address [lindex $argv 0]
spawn sudo bluetoothctl -a
expect -re $prompt
send "remove $address\r"
sleep 1
expect -re $prompt
send "scan on\r"
send_user "\nSleeping\r"
sleep 5
send_user "\nDone sleeping\r"
send "scan off\r"
expect "Controller"
send "trust $address\r"
sleep 2
send "pair $address\r"
sleep 2
send "0000\r"
sleep 3
send_user "\nShould be paired now.\r"
send "quit\r"
expect eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment