0

I have a bluetooth device, I want to connect it to Windows with Python, almost exactly how you do it with the UI just programmatically. How could I achieve this? I assume I should use the win32 api but I would love some guidance. It seems this is the function that I need to use, but I cant seem to even run it; not sure how.

Thanks

JustOscarJ
  • 99
  • 1
  • 8
  • What kind of device is it? Bluetooth classic or BLE? What do you want to do once you are connected? For classic there is: https://stackoverflow.com/a/62815818/7721752 and for BLE there is https://github.com/hbldh/bleak – ukBaz Jun 14 '22 at 12:44
  • Not sure what type it is, it's a Nintendo Switch Joycon, Google says Bluetooth 3.0 but I'm not sure how useful that is. EDIT: I am trying Bleak already but it's not finding it (while windows bluetooth is) – JustOscarJ Jun 14 '22 at 12:47
  • Bluetooth 3.0 would fall under the classic category. However, the previous solution I linked to is for RFCOMM and not game pads/HID. You might need to go for something like https://pypi.org/project/winrt/ – ukBaz Jun 14 '22 at 13:26

1 Answers1

0

you can try using PyBluez, I found that to be easier to use https://github.com/pybluez/pybluez

docs: https://pybluez.readthedocs.io/en/latest/install.html

if you are on windows 10 you need to install some dependencies described here

Mando
  • 33
  • 4
  • I did try PyBluez but it couldn't find my device (windows was finding it), PyBluez was finding my phone though, just not the device I wanted it to find. – JustOscarJ Jun 14 '22 at 12:24
  • have you installed the correct dependencies? I had a similar problem and I solved installing the windows 10 sdk from the docs – Mando Jun 14 '22 at 12:27
  • and also make sure your other device is discoverable try visualizing it via your phone's bluethoot menu – Mando Jun 14 '22 at 12:32
  • Could it be because the device I am connecting want's to be the child of my computer but the phone wants to be the parent of my computer? Don't know how to really say it. – JustOscarJ Jun 14 '22 at 12:39