Page 1 of 1

PyBluez is not creating a port

Posted: Sat May 27, 2017 6:21 am
by EinSoldiatGott
Hi. I'm using
python 3.4
bluez 5.23
raspbian jessie
RBPI3

I have a bluetooth SPP device, manually paired with password, previously I followed the instructions to add a spp.
If I run:

Code: Select all

 sudo rfcomm connect hci0 00:19:5D:FE:80:11
I can succesfully ser the rfcomm0 created,
I can see in the sysBar Bluetooth that my device is connected
I can connect to it via python pyserial using /dev/rfcomm0 and get data


Image

Everything works perfect, but I'l like to use a more pythonist way to connect the device

So I tried pyBluez

But
If I conect via pyBluez (after verifying the device is discoverable) I can see in the sysBar Bluetooth that my device is connected
But any new serial port is created, ls /dev/ list a lot of devices but I tried many of them and none of them seems to be linked to the new conenction (Even tried the ttyAMA0) tried also with cat and minicom

Code: Select all

                uuid = "00001101-0000-1000-8000-00805F9B34FB"
                servicios = bluetooth.find_service(uuid=uuid, address=self.mac)

                if len(servicios) == 0:
                    return False

                dispositivo_spp = servicios[0]
                port = dispositivo_spp["port"]
                name = dispositivo_spp["name"]
                host = dispositivo_spp["host"]

                self.sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
                self.sock.connect((host, port))
Image

So, do you know how to tell pyBluez to link the new port to the dir /dev/rfcomm0? or how to know what port has it created?

Thanks

Re: PyBluez is not creating a port

Posted: Sat May 27, 2017 12:01 pm
by Douglas6
Pybluez will not create a virtual serial port. You'll need to use rfcomm for that. If you like, you can run rfcomm from a systemd unit at boot time. Then you can use PySerial to open the port and read/write to it.

Re: PyBluez is not creating a port

Posted: Sat May 27, 2017 5:21 pm
by EinSoldiatGott
Douglas6 wrote:Pybluez will not create a virtual serial port. You'll need to use rfcomm for that. If you like, you can run rfcomm from a systemd unit at boot time. Then you can use PySerial to open the port and read/write to it.
ok :( I wanted to verify that the device is discoverable because is part of my goals, detect if someone stole the device jeje.

But ok, I'll discover the device with pybluez and then use rfcomm with subprocess