Requirement: I need to connect to a remote bluetooth device & port and send data using a device file. 1. First scan the nearest bluetooth devices 2. connect to a remote BT addr & channel and communicate using a device file (/dev/rfcomm0)
I'm stuck at the second step. I'm able to do it through linux shell
sudo rfcomm connect /dev/rfcomm0 00:11:22:33:44:55 1 &
This works and then I open my python interpreter and communicate to the remote device using the rfcomm0 device file.
But my requirement is such that the device addr could be changing. So I want to connect and release the connections through python program.
I tried using python subprocess. But the problem is it returns immediately with a returncode 0 and then the connection is established after certain latency.
import subprocess
host = '00:11:22:33:44:55'
port = "1"
subprocess.call(["rfcomm connect",host,port,"&"],shell=True)
I'm looking if there is any pyBluez or any other python alternative to achieve this.
&
, then. that puts the external process into the background, and "returns" immediately. without the&
the external process will block until it itself exits. – Marc B