OpenBluetoothToolbox / SimpleBLE

SimpleBLE - the all-in-one Bluetooth library for MacOS, iOS, Windows, Linux and Android.
https://www.simpleble.org
Other
619 stars 107 forks source link

Connecting directly to known peripheral under Python #306

Open ullix opened 2 months ago

ullix commented 2 months ago

I do know the adapter, I have, and from my peripheral I do know both identifier and address. Is there a way do connect to it directly without having to go via get_adapters and scan_get_results?

eriklins commented 2 months ago

Cannot comment on get_adapters, but it’s not possible to connect to a peripheral without prior scanning. A BLE advert is considered the invitation for engaging a connection. Without the central does not know about the peripheral and open time slots for connecting.

ullix commented 2 months ago

Well, I do not really know how others are doing it, but at least in these 2 cases the address suffices (plus perhaps the relevant *UUID): https://github.com/sercona/Owon-Multimeters/issues/4#issue-2285552174 https://github.com/sercona/Owon-Multimeters/issues/4#issuecomment-2104203436

eriklins commented 2 months ago

Then the advert scanning is done somehow/somewhere automagically in lower code layers there. This is not a limitation of SimpleBLE but it's how BLE works and how it has been defined in the BT/BLE spec.

ullix commented 2 months ago

When I run stand-alone code based on your simplepyble notify example, it runs well and fast for hours on end with no issues.

However, when I put this (rather simple) code into my "big code", it lasts for only 1 ... 100 sec before it crashes with a Segmentation fault!

The big code uses PyQt5, often the culprit for SegFaults. Any suggestion what to look for? There is no PyQt5 stuff in the part of the simplepyble code.