summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2017-07-24 15:47:57 -0400
committerJoel Fischer <joeljfischer@gmail.com>2017-07-24 15:47:57 -0400
commit45646e9671626b8431984779209dad16d75ccf47 (patch)
treee3287db06bcd0188a828efa97abd284b2d32430b
parente10c51186223e59579b07e89b92982687f3a7d16 (diff)
downloadsdl_ios-45646e9671626b8431984779209dad16d75ccf47.tar.gz
* SDLControlFramePayloadRPCStartService now can be init with a string directly
* SDLGlobals maxProxyProtocolVersion renamed * Assemble and attach the protocol version to the RPCStartService control message
-rw-r--r--SmartDeviceLink/SDLControlFramePayloadRPCStartService.h1
-rw-r--r--SmartDeviceLink/SDLControlFramePayloadRPCStartService.m9
-rw-r--r--SmartDeviceLink/SDLGlobals.h2
-rw-r--r--SmartDeviceLink/SDLGlobals.m6
-rw-r--r--SmartDeviceLink/SDLProtocol.m7
5 files changed, 19 insertions, 6 deletions
diff --git a/SmartDeviceLink/SDLControlFramePayloadRPCStartService.h b/SmartDeviceLink/SDLControlFramePayloadRPCStartService.h
index 8dba5d184..20acee9d1 100644
--- a/SmartDeviceLink/SDLControlFramePayloadRPCStartService.h
+++ b/SmartDeviceLink/SDLControlFramePayloadRPCStartService.h
@@ -17,6 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (copy, nonatomic, readonly, nullable) NSString *protocolVersion;
- (instancetype)initWithMajorVersion:(NSUInteger)majorVersion minorVersion:(NSUInteger)minorVersion patchVersion:(NSUInteger)patchVersion;
+- (instancetype)initWithVersion:(NSString *)stringVersion;
@end
diff --git a/SmartDeviceLink/SDLControlFramePayloadRPCStartService.m b/SmartDeviceLink/SDLControlFramePayloadRPCStartService.m
index c60c9f1fd..e2990d973 100644
--- a/SmartDeviceLink/SDLControlFramePayloadRPCStartService.m
+++ b/SmartDeviceLink/SDLControlFramePayloadRPCStartService.m
@@ -24,10 +24,17 @@ NS_ASSUME_NONNULL_BEGIN
@implementation SDLControlFramePayloadRPCStartService
- (instancetype)initWithMajorVersion:(NSUInteger)majorVersion minorVersion:(NSUInteger)minorVersion patchVersion:(NSUInteger)patchVersion {
+ self = [self initWithVersion:[NSString stringWithFormat:@"%lu.%lu.%lu", majorVersion, minorVersion, patchVersion]];
+ if (!self) return nil;
+
+ return self;
+}
+
+- (instancetype)initWithVersion:(NSString *)stringVersion {
self = [super init];
if (!self) return nil;
- _protocolVersion = [NSString stringWithFormat:@"%lu.%lu.%lu", majorVersion, minorVersion, patchVersion];
+ _protocolVersion = stringVersion;
return self;
}
diff --git a/SmartDeviceLink/SDLGlobals.h b/SmartDeviceLink/SDLGlobals.h
index f96af1246..990157069 100644
--- a/SmartDeviceLink/SDLGlobals.h
+++ b/SmartDeviceLink/SDLGlobals.h
@@ -11,7 +11,7 @@
#define SDL_SYSTEM_VERSION_LESS_THAN(version) ([[[UIDevice currentDevice] systemVersion] compare:version options:NSNumericSearch] == NSOrderedAscending)
#define BLOCK_RETURN return
-extern NSString *const maxProxyProtocolVersion;
+extern NSString *const SDLMaxProxyProtocolVersion;
extern NSUInteger const SDLDefaultMTUSize;
extern NSUInteger const SDLV1MTUSize;
diff --git a/SmartDeviceLink/SDLGlobals.m b/SmartDeviceLink/SDLGlobals.m
index 0f7de9344..8be8afc64 100644
--- a/SmartDeviceLink/SDLGlobals.m
+++ b/SmartDeviceLink/SDLGlobals.m
@@ -9,7 +9,7 @@
#import "SDLGlobals.h"
// VERSION DEPENDENT CODE
-NSString *const maxProxyProtocolVersion = @"5.0.0";
+NSString *const SDLMaxProxyProtocolVersion = @"5.0.0";
NSUInteger const SDLDefaultMTUSize = UINT32_MAX;
NSUInteger const SDLV1MTUSize = 1024;
@@ -53,7 +53,7 @@ NSUInteger const SDLV3MTUSize = 131024;
#pragma mark - Custom Getters / Setters
- (void)setMaxHeadUnitVersion:(NSString *)maxHeadUnitVersion {
- self.protocolVersion = [self sdl_isVersion:maxHeadUnitVersion greaterThanVersion:maxProxyProtocolVersion] ? maxProxyProtocolVersion : maxHeadUnitVersion;
+ self.protocolVersion = [self sdl_isVersion:maxHeadUnitVersion greaterThanVersion:SDLMaxProxyProtocolVersion] ? SDLMaxProxyProtocolVersion : maxHeadUnitVersion;
_maxHeadUnitVersion = maxHeadUnitVersion;
}
@@ -69,7 +69,7 @@ NSUInteger const SDLV3MTUSize = 131024;
case 3: // fallthrough
case 4: {
// If the head unit isn't running v3/4, but that's the connection scheme we're using, then we have to know that they could be running an MTU that's not 128k, so we default back to the v1/2 MTU for safety.
- if ([self sdl_isVersion:self.maxHeadUnitVersion greaterThanVersion:maxProxyProtocolVersion]) {
+ if ([self sdl_isVersion:self.maxHeadUnitVersion greaterThanVersion:SDLMaxProxyProtocolVersion]) {
return SDLV1MTUSize;
} else {
return SDLV3MTUSize;
diff --git a/SmartDeviceLink/SDLProtocol.m b/SmartDeviceLink/SDLProtocol.m
index e53e287c9..1682ab6bd 100644
--- a/SmartDeviceLink/SDLProtocol.m
+++ b/SmartDeviceLink/SDLProtocol.m
@@ -108,6 +108,8 @@ typedef NSNumber SDLServiceTypeBox;
- (SDLProtocolMessage *)sdl_createStartServiceMessageWithType:(SDLServiceType)serviceType encrypted:(BOOL)encryption {
SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:[SDLGlobals globals].majorProtocolVersion];
+ NSData *payload = nil;
+
switch (serviceType) {
case SDLServiceType_RPC: {
// Need a different header for starting the RPC service, we get the session Id from the HU, or its the same as the RPC service's
@@ -117,6 +119,9 @@ typedef NSNumber SDLServiceTypeBox;
} else {
header.sessionID = 0;
}
+
+ SDLControlFramePayloadRPCStartService *startServicePayload = [[SDLControlFramePayloadRPCStartService alloc] initWithVersion:SDLMaxProxyProtocolVersion];
+ payload = startServicePayload.data;
} break;
default: {
header.sessionID = [self sdl_retrieveSessionIDforServiceType:SDLServiceType_RPC];
@@ -129,7 +134,7 @@ typedef NSNumber SDLServiceTypeBox;
// Sending a StartSession with the encrypted bit set causes module to initiate SSL Handshake with a ClientHello message, which should be handled by the 'processControlService' method.
header.encrypted = encryption;
- return [SDLProtocolMessage messageWithHeader:header andPayload:nil];
+ return [SDLProtocolMessage messageWithHeader:header andPayload:payload];
}
- (void)sdl_initializeTLSEncryptionWithCompletionHandler:(void (^)(BOOL success, NSError *error))completionHandler {