javl / InstaxBLE

MIT License
54 stars 6 forks source link

Todo: integrate different backends into single module #5

Closed javl closed 1 year ago

javl commented 1 year ago

It would be great if the GATT and socket approach would both work from the same module so you can install it and load the right back-end depending on your system.

javl commented 1 year ago

I've changed the code so it pulls in the right files depending on the platform. This means the method names (connect, send_packet, etc.) can be always the same, but they call different code for Linux / MacOS (and Windows at some point) in the background. This way you only have to write a single script and the system will use sockets or gatt depending on the platform.

At the moment this works for the Linux version, but the MacOS version uses Bleak which is asynchronous. This is already a major pain in the butt when you run it standalone, but it's especially confusing if you want to run a specific function like find_device() as a regular function on Linux, but then need it to be async on MacOS. So next step: find a different (not async) bluetooth platform to use on MacOS.

javl commented 1 year ago

With the change to Simplepyble this isn't needed anymore!