Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 371
user3712524 Avatar asked Jul 11 '14 21:07

user3712524


People also ask

Can iPhone connect to BLE?

BLE and Apple The iOS5 SDK introduced Core Bluetooth framework that allows interact with BLE devices either as a central or a peripheral. All iOS devices since the iPhone 4S support BLE.

Does iPad support Bluetooth low energy?

Bluetooth Low Energy is supported on the following iPads: iPad 4th Generation and newer. iPad Mini 2 and newer.

Is pairing required for BLE?

cpp already told you in his answer pairing (the exchange of keys) and bonding (saving of said keys) is not required for the communication with BLE devices and only needed if the device requires a secured connection.

How do I turn off Bluetooth low energy on my iPhone?

To turn Low Power Mode on or off, go to Settings > Battery. You can also turn Low Power Mode on and off from Control Center. Go to Settings > Control Center > Customize Controls, then select Low Power Mode to add it to Control Center.


1 Answers

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:

  • Using Bluetooth Low Energy from The Command Line
  • Bluetooth Low Energy Listening for Notifications/Indications
  • Raspberry Pi iBeacon Connection Timing Out
  • Attribute Requires Authentication Before Read/Write

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,

like image 180
Youssif Saeed Avatar answered Oct 04 '22 19:10

Youssif Saeed