0
votes

I cannot get Bluetooth working consistently on a Raspberry Pi. Installing bluez with "apt-get install bluez" renders gatttool useless. I always get the error "host is down". This has been addressed in another post: BLE gatttool cannot connect even though device is discoverable with hcitool lescan

Their solution was to install bluez v5.30 by compiling the source. This causes the Pi to not automatically power up the bluetooth device (a USB dongle). I have to enable the dongle with "sudo hcitool device up". It is extremely inconvenient to type in the command line with root permissions every time my Pi is turned on or has its dongle removed.

Does anyone have a solution where both gatttool works and bluetooth devices are automatically recognized and enabled?

1
Does RPi use udev? If so you can write a udev rule to bring up the hci interface whenever the kernel sees a new one. Something like: ACTION=="add", KERNEL=="hci*", RUN+="/bin/hciconfig %k up"kaylum
Could you explain this? I do not know what udev is or where this rule should be writtenpetEEy
udev is a Linux device management system. Of relevance here is that it can do user level device event notification. So you can run a script whenever a device is detected or removed. So place the above command into a udev rule file. Naming is similar to the rc files in that the name determines the order of processing. In your case it probably doesn't matter so place the above command into something like /etc/udev/rules.d/90-hci.rules. That rule will bring up any bluetooth adapter that is inserted.kaylum

1 Answers

-1
votes

I hope this will work sudo cp attrib/gatttool /usr/bin/