54

I'm trying to do a lescan using hcitool on the raspberry pi.

The command prints out

Set scan parameters failed: Input/output error. 

I'm not sure, what exactly happens here. My iPhone is advertising here.

I'm using a BLE dongle from IOGear.

However, if I restart my machine, it shows the a MAC address after I issue the lescan command, and starts showing the same error after I issue the lescan command a couple of more times. Is it like, the lescan command cannot be issued more than once?

Youssif Saeed
  • 11,789
  • 4
  • 44
  • 72
arpwal
  • 895
  • 1
  • 9
  • 17
  • try unplugging it and re-plugging it in. There's all sorts of ways the dongles can get into states where they don't respond the way you want. The IOGear one seems to be the best, though. – Tim Tisdall Feb 27 '14 at 20:02
  • @aauser - did you ever solve this? I'm stuck on the same problem. – Duncan Bayne Mar 10 '14 at 02:14
  • @aauser - I should mention that I'm using a D-Link DBT-120 on 64-bit Linux Mint 16 (Petra). – Duncan Bayne Mar 10 '14 at 04:32
  • Hey @DuncanBayne, not really. I did replug the usb module, however the error kept repeating. – arpwal Mar 13 '14 at 07:59
  • 1
    It appears the BlueZ BLE scanning is still pretty buggy. However, this thread might help: https://redbearlab.zendesk.com/entries/23561363-BLE-Shield-with-USB-Dongle-and-Python- – David H. Bennett Mar 17 '14 at 00:20
  • 1
    Also, what is your kernel and BlueZ versions? The end of this thread mentions kernel 3.5 or greater. http://www.linkedin.com/groups/Anyone-able-get-BTLE-completely-4232349.S.5806578412524969986 – David H. Bennett Mar 17 '14 at 00:23
  • @DavidH.Bennett: kernel 3.8, latest BlueZ built from source. I *think* the problem may be my device ... I'm going to buy a Plugable dongle and see if that fixes it. Of course first I have to set up a drop shipping account in the US as they don't ship to Australia. Shave that yak. – Duncan Bayne Mar 18 '14 at 05:46
  • `hcitool` has been deprecated for a long time. Do not use it. – Zimano Jun 15 '19 at 12:58

11 Answers11

63

That happens often really often to me. I'm developing with it and it just happens from time to time. I was also able to reproduce your error within 5 minutes ;-) I'm running bluez v.5.17. However i can run lescan more than one time without this error.

hcitool lescan
Set scan parameters failed: Input/output error

try:

hciconfig hci0 down
hciconfig hci0 up

and check the status afterwords.

if this doesn't work or it hangs in DOWN status, try:

service bluetooth restart
service dbus restart

(all commands as superuser)

And close all application that may access bluetooth. For example hcidump.

If that doesn't work you normally have to unplug it. But there is another dirty hack to do this. It works by setting the authorized to 0 and than 1 again. This forces the usb dongle to init.

lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. 
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. 
Bus 001 Device 004: ID 0a5c:21e8 Broadcom Corp. 


cd /sys/bus/usb/devices/

grep -i -s -r 0a5c *
…
1-1.2/idVendor:0a5c
…

cd 1-1.2

echo 0 > authorized
echo 1 > authorized
Rob Anderson
  • 2,377
  • 3
  • 22
  • 31
9

Upgrading to bluez v5.43 fixed this for me.

To upgrade to the newest bluez, you need to do a "manual" installation (not apt-get), downloading from the bluez website. I recommend this video walkthrough if you are new installing packages or need help.

After installing the latest bluez, I had to run a couple commands before it worked.

  1. systemctl daemon-reload : Restarts the system daemon.

  2. sudo service bluetooth restart : Restarts the Bluetooth service.

  3. sudo hciconfig hci0 up : This was needed for my Raspberry Pi 3, with the built-in BT found at hci0.

After these commands, sudo hcitool lescan and its variants all seem to work.

ZX9
  • 898
  • 2
  • 16
  • 34
6

I had the same error with hcitool, while bluetoothctl worked just fine. Then I ran across this article stating that all "tools using raw socket shall be considered deprecated" (hcitool, hcicfg, etc.).

So maybe just open bluetoothctl and issue a scan on command.

Jason Stewart
  • 374
  • 4
  • 7
6

For those using Bluetooth 5.x devices and getting the same error, sudo hcitool lescan will throw a Set scan parameters failed: Input/output error. for Bluetooth 5.x LE devices, as hcitool is deprecated.

If you want to do a Bluetooth LE (low-energy) scan using a newer Bluetooth 5.x device, try using bluetoothctl instead:

bluetoothctl scan le

As others have mentioned, it's also worth making sure that you have the latest bluez version. Newer versions of linux-firmware or the Linux Kernel may also help if your Bluetooth device is especially new.

Alois Klink
  • 646
  • 8
  • 9
4

sudo service bluetooth restart helps me on Raspibian Buster.

in case of Set scan parameters failed: Input/output error. error in sudo hcitool lescan.

But is is occuring randomly again, so some system library has probably some issue.

Martin
  • 696
  • 6
  • 7
  • After some fighting with this issue I disabled the internal Raspberry bluetooth and bought USB Bluetooth dongle with BLE support. (model: CONNECT IT BT403). The USB bluetooth works perfectly for a weeks without any issue. – Martin Mar 25 '20 at 12:36
2

To those finding this question now, it is fixed as of Bluez v5.41. All you need to to is download and install. You can download the lastest version from http://www.bluez.org/download/.

2

I have removed Bluez and then I just installed it again, and it worked for me:

sudo apt remove --purge bluez bluez-* -y


apt install bluez

And then

hcitool lescan 

That should be enough.

nachtjasmin
  • 386
  • 4
  • 13
ericfrol
  • 101
  • 1
  • 1
  • 6
0

It is possible, that HCI is currently in use. In my case I must stop Node-Red and it works. So take care, that the HCI isn't in use.

Restart the HCI is a way, to solve the problem temporarily, but it doesn't solve the problem right.

Sean Stayns
  • 4,082
  • 5
  • 25
  • 35
0

I am using Version 5.53 I have two Bluetooth devices (hic0 and hic1) I tried all kinds of ways to to reset the devices ... The only way that worked was to physically unplug and re-insert the hic1 dongle. This is the one that supports ble. Then it works until I reboot. I really wish there was a pure software solution way to do this.

r.t.s.
  • 585
  • 1
  • 4
  • 12
-1

What worked for me though is opening up the Bluetooth settings on my Ubuntu and manually removing the unused devices. Immediately lescan started working.

double-beep
  • 5,031
  • 17
  • 33
  • 41
Ace
  • 1,501
  • 4
  • 30
  • 49
-10
sudo hcitool lescan

Just use sudo & will scan

Gynteniuxas
  • 7,035
  • 18
  • 38
  • 54