7

I have a Raspberry Pi 3 and I am trying to make it discoverable for iOS devices. I ran sudo hciconfig hci0 piscan to make it discoverable. I can see it with my iMac.

On iOS, I am using CoreBluetooth and running a scan for nearby devices. I can discover several FitBit devices and my iMac, but the Raspberry Pi is not showing up.

Is there another setting that I have to enable for Bluetooth LE discoverability? Is the Raspberry Pi 3 compatible with iOS for bluetooth connectivity?

Thanks in advance. I appreciate any help with this.

Jeremiah Jessel
  • 430
  • 3
  • 13

3 Answers3

16

After much research and some help from a Twitter friend, to enable the LE broadcast you have to use one of the following commands.

sudo hciconfig hci0 leadv 0
sudo hciconfig hci0 leadv 3

The 0 indicates connectable.

The 3 indicates non connectable.

Jeremiah Jessel
  • 430
  • 3
  • 13
3

For those having issue connection to Iphone, the only way I found to make the RPi visible in the Bluetooth Scanning screen is to set the raspberry PI role/profile as audio sink as per below in addition to the posted in @Jeremiah Jessel answer:

sudo /bin/hciconfighci0 inqdata "0c097261737062657272797069020a00091002006b1d460217050d03001801180e110c1115110b1100"

all in one line, the long string is the enquiry data, in this string we are setting the bluetooth name and the profiles supported by our raspberry PI

Jonathan Ruiz
  • 180
  • 1
  • 7
3

For anyone that was helped by HubuN and was wondering the same thing as Manuel Otto, you can change the name by editing the hex data after 0c09 and before 020a. I don't have the reputation to add a comment, which is why I'm adding a separate answer.

Using HubuN's example:

sudo /bin/hciconfig hci0 inqdata "0c097261737062657272797069020a00091002006b1d460217050d03001801180e110c1115110b1100"

"raspberrypi" is 7261737062657272797069

So let's say you wanted to change it to "MyName"

You would get the hex for "MyName" and fill the remaining empty data with 0's

4d794e616d65 = "MyName"

7261737062657272797069 = "raspberrypi"

4d794e616d650000000000 = "MyName     "

Which gives you:

sudo /bin/hciconfig hci0 inqdata "0c094d794e616d650000000000020a00091002006b1d460217050d03001801180e110c1115110b1100"

I'm not super familiar with the rest of the hex code, so if someone else wants to explain it, or even provide an easier solution, feel free.

(Note: you can use a tool like this one to convert from text to HEX)

Dana Woodman
  • 4,148
  • 1
  • 38
  • 35
Nick M
  • 61
  • 1
  • 2