Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Application Launching (SDL 4.0) #45

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1dcfc1e
Remove <SmartDeviceLink/SmartDeviceLink.h> import from SDLRPCMessage.m
joeljfischer Jan 20, 2015
b40b437
Update README.md
joeljfischer Jan 20, 2015
95f366b
Merge pull request #51 from smartdevicelink/hotfix/Contributing_File
joeljfischer Jan 26, 2015
9d7c698
Merge pull request #41 from smartdevicelink/Minor-Readme-Update
joeljfischer Jan 26, 2015
0a7407f
Merge pull request #39 from smartdevicelink/hotfix/SDLRPCMessage_Impo…
joeljfischer Jan 26, 2015
e0f8b07
Fix some weird formatting in SDLProxy
joeljfischer Jan 21, 2015
89328a3
Query Apps and Launch App SDLRequestType enums
joeljfischer Jan 21, 2015
99554c4
Fixed a bug with RPC Type
joeljfischer Jan 21, 2015
9550055
Fixed a warning with sendRPC method
joeljfischer Jan 21, 2015
7831cee
Refactor enormous handleRpcMessage method
joeljfischer Jan 21, 2015
422a5f5
Separate out the "after invoke" RPC handlers
joeljfischer Jan 21, 2015
735bb5d
Further separation of methods
joeljfischer Jan 21, 2015
568b94b
Launch an app when requested
joeljfischer Jan 21, 2015
e840c14
Query Apps filtering
joeljfischer Jan 22, 2015
4a3c9e8
Fix some weird formatting in SDLProxy
joeljfischer Jan 21, 2015
125461d
Refactor enormous handleRpcMessage method
joeljfischer Jan 21, 2015
9a8d7d8
Separate out the "after invoke" RPC handlers
joeljfischer Jan 21, 2015
8cc5daa
Further separation of methods
joeljfischer Jan 21, 2015
93001a6
Launch an app when requested
joeljfischer Jan 21, 2015
2cfb2f2
Query Apps filtering
joeljfischer Jan 22, 2015
9c850a2
Fix some merge issues
joeljfischer Jan 22, 2015
22d51fc
Remove app state observers when protocol is closed
joeljfischer Jan 23, 2015
534d01c
Filtering the Query Response now sends back data
joeljfischer Jan 23, 2015
0485e1a
Add an error log when launch app fails
joeljfischer Jan 23, 2015
4b44c0a
Set Max_Version_To_Send to 4
joeljfischer Jan 26, 2015
e1d7613
Add a log for Mobile HMI state change
Jan 27, 2015
209693b
Remove property for QueryAppsManager
Jan 28, 2015
cfb55d5
SDLRPCNotifications build on proxy have correct messageType
Feb 9, 2015
45ea0b5
More possible v4 fixes
Feb 10, 2015
b326f55
Updated to support version > 2 coming back from the head unit.
justinjdickow Feb 10, 2015
1e3a3c7
Retain system request task in set until finished
Feb 11, 2015
82d2f75
Query Apps URL Request uses data task
Feb 12, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ SDL iOS

SmartDeviceLink iOS Proxy

