Skip to content
Advertisement

Does bluez support low energy pairing with ios devices?

I have been beating my head on the wall with this project. I have an app built to an iPhone 5 that needs to communicate with my mac via bluetooth low-energy, and I want to do it through linux using the bluez protocol. I have my mac dual booted with ubuntu 12.04 and my iPhone app is connectible (acting as a peripheral), which I verified with lightblue. So, my question is, basically, is this possible? Will bluez support this type of connection, or will it only work if I use a dongle?

I have tried many different permutations of bluez. My linux kernel is 3.11.0. I think I am currently running bluez 4.98. I can get the hcitool to sense my app, then I use gatttool -b -I -t random which gives me the [ ][MAC…….][LE]> then I type connect, I get [CON][MAC…….][LE]> for about 15 seconds and then the CON goes away. That was the best I could do. Actually, at this point I’m not even getting that anymore. I’m getting any one of 3 errors. Either connection refused (111), could not create connection, or device busy (16).

Anyway, any help is appreciated!

Thanks.

Advertisement

Answer

To quickly answer your question, yes BlueZ DOES support pairing with iOS devices. That being said, the way Bluetooth Low Energy works is that you only need pairing if you want to perform an action on a characteristic (i.e. reading, writing, or enabling indications/notifications), and that characteristic requires pairing for that action to be performed. In other words, I think that the errors you are seeing are unrelated to pairing (since they occur before you do anything to the characteristics). I recommend that you try resetting the hci device with the command:

hciconfig hciX reset

Where hciX is the local hci device you are using.

If that doesn’t work, try using #hcidump or #btmon to read the raw hci data and possibly get a clearer picture of what exactly might be happening.

If you want to make sure that you have a local hci device (and therefore meaning you wouldn’t need a dongle), run the following command

hcitool dev

This should display the local hci devices. If the response is empty, that means that your Linux system is not using Apple’s Bluetooth hardware, and that you probably need a dongle.

Also, watch out for other common errors, i.e. are you sure that your peripheral device is connectable, does it have proper implementation of services and characteristics, does the peripheral device have a random address (hence the -t random option?), are you sure you can see it from your linux machine (e.g. with the #hcitool lescan command), and if you are using the gatttool command correctly. There are a couple of good bluez questions on this site that might be beneficial to look at:

Finally, when it comes to pairing, you have to increase the security level by passing “–sec-level=medium” or “–sec-level=high”, e.g.

gatttool --sec-level=high -t random -b <MAC Address> --primary

or

gatttool -l high -t random -b <MAC Address> --primary

This should initiate the pairing process, and then result in a pop-window to appear asking you to accept the pairing request

I hope that this helps,

Advertisement