How can I create a Bluetooth serial connection between an iPhone and an Arduino+Bluetooth Mate? - iphone

I have a project where I need my iPhone to communicate with an Arduino. Bluetooth seems like the best option for the communication. How should I program my iPhone (what framework?) to communicate with the Bluetooth Mate or do Apple's restrictions prevent this? Is it possible with a jailbroken iPhone? Is there a better way other than Bluetooth? Sample code would be helpful.
Thanks in advance

Actually you can make it happen now without Jailbreaking or MFi enrollment.
Take a look ate Bluetooth 4.0 in newer iOS devices and Arduino BT 4.0 shield.
This might help: http://blog.makezine.com/2012/03/19/bluetooth-4-0-from-arduino-to-iphone-no-jailbreaking-no-mfi/

Meanwhile there is an Arduino shield available from Seeedstudio: Bluetooth Low Energy Shield
Devices following the Bluetooth 4.0 specification can be accessed by all iPhone/iPad models with a Bluetooth 4.0 chip inside (currently iPhone 4S, 5 and iPad 3) running with iOS 6. You no longer need to be part of the MFI program or jailbreak the device for most purposes. Use the Core Bluetooth Framework that's also discussed in the WWDC 2012 videos Core Bluetooth 101 (Core OS) and Advanced Core Bluetooth (Core OS).

It's been a while since I was in contact with embedded bluetooth-to-iphone devices, but as far as I remember you have to buy authentication chips from apple.
Apple MFi
But as jailbreak is an option this might work. But I never tried this, because I once was in possession of some authentication chips.
I found btstack with a quick googling, maybe it's helpful.

Try instaling bluetoth iBlueNova, and it will comunicate with each device.

Yes, the best way to do this would be to use Blynk. Make an account, copy the example code, and get started with the Blynk app!

Apple's OS app sandbox prevents generic (Classic non-BLE) Bluetooth serial data comm on stock OS devices, except for a few companies registered in their MFi program.

The most reliable and possibly the easiest solution is to the use the Arduino Ethernet shield with a physical network connection to your WiFi router. The Arduino would host web pages or respond directly to http that did your work for you.
No jailbreaking, no BT programming, no serial com port stuff. Just regular old web pages. Sweet stuff.
The simplest solution would be to navigate with any browser on your network, including your iPhone, to your Arduino and issues commands.
Example:
http://192.168.1.101/?1
192.168.1.101 = the IP of your Arduino
?1 would mean PIN13 pulled high (i.e. turn on the LED)
Your code would be something like:
EthernetClient client = server.available();
while (client.connected())
{
if (client.available())
{
char cVar = client.read();
if (cVar != '?') return;
Serial.Print(cVar)
if (cVar == '1') digitalWrite(13, HIGH); //turn on the led
}
}
That code is quick and dirty so don't hold it against me!
Let me know what you decide and how it works out. I need to go read up on http://blog.makezine.com/2012/03/19/bluetooth-4-0-from-arduino-to-iphone-no-jailbreaking-no-mfi/
Thanks for that link ygbr!

Related

Connecting hc-05 with iPhone SE iOS(v11.0)

I have done some research on core bluetooth framework. Successfully setup discovery of peripheral of other iPhone, connect, discovered services and characteristics and write some values. All went well. Surprisingly come to know there is apple MIFI program (need to research on it).
In excitement I ordered iPhoneSE, HC-05 bluetooth module, Arduino Builder's Kit R2 with original Arduino UNO. It took some days/wasted in shipment and decent amount and now it's not working.
I write proper set up/initialization for peripheral and central classes, adopted delegates and I think it's all correct. However I am not able to connect to HC-05 bluetooth module.
Observations:
On a Android device i turned on bluetooth in device settings, HC-05
was able to be discovered, enter 0000/1234 (password as per
documentation). And yes i was able to connect it. It means HC-05 is
not malfunctioning.
On a iPhoneSE iOS v11.0, Setting -> turn on bluetooth. But HC-05 is
not discoverable.
I simply want to be successfully discover and connect to HC-05 module using BLE technology. Then with delegate methods look up services/characteristics and then try to on/off led.
I can provide more info and background if needed.
I need some help and direction so that I can purchase the correct bluetooth module which connect to iPhone, and I am sure I can do it.
Thanks.
To answer above question-
HC-05 will not connect iPhone. Because HC_05 is not bluetooth low energy.
I have used AT-09 from amazon.
I have written complete article how I achieved it here, and challanges I faced with solution.
The HC-05 isn't compatible with iOS.
This is because Apple uses MFi Licensing Program and HC-05 is not licensed.
To get things working go for a module supporting minimal BT Version V4.0 BLE. Even better, BT Version: V4.2 BLE & V5.0 (better range and larger packet-size), if iOS (v11.0) supports it.
I am not going to recommend a specific model, that's what Google is for.
Apple devices under the MFi licensing scheme only support limited profiles.
HC-05 is based on Bluetooth 2.0. What will work for Apple mobile devices (iPhone, iPad) will be those modules that utilise Bluetooth 4.0 or Bluetooth Low Energy (BLE).

Create an iPad app that can send/receive data via the USB cable?

