Using bluez to access Bluetooth Low Energy devices

bluetoothbluez

I would like to connect to a Bluetooth Low Energy (BTLE, Bluetooth Smart) device using a linux box with bluez and a bluetooth dongle. I have Orico BTA-402 dongle with CSR chipset; Ubuntu 14.04. I figured out how to make it the dongle appear as a device to a phone (hciconfig hci0 leadv 3).

What I would like is the opposite, for the dongle/linux box to scan for devices, connect to a device, enumerate characteristics, and read/write them. How do I do that?

Best Answer

The hcitool lescan answer is incomplete. it will loop. You want a timeout, but a timeout that will not cause issue to hcitool (the default signal would)

For 5 seconds:

timeout -s SIGINT 5s hcitool -i hci0 lescan --passive

Then you can use gatttool:

sudo gatttool -i hci1 -b BC:6A:29:AC:2E:B4 -I

For more details on what to do after the connect: http://joost.damad.be/2013/08/experiments-with-bluetooth-low-energy.html

Related Question