Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bluetooth Classic with iOS ExternalAccessoryFramework

I'm looking at development of an iOS app that will communicate with Bluetooth classic devices using iOS Supported Bluetooth Profiles

As I understand, this should be possible using the External Accessory framework and should not require participation in the MFi program. From the MFi FAQ:

What types of accessories and technologies are not part of the MFi Program?

Accessories that do not use any of the MFi licensed technology listed above are not part of the MFi Program. For example:

  • Accessories that use only standard Bluetooth profiles supported by iOS

So far, so good. The External Accessory Framework doc introduction says (emphasis added):

The External Accessory framework provides support for communicating with external hardware connected to an iOS-based device through the 30-pin dock connector or wirelessly using Bluetooth. Applications that support external accessories must be sure to configure their Info.plist file correctly. Specifically, you must include the UISupportedExternalAccessoryProtocols key to declare the specific hardware protocols your application supports.

Where are the values for the for the "specific hardware protocols" noted above documented? I'm assuming that this is referring to Bluetooth profiles?

FWIW, I've downloaded and attempted to run Apple's EADemo app. It includes the values com.apple.p1 and com.apple.p2 for the UISupportedExternalAccessoryProtocols key. When I run the EADemo app on a 4th gen iPod Touch/iOS8.1.3 it does not find any BT devices. It should find the Jawbone speaker that it is connected to.

To simplify, I've also created a very small sample app to listen for EAAccessoryDidConnectNotification notifications:

- (void)viewDidLoad {
    [super viewDidLoad];        
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accessoryDidConnect:) name:EAAccessoryDidConnectNotification object:nil];
    [[EAAccessoryManager sharedAccessoryManager] registerForLocalNotifications];

}

- (void) accessoryDidConnect:(NSNotification *)notification {
    EAAccessory *connectedAccessory = [[notification userInfo] objectForKey:EAAccessoryKey];
    NSLog(@"didConnect: %@", connectedAccessory.name);
}

When I run the code on the iPod Touch, no notifications are received. While the app is running. I've turned the Jawbone speaker off and then on to initiate a connection. (I can confirm that it does connect by looking at Settings->Bluetooth).

I've added the UISupportedExternalAccessoryProtocols key to the app plist and left the values array empty and added com.apple.p1 and com.apple.p2 (as in the EADemo app).

Any ideas on what I'm missing? How can an iOS app be made to communicate with a Bluetooth classic device?

like image 998
TomH Avatar asked Feb 08 '15 18:02

TomH


People also ask

Does iOS support classic Bluetooth?

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.

What is External Accessory framework?

The framework supports hardware that connects to an iOS or iPadOS device physically through an Apple Lightning or a 30-pin connector, or wirelessly with Bluetooth technology. The framework notifies your app when the accessory connects or disconnects from the user's device.

What is accessory framework?

Open Accessory API or Open Accessory Framework - this is the API/framework in the Android development environment that allows the Android applications to transmit data in and out of the available USB port. This is provided by Google through the Android SDK.

Does Bluetooth classic use GATT?

Bluetooth 4.0, which includes the Low Energy specification, brings two new protocols to the standard: ATT (Attribute Protocol) and GATT (Generic Attribute Profile). They are mainly targeted at Low Energy mode, and every LE profile is expected to use them. But they can also be used over Classic Bluetooth (BR/EDR).


1 Answers

TL;DR: The EA Framework will work only with MFi devices.

From Apple Technical Developer Support:

Hello Tom,

In response to your questions regarding the use of the External Accessory framework

Q1. If I'm attempting to programmatically connect to a BT device with any of these profiles using the EA framework, must the device be MFi compliant? Response - yes. The Accessory must implement a special protocol to identify data to be sent/received across the selected transport as EA supported data.

Q2. As an example, can I write code using the EA framework to connect to a Bluetooth speaker that is not MFi compliant? Response - Most Classic Bluetooth speakers use AVRCP/A2DP to transport audio data across Bluetooth with an iPhone. Such data is completely separate from the data marked for External Accessory support. The EA framework cannot be used to access the data sent via AVRCP/A2DP. However some speakers do implement a separate EA data exchange, which will work with an EA Framework application. However the direct answer - no. An EA framework app will opnly function with an MFI compliant accessory - even more of a subset - one desigend for use with EA.

Comment - Jawbone speaker does not appear in UITableView in the EADemo application. Response - this is correct. The Jawbone speaker is not an EA accessory. However the Nike Fuelband is an EA Accessory. An important consideration - to use the EA Framework, you must work with the accessory vendor to learn the data protocol supported by the accessory - what the data looks like when receiving and sending data.

like image 167
TomH Avatar answered Nov 06 '22 06:11

TomH