Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6180

Ubuntu 20.04.2 Bluetoothctl SCAN from bash script

$
0
0

Ubuntu 20.04.2 LTSbluetoothctl Version 5.53

The problem I have is a bluetooth headset being unable to directly pair without errors when switching between Ubuntu/Windows on a dual boot machine (I believe due to the process which bluetooth issues/stores public keys)

I am trying to run a simple script to remove a specific bluetooth address (device), flush its information and re-pair.

I have tried various iterations of:

#!/bin/bash#remove old connection echo -e 'power on\ndisconnect 88:88:E1:21:52:BE\nremove 88:88:E1:21:52:BE\nquit' | bluetoothctlsudo systemctl restart bluetooth sleep 1echo -e 'power on' | bluetoothctlecho -e 'default-agent' | bluetoothctlecho -e 'discoverable on\ndiscoverable-timeout 100\nscan on' | bluetoothctlsleep 10echo -e 'pairable on' | bluetoothctl# Re-Add our deviceecho -e 'trust 88:88:E1:21:52:BE\npair 88:88:E1:21:52:BE' | bluetoothctlsleep 4echo -e 'connect 88:88:E1:21:52:BE' | bluetoothctlecho -e 'discoverable off' | bluetoothctlecho -e 'quit' | bluetoothctl

Output as follows:

Agent registered[bluetooth]# power on[bluetooth]# disconnect 88:88:E1:21:52:BEAttempting to disconnect from 88:88:E1:21:52:BE[bluetooth]# remove 88:88:E1:21:52:BE[bluetooth]# quitAgent registered[bluetooth]# power onAgent registered[bluetooth]# default-agentAgent registered[bluetooth]# discoverable on[bluetooth]# discoverable-timeout 100[bluetooth]# scan onAgent registered[bluetooth]# pairable onAgent registered[bluetooth]# trust 88:88:E1:21:52:BEDevice 88:88:E1:21:52:BE not available[bluetooth]# pair 88:88:E1:21:52:BEDevice 88:88:E1:21:52:BE not availableAgent registered[bluetooth]# connect 88:88:E1:21:52:BEDevice 88:88:E1:21:52:BE not availableAgent registered[bluetooth]# discoverable offAgent registered[bluetooth]# quit

However while following on the bluetoothctl command output in a seperate window

[CHG] Controller C8:58:C0:C4:41:F8 Name: [ControllerID][CHG] Controller C8:58:C0:C4:41:F8 Alias: BlueZ 5.53[CHG] Controller C8:58:C0:C4:41:F8 Alias: [ControllerID]**[CHG] Controller C8:58:C0:C4:41:F8 Discovering: no**[CHG] Controller C8:58:C0:C4:41:F8 Discoverable: yes

The Scan on command has not had the desired effect. The bluetooth controller is not discovering and discovers no devices ergo no connection to said devices can be made.

When moving directly into the bluetoothctl command line, the scan on command has the desired effect and the controller begins scanning. Why is the scan ON command from the ubuntu terminal/bash script not having the desired effect?


Viewing all articles
Browse latest Browse all 6180

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>