summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2019-05-20 15:44:22 -0400
committerJoel Fischer <joeljfischer@gmail.com>2019-05-20 15:44:22 -0400
commit56db755d7fb0b47ff30f907c48695e091e70f674 (patch)
treeee1b9ae7e5ac4e8fa135772f79277f3c2a6e3c5d
parentc79402553372fbc7e5786a8a279225c301832fa8 (diff)
downloadsdl_ios-56db755d7fb0b47ff30f907c48695e091e70f674.tar.gz
-rw-r--r--SmartDeviceLink/SDLIAPControlSession.m20
-rw-r--r--SmartDeviceLink/SDLIAPDataSession.m2
-rw-r--r--SmartDeviceLink/SDLIAPTransport.m4
3 files changed, 11 insertions, 15 deletions
diff --git a/SmartDeviceLink/SDLIAPControlSession.m b/SmartDeviceLink/SDLIAPControlSession.m
index 4829db8a2..773860d81 100644
--- a/SmartDeviceLink/SDLIAPControlSession.m
+++ b/SmartDeviceLink/SDLIAPControlSession.m
@@ -52,7 +52,7 @@ int const ProtocolIndexTimeoutSeconds = 10;
} else {
SDLLogD(@"Starting a control session with accessory (%@)", self.accessory.name);
- if (![self start]) {
+ if (![self sdl_start]) {
SDLLogW(@"Control session failed to setup with accessory: %@. Attempting to create a new control session", self.accessory);
[self destroySession];
if (self.delegate == nil) { return; }
@@ -64,8 +64,8 @@ int const ProtocolIndexTimeoutSeconds = 10;
}
}
-- (BOOL)start {
- if (![self start]) { return NO; }
+- (BOOL)sdl_start {
+ if (![super start]) { return NO; }
// No need for its own thread as only a small amount of data will be transmitted before control session is destroyed
SDLLogD(@"Created the control session successfully");
[self startStream:self.eaSession.outputStream];
@@ -187,17 +187,13 @@ int const ProtocolIndexTimeoutSeconds = 10;
SDLLogD(@"Control Stream will switch to protocol %@", indexedProtocolString);
// Destroy the control session as it is no longer needed, and then create the data session.
- dispatch_sync(dispatch_get_main_queue(), ^{
- [self destroySession];
- });
+ [self destroySession];
if (self.accessory.isConnected) {
- dispatch_async(dispatch_get_main_queue(), ^{
- if (self.delegate != nil) {
- [self.delegate controlSession:self didReceiveProtocolString:indexedProtocolString];
- }
- [self.protocolIndexTimer cancel];
- });
+ if (self.delegate != nil) {
+ [self.delegate controlSession:self didReceiveProtocolString:indexedProtocolString];
+ }
+ [self.protocolIndexTimer cancel];
}
}
diff --git a/SmartDeviceLink/SDLIAPDataSession.m b/SmartDeviceLink/SDLIAPDataSession.m
index 4121d2493..ada525dd4 100644
--- a/SmartDeviceLink/SDLIAPDataSession.m
+++ b/SmartDeviceLink/SDLIAPDataSession.m
@@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
} else {
SDLLogD(@"Starting data session with accessory: %@, using protocol: %@", self.accessory.name, self.protocolString);
- if (![self start]) {
+ if (![super start]) {
SDLLogW(@"Data session failed to setup with accessory: %@. Retrying...", self.accessory);
[self destroySession];
if (self.delegate == nil) { return; }
diff --git a/SmartDeviceLink/SDLIAPTransport.m b/SmartDeviceLink/SDLIAPTransport.m
index 53bec16a0..d4ddee6b6 100644
--- a/SmartDeviceLink/SDLIAPTransport.m
+++ b/SmartDeviceLink/SDLIAPTransport.m
@@ -190,11 +190,11 @@ int const CreateSessionRetries = 3;
if (!self.controlSession.isSessionInProgress && !self.dataSession.isSessionInProgress) {
SDLLogV(@"Accessory (%@, %@), disconnected, but no session is in progress.", accessory.name, accessory.serialNumber);
[self sdl_closeSessions];
- } else if (accessory.connectionID == self.dataSession.connectionID) {
+ } else if (self.dataSession.isSessionInProgress) {
// The data session has been established. Tell the delegate that the transport has disconnected. The lifecycle manager will destroy and create a new transport object.
SDLLogV(@"Accessory (%@, %@) disconnected during a data session", accessory.name, accessory.serialNumber);
[self sdl_destroyTransport];
- } else if (accessory.connectionID == self.controlSession.connectionID) {
+ } else if (self.controlSession.isSessionInProgress) {
// The data session has yet to be established so the transport has not yet connected. DO NOT unregister for notifications from the accessory.
SDLLogV(@"Accessory (%@, %@) disconnected during a control session", accessory.name, accessory.serialNumber);
[self sdl_closeSessions];