On a RPi4 with Debian I use
sudo bluetoothctl
power on
discoverable on
pairable on
agent NoInputNoOutput
default-agent
to be able to pair e.g. my smartphone to this Rpi. These steps are also possible to trigger from an python script (e.g. with subprocess.run() ).
After that steps I can connect a profile like Audio streaming. In bluetoothctl it needs to
- confirm the passkey with typing
yesand press enter - confirm the "audio-request" in the agent with
yesand press enter.
I would like to confirm the steps 1. and 2. with a python script. Like listening on the Bluetooth agent and as soon as it asks for confirmation, i would like to feedback yes.
But I don't know how I can interact with that Bluetoothctl agent on python.
I already tried to open a subprocess
returnstring = subprocess.run(["bluetoothctl"], stdout = subprocess.PIPE, timeout = 5 )
in python with timeout (5s). My hope was, to finally get as STDOUT a string with the question about "... accepting profile: yes/no". But I just received an error and timeout.
Any proposals?
Thank you!