Open edouardkleinhans opened 6 years ago
Did you try with sudo?
all the command are executed as root.
I think I have the same problem just with the TI Sensortag (running as root - debugging on). Running on a Raspberry Pi with a BLE USB; hcitool is able to scan:
sudo python sensortagcollector.py Running /usr/local/lib/python2.7/dist-packages/bluepy/bluepy-helper Sent: le on
Got: '' Got: '' Got: '' Got: '' Got: '' Got: '' Sent: le on
Traceback (most recent call last):
File "sensortagcollector.py", line 317, in
Same issue for me. On a Orange PI Zero , i've try 2 different USB adapter ( CSR 4.0 and Orico ) Both working perfectly with hcitools.
Scanning for devices... Traceback (most recent call last): File "/usr/local/bin/blescan", line 9, in <module> load_entry_point('bluepy==1.1.2', 'console_scripts', 'blescan')() File "/usr/local/lib/python2.7/dist-packages/bluepy/blescan.py", line 122, in main devices = scanner.scan(arg.timeout) File "/usr/local/lib/python2.7/dist-packages/bluepy/bluepy/btle.py", line 679, in scan self.start(passive=passive) File "/usr/local/lib/python2.7/dist-packages/bluepy/bluepy/btle.py", line 617, in start self._mgmtCmd("le on") File "/usr/local/lib/python2.7/dist-packages/bluepy/bluepy/btle.py", line 276, in _mgmtCmd "Failed to execute mgmt cmd '%s'" % (cmd)) bluepy.bluepy.btle.BTLEException: Failed to execute mgmt cmd 'le on'
I try to rebuild helper with the same results.
same problem on my kali linux 2017 I try running : $sudo bleah t0 BTLE Exception: Failed to execute mgmt cmd 'le on'
any help thanks in advance
I have the same question. (2017kali\bleah ) Thanks for any help!!!!!!
What output does bluepy-helper give when you run it directly?
/usr/local/lib/python2.7/dist-packages/bluepy/bluepy-helper 0 help le on
I had the same error, but sudo
makes it work for me. Do we know which group or permissions it requires? I would like to make it run with my user.
sudo setcap 'cap_net_raw,cap_net_admin+eip' bluepy-helper
This gives everyone permission to execute bluepy-helper.
i'm getting:
MQTT connection returned result: Connection Accepted. Traceback (most recent call last): File "miscalegw.py", line 99, in <module> main() File "miscalegw.py", line 96, in main devices = scanner.scan(5) File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 679, in scan self.start(passive=passive) File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 617, in start self._mgmtCmd("le on") File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 276, in _mgmtCmd "Failed to execute mgmt cmd '%s'" % (cmd)) bluepy.btle.BTLEException: Failed to execute mgmt cmd 'le on'
i tried all the answer i could find, tried running as root, with sudo, i checked the interface and it's 0
def init(self, iface=0):
anyone can help?
have you tried running bluepy-helper directly and tried to execute "le on" manually?
im getting: "bluepy-helper: command not found" eventough i can see the file and it is executeable
I guess you are not so familiar with linux command line.
to run the executable, you must execute it the following way:
./bluepy-helper 0
If you forget the "./", the system will assume you try to start a program that is available in your PATH.
With the "./" you give the direct address of your executable.
The "0" defines the interface you want to use. If you only have one bluetooth interface, 0 will be correct,
if you have multiple, you can use 1, ...
If the program complains about permissions, try it again with super user rights:
sudo ./bluepy-helper 0
thanks for your explanation, i learned something new :) im running now /usr/local/lib/python3.5/dist-packages/bluepy $ ./bluepy-helper 0 help le on and im not getting any response, just the curser blinking, is that ok?
same with sudo
if you type 'help' you will see all possibilities.
As i can see in your error message, your problem already occurs when trying to execute the command
le on
(to put it in bluetooth low energy mode)
so i suggest you try that command.
for some reason "help" also doesnt give me any result...just blinking
i'm using it in python 2.7 but i'll set up a 3.5 to test
(venv) ~/python_sandbox/test_bluepy3/venv/lib/python3.5/site-packages/bluepy $sudo ./bluepy-helper 0 help
rsp=$stat state=$disc mtu=h0 sec='low
It seems to work on my computer. I also have a blinking cursor, but if i type help, i do get this help message. And have you tried other commands? Do you see "help" appearing on your blinking cursor as you type? don't forget to press enter.
Just to be sure, you have to start the program with
sudo ./bluepy-helper 0
and after it's started, you need to type 'help' or 'le on'
Same error, but when doing multiple calls in quick succession. Python 3.4 on a Pi Zero W with Dietpi Stretch.
2018-02-20 17:23:54.673 Error: (Mi Flower Mate) ----> Line 55 in /home/pi/domoticz/plugins/mi_flower_mate/miflora/backends/bluepy.py, function connect 2018-02-20 17:23:54.673 Error: (Mi Flower Mate) ----> Line 353 in /usr/local/lib/python3.4/dist-packages/bluepy/btle.py, function init 2018-02-20 17:23:54.674 Error: (Mi Flower Mate) ----> Line 402 in /usr/local/lib/python3.4/dist-packages/bluepy/btle.py, function _connect
(working on a plugin that uses this library: https://github.com/flatsiedatsie/Mi_Flower_mate_plugin)
I typed 'le on' on bluepy-helper, and I got 'rsp=$mgmt code=$protoerr'.
now im able to run and getting same message: rsp=$mgmt code=$protoerr
i also get the protoerr if i'm not running as superuser (sudo ./bluepy-helper 0).
sudo ./bluepy-helper 0
le on
sudo setcap 'cap_net_raw,cap_net_admin+eip' bluepy-helper
(make sure u are in the directory with the bluepy-helper executable)
I don't know exactly what this does, but it allows me to run bluepy-helper without root privileges (sudo)./bluepy-helper 0
If you have problems, please post the commands you used and the output. FIY i'm running it on ubuntu 16.04 and tested it with python 3.5
i ran it before with sudo.
sudo ./bluepy-helper 0 le on rsp=$mgmt code=$protoerr
im on mint (ubuntu 16.04), python 3.5.2
In that case i don't have an explanation, my solution was the capabilities.. Maybe have a try with gatttool to see if you can set up a connection, and hciconfig to check if your bluetooth interfaces are up and running
thanks again for all your help
Here the issue still persists if there are multiple calls in a row:
https://www.domoticz.com/forum/viewtopic.php?f=65&t=22281
on Domoticz plugins are run an root, so that's not an issue.
Hi, was anyone able to solve this problem? I have been stuck on it for a while and I still get the same error bluepy.btle.BTLEException: Failed to execute mgmt cmd 'le on'
Failed to execute mgmt cmd 'le on'.
I'm still testing, but this works [EDITED]:
sudo /usr/local/lib/python3.6/site-packages/bluepy/bluepy-helper 0
or wherever you have bluepy-helperrsp=$mgmt code=$success
Ran @PrzemoF 's post and got rsp=$mgmtcode=$mgmterrestat=h11emsg='Invalid Index
on 16.04, py 3.7
Help us Obiwon Kanobi! You're our only hope!
I'm still testing, but this works [EDITED]:
- Start from one terminal:
sudo /usr/local/lib/python3.6/site-packages/bluepy/bluepy-helper 0
or wherever you have bluepy-helper- Type "le on" and you should get this:
rsp=$mgmt code=$success
- Do whatever you need to do from another terminal.
I tried the same and I got: rsp=$mgmtcode=$mgmterrestat=hBemsg='Rejected
What should I do next?
Hi. The Error still exists. With sudo it works:
me@mypc:~$ sudo ./.local/lib/python3.6/site-packages/bluepy/bluepy-helper 0
\# bluepy-helper.c version 1.3.0 built at 20:40:35 on May 3 2019
le on
rsp=$mgmtcode=$success
But without sudo it wont:
me@mypc:~$ sudo setcap 'cap_net_raw,cap_net_admin+eip' ./.local/lib/python3.6/site-packages/bluepy/bluepy-helper
me@mypc:~$ ./.local/lib/python3.6/site-packages/bluepy/bluepy-helper 0
\# bluepy-helper.c version 1.3.0 built at 20:40:35 on May 3 2019
le on
rsp=$mgmtcode=$mgmterrestat=h14emsg='Permission Denied
Are there any plans to fix it. I want to use bt-mqtt-gateway to get a connection to an nrf52840 running circuitpython.
Note that when running python scripts with sudo, your normal user and the super-user ivoked by sudo, may have a different default python location.
When using sudo with running a python script you may need to specify the full system path to the version of python you inteend to run
I'm running on Rasbian PC.
sudo ./bluepy-helper 0
and getting
le on
rsp=$mgmtcode=$mgmterrestat=h11emsg='Invalid Index
please suggest what might be wrong?
Re: https://github.com/IanHarvey/bluepy/issues/218#issuecomment-350680433
sudo setcap 'cap_net_raw,cap_net_admin+eip' bluepy-helper
This gives everyone permission to execute bluepy-helper.
cap_net_admin,cap_net_raw+ep
without i
("inheritable") is sufficient:
$ sudo setcap cap_net_raw,cap_net_admin+ep bluepy-helper
$ getcap bluepy-helper
bluepy-helper = cap_net_admin,cap_net_raw+ep
$ bluepy-helper
# bluepy-helper.c version 1.3.0 built at 06:27:58 on Jul 16 2019
le on
rsp=$mgmtcode=$success
$ uname -r
5.10.17-v7l+
I'm running on Rasbian PC.
sudo ./bluepy-helper 0
and getting
le on rsp=$mgmtcode=$mgmterrestat=h11emsg='Invalid Index
please suggest what might be wrong?
Firstly, make sure that your BLE device is existing, using following command
$ hciconfig
If the device is existing, it will like this
hci0: Type: Primary Bus: USB BD Address: 00:1A:7D:DA:71:11 ACL MTU: 310:10 SCO MTU: 64:8 UP RUNNING RX bytes:883983 acl:0 sco:0 events:23598 errors:0 TX bytes:6053 acl:0 sco:0 commands:160 errors:0
Your error is because that the BLE device is not activated. You can use this command to activate it.
$ sudo hciconfig [hci0] up
Hello @EricRongkai,
$ hciconfig
gave me
Command 'hciconfig' not found, but can be installed with:
sudo snap install bluez # version 5.48-3, or
sudo apt install bluez # version 5.53-0ubuntu3.3
I installedsudo apt install bluez # version 5.53-0ubuntu3.3
and ran $ sudo hciconfig [hci0] up
, however, I get Can't get device info: No such device
. Same thing happened with sudo snap install bluez # version 5.48-3.
Now, when I run hciconfig
, nothing happens. I still get rsp=$mgmtcode=$mgmterrestat=h11emsg='Invalid Index
after le on
command.
Hello,
I'm trying to run you sample code (http://ianharvey.github.io/bluepy-doc/scanner.html#sample-code) on my orangepi with a bluetoot v4 dongle, but it doesn"t work.
root@orangepipcplus:~# lsusb Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 007 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
root@orangepipcplus:~# hcitool dev Devices: hci0 00:1A:7D:DA:71:13
root@orangepipcplus:~# python test.py Traceback (most recent call last): File "test.py", line 14, in
devices = scanner.scan(10.0)
File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 679, in scan
self.start(passive=passive)
File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 617, in start
self._mgmtCmd("le on")
File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 276, in _mgmtCmd
"Failed to execute mgmt cmd '%s'" % (cmd))
bluepy.btle.BTLEException: Failed to execute mgmt cmd 'le on'
Any idea of what's wrong ?