- 
      
- 
        Save schollz/cd785d6c00f598f48c85c261bb0cbd93 to your computer and use it in GitHub Desktop. 
    Bluetoothctl automation
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/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