Is it possible to develop an iOS app with bluetooth capabilities? - ios

Would the following be possible?
Let's say I have a scale with Bluetooth capabilities, when I turn it on, it sends the weight via BT.
Is it technically possible to develop an iOS app which pairs with the scale and receives the data from it?

According to Apple:
Technical Q&A QA1657: Using External
Accessory framework with Bluetooth
devices.
Q: I understand that the External Accessory framework in iOS 3.0 and later will allow 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. MFi compliant accessories can be implemented as wired devices, meaning they plug in to the Apple device's 30-pin or Lightning connector, or as wireless devices, whereby they use Bluetooth as the communication channel. Either way, an application that uses the External Accessory framework will not be notified of an accessory's presence unless the accessory identifies itself as being MFi compliant, i.e., it was specifically designed to interface with an iOS application.

Yes, we can connect Bluetooth devices with iOS application through Core bluetooth framework. This framework is supported on the iPhone 4s, iPhone5,iPhone 5S ,iPad3. We can use BLE 4.0 for the communication between scale and iOS application. Here, iOS application become the client and scale become the peripheral. You Can set as well as get data from the weighing scale.

While the External Accessory Framework with Bluetooth is one of the possible solutions, it has additional requirements to be built as per Apple MFi, here Bluetooth reference is to the Classic Bluetooth (Version 3.x and below)
The best solution for the use case you have defined is to use the Bluetooth Low Energy (LE) (aka Bluetooth Smart) technology (Bluetooth 4.0) and it is available to applications as part of the Core Bluetooth Frameworks
Here are the APIs for Core Bluetooth that applications can use.
While currently Bluetooth Low Energy is supported on the latest iPhone 4S, New Mac Mini & Macbook Air - its expected most new Apple & Others hardware will have this standard.

Related

What's the difference between the CoreBluetooth and ExternalAccessory frameworks?

Apple provides the following two frameworks for communicating with nearby Bluetooth devices with iOS.
CoreBluetooth:
The Core Bluetooth framework provides the classes needed for your iOS and Mac apps to communicate with devices that are equipped with Bluetooth low energy wireless technology.
ExternalAccessory:
The External Accessory framework provides support for communicating with external hardware connected to an iOS-based device through either the Apple Lightning or 30-pin connector, or wirelessly using Bluetooth.
I have previously used the CoreBluetooth framework to successfully communicate with Bluetooth devices. However, I am now trying to communicate with a Bluetooth printer and it doesn't show up in the scan for nearby devices. Using the ExternalAccessory framework, it does.
How do these two frameworks differ as far as communicating with Bluetooth devices is concerned? Why do different Bluetooth devices require the use of different frameworks?
There are two kinds of Bluetooth, Bluetooth LE which is very limited in bandwidth but that doesn't require any user pairing in the settings app and Bluetooth Classic, which requires the user to pair the device but gives you more functionality and bandwidth. CoreBluetooth supports Bluetooth LE and you can use it with a developer account. Bluetooth Classic requires that you join the Apple MFi program.
Core Bluetooth only allows you to communicate with Bluetooth Low Energy devices using the GATT profile.
The External Accessory framework allows communication with 'legacy' Bluetooth devices using profiles such as the Serial Port Protocol (SPP). In order to communicate with devices using the External Accessory framework, the device must be certified under the MFi program.
I also believe that in order to get an app that can communicate with with an MFi device using the External Accessory Framework approved, the MFi licensee (i.e. the printer vendor) needs to provide some paperwork to authorise your app.

Use bluetooth in iOS application

