0

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

  1. confirm the passkey with typing yes and press enter
  2. confirm the "audio-request" in the agent with yes and 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!

2
  • 1
    Does this answer your question? How can I automate pairing RPi and Android with bluetooth Batch script Commented Apr 28, 2023 at 5:25
  • OK i understood that i need to use dbus to control bluetooth. But the example code given in the post above did not help, as it is not working for me somehow... i need to check. Commented Apr 30, 2023 at 8:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.