We're still working on creating documentation for each of these individual repositories, but in the meantime, you can find more information about SmartDeviceLink [here](https://github.com/smartdevicelink/sdl_core/blob/master/README.md) and [here](http://projects.genivi.org/smartdevicelink/about).
We're still working on creating documentation for each of these individual repositories, but in the meantime, you can find more information about SmartDeviceLink [on the SDL Core README](https://github.com/smartdevicelink/sdl_core/blob/master/README.md) and [on Genivi](http://projects.genivi.org/smartdevicelink/about).
8 changes: 8 additions & 0 deletions sdl_ios/SmartDeviceLink.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,8 @@
59A031D01978FBB1003E8ECF /* SDLTransport.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A02FED1978FBA1003E8ECF /* SDLTransport.h */; settings = {ATTRIBUTES = (Public, ); }; };
59A031D11978FBB1003E8ECF /* SDLTransportDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A02FEE1978FBA1003E8ECF /* SDLTransportDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
59BF0A7019790C56008C6783 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 59A02FE41978FBA1003E8ECF /* InfoPlist.strings */; };
5D2DAD901A715243004CD90E /* SDLQueryAppsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D2DAD8E1A715243004CD90E /* SDLQueryAppsManager.h */; };
5D2DAD911A715243004CD90E /* SDLQueryAppsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D2DAD8F1A715243004CD90E /* SDLQueryAppsManager.m */; };
E932AD8B19A26CCF00D8155B /* SDLPolicyDataParser.h in Headers */ = {isa = PBXBuildFile; fileRef = E932AD8919A26CCF00D8155B /* SDLPolicyDataParser.h */; settings = {ATTRIBUTES = (Public, ); }; };
E932AD8C19A26CCF00D8155B /* SDLPolicyDataParser.m in Sources */ = {isa = PBXBuildFile; fileRef = E932AD8A19A26CCF00D8155B /* SDLPolicyDataParser.m */; };
E98A9C8719C74C7400C84B3F /* SDLObjectWithPriority.h in Headers */ = {isa = PBXBuildFile; fileRef = E98A9C8519C74C7400C84B3F /* SDLObjectWithPriority.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -1007,6 +1009,8 @@
59A02FED1978FBA1003E8ECF /* SDLTransport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLTransport.h; sourceTree = "<group>"; };
59A02FEE1978FBA1003E8ECF /* SDLTransportDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLTransportDelegate.h; sourceTree = "<group>"; };
59E5A3D4194E318200B908AA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
5D2DAD8E1A715243004CD90E /* SDLQueryAppsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLQueryAppsManager.h; sourceTree = "<group>"; };
5D2DAD8F1A715243004CD90E /* SDLQueryAppsManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLQueryAppsManager.m; sourceTree = "<group>"; };
E932AD8919A26CCF00D8155B /* SDLPolicyDataParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLPolicyDataParser.h; sourceTree = "<group>"; };
E932AD8A19A26CCF00D8155B /* SDLPolicyDataParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLPolicyDataParser.m; sourceTree = "<group>"; };
E98A9C8519C74C7400C84B3F /* SDLObjectWithPriority.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLObjectWithPriority.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1133,6 +1137,8 @@
59A02E401978FBA0003E8ECF /* SDLProxyFactory.m */,
59A02E411978FBA0003E8ECF /* SDLTTSChunkFactory.h */,
59A02E421978FBA0003E8ECF /* SDLTTSChunkFactory.m */,
5D2DAD8E1A715243004CD90E /* SDLQueryAppsManager.h */,
5D2DAD8F1A715243004CD90E /* SDLQueryAppsManager.m */,
);
name = Proxy;
sourceTree = "<group>";
Expand Down Expand Up @@ -1903,6 +1909,7 @@
59A0306F1978FBA2003E8ECF /* SDLLanguage.h in Headers */,
59A02FF01978FBA1003E8ECF /* SDLConsoleController.h in Headers */,
59A0302B1978FBA1003E8ECF /* SDLProxyFactory.h in Headers */,
5D2DAD901A715243004CD90E /* SDLQueryAppsManager.h in Headers */,
59A030731978FBA2003E8ECF /* SDLMaintenanceModeStatus.h in Headers */,
59A031051978FBA5003E8ECF /* SDLScrollableMessage.h in Headers */,
59A0301E1978FBA1003E8ECF /* SDLProxyListener.h in Headers */,
Expand Down Expand Up @@ -2211,6 +2218,7 @@
59A030071978FBA1003E8ECF /* SDLV1ProtocolMessage.m in Sources */,
59A030761978FBA2003E8ECF /* SDLMediaClockFormat.m in Sources */,
59A030901978FBA2003E8ECF /* SDLSoftButtonType.m in Sources */,
5D2DAD911A715243004CD90E /* SDLQueryAppsManager.m in Sources */,
59A030FA1978FBA5003E8ECF /* SDLPerformAudioPassThru.m in Sources */,
59A030CA1978FBA4003E8ECF /* SDLOnKeyboardInput.m in Sources */,
E9A6E33F19CB30FD0054E1AD /* SDLLockScreenStatus.m in Sources */,
Expand Down
4 changes: 4 additions & 0 deletions sdl_ios/SmartDeviceLink/SDLAbstractProtocol.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ - (void)sendEndSessionWithType:(SDLServiceType)serviceType sessionID:(Byte)sessi
[self doesNotRecognizeSelector:_cmd];
}

- (void)sendRPC:(SDLRPCMessage *)message {
[self doesNotRecognizeSelector:_cmd];
}

- (void)sendRPCRequest:(SDLRPCRequest *)rpcRequest {
[self doesNotRecognizeSelector:_cmd];
}
Expand Down
3 changes: 2 additions & 1 deletion sdl_ios/SmartDeviceLink/SDLInterfaceProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- (void)handleBytesFromTransport:(NSData *)receivedData;
- (void)sendStartSessionWithType:(SDLServiceType)sessionType;
- (void)sendEndSessionWithType:(SDLServiceType)sessionType sessionID:(Byte)sessionID;
- (void)sendRPCRequest:(SDLRPCRequest *)rpcRequest;
- (void)sendRPCRequest:(SDLRPCRequest *)rpcRequest __deprecated_msg("use sendRPC: instead");
- (void)sendRPC:(SDLRPCMessage *)message;

