0
hci_le_create_conn(device,htobs(0x0010),htobs(0x0010),0,0,
                     peeraddr,0,15,15,0,3200,1,1,0,1000);

I get errno = 5 form above, and it means that the command has not been received and is not being processed in the host controller.

Could someone tell me where is wrong?

I want to connect my bluetooth smart device with my linux computer, but it not works. Here is the fucntion hci_le_create_conn's params below.

int hci_le_create_conn(int dd, uint16_t interval, uint16_t window,
        uint8_t initiator_filter, uint8_t peer_bdaddr_type,
        bdaddr_t peer_bdaddr, uint8_t own_bdaddr_type,
        uint16_t min_interval, uint16_t max_interval,
        uint16_t latency, uint16_t supervision_timeout,
        uint16_t min_ce_length, uint16_t max_ce_length,
        uint16_t *handle, int to)
Samuel
  • 803
  • 8
  • 17
  • 1
    Do you really have to use hci_lib rather than the DBUS interface? hci_lib is not officially supported and going down that route is just a pathway to pain IMHO (I've previously evaluated it). – kaylum Dec 17 '15 at 19:52
  • @kaylum - does the DBUS interface allow accessing GATT attributes that are non-standard and/or not part of a profile? When I started with Bluez I was told I couldn't do that with DBUS so I ended up using kernel calls (which is what the shared library ultimately does). – Tim Tisdall Dec 18 '15 at 13:46
  • @TimTisdall Yes it does. As of two or three months ago. The new [gatt API](http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt) is now available. But it is still technically experimental and is made available by passing -E to bluetoothd. I've used it and it works well. – kaylum Dec 18 '15 at 20:27
  • Check out my included answer [here](http://stackoverflow.com/questions/29767053/bluez-programming/32958792#32958792) and [here](http://stackoverflow.com/questions/34281145/bluez-5-36-startdiscovery-method/34330349#34330349) for more information on the DBus interface! – Zimano Dec 22 '15 at 08:29

2 Answers2

1

Use the bluetooth daemon to reset your hardware:

sudo bluetoothctl

power off

power on

I believe BlueZ is in the process of phasing out tools like hciconfig and hcitool. More information can be found here.

Zimano
  • 1,870
  • 2
  • 23
  • 41
-1

I should run sudo hciconfig hci0 down and sudo hciconfig hci0 up before run the function.

Anyway, I successfully connected to my BLE device!

Samuel
  • 803
  • 8
  • 17
  • I'm pretty sure that's what `hciconfig hci0 reset` does. – Tim Tisdall Dec 18 '15 at 13:49
  • go through source code of hciconfig hci0 reset and implement similar feature in your program ,so every time you dont need to issue it from command line – Jagdish Dec 21 '15 at 11:21
  • `hciconfig` is being phased out of BlueZ, just as `hcitool` and the like is. It makes use of raw socket calls. Please do not recommend these as an answer. – Zimano Dec 22 '15 at 08:27