iOS app with bluetooth as a trigger - ios

I'm trying to help produce a location-specific iOS app that needs an external trigger to start audio playback when it approaches a given location within the building. (no GPS access)
Has anyone had experience doing something similar? One thought I had was to lay out some bluetooth "transmitters" (like an xbee+arduino) around the building, and if the iPhone's bluetooth was close enough to identify it, it would trigger the audio.
I've never worked with bluetooth or an application of this sort before, so any advice would be much appreciated.

Bluetooth would certainly work, although other methods might, too. The only downside to Bluetooth is that you would either need to work within the APple MFi program for standard Bluetooth or restrict the devices used to the iPhone 4s or later or the iPad 3rd Generation or later so you could use Bluetooth LE (Bluetooth 4.0).
Assuming you can use Bluetooth LE, it's not only possible, Apple demoed one such technology. Once you're signed up as a developer, check out Session 705, Advanced Core Bluetooth, from WWDC 2012. The ending demo is exactly what you're looking for, and the session describes how to do it and provides source code.

Related

how to make iOS app connecting with bluetooth?

how to make iOS app with bluetooth?
I need an app which connects and exchange data via bluetooth with other devices, laptop for example.
Many packages for BLE and cant find for classic bluetooth
If you want to use the classic Bluetooth interface of an Apple iOS device, you have to comply with/accept Apple's MFi licensing programme (Made for iPhone/iPod/iPad), which is a major hurdle and the reason for the lack of corresponding libraries.
Short answer: you don't want classic Bluetooth for this. You want BLE. It supports everything you want for this kind of use case. See Core Bluetooth.
Much too long answer about classic Bluetooth and iPhones from my years building earbuds:
Continuing from Risto's answer, even with MFi certification (which requires adding an extra chip to your device, not just licensing), you still don't get general access to the BR/EDR ("classic") interface. You only get access to iAP2, which is an SPP-like serial protocol, but is not SPP. If you're porting from Android, you probably are using SPP, and sorry, that's just not available. You're going to need to switch to BLE.
MFi certification is a useful if you build an audio device that also needs a non-audio control channel. It makes it easy to ensure that both the audio connection and control connection are connected to the same device. This is extremely difficult to do with BLE. But iAP2 isn't a particularly nice protocol, and has weird corner cases. You should not go through the cost and trouble of MFi just to get a SPP-like serial protocol.
On iPhones, access to BR/EDR non-audio profiles is limited to the proprietary iAP2 and GATT over BR/EDR (which is less useful than it sounds since most chips don't support it). Classic audio profiles are limited to what Apple's audio frameworks support, which is not very flexible.
If you make a Bluetooth audio device, have a little extra room on your board, enough margin to add a chip to your BOM, and your SoC supports it, MFi is definitely worth exploring. You can improve the pairing experience marginally and it makes it a bit easier to manage an extra control channel. Plus, you get to add that "Made for iPhone" logo to your packaging. For hearing aids (which I have less experience with), I expect that MFi is a must-have today. From my casual investigation, it looks like it adds some really nice capabilities.
For everyone else, you want BLE.

Inter App Communication between iOS App and Atmega 1284 microprocessor via bluetooth

What I am trying to accomplish:
User enters a password on the iOS app. If the password is correct, then send a one bit value to the microprocessor that indicates the user got the right password. The microprocessor can then start up the step motor to open the door latch.
Has anyone tried to achieve this before? If so, can you please point me in a general direction. I don't know how to approach this problem. I couldn't really find a tutorial for this. My questions are:
Is there a specific Bluetooth I need to purchase? such as only BLE devices
I see a lot of examples of Bluetooth communication between iOS and Ardunio. Would the execution of events be similar for my needs?
Is there another approach to my problem? rather than using Bluetooth?
I think reading the Core Bluetooth Programming Guide is a great start. However, this assumes the device you're connecting to is using Bluetooth 4.x which is widely known as Bluetooth Low Energy (BLE). If the device you're connecting to is using Bluetooth 2.x, you'll have to use the External Accessories Framework.
EA supports only devices that have been certified MFI (Made for iPhone) by Apple.
To make a long story short, if the device you're trying to connect to is Bluetooth 2.x and it's not MFI, you're basically SOL.
Otherwise, you can start connecting to that device pretty easily. Check out LightBlue as a way to test if you connect to the device. It will work with any BLE device.
Here's a simple tutorial to get you going with Core Bluetooth.

iOS PKPKT BLE concept

I understand that the iOS App "PKPKT" is using BLE (Bluetooth Low Enery). But what I am curious about it is, is it purely using BLE only? Or does it switching between BLE and Classic Bluetooth?
I tested with a iPhone 5 and a iPhone 5s with both installed the app. I turned on bluetooth on both devices. And then i checked the "DEVICES" list to see if the other iPhone is paired with one another, I found that they are not. Until i launched the PKPKT on one of the device, and the i check the "DEVICE" list again, now they are paired and connected. So, i'm thinking is this pairing done by the BLE pairing? Meaning one of "Just works", "Out of Band", or "Passkey entry" methods.
There is also a "Chat" functionality in that app. This make me curious if the chatting function using BLE or Classic Bluetooth?
So my question is actually "Is switching between BLE and Classic bluetooth possible?". This is part of the study on this BLE technology. Hopefully someone could help me and other newbie on this new technology.
Thanks in advance!
I wrote PKPKT. I only use BLE. No classic. iBeacon is cool but doesn't have the background scanning needed to discover other players. I use game center, but only for scores, no sessions. It's optional in the app to enable game center (those banners can be distracting!)
The chat is also over BLE.
Because the connections are not encrypted, you don't need to manually pair the devices, and "just works"
I think you might find this link helpful. It implements something that looks to be a simpler version of PKPKT. I believe the app uses a combination of GameKit/iBeacon. The app requires iOS7.0+ and states, "PKPKT does the hard work of finding other players by detecting them using Bluetooth Low Energy (BLE) in the background." iBeacon would be the most battery-efficient way of accomplishing this and is a new feature in iOS 7. There is a wealth of information online(particularly on SO) about peer to peer bluetooth gaming using GameKit, if you are interested.
We can't say for sure unless the developer lets us know. If one were to attempt to recreate the application, GameKit and iBeacon would be the technologies that I believe most would recommend.
You might find this project helpful as an overview of how to use Bluetooth LE to communicate between two devices. You don't need to pair the devices, and unlike iBeacons, it works when the app is in the background.
SimpleShare - Easy Proximity-based Sharing for iOS
You can use the delegate methods of the SimpleShare project to easily share arrays of strings between nearby users running your app, such as user IDs, which you could then use to get more info, photos, etc, about that user from a web service.

How to use bluetooth classic instead of LE

In reference to Dennis Mathews answer how do you specify Bluetooth Classic instead of LE on iOS? Is there a different api from Core Bluetooth Framework?
Joels there is a very clear way to use Bluetooth classic on iOS. It is with the External Accessory framework (it also includes direct hardware connections in addition to Bluetooth classic however).
You need to add the ExternalAccessory.framework and specify "App communicates with an accessory" in the required background modes inside your plist to get started. It should be noted however that with Bluetooth classic, the user must add your Bluetooth device from the System Bluetooth settings. It is only with Bluetooth LE that we are able to add devices from the app side.
Check out the docs on the External Accessory Framework
In response to your question regarding the MFi program, this should clarify:
I want to develop an iOS app that communicates with an MFi accessory. Do I need to join the MFi Program?
No. iOS app developers do not need to join the MFi Program. Everything app developers need is in the External Accessory Framework,
which is provided in the iOS SDK. To access the iOS SDK, please join
the iOS Developer Program: https://developer.apple.com/programs/ios/.
If you'd like to learn more, consult the MFi FAQ
If your external accessory doesn't need high bandwidth in the connection to iOS, and you wish to use (or must use) 2.x/classic BT, (instead of 4.x/LE/Smart, which is very low bandwidth but requires no MFi dancing) you may be able to communicate by emulating a BT HID keyboard in your accessory.
It's hardly optimal, especially since the HID reverse channel is pretty limited (I think to things like lighting the caps lock key in the basic keyboard configuration (HID page 7 mapping, if I recall correctly.) OTOH, if your primary task is to push data to the iOS device, sending the data as keystrokes would not be too awful. (and might even be seen as virtue during testing :)
HID devices can declare additional capabilities in table defined keymaps, but I'm not sure if an iOS app can get at those alternate mappings with sanctioned APIs.

iOS receive data from bluetooth and then send information to a database on another server through wi-fi

Which libraries should I look into for the following tasks?
I want to receive a string from another device via Bluetooth (this will require looking at a list of nearby devices and choosing the right one.
I then want to send the String to a database via Wi-fi
This is a simple version of what I actually want to do, but I need to know how to do those things first. Also, any design tips would be greatly appreciated (like having multiple screens, which classes to write, etc).
The ordinary iOS Bluetooth APIs are only available if you enter into Apple's "Made for iPod" program. See MFi Program
If your device can use the newer "low energy" Bluetooth LE, you can look in the corebluetooth framework
There is an example of a Bluetooth LE heart rate monitor program here.
For WiFi, you can use any of several APIs from Apple and others: Berkeley unix sockets, NSURLConnection, CFNetwork, AsyncSocket, etc.
If you mean receive a string from another iOS device, the statement here about needing to be a part of the "Made For iPod" program is incorrect. This would be required if you mean you are trying to build an accessory for iPhone, iPad, or iPod.
The easiest way to "discover" other iOS devices (running your app) and transfer data between them is GKSession from the GameKit Framework. Beam It! is pretty good example code for this.
Once you initialize a GKSession just set a GKSessionDelegate and set the session's available property to YES. Check out the four required GKSessionDelegate methods and the Beam It! sample code.
http://arctouch.com/beamit/ //Beam It! code
Your best bet is to study Apple's WiTap sample app. That will answer your question #1. For question 2, you can use Apple's coredata. If you are not familiar with coredata, check out this site's tutorials.

Resources