hci_inquiry always returns 0 on pi

122 Views Asked by At

Everytime I call hci_inquiry I get a return code of 0. The bluetooth interface is up. If I run hci_devinfo on the device I get the following information.

root@piBox:/home/pi# ./mytest 
Device Addr: B8:27:EB:A3:F0:73
Device Id: 0
Device Name: hci0
Flags: 5
Type: 3
Link Policy: 5
Link Mode: 8000
Number of Resp: 0

if I run bluetoothctl scan on I get the following:

[bluetooth]# scan on
Discovery started
[CHG] Controller B8:27:EB:A3:F0:73 Discovering: yes
[NEW] Device 3A:53:34:A7:31:21 3A-53-34-A7-31-21
[NEW] Device C8:FF:77:C2:9A:1E VV6-US-KHA0033A
[NEW] Device 88:6B:0F:BC:D8:53 Bowflex T216
[NEW] Device 63:F6:DC:71:16:58 63-F6-DC-71-16-58
[NEW] Device C6:0D:C8:A1:75:D6 Versa 2
[NEW] Device CB:1A:58:38:37:2B USB ANT STICK
[NEW] Device 6B:8D:76:BB:48:B0 6B-8D-76-BB-48-B0
[NEW] Device 5A:0B:D6:D3:54:72 5A-0B-D6-D3-54-72
[NEW] Device 46:12:46:A0:A0:7D 46-12-46-A0-A0-7D
[NEW] Device 64:16:66:71:3D:32 N04CU
[NEW] Device E2:FC:77:B9:E8:D7 Stryd
[NEW] Device DF:C5:F9:B7:C9:34 N046H

Why does the hci_inquiry return 0 when there are devices out there?

I have added debug to print out all errors and also dump the device info. I get no errors and I get the correct device name and address.

1

There are 1 best solutions below

0
Gustavo da Silva Serra On

In my situation what happened is that I scanned for devices while my BT adapter wasn't plugged in. After plugging the adapter I still received 0 devices. The solution was to restart the bluetooth.service. I saw some comments around about setting AutoEnable to false in /etc/bluetooth/main.conf, so maybe this will help.