diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2017-06-29 13:13:44 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2017-06-29 13:13:44 -0400 |
commit | 6a9bdbc027f53e9e150b62ed8c3fbed61a1bcf42 (patch) | |
tree | 10fd8ac7ddb2cc23de829035931db6d313c5d04d | |
parent | a66f3e41981d0887c9b14b304ef0e4791be6d585 (diff) | |
download | sdl_ios-6a9bdbc027f53e9e150b62ed8c3fbed61a1bcf42.tar.gz |
Update example app with a GetVehicleData command
3 files changed, 71 insertions, 38 deletions
diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj index 5ef3ec39d..64651d7d7 100644 --- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj +++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj @@ -4301,6 +4301,7 @@ TargetAttributes = { 5D4019AE1A76EC350006B0C2 = { CreatedOnToolsVersion = 6.1.1; + DevelopmentTeam = NCVC2MHU7M; SystemCapabilities = { com.apple.BackgroundModes = { enabled = 1; @@ -5177,7 +5178,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = NCVC2MHU7M; INFOPLIST_FILE = "$(SRCROOT)/SmartDeviceLink_Example/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -5191,7 +5192,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = NCVC2MHU7M; INFOPLIST_FILE = "$(SRCROOT)/SmartDeviceLink_Example/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/SmartDeviceLink_Example/Base.lproj/ConnectionTCPTableViewController.storyboard b/SmartDeviceLink_Example/Base.lproj/ConnectionTCPTableViewController.storyboard index 63324d6de..6f06da1a2 100644 --- a/SmartDeviceLink_Example/Base.lproj/ConnectionTCPTableViewController.storyboard +++ b/SmartDeviceLink_Example/Base.lproj/ConnectionTCPTableViewController.storyboard @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="l5Q-ZP-1BO"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="l5Q-ZP-1BO"> <device id="retina4_7" orientation="portrait"> <adaptation id="fullscreen"/> </device> <dependencies> <deployment identifier="iOS"/> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/> <capability name="Constraints to layout margins" minToolsVersion="6.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> @@ -28,13 +28,13 @@ <rect key="frame" x="0.0" y="0.0" width="375" height="43"/> <autoresizingMask key="autoresizingMask"/> <subviews> - <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="IP Address" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="xqM-s4-9RV"> + <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="IP Address" clearsOnBeginEditing="YES" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="xqM-s4-9RV"> <rect key="frame" x="8" y="0.0" width="359" height="44"/> <constraints> <constraint firstAttribute="height" constant="44" id="5Pw-mh-x83"/> </constraints> <fontDescription key="fontDescription" type="system" pointSize="17"/> - <textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" keyboardType="decimalPad"/> + <textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" keyboardType="URL"/> </textField> </subviews> <constraints> diff --git a/SmartDeviceLink_Example/Classes/ProxyManager.m b/SmartDeviceLink_Example/Classes/ProxyManager.m index 7b08c4f2d..126ea0875 100644 --- a/SmartDeviceLink_Example/Classes/ProxyManager.m +++ b/SmartDeviceLink_Example/Classes/ProxyManager.m @@ -72,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN [self sdlex_updateProxyState:ProxyStateSearchingForConnection]; // Check for previous instance of sdlManager if (self.sdlManager) { return; } - SDLLifecycleConfiguration *lifecycleConfig = [self.class setLifecycleConfigurationPropertiesOnConfiguration:[SDLLifecycleConfiguration defaultConfigurationWithAppName:SDLAppName appId:SDLAppId]]; + SDLLifecycleConfiguration *lifecycleConfig = [self.class sdlex_setLifecycleConfigurationPropertiesOnConfiguration:[SDLLifecycleConfiguration defaultConfigurationWithAppName:SDLAppName appId:SDLAppId]]; // Assume this is production and disable logging lifecycleConfig.logFlags = SDLLogOutputNone; @@ -87,7 +87,7 @@ NS_ASSUME_NONNULL_BEGIN [self sdlex_updateProxyState:ProxyStateSearchingForConnection]; // Check for previous instance of sdlManager if (self.sdlManager) { return; } - SDLLifecycleConfiguration *lifecycleConfig = [self.class setLifecycleConfigurationPropertiesOnConfiguration:[SDLLifecycleConfiguration debugConfigurationWithAppName:SDLAppName appId:SDLAppId ipAddress:[Preferences sharedPreferences].ipAddress port:[Preferences sharedPreferences].port]]; + SDLLifecycleConfiguration *lifecycleConfig = [self.class sdlex_setLifecycleConfigurationPropertiesOnConfiguration:[SDLLifecycleConfiguration debugConfigurationWithAppName:SDLAppName appId:SDLAppId ipAddress:[Preferences sharedPreferences].ipAddress port:[Preferences sharedPreferences].port]]; SDLConfiguration *config = [SDLConfiguration configurationWithLifecycle:lifecycleConfig lockScreen:[SDLLockScreenConfiguration enabledConfiguration]]; self.sdlManager = [[SDLManager alloc] initWithConfiguration:config delegate:self]; @@ -105,10 +105,10 @@ NS_ASSUME_NONNULL_BEGIN [weakSelf sdlex_updateProxyState:ProxyStateConnected]; - [weakSelf setupPermissionsCallbacks]; + [weakSelf sdlex_setupPermissionsCallbacks]; if ([weakSelf.sdlManager.hmiLevel isEqualToEnum:[SDLHMILevel FULL]]) { - [weakSelf showInitialData]; + [weakSelf sdlex_showInitialData]; } }]; } @@ -120,22 +120,28 @@ NS_ASSUME_NONNULL_BEGIN self.sdlManager = nil; } -- (void)showInitialData { + +#pragma mark - Helpers + +- (void)sdlex_showInitialData { if ((self.initialShowState != SDLHMIInitialShowStateDataAvailable) || ![self.sdlManager.hmiLevel isEqualToEnum:[SDLHMILevel FULL]]) { return; } + + SDLSetDisplayLayout *displayLayout = [[SDLSetDisplayLayout alloc] initWithLayout:[[SDLPredefinedLayout NON_MEDIA] value]]; + [self.sdlManager sendRequest:displayLayout]; self.initialShowState = SDLHMIInitialShowStateShown; SDLShow* show = [[SDLShow alloc] initWithMainField1:@"SDL" mainField2:@"Test App" alignment:[SDLTextAlignment CENTERED]]; - SDLSoftButton *pointingSoftButton = [self.class pointingSoftButtonWithManager:self.sdlManager]; + SDLSoftButton *pointingSoftButton = [self.class sdlex_pointingSoftButtonWithManager:self.sdlManager]; show.softButtons = [@[pointingSoftButton] mutableCopy]; - show.graphic = [self.class mainGraphicImage]; + show.graphic = [self.class sdlex_mainGraphicImage]; [self.sdlManager sendRequest:show]; } -- (void)setupPermissionsCallbacks { +- (void)sdlex_setupPermissionsCallbacks { // This will tell you whether or not you can use the Show RPC right at this moment BOOL isAvailable = [self.sdlManager.permissionManager isRPCAllowed:@"Show"]; NSLog(@"Show is allowed? %@", @(isAvailable)); @@ -159,13 +165,14 @@ NS_ASSUME_NONNULL_BEGIN }]; } -+ (SDLLifecycleConfiguration *)setLifecycleConfigurationPropertiesOnConfiguration:(SDLLifecycleConfiguration *)config { ++ (SDLLifecycleConfiguration *)sdlex_setLifecycleConfigurationPropertiesOnConfiguration:(SDLLifecycleConfiguration *)config { SDLArtwork *appIconArt = [SDLArtwork persistentArtworkWithImage:[UIImage imageNamed:@"AppIcon60x60@2x"] name:@"AppIcon" asImageFormat:SDLArtworkImageFormatPNG]; config.shortAppName = @"SDL Example"; config.appIcon = appIconArt; config.voiceRecognitionCommandNames = @[@"S D L Example"]; config.ttsName = [SDLTTSChunk textChunksFromString:config.shortAppName]; + return config; } @@ -179,7 +186,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - RPC builders -+ (SDLAddCommand *)speakNameCommandWithManager:(SDLManager *)manager { ++ (SDLAddCommand *)sdlex_speakNameCommandWithManager:(SDLManager *)manager { NSString *commandName = @"Speak App Name"; SDLMenuParams *commandMenuParams = [[SDLMenuParams alloc] init]; @@ -191,13 +198,13 @@ NS_ASSUME_NONNULL_BEGIN speakNameCommand.cmdID = @0; speakNameCommand.handler = ^void(SDLOnCommand *notification) { - [manager sendRequest:[self.class appNameSpeak]]; + [manager sendRequest:[self.class sdlex_appNameSpeak]]; }; return speakNameCommand; } -+ (SDLAddCommand *)interactionSetCommandWithManager:(SDLManager *)manager { ++ (SDLAddCommand *)sdlex_interactionSetCommandWithManager:(SDLManager *)manager { NSString *commandName = @"Perform Interaction"; SDLMenuParams *commandMenuParams = [[SDLMenuParams alloc] init]; @@ -211,34 +218,50 @@ NS_ASSUME_NONNULL_BEGIN // NOTE: You may want to preload your interaction sets, because they can take a while for the remote system to process. We're going to ignore our own advice here. __weak typeof(self) weakSelf = self; performInteractionCommand.handler = ^void(SDLOnCommand *notification) { - [weakSelf sendPerformOnlyChoiceInteractionWithManager:manager]; + [weakSelf sdlex_sendPerformOnlyChoiceInteractionWithManager:manager]; }; return performInteractionCommand; } -+ (SDLSpeak *)appNameSpeak { ++ (SDLAddCommand *)sdlex_vehicleDataCommandWithManager:(SDLManager *)manager { + SDLMenuParams *commandMenuParams = [[SDLMenuParams alloc] init]; + commandMenuParams.menuName = @"Get Vehicle Data"; + + SDLAddCommand *getVehicleDataCommand = [[SDLAddCommand alloc] init]; + getVehicleDataCommand.vrCommands = [NSMutableArray arrayWithObject:@"Get Vehicle Data"]; + getVehicleDataCommand.menuParams = commandMenuParams; + getVehicleDataCommand.cmdID = @2; + + getVehicleDataCommand.handler = ^void(SDLOnCommand *notification) { + [ProxyManager sdlex_sendGetVehicleDataWithManager:manager]; + }; + + return getVehicleDataCommand; +} + ++ (SDLSpeak *)sdlex_appNameSpeak { SDLSpeak *speak = [[SDLSpeak alloc] init]; speak.ttsChunks = [SDLTTSChunk textChunksFromString:@"S D L Example App"]; return speak; } -+ (SDLSpeak *)goodJobSpeak { ++ (SDLSpeak *)sdlex_goodJobSpeak { SDLSpeak *speak = [[SDLSpeak alloc] init]; speak.ttsChunks = [SDLTTSChunk textChunksFromString:@"Good Job"]; return speak; } -+ (SDLSpeak *)youMissedItSpeak { ++ (SDLSpeak *)sdlex_youMissedItSpeak { SDLSpeak *speak = [[SDLSpeak alloc] init]; speak.ttsChunks = [SDLTTSChunk textChunksFromString:@"You missed it"]; return speak; } -+ (SDLCreateInteractionChoiceSet *)createOnlyChoiceInteractionSet { ++ (SDLCreateInteractionChoiceSet *)sdlex_createOnlyChoiceInteractionSet { SDLCreateInteractionChoiceSet *createInteractionSet = [[SDLCreateInteractionChoiceSet alloc] init]; createInteractionSet.interactionChoiceSetID = @0; @@ -253,7 +276,7 @@ NS_ASSUME_NONNULL_BEGIN return createInteractionSet; } -+ (void)sendPerformOnlyChoiceInteractionWithManager:(SDLManager *)manager { ++ (void)sdlex_sendPerformOnlyChoiceInteractionWithManager:(SDLManager *)manager { SDLPerformInteraction *performOnlyChoiceInteraction = [[SDLPerformInteraction alloc] init]; performOnlyChoiceInteraction.initialText = @"Choose the only one! You have 5 seconds..."; performOnlyChoiceInteraction.initialPrompt = [SDLTTSChunk textChunksFromString:@"Choose it"]; @@ -277,7 +300,7 @@ NS_ASSUME_NONNULL_BEGIN }]; } -+ (SDLSoftButton *)pointingSoftButtonWithManager:(SDLManager *)manager { ++ (SDLSoftButton *)sdlex_pointingSoftButtonWithManager:(SDLManager *)manager { SDLSoftButton* softButton = [[SDLSoftButton alloc] initWithHandler:^(__kindof SDLRPCNotification *notification) { if ([notification isKindOfClass:[SDLOnButtonPress class]]) { SDLAlert* alert = [[SDLAlert alloc] init]; @@ -297,7 +320,7 @@ NS_ASSUME_NONNULL_BEGIN return softButton; } -+ (SDLImage *)mainGraphicImage { ++ (SDLImage *)sdlex_mainGraphicImage { SDLImage* image = [[SDLImage alloc] init]; image.imageType = SDLImageType.DYNAMIC; image.value = MainGraphicArtworkName; @@ -305,26 +328,35 @@ NS_ASSUME_NONNULL_BEGIN return image; } ++ (void)sdlex_sendGetVehicleDataWithManager:(SDLManager *)manager { + SDLGetVehicleData *getVehicleData = [[SDLGetVehicleData alloc] initWithAccelerationPedalPosition:YES airbagStatus:YES beltStatus:YES bodyInformation:YES clusterModeStatus:YES deviceStatus:YES driverBraking:YES eCallInfo:YES emergencyEvent:YES engineTorque:YES externalTemperature:YES fuelLevel:YES fuelLevelState:YES gps:YES headLampStatus:YES instantFuelConsumption:YES myKey:YES odometer:YES prndl:YES rpm:YES speed:YES steeringWheelAngle:YES tirePressure:YES vin:YES wiperStatus:YES]; + + [manager sendRequest:getVehicleData withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + NSLog(@"vehicle data response: %@", response); + }]; +} + -#pragma mark - Files / Artwork +#pragma mark - Files / Artwork -+ (SDLArtwork *)pointingSoftButtonArtwork { ++ (SDLArtwork *)sdlex_pointingSoftButtonArtwork { return [SDLArtwork artworkWithImage:[UIImage imageNamed:@"sdl_softbutton_icon"] name:PointingSoftButtonArtworkName asImageFormat:SDLArtworkImageFormatPNG]; } -+ (SDLArtwork *)mainGraphicArtwork { ++ (SDLArtwork *)sdlex_mainGraphicArtwork { return [SDLArtwork artworkWithImage:[UIImage imageNamed:@"sdl_logo_green"] name:MainGraphicArtworkName asImageFormat:SDLArtworkImageFormatPNG]; } -- (void)prepareRemoteSystem { - [self.sdlManager sendRequest:[self.class speakNameCommandWithManager:self.sdlManager]]; - [self.sdlManager sendRequest:[self.class interactionSetCommandWithManager:self.sdlManager]]; +- (void)sdlex_prepareRemoteSystem { + [self.sdlManager sendRequest:[self.class sdlex_speakNameCommandWithManager:self.sdlManager]]; + [self.sdlManager sendRequest:[self.class sdlex_interactionSetCommandWithManager:self.sdlManager]]; + [self.sdlManager sendRequest:[self.class sdlex_vehicleDataCommandWithManager:self.sdlManager]]; dispatch_group_t dataDispatchGroup = dispatch_group_create(); dispatch_group_enter(dataDispatchGroup); dispatch_group_enter(dataDispatchGroup); - [self.sdlManager.fileManager uploadFile:[self.class mainGraphicArtwork] completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) { + [self.sdlManager.fileManager uploadFile:[self.class sdlex_mainGraphicArtwork] completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) { dispatch_group_leave(dataDispatchGroup); if (success == NO) { @@ -334,7 +366,7 @@ NS_ASSUME_NONNULL_BEGIN }]; dispatch_group_enter(dataDispatchGroup); - [self.sdlManager.fileManager uploadFile:[self.class pointingSoftButtonArtwork] completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) { + [self.sdlManager.fileManager uploadFile:[self.class sdlex_pointingSoftButtonArtwork] completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) { dispatch_group_leave(dataDispatchGroup); if (success == NO) { @@ -344,7 +376,7 @@ NS_ASSUME_NONNULL_BEGIN }]; dispatch_group_enter(dataDispatchGroup); - [self.sdlManager sendRequest:[self.class createOnlyChoiceInteractionSet] withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { + [self.sdlManager sendRequest:[self.class sdlex_createOnlyChoiceInteractionSet] withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) { // Interaction choice set ready dispatch_group_leave(dataDispatchGroup); }]; @@ -352,7 +384,7 @@ NS_ASSUME_NONNULL_BEGIN dispatch_group_leave(dataDispatchGroup); dispatch_group_notify(dataDispatchGroup, dispatch_get_main_queue(), ^{ self.initialShowState = SDLHMIInitialShowStateDataAvailable; - [self showInitialData]; + [self sdlex_showInitialData]; }); } @@ -375,7 +407,7 @@ NS_ASSUME_NONNULL_BEGIN self.firstTimeState = SDLHMIFirstStateNonNone; // Send AddCommands - [self prepareRemoteSystem]; + [self sdlex_prepareRemoteSystem]; } if ([newLevel isEqualToEnum:[SDLHMILevel FULL]] && (self.firstTimeState != SDLHMIFirstStateFull)) { @@ -385,7 +417,7 @@ NS_ASSUME_NONNULL_BEGIN if ([newLevel isEqualToEnum:[SDLHMILevel FULL]]) { // We're always going to try to show the initial state, because if we've already shown it, it won't be shown, and we need to guard against some possible weird states - [self showInitialData]; + [self sdlex_showInitialData]; } } |