wanstreet
Posts: 40
Joined: Fri Jun 01, 2018 5:28 am

hci0 fails to initialise while scanning for bluetooth-LE in 3b+

Fri Jun 14, 2019 7:32 am

Hello ,
I am currently working on scanning of bluetooth - LE devices and printing them
I am using bluepy library from github and it works fine.
The thing is sometimes I am getting these errors regarding the
initialisation of hci0
before trying to scan again.

to make sure the device keeps running , i have added some exception to counter the inistialisation problem

Code: Select all

resp = subprocess.call(['sudo','hciconfig','hci0','down'])
time.sleep(0.5)
resp = subprocess.call(['sudo','hciconfig','hci0','up'])
My question is , can I use the onboard BT for maybe future production use? Or do I need to use a separate module
Thank you

fanoush
Posts: 464
Joined: Mon Feb 27, 2012 2:37 pm

Re: hci0 fails to initialise while scanning for bluetooth-LE in 3b+

Fri Jun 14, 2019 8:23 am

I am not sure if I understood correctly what I've read previously but I think some of those libraries takeover the hci interface so the safest is to stop system bluetooth service via something like '/etc/init/d/bluetooth stop' before using it.

On the other hand if your library is written on top of bluez stack the service should be running.

So try to stop bluetooth service and initialize hci0 yourself and see if the issue goes away.

EDIT:
see e.g. instructions here https://github.com/noble/bleno for bleno node.js library, but maybe the one you are using is different and cooperates with system bluetooth service.

wanstreet
Posts: 40
Joined: Fri Jun 01, 2018 5:28 am

Re: hci0 fails to initialise while scanning for bluetooth-LE in 3b+

Sat Jun 15, 2019 10:33 am

fanoush wrote:
Fri Jun 14, 2019 8:23 am
I am not sure if I understood correctly what I've read previously but I think some of those libraries takeover the hci interface so the safest is to stop system bluetooth service via something like '/etc/init/d/bluetooth stop' before using it.

On the other hand if your library is written on top of bluez stack the service should be running.

So try to stop bluetooth service and initialize hci0 yourself and see if the issue goes away.

EDIT:
see e.g. instructions here https://github.com/noble/bleno for bleno node.js library, but maybe the one you are using is different and cooperates with system bluetooth service.
ok, ya i think my library follows the bluez stack,
the thing is when I get the initialisation error, I end up running those switching off the hci0 and switching on the hci0 , sometimes for unknown reasons I am getting the initialisation error. But i will look into the bleno and see if it solves my issue.
thanks

Return to “Python”