After days of searching for solution, I finally solved this problem(Or I hope I solved it.). I'm posting my answer here so if anyone has the same problem can have an idea.
You can never trust EAAccessoryManager, it may have ghost accessory. So initiate _accessoryList using the following command doesn't always work.
_accessoryList = [[NSMutableArray alloc] initWithArray:[[EAAccessoryManager sharedAccessoryManager] connectedAccessories]];
If you initiate an accessoryList with a ghost accessory, for sure you cannot successfully initiate an EASession.
The right way is to use EAAccessory Notification, which described in this answer, but it didn't say how to do it in detail.
First, you need to create post two notifications:
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(accessoryConnected:) name:EAAccessoryDidConnectNotification object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(accessoryDisconnected:) name:EAAccessoryDidConnectNotification object:nil];
[[EAAccessoryManager sharedAccessoryManager]registerForLocalNotifications];
Then in accessoryConnected and accessoryDisconnected, you can do the following.
- (void)accessoryConnected:(NSNotification *)notification
{
NSLog(@"EAController::accessoryConnected");
EAAccessory *connectedAccessory = [[notification userInfo] objectForKey:EAAccessoryKey];
[[self accessoryList] addObject:connectedAccessory];
if ([_accessoryList count])
{
_selectedAccessory = [_accessoryList objectAtIndex:0];
NSArray *protocolStrings = [_selectedAccessory protocolStrings];
if ([protocolStrings count]) {
self.protocolString = [protocolStrings objectAtIndex:0];
[self openSession];
}
}
}
- (void)accessoryDisconnected:(NSNotification *)notification
{
EAAccessory *disconnectedAccessory = [[notification userInfo] objectForKey:EAAccessoryKey];
int disconnectedAccessoryIndex = 0;
for(EAAccessory *accessory in [self accessoryList]) {
if ([disconnectedAccessory connectionID] == [accessory connectionID]) {
break;
}
disconnectedAccessoryIndex++;
}
if (disconnectedAccessoryIndex < [[self accessoryList] count]) {
[[self accessoryList ] removeObjectAtIndex:disconnectedAccessoryIndex];
} else {
NSLog(@"could not find disconnected accessory in accessory list");
}
NSLog(@"_accessory did disconnect: %@",_accessoryList);
}