Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. set timeout 30
  2. spawn bluetoothctl
  3. expect "# "
  4. send "agent off\r"
  5. expect "?egistered"
  6. send "\r"
  7.  
  8. expect "# "
  9. send "agent on\r"
  10. expect "Agent registered"
  11. send "\r"
  12.  
  13. expect "# "
  14. send "default-agent\r"
  15. expect "Default agent request successful"
  16. send "\r"
  17.  
  18. expect "# "
  19. send "trust [lindex $argv 0]\r"
  20.  
  21. expect "Changing"
  22. send "connect [lindex $argv 0]\r"
  23.  
  24. expect "Connection successful"
  25. send "exit\r"
  26.  
  27.  
  28.  
  29. -----
  30.  
  31.  
  32. cd $(dirname $0)
  33. echo "Pairing..."
  34. expect pair_bluetooth_device.expect > expect_script.log
  35. chmod 777 expect_script.log
  36. sleep 2
  37.  
  38. echo "Trusting and connecting.."
  39. device_mac_address=$(cat expect_script.log | grep -Pom 1 "(?<=Device ).*(?= Connected)")
  40. echo mac address is $device_mac_address
  41. if [[ ! -z $device_mac_address ]] ; then
  42. expect trust_and_connect.expect $device_mac_address
  43. else
  44. echo "No device connected"
  45. fi
  46. rm expect_script.log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement