How can I connect an iOS device to non iOS device (Arduino devices) via Bluetooth? - iphone

After searching on Google, I found that people say it's only possible to connect an iOS device with a non iOS device with the 'MFi program'. Is that true?
My project is mainly focused on sending and receiving information with the Arduino device via Bluetooth directly.
Is communication between iOS and non iOS devices without jailbreak possible? If yes, is there a reference?
(I viewed Stack Overflow question How can an iPhone access another non-iPhone device over wireless or Bluetooth?.)

As I stated in the above-linked question, general Bluetooth communication to external devices on non-jailbroken iOS devices is restricted to MFi-compliant Bluetooth hardware.
However, newer iOS devices (iPhone 4S, new iPad) are capable of Bluetooth 4.0 LE communication with external devices without the need for those devices to be MFi-compliant. This interaction is done through the new Core Bluetooth framework, which lets you send and receive arbitrary data to and from Bluetooth LE devices. This only works with those listed newer iOS devices, though.
Tim points out an interesting hack that you might be able to get away with in making your device appear like a Bluetooth HID keyboard. Devices like this barcode scanner have special modes to appear as HID devices to iOS. You might be able to pull something together based on this, but all data transfer will be one-way from your device, and it looks like this will require entering that data into text fields as if you had a keyboard connected.

Alasdair Alan's "iOS Sensor Apps with Arduino" is a good resource to look at. I've used Wifi with another microprocessor (mbed) but not sure about bluetooth. Alasdair is active on Twitter and he usually is kind enough to answer questions.

Related

Is there a way to read data from a Non-Apple Bluetooth Device with the iPhone?