I'm currently digging my through the nest of using Bluetooth in my iOS application and I find it quite hard to find the information I'm looking for.
Can I turn on Bluetooth from within my app or does the user have to do it manually?
Can I use the basic Bluetooth fetaures (such as Discovery, connecting and Sending Data) with other devices running Bluetooth < 4.0 (classic)
AFAIK CoreBluetooth Framework can only be used to communicate with devices running Bluetooth 4.0+. Which framework is used to communicate with Bluetooth < 4.0 devices?
Is it possible to use Bluetooth in such a way that Apple will reject my App on App Store? And which ways would that be?
Is there a difference between paired and unparied communication? Can one communicate with another device without being paried? Can pairing be initated from an app?
To give some Context to my question: I'm currently developing a part of a Home Automation Application where the App needs to communicate with an embedded device which does not yet have Wifi. It has not been decided which Bluetooth version will run on the embedded device. The same functionality will be implemented in an Android application.
Thankful for some input from some with Bluetooth experience for iOS.
you cannot turn on Bluetooth from your app. The user must do it using settings or the control center.
unless you device is MFi certified you can only communicate with Bluetooth Low Energy devices
the external accessory framework is used to communicate with MFi devices that use "classic" Bluetooth
I am not aware of any use of Core Bluetooth that will lead to app rejection. If your app supports an MFi accessory that isn't associated with your company then your app will be rejected.
you can initiate bonding (commonly known as pairing but it is actually different) by requiring encryption for an attribute. Once the bonding is complete there is no difference in how you transfer data, but the data will be encrypted over the air.

Core Bluetooth with Bluetooth 2.1

Can I connect iPhone and bluetooth 2.1 device and work with them via Core Bluetooth? I just need to send and receive some NSString data from/to iPhone.
No, Core Bluetooth only supports Bluetooth Low Energy/Bluetooth 4.0 devices. You can only connect to Bluetooth 2.1 devices via the MFI program and the external accessory framework.
The only exception is "standard" devices such as keyboards and audio devices (hands free etc). However in these cases you can't access any underlying Bluetooth information - you can simply send audio or receive keyboard input.
The only way your own device talk to your iPhone is Bluetooth Low energy if you can not apply MFI program(Most of cases). You need some Bluetooth Low Energy DevKit like TI2540/TI2541 or Nordic or Dialog, they are equipped with rich interface like UART, button, LED and simple speaker. The cheapest chip on market is TI2540(also oldest), but it is MCS51 based core MCU, not very friendly. Other arm based dev kits are more friendly.
The core bluetooth in iOS is not very easy to use, I will recommend you try https://github.com/kickingvegas/YmsCoreBluetooth , it is awesome.
Not possible to work with 2.1 bluetooth in core bluetooth library.
Core bluetooth support Bluetooth Low Energy(BLE) support.Ex. Bluetooth 4 or greater version of BLE devices.
Bluetooth 2.1 is classic bluetooth device.

how to connect to Bluetooth 2.1 enabled device with iphone 5 in ios

I have a medical device which is Bluetooth enabled with version 2.1+EDR.
I want to integrate the device inside my application. I am targeting mainly the iOS devices with BLE/Bluetooth 4.0 .
Any idea the latest iOS devices will be compatible with mentioned medical device. IF so how will be the approach.(means I can use Corebluetooth ,EAAccessory framework or I have enroll the MFi Program).
If the device is Bluetooth 4/Bluetooh Low Energy (also known as Bluetooth Smart) the you can use Core bluetooth. If it is Bluetooth 2.1 then you need to go through the MFI program and embed an Apple chip in your device I order to identify it to iOS and use the external accessory framework

Can an app receive bluetooth data if it is locked?

Simply that question. You see other devices stating that they can, but built on older platforms. Any sample code would be great.
Yes, it is possible. You need to set UIBackgroundModes to "bluetooth-central" in info.plist file.
Note also, that Technical Q&A QA1657 in iOS Developer Library says the following
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. MFi compliant accessories can be implemented as wired devices, meaning they plug in to the iOS device's 30-pin connector, or as wireless devices, whereby they use Bluetooth as the communication channel. Either way, an application that uses the External Accessory framework will not be notified of an accessory's presence unless the accessory identifies itself as being MFi compliant, i.e., it was specifically designed to interface with an iOS application.
Developer reference also says that there is a Core Bluetooth framework for Low Energy devices in iOS5, but it's for Bluetooth 4.0 devices (BTLE) only, currently on the iPhone 4S.

Resources