Bluetooth Connectivity in iOS – Part 1

0
120

Bluetooth Connectivity in iOS 

Bluetooth is a technology that is used to exchange data packets between two devices. Hence Bluetooth Connectivity in iOS has become one of the important aspect in modern day applications with IOT.

In the last decade we have witnessed some incredible developments have come in the way we use our mobile phones and other technologies specially Bluetooth.

So like other mobile operating systems iOS too comes with an option to connect to the Bluetooth via the phone’s settings menu. It is seen that due to lack of correct information  .

So in this blog we have tried to explain you the different profiles available in the Bluetooth and its connectivity with iOS.

iOS supports and connects to two different type of Bluetooth devices – one that is termed as BLE – Bluetooth Low Energy device and the other is a Bluetooth classic device.

Well, you did not get it right ?????????????? Let’s explain it a bit.

First let’s cover the most common form of Bluetooth Device which is a classic Bluetooth device.

Bluetooth Classic is designed for continuous two-way data transfer with high Application throughput (up to 2.1 Mbps); highly effective, but only for short distances.

So, it’s a perfect solution in the case of streaming audio and video, or mice and other devices that need a continuous, broadband link. There are different Bluetooth profiles which comes under Bluetooth classic :

Serial Port Profile:

If you’re replacing a serial communication interface (like RS-232 or a UART) with Bluetooth, SPP is the profile for you. SPP is great for sending bursts of data between two devices. It’s is one of the more fundamental Bluetooth profiles (Bluetooth’s original purpose was to replace RS-232 cables after all).

Human Interface Device (HID):

HID is the go-to profile for Bluetooth-enabled user-input devices like mice, keyboards, and joysticks. It’s also used for a lot of modern video game controllers, for PS3 controllers.

HSP – HeadSet Profile & HFP – Hands Free Profile

HSP is a Bluetooth profile that enables wireless connection between a phone and a Bluetooth headset. It supports simultaneous two-way audio but not stereo.

HFP is used in the hands-free audio systems built into cars. It implements a few features on top of those in HSP to allow for common phone interactions (accepting/rejecting calls, hanging up, etc.) to occur while the phone remains in your pocket.

Advanced Audio Distribution Profile (A2DP)

Advanced audio distribution profile (A2DP) defines how audio can be transmitted from one Bluetooth device to another.

Where HFP and HSP send audio to and from both devices, A2DP is a one-way street, but the audio quality has the potential to be much higher.

A2DP is well-suited to wireless audio transmissions between an MP3 player and a Bluetooth-enabled stereo.

A/V Remote Control Profile (AVRCP)

The audio/video remote control profile (AVRCP) allows for remote controlling of a Bluetooth device.

It’s usually implemented alongside A2DP to allow the remote speaker to tell the audio-sending device to fast-forward, rewind, etc.

Another mode of communicating with Bluetooth is BLE ( Bluetooth Low Energy):

BLE is a wireless personal area network technology designed and marketed by the Bluetooth Special Interest Group (Bluetooth SIG) aimed at novel applications in the healthcare, fitness, beacons, security, and home entertainment industries.

Compared to Classic Bluetooth, Bluetooth Low Energy is intended to provide considerably reduced power consumption and cost while maintaining a similar communication range.

BLE finds application largely in IoT and also other utility applications. BLE uses GATT profile (General Attribute Profile). General Attribute Profile is built on top of Attribute Protocol (ATT) and establishes common operations and a framework for the data transported and stored by the Attribute Protocol.

Please refer to the below mentioned diagram to understand the Bluetooth stack.

 

Bluetooth Connectivity IOS

After WWDC 2019,  docs on apple developer portal claimed to connect to classic Bluetooth devices using one of its frameworks : Core Bluetooth. However this is pretty misleading, as in practice this is not quite feasible till iOS 13.3. Lets take a look

Apple allows Bluetooth connectivity in iOS using two of its frameworks

Core Bluetooth communicates with Bluetooth Low Energy devices. The official apple documentation claims that using Core Bluetooth you can connect to the BR/EDR devices.

However which is not the case. If you go through the video of WWDC 2019 and look at what their team has to say about it, you would know that apple allows you to scan and connect the BR/EDR “CLASSIC” devices via a BLE service ID.

This means that the BR/EDR device which you would want to connect via Core Bluetooth should be having GATT profiles. For the Bluetooth devices with dual- mode apple uses Cross Transport Delivery Key to connect to the BR/EDR device if connected to it via the GATT profile.

To summarise apple still do not have any apis or any method to connect to a non- GATT BR/EDR (classic) device using Core Bluetooth.

The second way of connecting the classic devices is using External Accessory framework. But a big caveat with this is that External accessory only recognises MFI compliant devices.

What is MFI :-

MFI is a licensing program for developers of hardware and software peripherals that work with Apple’s iPod, iPad and iPhone. The name is a shortened version of the long-form Made for iPod, the original program that ultimately became MFI.

When you are enroll with a MFi you get a protocol string or rather a unique string for the device you enrolled which you can pass in the delegate methods of EAAccessoryDelegate.

The steps and code to connect to the BLE using Core Bluetooth and MFi device using External Accessory framework is available in the second  part. You can refer to the below WWDC 2019 .

Article Written By :- Kumar Gaurav

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here