I really searched on this topic for a while now. Especially when iOS 3 was the latest software version on the iPhone.
I wonder if there is a possibility to connect the iPhone to an external device via Bluetooth using the SDK and retrieve measured data?
Thanks for your help!
Greeting!
mary
If the Bluetooth device can masquerade as a Bluetooth keyboard, then it can send data to an iOS device encoded as keystrokes.
If the Bluetooth device is or can masquerade as a headset, then it might be able to send data encoded by an audio modulation scheme, such as FSK. A matching modem/codec will need to be running in the iOS app.
For the newest iOS devices (4S) you can use the new Bluetooth LE protocol to send data (older Bluetooth data communication protocols are not available to apps unless you are in Apple's NDA MFi program).
You have to look into the MFi Program by apple since you want your devices communicating. It provides support on using an external accessory with your iPhone, though you have to register/pay for it.

Bluetooth on iOS

What are the limitations of the Bluetooth on iOS? Can I program a Bluetooth in a way it makes the discovery procedure to find neighbor devices, selects a device from list, pair with it and starts over sockets exchanging some data (e.g. for peer2peer game? Is that possible?
All hardware that can communicate with iOS devices using Bluetooh must comply with the MFI (made for iPhone) program. It requires the vendor to use certain kinds of hardware and require a device certification. The program is under a strict NDA.
It basically means that you can only make a connection between iOS devices or devices with the MFI label and not just connect to a another cellphone -unless your iOS device is Jailbroken of course.
yes it is possible. BTW only iOS devices are supported.
Take a look at GameKit framework in the documentation.

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?
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.
As far as i know, if your external device is non iOs device then you should use External Accessory Framework to communicate your application with it. Threfore, you external device should be certified by Apple through the Made for Ipod program (MFI). Hope this helps.
If you want to use classic Bluetooth (not BLE), then you have to first PAIR the iOS device to the Bluetooth device (in Settings). If you can't do that then you can't communicate with it with your app.
NO. whether device is MFi certified or not, you can connect device to iphone if bluetooth profile is HFP, or HID's (ordinary profiles. not iAP profile). Think about bluetooth headset or keyboard. does it need MFi mark on it to use? NO. Never.

iPhone - Possible to detect bluetooth id from non-mfi bluetooth device?

I want to place bluetooth devices in different locations and record when the phone gets into each's range. I realize iphone can only connect to mfi devices but can it find out a device id for non-mfi??
If there is a way, would this pass apples app review? I need this app to be able to get into the app store.
Yup, if you have Bluetooth enabled on the iPhone other devices can connect to it. In particular they could do SDP queries (or Remote Name Requests or even a RFCOMM connect).
Or if the phone is in Bluetooth discoverable mode the other devices could do device discovery (inquiry) to find it. (Does the phone stay in discoverable mode when locked?)
It's not entirely clear from your question whether you want an iPhone app to detect the devices, or the devices to detect the phone.
If you have the former in mind, your requirement is exactly what BtLE's (Bluetooth 4.0/Smart/LE) advertising capability is for. Apple's iBeacon technology is such an implementation, or you might roll your own. It'll allow you to do fine grained location in an iOS6+ app running on 4S, 5, and recent iPads. BtLE advertisement detecting apps will easily pass App store guidelines.
From the other direction, devices with BT 2.x - 4.x radios, or with wifi radios, or with various scanners and software radios, will be able to detect mobile phones, tablets, and other radio equipped devices. How much can be discovered is wildly variable.

How can an iPhone access another non-iPhone device over wireless or Bluetooth?

I'm trying to figure out if an iPhone can connect to another non-iPhone device over wireless or Bluetooth and have seen conflicting information. Much of what I've found was before version 3.0 of the SDK came out, when it certainly wasn't possible. Looking at Stack Overflow questions, like Can the iPhone 3.0 SDK provide full access to Bluetooth devices (headsets)? mention you can't connect to an arbitrary device unless if it's part of the "Works for iPhone" device. Do I need hardware that is part of this program?
Looking through the Apple documentation, Peer-to-Peer Connectivity, it mentions connecting two iPhones, not an iPhone to another Bluetooth device. Then there are articles like iPhone SDK focus: Bluetooth enhancements that includes this quote
...and with the newly-announced "standard support" should allow file transfer between the iPhone and a computer, as well as between nearby iPhones
Another Stack Overflow question, GameKit in iPhone SDK 3.0, mentions Bonjour, and the Apple documentation for Bonjour talks about connecting to Bonjour devices, but can an iPhone connect to any Bonjour device? Does it have to have a Wi-Fi connection, or can it use Bluetooth?
Even if I could use Bluetooth to connect to another device, it won't be available on first generation iPhones and iTouches, I believe. Is that correct? I'm thinking of an iPhone application that would need to communicate with other non-iPhone devices in the area, probably using Bluetooth, but possibly a direct wireless connection. What are the possibilities and limitations of this approach? Is it not possible to have an iPhone connect to an arbitrary Bluetooth device? Does the other device have to be on a wireless Bonjour network that? I'm trying to figure out if it's even possible for this to work or if it's not worth the effort.
The only way to communicate with other Bluetooth devices via the External Accessory framework in iPhone OS 3.0 is if they are in the Made for iPod accessory program. Even though they communicate through standard Bluetooth connections, accessories need special hardware in order to process the data stream coming from the iPhone / iPod touch. Unfortunately, this means that your idea of communicating with generic Bluetooth devices won't work on iPhone OS 3.0.
If the devices you want to talk to are Bonjour-discoverable via Wi-Fi, they don't need to be part of the Made for iPod program. However, that doesn't sound like your case.
Third-party developers in the near future may produce dongles that connect through the 30-pin dock port and give access to existing Bluetooth devices. If these developers opened up their communication protocol, that might enable your goal of communicating with these devices.
You can use NSStream for opening IPv4/IPv6 sockets on the iPhone. The devices to which you're connecting do not have to be iPhones or use Wi-Fi necessarily. Because of how network communication protocols are laid out, you simply don't have to care what kind of device your iPhone is communicating with.
Bonjour, on the other hand, uses NSStream internally. It's basically a nifty little wrapper which allows for auto-discovery. You need the Bonjour protocol installed on all devices which you want to participate in the auto-discovery process. There is even an implementation for Windows.
As part of the iPhone OS 3.0 SDK, Apple announced the ability to control hardware accessories through either Bluetooth or the dock connector. The dock connector supports standard protocols (that is, play, pause, etc.) as well as any custom protocols the developer wants to implement.
As far as connecting via Bluetooth, you can talk to other iPhones or other devices. For example, you can use stereo Bluetooth to connect compatible Bluetooth stereo headphones, car kits, or other accessories.
As far as what devices support Bluetooth communication, everything except the first generation iPod Touch should be okay.
See also Apple's page on iPhone OS accessories.