I am developing a simple app in python that uses bluez and dbus. The app should pair with a Bluetooth device - a raspberry Pi. I failed at pairing once, and now not only am I not able to reproduce the error, I can't even find the device anymore.
what I did:
- scanned for all the devices ( using the startDiscovery() function on an object implementing org.bluez.Adapter1 interface)
- checked every found device if its MAC address matches the one I am looking for
- after finding the device I was looking for, I used its path to create a proxy object ( with bus.get_object('org.bluez', device_path) )
- I created org.bluez.device1 interface on this object ( with dbus.Interface(device_obj, 'org.bluez.Device1') )
- I set the the "Trusted" property of this interface to True
- I called the Pair() function on this interface
This resulted in failed Pair attempt - it happened only once, I was not able to track down the error. Furthermore - the bluetooth on the raspberry Pi I tried to pair with stopped working: I was not able to advertise anymore. Rebooting and reinstalling bluez did not help, I had to reflash the SD card and install a fresh OS to make the bluetooth on RPi functional again.
On the application side I am able to scan and see all the other BT devices, except the one I failed to pair with. I tried rebooting, and reinstalling my code in the virtual environment.
If I run the bluetoothctl scan on program, I am able to see that RPi I am looking for. The bluetoothctl paired-devices list is empty. I belive the problem must be in my app.
I am really confused, and would be very grateful for any tips or suggestions.