diff --git a/SmartDeviceLink/SDLIAPDataSession.m b/SmartDeviceLink/SDLIAPDataSession.m index 3cd2d7492..5bf61e304 100644 --- a/SmartDeviceLink/SDLIAPDataSession.m +++ b/SmartDeviceLink/SDLIAPDataSession.m @@ -110,9 +110,6 @@ - (void)sdl_stopAndDestroySession { [self sdl_isIOThreadCanceled:self.canceledSemaphore completionHandler:^(BOOL success) { if (success == NO) { SDLLogE(@"Destroying thread (IOStreamThread) for data session when I/O streams have not yet closed."); - - // FIX: Try to close the session if the canceledSemaphore is never triggered by the `sdl_accessoryEventLoop` - [self sdl_closeSession]; } self.ioStreamThread = nil; [super cleanupClosedSession]; diff --git a/SmartDeviceLink/SDLIAPTransport.m b/SmartDeviceLink/SDLIAPTransport.m index f65027e49..a1be67a65 100644 --- a/SmartDeviceLink/SDLIAPTransport.m +++ b/SmartDeviceLink/SDLIAPTransport.m @@ -98,8 +98,11 @@ - (void)sdl_accessoryConnected:(NSNotification *)notification { return; } + double retryDelay = self.sdl_retryDelay; + SDLLogD(@"Accessory Connected (%@), Opening in %0.03fs", notification.userInfo[EAAccessoryKey], retryDelay); + self.retryCounter = 0; - [self sdl_connect:newAccessory]; + [self performSelector:@selector(sdl_connect:) withObject:nil afterDelay:retryDelay]; } /** @@ -501,21 +504,14 @@ - (BOOL)createSessionWithAccessory:(EAAccessory *)accessory protocolString:(NSSt if ([protocolString isEqualToString:MultiSessionProtocolString] && SDL_SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9")) { self.dataSession = [[SDLIAPDataSession alloc] initWithAccessory:accessory delegate:self forProtocol:protocolString]; - - SDLLogD(@"Accessory Connected (%@), Opening immediately", accessory); [self.dataSession startSession]; return YES; } else if ([protocolString isEqualToString:ControlProtocolString]) { self.controlSession = [[SDLIAPControlSession alloc] initWithAccessory:accessory delegate:self]; - - double retryDelay = [self sdl_retryDelay]; - SDLLogD(@"Accessory Connected (%@), Opening in %0.03fs", accessory, retryDelay); - [self.controlSession performSelector:@selector(startSession) withObject:nil afterDelay:retryDelay]; + [self.controlSession startSession]; return YES; } else if ([protocolString isEqualToString:LegacyProtocolString]) { self.dataSession = [[SDLIAPDataSession alloc] initWithAccessory:accessory delegate:self forProtocol:protocolString]; - - SDLLogD(@"Accessory Connected (%@), Opening immediately", accessory); [self.dataSession startSession]; return YES; }