I want to create an iPad app that connects to another machine, laptop or otherwise, via USB and communicates to some other application I develop running there.
I know that this is easy to achieve via Bluetooth or WiFi but this particular set of solutions must be done via a USB cable.
Is it possible to do so without access to the Apple MFi program? (I am about 5 weeks in and the response is not looking good).
iOS App --> USB Cable --> Mac OSX --> Desktop App (without MFi access)
Thanks
To use USB communication Apple does not provide any API within IOS SDK. The only option right now is MFI. I don't think Apple will allow this in near future.
To use serial communication, you need MFI as you may have discovered. However, there is a poor man's way of achieving this. I have done so during development.
Enable "Internet sharing" on your device and connect to it. Use "ifconfig" on your Mac to find out the interface to use. You do not need to use this as the default connection, but it needs to be active. If I remember correctly, only one end can initiate connections (it was a while so I am sorry that I don't remember the details).
EDIT: I would also like to point out that I did this on an iPhone, not an iPad.
Not over USB but over RS232 (serial port)
Look here: http://www.redpark.com/c2db9.html
But:
The cable uses the old 30 pin connector, but according to them it's compatible with the Lightning adapter
The application won't be accepted on the AppStore, it's for internal use only.
There is a (small) book that explains how to use this cable to connect an iPhone directly to an Arduino, it's been published in late 2011. "iOS Sensor Apps with Arduino Wiring the iPhone and iPad into the Internet of Things" http://shop.oreilly.com/product/0636920021179.do

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.

iOS and Infrared

Is it possible to communicate with an Infrared device (USB Infrared, TV, Mobile Phone, etc) using iOS (iPhone or iPad)?
Well, i know it's possible, since there are many remote/universal remote applications in the AppStore. I basically want to know how?
What are the limitations and
requirements?
What kind of additional hardware is
required? If it's available in the
market?
Which protocols should i know about?
Which iOS libraries can help me in
the process.
Can anyone point me in the right direction. Thanks.
Any devices using IR for controllers are either wifi or have custom hardware that outputs IR signals based off of output from the device. So without using your own hardware, I don't believe this is possible
Infrared isn't unbuilt in iPhone. All those remote apps are wifi based.
The hardware isn't available but there is a hack you can make to the headphone socket.
http://arstechnica.com/apple/news/2011/01/project-hijack-uses-iphone-audio-jack-to-make-cheap-sensors.ars?utm_source=Ars+Technica+Newsletter&utm_campaign=05bfd22285-January_21_2011_Newsletter&utm_medium=email
There is no infrared connectivity within iOS.However there are bluetooth and wifi.Generally you can use bluetooth functionality by importing GameKit framework.Thanks

Is it possible, in principle, for an Android device to interface with an iPhone over Bluetooth/GameKit?

(I am not interested in pure theory, but as a practical near or mid-term possibility, say within 12-24 months.)
As a developer familiar with (but not specializing in) two major smartphone platforms, should I expect an Android library to come out which can spoof itself onto an iPhone app's GameKit-based network. It seems reasonable that a Bluetooth interface between platforms might square the opportunity to make useful applications, in the same way that modems benefited PC/Mac platforms via Metcalfe's Law.
I am looking for one of two answers:
Is this obviously not likely (e.g. because of encryption)? If so, what is the reason? Is it possible in principle, but requiring years of reverse-engineering (like SMB/CIFS/Samba)? Or is it a no-brainer and just a matter of time? Please give evidence supporting your reason.
Is there an alternative way to have direct peer-to-peer networking besides GameKit? For example, a hand-rolled network using Bluetooth or ad-hoc WiFi? It would be nice to spoof an Android device into an existing iPhone app but my main question is, can the devices speak with each other at all!
Yes, it is possible. GameKit is a protocol using TCP and/or UDP over a BNEP Bluetooth connection. It also uses a trick to identify other iOS devices using the Extended Inquiry mechanism in Bluetooth 2.1+.
I was able to simulate the EIR responses, now, someone needs to reverse engineer the GameKit protocol. This doesn't need Bluetooth, as it is also used for GameKit connections over WLAN.
If anybody can re-implment GameKit for WLAN connections, I can finish the Bluetooth version.
No, and it wont come soon or even at all... Apple pride themselves with their security features, and bluetooth connections can access private data. There will probably not be any cross platform bluetooth framework until something is agreed upon by both companies.
Bump as said by a previous answerer uses a remote server, and the data transferred is not via BT.
GameKit is Bonjour so a Bonjour (which is on IP) over Bluetooth on Android should work.
That should be possible as Bluetooth is capable of setting up tcp/ip networks. Though I have no knowledge of the IPhone SDK whatsoever, but Android does have a BluetoothSocket and BluetoothServerSocket for TCP connections.
This article, http://blog.moritzhaarmann.de/blog/2014/04/27/sorry-state-of-p2p/ written in 2014, suggest it is possible via Bluetooth LE. Available in Android 4.3+ and iOS6+
Two issues:
According to the Android Dashboard only around 30 percent of Android devices support Bluetooth LE https://developer.android.com/about/dashboards/index.html?utm_source=ausdroid.net
Communication between Android-to-Android must be done using some other method (which is not a big problem) because Android devices cannot act as server for B LE connections.
Bounjour on the iPhone gives you full access to all of the Bluetooth protocols, so you don't have to use GameKit. As for when someone will provide an easy to use iPhone to Android GameKit like framework - hard to tell.
An iPhone can already talk to any other Bluetooth device using Bonjour today.
-t
It is absolutely possible! In fact I am amazed that more people haven't done it!
Theory:
Bluetooth is just a wireless socket that you push data across and it comes across the other side, just like tcp/ip.
Practice:
http://www.techcrunch.com/2009/11/11/bump-goes-cross-platform-with-new-android-app-upgrades-iphone-version-too/
Better yet, Bump is cross-platform, which means that you can bump an Android phone with an iPhone and it should work seamlessly.