Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone Bluetooth Communication Examples

I've been trying to find examples on communicating with bluetooth devices on iOS and have been coming up short. As I understand it SPP is not yet supported. At the simplest level, I'd like to send a simple 1 or 0 signal to the bluetooth device I'm creating. (It's a bluetooth switch that would turn something on and off). Is there a way to cleverly do this through the HID or HFP profiles?

like image 414
Jeremy Gillick Avatar asked Feb 21 '12 22:02

Jeremy Gillick


People also ask

How is Bluetooth used in communication?

Bluetooth technology allows devices to communicate with each other without cables or wires. Bluetooth relies on short-range radio frequency, and any device that incorporates the technology can communicate as long as it is within the required distance.

What is the use of iPhone Bluetooth?

Using a Bluetooth connection, you can use third-party devices such as wireless keyboards, headphones, speakers, car kits, game controllers, and more with iPhone. Note: iPhone must be within about 33 feet (10 meters) of the Bluetooth device.

What Bluetooth protocol does Apple use?

One of the new specifications to appear on the new iPhone 8 and iPhone X is Bluetooth 5, an enhancement of the Bluetooth 4.2 Low Energy protocol.


1 Answers

The short answer to your question is that you can't connect to an arbitrary Bluetooth device you may happen to have, you can only connect to a Bluetooth device that has come through Apple's licensing program (i.e. the "Made for iPod/iPhone" label). From Apple's documentation:

Q: [The External Accessory framework allows] my application to communicate with Bluetooth devices. So why doesn't my application see the Bluetooth accessory sitting next to my iPhone?
A: The External Accessory framework is designed to allow iOS applications to communicate only with hardware accessories that are developed under Apple's MFi licensee program.

So there is no public API for accessing an arbitrary Bluetooth device from within iOS: you have to go through the External Accessory Framework to communicate via Bluetooth, and the EAF's mission is "communicate with MFi devices," not "communicate with arbitrary external devices." A sufficiently ingenious developer could probably hack something in there, but -

  • it's a non-trivial undertaking
  • you are spectacularly unlikely to get past the App Store approval process

So there's just not much percentage in it - the effort of doing so is unlikely to reward you.

If there already exists an MFi device that can be coerced into doing something that you want, that's probably your best chance - short of going through the MFi approval/licensing process yourself, of course. If you want to do so, have at it and good luck.

I'm answering this question late because Zeroxide's answer is incorrect (you can use a random Bluetooth keyboard with your iOS device because Apple implemented that connection, which is different from giving you a public API path to doing likewise) and I find Rokridi's answer to be incomplete-though-headed-in-the-right-direction.

Edit: A caveat has since been added to the linked Apple page about Bluetooth Low-Energy devices. So there's a loophole, but it's not a big one because very, very few Bluetooth LE devices have actually been produced as yet.

like image 126
Brighid McDonnell Avatar answered Sep 24 '22 08:09

Brighid McDonnell