What hardware attributes can iOS device detect or obtain when connected to an MFI hardware?
Asked Answered
G

1

9

I am dealing with External Accessories and MFI for a project and have this question:

What 3rd party hardware attributes, if any, can be recognized after connecting an iOS device to the MFI hardware? Specifically, I am looking for a generic way to determine the device classes or capabilities rather than having to check the specific manufacturer and device names, similar to how Android can do it (see below). Is this possible?

http://developer.android.com/reference/android/bluetooth/BluetoothClass.Device.html

The end goal: Toggle a boolean when connected to an audio dock; ignore other events. I’m not sure how granular iOS can get. Can iOS tell the difference between an audio dock and a Golf Putter App Cradle ? Does MFi grant insight into the capabilities of a device?

I will be targeting iOS 4.2+.

Gynandry answered 20/8, 2012 at 15:38 Comment(0)
M
6

You can request to get notifications by the EAAccessoryManagerclass (via registerForLocalNotificationsmethod). To do so, you need to add the ExternalAccessory.framework to your project.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_accessoryDidDisconnect:) name:EAAccessoryDidDisconnectNotification object:nil];
[[EAAccessoryManager sharedAccessoryManager] registerForLocalNotifications];

Once a hardware is added, you get a notification with EAAccessoryKey, what in turn can be used to get an EAAccessory from the accessory manager

- (void)_accessoryDidConnect:(NSNotification *)notification {
      EAAccessory *accessory = [[notification userInfo] objectForKey:EAAccessoryKey];

The accessory has a number of properties that should help to identify which kind of hardware have been connected:

NSString* name  
NSString* manufacturer  
NSString* modelNumber  
NSString* serialNumber  
NSString* firmwareRevision  
NSString* hardwareRevision  
NSArray* protocolStrings

I have no idea, what your audio dock provides here, but it should easy to simply try and hope that it is consistent for all devices :-)

If you are not interested in a specific device but in a class of devices (with a specific behavior), protocolStrings should be useful. The array consists of strings that name protocols (in sense of behaviors, not in ObjectiveC sense). The names are formatted as reverse-DNS strings (com.mycompany.myprotocol).

If you provide one or more of such protocol names in the UISupportedExternalAccessoryProtocols section (type: array of strings) of your app’s Info.plist file, your app will be started if a proper device is connected.

Mishear answered 23/8, 2012 at 7:18 Comment(2)
thanks - I am aware of this info but I would like a more generic approach of getting device class as checking for specific info like you have it is very taxing and not practical. I am looking for something similar to what Android can do here: developer.android.com/reference/android/bluetooth/…Gynandry
Offering the bonus to Matthias since there is no more answers and he cares enough to post a detailed solution to this.Gynandry

© 2022 - 2024 — McMap. All rights reserved.