Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set timeout 30
- spawn bluetoothctl
- expect "# "
- send "agent off\r"
- expect "?egistered"
- send "\r"
- expect "# "
- send "agent on\r"
- expect "Agent registered"
- send "\r"
- expect "# "
- send "default-agent\r"
- expect "Default agent request successful"
- send "\r"
- expect "# "
- send "trust [lindex $argv 0]\r"
- expect "Changing"
- send "connect [lindex $argv 0]\r"
- expect "Connection successful"
- send "exit\r"
- -----
- cd $(dirname $0)
- echo "Pairing..."
- expect pair_bluetooth_device.expect > expect_script.log
- chmod 777 expect_script.log
- sleep 2
- echo "Trusting and connecting.."
- device_mac_address=$(cat expect_script.log | grep -Pom 1 "(?<=Device ).*(?= Connected)")
- echo mac address is $device_mac_address
- if [[ ! -z $device_mac_address ]] ; then
- expect trust_and_connect.expect $device_mac_address
- else
- echo "No device connected"
- fi
- rm expect_script.log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement