4

I have the following Python code:

import bluetooth
print(bluetooth.discover_devices())

This always waits a few seconds and prints out an empty list.

My bluetooth adapter appears to be working, as I can discover devices with bluetoothctl easily by typing scan on.

How can I fix/troubleshoot this?

888
  • 291
  • 3
  • 11
  • Although a bit late to answer, but were you running the python interpreter with sudo? – Daniel Santos Jan 16 '18 at 06:13
  • Again a bit late, but I have the same problem @DanielSantos. Tried with sudo, still no luck. Notable that I used `sudo idle`, so not exactly the python command. Running python 3.6.7 – Nuclear_Man_D May 21 '19 at 18:13

2 Answers2

1

Try using: print(bluetooth.discover_devices(duration=8, lookup_names=True, flush_cache=True, lookup_class=False)) as this example sugests

vik0t0r
  • 11
  • 1
0

It looks like PyBlueZ doesn't support BLE, but you could try using alternative libraries like bluepy or pygatt.

I'm currently using bluepy. It's kinda hard to start with the documentation, but in the end, it works just fine.

dieserniko
  • 121
  • 7