@end
90 changes: 54 additions & 36 deletions sdl_ios/SmartDeviceLink/SDLProtocol.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
#import "SDLRPCPayload.h"
#import "SDLDebugTool.h"
#import "SDLPrioritizedObjectCollection.h"
#import "SDLRPCNotification.h"
#import "SDLRPCResponse.h"


const NSUInteger MAX_TRANSMISSION_SIZE = 512;
const UInt8 MAX_VERSION_TO_SEND = 3;
const UInt8 MAX_VERSION_TO_SEND = 4;

@interface SDLProtocol () {
UInt32 _messageID;
Expand Down Expand Up @@ -82,67 +84,83 @@ - (void)sendEndSessionWithType:(SDLServiceType)serviceType sessionID:(Byte)sessi

}

// SDLRPCRequest in from app -> SDLProtocolMessage out to transport layer.
- (void)sendRPCRequest:(SDLRPCRequest *)rpcRequest {

NSData *jsonData = [[SDLJsonEncoder instance] encodeDictionary:[rpcRequest serializeAsDictionary:self.version]];
- (void)sendRPC:(SDLRPCMessage *)message {
NSParameterAssert(message != nil);
NSData *jsonData = [[SDLJsonEncoder instance] encodeDictionary:[message serializeAsDictionary:self.version]];
NSData* messagePayload = nil;

NSString *logMessage = [NSString stringWithFormat:@"%@", rpcRequest];
NSString *logMessage = [NSString stringWithFormat:@"%@", message];
[SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName];


if(self.version == 1) {
messagePayload = jsonData;
} else if (self.version == 2) {
// Serialize the RPC data into an NSData
SDLRPCPayload *rpcPayload = [[SDLRPCPayload alloc] init];
rpcPayload.rpcType = 0;
rpcPayload.functionID = [[[[SDLFunctionID alloc] init] getFunctionID:[rpcRequest getFunctionName]] intValue];
rpcPayload.correlationID = [rpcRequest.correlationID intValue];
rpcPayload.jsonData = jsonData;
rpcPayload.binaryData = rpcRequest.bulkData;
messagePayload = rpcPayload.data;

// Build the message payload. Include the binary header if necessary
switch (self.version) {
case 1: {
// No binary header in version 1
messagePayload = jsonData;
} break;
case 2: // Fallthrough
case 3:
case 4:
default: {
// Build a binary header
// Serialize the RPC data into an NSData
SDLRPCPayload *rpcPayload = [[SDLRPCPayload alloc] init];
rpcPayload.functionID = [[[[SDLFunctionID alloc] init] getFunctionID:[message getFunctionName]] intValue];
rpcPayload.jsonData = jsonData;
rpcPayload.binaryData = message.bulkData;

// If it's a request or a response, we need to pull out the correlation ID, so we'll upcast
if ([message isKindOfClass:SDLRPCRequest.class]) {
rpcPayload.rpcType = SDLRPCMessageTypeRequest;
rpcPayload.correlationID = [((SDLRPCRequest *)message).correlationID intValue];
} else if ([message isKindOfClass:SDLRPCResponse.class]) {
rpcPayload.rpcType = SDLRPCMessageTypeResponse;
rpcPayload.correlationID = [((SDLRPCResponse *)message).correlationID intValue];
} else {
rpcPayload.rpcType = SDLRPCMessageTypeNotification;
}

NSAssert(NO, @"sendRPCMessage:withType: must handle additional versions");
} break;
}

//

// Build the protocol level header & message
//
SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:self.version];
header.frameType = SDLFrameType_Single;
header.serviceType = SDLServiceType_RPC;
header.frameData = SDLFrameData_SingleFrame;
header.sessionID = self.sessionID;
header.bytesInPayload = (UInt32)messagePayload.length;

// V2+ messages need to have message ID property set.
if (self.version >= 2) {
[((SDLV2ProtocolHeader*)header) setMessageID:++_messageID];
}


SDLProtocolMessage *message = [SDLProtocolMessage messageWithHeader:header andPayload:messagePayload];


//

SDLProtocolMessage *protocolMessage = [SDLProtocolMessage messageWithHeader:header andPayload:messagePayload];

// See if the message is small enough to send in one transmission.
// If not, break it up into smaller messages and send.
//
if (message.size < MAX_TRANSMISSION_SIZE)
if (protocolMessage.size < MAX_TRANSMISSION_SIZE)
{
[self logRPCSend:message];
[self sendDataToTransport:message.data withPriority:SDLServiceType_RPC];
[self logRPCSend:protocolMessage];
[self sendDataToTransport:protocolMessage.data withPriority:SDLServiceType_RPC];
}
else
{
NSArray *messages = [SDLProtocolMessageDisassembler disassemble:message withLimit:MAX_TRANSMISSION_SIZE];
NSArray *messages = [SDLProtocolMessageDisassembler disassemble:protocolMessage withLimit:MAX_TRANSMISSION_SIZE];
for (SDLProtocolMessage *smallerMessage in messages) {
[self logRPCSend:smallerMessage];
[self sendDataToTransport:smallerMessage.data withPriority:SDLServiceType_RPC];
}

}
}

// SDLRPCRequest in from app -> SDLProtocolMessage out to transport layer.
- (void)sendRPCRequest:(SDLRPCRequest *)rpcRequest {
[self sendRPC:rpcRequest];
}

- (void)logRPCSend:(SDLProtocolMessage *)message {
Expand Down
27 changes: 17 additions & 10 deletions sdl_ios/SmartDeviceLink/SDLProtocolHeader.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,27 @@ - (NSString *)description {
return description;
}


+ (SDLProtocolHeader *)headerForVersion:(UInt8)version {
if (version == 1) {
return [[SDLV1ProtocolHeader alloc] init];
}

if (version == 2) {
return [[SDLV2ProtocolHeader alloc] init];
}

// TODO: some error handling here if unknown version is asked for,
// but that needs to be balanced against future proofing. i.e. V3.
// Requirements around V3 are as yet undefined so give a V2 header
return [[SDLV2ProtocolHeader alloc] init];
// lol wat.
switch (version) {
case 0: {
return [[SDLV2ProtocolHeader alloc] initWithVersion:2];
} break;
case 1: {
return [[SDLV1ProtocolHeader alloc] init];
} break;
case 2:
case 3:
case 4: {
return [[SDLV2ProtocolHeader alloc] initWithVersion:version];
} break;
default: {
return [[SDLV2ProtocolHeader alloc] initWithVersion:2];
} break;
}
}

@end
2 changes: 1 addition & 1 deletion sdl_ios/SmartDeviceLink/SDLProtocolMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ - (NSString *)description {
// If it's an RPC, provide greater detail
if (self.header.serviceType == SDLServiceType_RPC && (self.header.frameType == SDLFrameType_Single)) {
// version of RPC Message determines how we access the info.
if (self.header.version == 2) {
if (self.header.version >= 2) {
SDLRPCPayload *rpcPayload = [SDLRPCPayload rpcPayloadWithData:self.payload];
if (rpcPayload) {
NSString *functionName = [[[SDLFunctionID alloc] init] getFunctionName:rpcPayload.functionID];
Expand Down
9 changes: 6 additions & 3 deletions sdl_ios/SmartDeviceLink/SDLProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@
-(void) dispose;
-(void) addDelegate:(NSObject<SDLProxyListener>*) delegate;

-(void) sendRPCRequest:(SDLRPCMessage*) msg;
-(void) handleRpcMessage:(NSDictionary*) msg;
-(void) sendRPC:(SDLRPCMessage *)message;
-(void) sendRPCRequest:(SDLRPCMessage*) msg __deprecated_msg("use sendRPC: instead");

-(void) handleRPCDictionary:(NSDictionary *)message;
-(void) handleRpcMessage:(NSDictionary*) msg __deprecated_msg("use handleRPCDictionary: instead");

-(NSString*) getProxyVersion;

Expand All @@ -43,7 +46,7 @@
-(NSObject<SDLTransport>*)getTransport;
-(NSObject<SDLInterfaceProtocol>*)getProtocol;

- (void)putFileStream:(NSInputStream*)inputStream :(SDLPutFile*)putFileRPCRequest __deprecated_msg("use -putFileStream:withRequest: instead");
- (void)putFileStream:(NSInputStream*)inputStream withRequest:(SDLPutFile*)putFileRPCRequest;
- (void)putFileStream:(NSInputStream*)inputStream :(SDLPutFile*)putFileRPCRequest __deprecated_msg("use -putFileStream:withRequest: instead");

@end
Loading