I want to set up the Bluetooth on boot so I can connect to it whenever I want with a device which is not trusted by the Raspberry Pi Bluetooth. I set up the Bluetooth on boot on my Raspberry Pi this way. In /etc/rc.local, I added :

sudo bluetoothctl <<EOF
power on
discoverable on
pairable on

sudo hciconfig hci0 sspmode 0
sudo bt-agent -c NoInputNoOutput -p /root/bluetooth.cfg &

I use a Bluetooth configuration file to secure the Bluetooth connection, more information here

The problem is, after some time (~3 minutes), the discoverable mode is automatically turned OFF and I cannot connect to

Another problem is, after a device connect/disconnect, the discoverable mode is also turned OFF.

Is this possible to keep the discoverable mode ON every time and even if some Bluetooth devices connect/disconnect to the Raspberry ?

Edit: I'm using the Raspberry Pi Model B V1.2

  • 1
    Yes, I have spent over 10 hours doing what you are doing and finding what you are finding. I read that Rpi3 BLE (BlueLink or similar) is not well supported. Now I have just installed buster, waiting for Rpi4 (ordered a couple of days ago from a shop in stock) & will try again. BTW, I am using Rpi stretch 9 GUI desktop and installed all BLE stuff I searched. But then I read that BLE config files scattered here and there and some of them crash with each other. ( raspberrypi.stackexchange.com/questions/99017/… ) – tlfong01 Jun 27 '19 at 3:04
  • You think it's because of the RPI Bluetooth chip ? It seems to work fine but, I think that, after 3 minutes, the discoverable mode is automatically shutdown to save power. I will soon try with the Raspberry Pi Compute Module 3 and the ATWILC3000 chip. I'll keep you informed if this resolve the problem. – Antoine Boré Jun 27 '19 at 3:08
  • No, I am not saying the hardware, ie, BLE chip is problematic. It is the BLE software drivers that are buggy, or not up to date. Rpi 4 has BT5, so I hope they have a less buggy version. A couple of years ago, I also played with Blue Tooth serial modules, and I also found the BT connections not reliable, with frequent disconnections and need to annoyingly hardware reset. I did try over 10 modules (HC/HM 04/05/10 etc) then. This time I also order "improved" version of BLE 4.0 but not yest tried. Hope you have luck with CM3 and the other BT chip (built into CM3, not an USB module?) . – tlfong01 Jun 27 '19 at 3:19
  • I hope so... I only have to send/receive a small amount of data. Indeed, I want to use the Bluetooth connection so the user can enable the hostapd.service without access to the Raspberry Pi. The solution may be to write a small script ? The CM3 has no built-in Wi-Fi/BT, so the ATWILC3000 is an external serial module. – Antoine Boré Jun 27 '19 at 3:27

I continued my research and found an answer that works for me. There is a DiscoverableTimeout on /etc/bluetooth/main.conf which is, by default, set to 300s.

I just add DiscoverableTimeout = 0 on this configuration files.

  • How nice. So you have solved the Blue Tooth problem that have been disturbing so many newbies for a long time. – tlfong01 Jun 27 '19 at 6:14

You need to trust the device you are trying to connect to through Bluetooth of the Raspberry Pi (look up help menu for list of available commands). I could only get partial pairing enabled on my iPhone, until I trusted the iPhone MAC address.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.