3

It has turned out to me that hcitool is not capable of running lescan on Bluetooth v5.X hardware. Running sudo hcitool lescan would result in this error: Set scan parameters failed: Input/output error.

The community suggests to use bluetoothctl instead (e.g. here) but gatttool is dependent on hcitool for scanning ble devices. While gatttool serves as a ble backend on many apps, still no solution is provided to resolve the Input/output error mentioned above. Does anybody know how to resolve the above error?

I have tested the full functionality of my BLE on Windows 10 but in Ubuntu I have failed so far. My laptop has the following bluetooth hardware:

$ hciconfig -a
hci0:   Type: Primary  Bus: USB
    BD Address: 4C:1D:96:30:83:6E  ACL MTU: 1021:4  SCO MTU: 96:6
    UP RUNNING 
    RX bytes:8099 acl:34 sco:0 events:591 errors:0
    TX bytes:11990 acl:34 sco:0 commands:452 errors:0
    Features: 0xbf 0xfe 0x0f 0xfe 0xdb 0xff 0x7b 0x87
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
    Link policy: RSWITCH SNIFF 
    Link mode: SLAVE ACCEPT 
    Name: 'xxxx'
    Class: 0x0c010c
    Service Classes: Rendering, Capturing
    Device Class: Computer, Laptop
    HCI Version: 5.1 (0xa)  Revision: 0x100
    LMP Version: 5.1 (0xa)  Subversion: 0x100
    Manufacturer: Intel Corp. (2)

I have Ubuntu 20.04 with bluez v5.53.

mhr
  • 144
  • 3
  • 12
  • 1
    You should use the dbus api. Hcitool is deprecated. – Emil Dec 16 '20 at 06:54
  • 1
    gatttool and hcitool were both [deprecated](https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=b1eb2c4cd057624312e0412f6c4be000f7fc3617) back in 2017. [D-Bus API](http://www.bluez.org/bluez-5-api-introduction-and-porting-guide/) is documented at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc and there are examples at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test. – ukBaz Dec 16 '20 at 07:34
  • @ukBaz Could you provide your comment as an answer so that I can accept it? – mhr Jan 01 '21 at 11:03

1 Answers1

2

gatttool and hcitool were both deprecated back in 2017.

D-Bus API is documented at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc

And there are examples at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test.

For exploration on the command line then either btmgmt or bluetoothctl should cover most situations.

ukBaz
  • 6,985
  • 2
  • 8
  • 31
  • can you explain more? What should we be using now for simple testing/debugging instead of `hcitool`? – dalanmiller Feb 14 '21 at 08:37
  • 1
    Updated the answer with the command line tool names. I think what you are interested in is using the additions [PHY's](https://punchthrough.com/crash-course-in-2m-bluetooth-low-energy-phy/) that are available with BLE 5.0. This seems best done with `btmgmt` on the command line – ukBaz Feb 14 '21 at 08:57