Skip to content

Instantly share code, notes, and snippets.

@schollz
Forked from RamonGilabert/bluetooth.sh
Created February 17, 2018 20:53
Show Gist options
  • Save schollz/cd785d6c00f598f48c85c261bb0cbd93 to your computer and use it in GitHub Desktop.
Save schollz/cd785d6c00f598f48c85c261bb0cbd93 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