I am using EAAccessoryManager to connect my application to a MFI accessory. During the initial connection, in bluetooth setting screen, it showing as device connected.
When i try to get the list of connected device using
[accessoryManager connectedAccessories]
, it returns a empty array. But when i use showBluetoothAccessoryPickerWithNameFilter
, it shows me the accessory in the list.
The problem is i don't want user to choose the accessory. I want to make this a automated process. I have included the accessory protocol string in info.plist too. Please guide me with this issue. What mistake i am doing here ?
I had the same issue and was able to resolve it by adding a Supported external accessory protocols
key to my info.plist
file (raw key name is UISupportedExternalAccessoryProtocols
). In my case, I wanted to scan for connected PayPal™ credit card terminals and Zebra™ printers. Here's the corresponding extract from my info.plist:
<key>UISupportedExternalAccessoryProtocols</key>
<array>
<string>com.paypal.here.reader</string>
<string>com.zebra.rawport</string>
</array>
Once I added these, connectedAccessories
was populated.
Could you try this function?
- (void)_getAttachedDevices;
{
EAAccessoryManager* accessoryManager = [EAAccessoryManager sharedAccessoryManager];
if (accessoryManager)
{
NSArray* connectedAccessories = [accessoryManager connectedAccessories];
NSLog(@"ConnectedAccessories = %@", connectedAccessories);
}
else
{
NSLog(@"No accessoryManager");
}
}
Which result do you get?
Obviously remember that EAAccessory is only for the Made-For-iPod/iPhone/iPad/AirPlay licensed accessories; so if you have no licensed accessory you'll see always an empty array. Do you have a regular licensed MFI accessory?
In addiction I suggest if you haven't read it yet the Apple Documentation.
EDIT 1:
If you are still stuck try to implement the notification for connect/disconnect:
[[EAAccessoryManager sharedAccessoryManager] registerForLocalNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(accessoryDidConnect:)
name:EAAccessoryDidConnectNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(accessoryDidDisconnect:)
name:EAAccessoryDidDisconnectNotification
object:nil];
Do you see the connection for your device? If yes try to get the list of connected devices on
accessoryDidConnect
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With