Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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+.

like image 558
Boon Avatar asked Aug 20 '12 15:08

Boon


1 Answers

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.

like image 171
Matthias Avatar answered Oct 06 '22 14:10

Matthias