IanHarvey / bluepy

Python interface to Bluetooth LE on Linux
Other
1.59k stars 491 forks source link

Failed to execute management command 'scan' #379

Open JackHilliard opened 4 years ago

JackHilliard commented 4 years ago

I am running bluepy through a script on a Raspberry Pi running Raspbian Jessie. I can scan every second for anywhere between a few seconds and nearly a minute until I get the error:

File "/usr/local/lib/python3.4/dist-packages/bluepy/btle.py" , line 852, in scan self.start(passive=passive) File "/usr/local/lib/python3.4/dist-packages/bluepy/btle.py" , line 800, in start self._mgmtCmd(self._cmd()) File "/usr/local/lib/python3.4/dist-packages/bluepy/btle.py" , line 312, in _mgmtCmd raise BTLEManagementError("Failed to execute management command '%s'" % (cmd), rsp) bluepy.btle.BTLEManagamentError: Failed to execute management command 'scan'

I've had this code working on other devices but I have no clue why it doesn't work on this pi.

Any help is much appreciated

JackHilliard commented 4 years ago

I reinstalled bluepy and changed the scan interval to 2 seconds and it seems to be working fine now

ArthurKun21 commented 4 years ago

Hi @JackHilliard how did you do that?

JackHilliard commented 4 years ago

To reinstall bluepy: sudo pip3 unintall bluepy sudo pip3 isntall bluepy

(Reinstalling only worked for python3 not python2.7 for this device)

I changed the scan interval by changing the timeout when calling scanner.scan

JackHilliard commented 4 years ago

Turns out that only worked temporarily, I now get the error again after 1 minute of using bluepy

shadetree01010100 commented 4 years ago

I assume that you're not calling scan() more frequently than the timeout, and/or from multiple threads, right? It might help if you can post the code in which you're looping and calling scan()

summer2009 commented 4 years ago

I have almost the same problem.The code like this: for i in range(1000): scan(,10)...