title: Initiate EASession Fail -- EAAccessory Doesn't Have Protocols
body: <p>I'm working on an iOS app communicate with Bluetooth 2.1.
  App connects to BT when it becomes active. It works fine if app goes to background and becomes active again.</p>
  
  <p>But I just noticed a problem: </p>
  
  <p>If I turn BT module power off, app get a notification where I do the following:</p>
  
  <pre><code>  - (void)accessoryDidDisconnect:(EAAccessory *)accessory
      {
          NSLog(@"EAController::accessoryDidDisconnect:");
          _selectedAccessory = nil;
          UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Lost connection. " delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
          [alert show];
          NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
          [defaults setBool:YES forKey:@"Lost Communication"];
          [self closeSession];
      }
  </code></pre>
  
  <p>Then I turn the module power back on, go to Settings -> Bluetooth, connect BT module to iPhone, active app (come back from background), EASession can not be initiated:</p>
  
  <pre><code>if (_session == nil)
      {
          NSLog(@"EAController::openSession");
          [_selectedAccessory setDelegate:self];
          _session = [[EASession alloc] initWithAccessory:[self selectedAccessory] forProtocol:_protocolString];
  
          if (_session)
          {
                      // Set up delegate........
          }
          else
          {
              NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
              [defaults setBool:NO forKey:Unit_Has_Connection_UserDefault_Key];
              NSLog(@"creating session failed");
          }
      }
  </code></pre>
  
  <p>Initiate _accessoryList and _selectedAccessory:</p>
  
  <pre><code>_accessoryList = [[NSMutableArray alloc] initWithArray:[[EAAccessoryManager sharedAccessoryManager] connectedAccessories]];
  _selectedAccessory = [_accessoryList objectAtIndex:0];
  </code></pre>
  
  <p>I found out _accessoryList has the accessory I'm using but it's "Protocols" is empty. </p>
  
  <pre><code>$12 = 0x1dd58050 &lt;__NSArrayI 0x1dd58050&gt;(
  &lt;EAAccessory: 0x1dd1dce0&gt; {
    connected:YES
    connectionID:XXX
    name: XXX
    manufacturer: XXX
    modelNumber: XXX
    serialNumber: 
    firmwareRevision: XXX
    hardwareRevision: XXX
    macAddress: XXX
    protocols: (
  )
    delegate: (null)
  }
  )
  </code></pre>
  
  <p>If I kill the app and restart, it works fine.</p>
  
  <p>Does anyone know how to solve this?</p>
  
  <p>This question is similar to <a href="https://stackoverflow.com/questions/4394291/easession-eaaccessorydelegate-and-error-opening-session-failed">this one</a> , but happens in different situations and the answer to that question doesn't seem to solve my problem.</p>