summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicoleYarroch <nicole@livio.io>2018-05-10 17:11:10 -0400
committerNicoleYarroch <nicole@livio.io>2018-05-10 17:11:10 -0400
commit77d8c679f194a7f898c4474651237c2e87495ea7 (patch)
tree0d2f04694a1651f3a05ac629b0d2e81dbcc12c0c
parent2ff3a1c98a5a72564f6a0d885ad2f7fd056e1738 (diff)
downloadsdl_ios-77d8c679f194a7f898c4474651237c2e87495ea7.tar.gz
Added documentation to Obj-C example app
Signed-off-by: NicoleYarroch <nicole@livio.io>
-rw-r--r--SmartDeviceLink_Example/AlertManager.m19
-rw-r--r--SmartDeviceLink_Example/AlertManager.swift10
-rw-r--r--SmartDeviceLink_Example/AudioManager.m43
-rw-r--r--SmartDeviceLink_Example/AudioManager.swift6
-rw-r--r--SmartDeviceLink_Example/Classes/ProxyManager.m112
-rw-r--r--SmartDeviceLink_Example/MenuManager.swift2
-rw-r--r--SmartDeviceLink_Example/ProxyManager.swift12
-rw-r--r--SmartDeviceLink_Example/VehicleDataManager.m39
-rw-r--r--SmartDeviceLink_Example/VehicleDataManager.swift13
9 files changed, 161 insertions, 95 deletions
diff --git a/SmartDeviceLink_Example/AlertManager.m b/SmartDeviceLink_Example/AlertManager.m
index 44fcf9557..cab877a5e 100644
--- a/SmartDeviceLink_Example/AlertManager.m
+++ b/SmartDeviceLink_Example/AlertManager.m
@@ -9,13 +9,28 @@
#import "AlertManager.h"
#import "SmartDeviceLink.h"
+NS_ASSUME_NONNULL_BEGIN
@implementation AlertManager
+/**
+ * Creates an alert with a single line of text
+ *
+ * @param textField1 The first line of a message to display in the alert
+ * @param textField2 The second line of a message to display in the alert
+ * @return An SDLAlert object
+ */
+ (SDLAlert *)alertWithMessage:(NSString *)textField1 textField2:(nullable NSString *)textField2 {
return [[SDLAlert alloc] initWithAlertText1:textField1 alertText2:textField2 duration:5000];
}
+/**
+ * Creates an alert with up to two lines of text and a close button that will dismiss the alert when tapped
+ *
+ * @param textField1 The first line of a message to display in the alert
+ * @param textField2 The second line of a message to display in the alert
+ * @return An SDLAlert object
+ */
+ (SDLAlert *)alertWithMessageAndCloseButton:(NSString *)textField1 textField2:(nullable NSString *)textField2 {
return [[SDLAlert alloc] initWithAlertText1:textField1 alertText2:textField2 alertText3:nil duration:5000 softButtons:@[[self sdlex_okSoftButton]]];
}
@@ -25,6 +40,6 @@
return okSoftButton;
}
-
-
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink_Example/AlertManager.swift b/SmartDeviceLink_Example/AlertManager.swift
index b4ecdad7d..c463e7d36 100644
--- a/SmartDeviceLink_Example/AlertManager.swift
+++ b/SmartDeviceLink_Example/AlertManager.swift
@@ -14,9 +14,11 @@ class AlertManager {
return SDLSoftButton(type: .text, text: "OK", image: nil, highlighted: true, buttonId: 1, systemAction: nil, handler: nil)
}
- /// Creates an alert with a single line of text
+ /// Creates an alert with one or two lines of text.
///
- /// - Parameter message: The message to display in the alert
+ /// - Parameters:
+ /// - textField1: The first line of a message to display in the alert
+ /// - textField2: The second line of a message to display in the alert
/// - Returns: An SDLAlert object
class func alertWithMessage(_ textField1: String, textField2: String? = nil) -> SDLAlert {
return SDLAlert(alertText1: textField1, alertText2: nil, alertText3: nil)
@@ -24,7 +26,9 @@ class AlertManager {
/// Creates an alert with up to two lines of text and a close button that will dismiss the alert when tapped
///
- /// - Parameter message: The message to display in the alert
+ /// - Parameters:
+ /// - textField1: The first line of a message to display in the alert
+ /// - textField2: The second line of a message to display in the alert
/// - Returns: An SDLAlert object
class func alertWithMessageAndCloseButton(_ textField1: String, textField2: String? = nil) -> SDLAlert {
return SDLAlert(alertText1: textField1, alertText2: textField2, alertText3: nil, duration: 5000, softButtons: [AlertManager.okSoftButton])
diff --git a/SmartDeviceLink_Example/AudioManager.m b/SmartDeviceLink_Example/AudioManager.m
index bf98ff010..6d1b66c48 100644
--- a/SmartDeviceLink_Example/AudioManager.m
+++ b/SmartDeviceLink_Example/AudioManager.m
@@ -71,12 +71,18 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
+/**
+ * Resets the manager
+ */
- (void)stopManager {
self.audioRecordingState = AudioRecordingStateNotListening;
self.audioData = [NSMutableData data];
self.speechTranscription = @"";
}
+/**
+ * Starts an audio recording using the in-car microphone. During the recording, a pop-up will let the user know that they are being recorded. The pop-up is only dismissed when the recording stops.
+ */
- (void)startRecording {
if (self.speechRecognitionAuthState != SpeechRecognitionAuthStateAuthorized) {
SDLLogW(@"This app does not have permission to access the Speech Recognition API");
@@ -97,6 +103,9 @@ NS_ASSUME_NONNULL_BEGIN
[self.sdlManager sendRequest:performAudioPassThru withResponseHandler:self.audioPassThruEndedHandler];
}
+/**
+ * Manually stop an ongoing audio recording.
+ */
- (void)stopRecording {
if (self.audioRecordingState != AudioRecordingStateListening) { return; }
self.audioRecordingState = AudioRecordingStateNotListening;
@@ -107,6 +116,9 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Audio Pass Thru Notifications
+/**
+ * SDL streams the audio data as it is collected.
+ */
- (nullable void (^)(NSData * _Nullable))audioDataReceivedHandler {
if (!_audioDataReceivedHandler) {
__weak typeof(self) weakSelf = self;
@@ -117,7 +129,7 @@ NS_ASSUME_NONNULL_BEGIN
weakSelf.audioRecordingState = AudioRecordingStateListening;
}
- AVAudioPCMBuffer *buffer = [weakSelf sdlex_convertDataToPCMFormattedAudio:[NSMutableData dataWithData:audioData]];
+ AVAudioPCMBuffer *buffer = [weakSelf sdlex_createPCMBufferWithData:[NSMutableData dataWithData:audioData]];
if (buffer == nil) { return; }
[weakSelf.speechRecognitionRequest appendAudioPCMBuffer:buffer];
};
@@ -126,6 +138,11 @@ NS_ASSUME_NONNULL_BEGIN
return _audioDataReceivedHandler;
}
+/**
+ * Called when `PerformAudioPassThru` request times out or when a `EndAudioPassThru` request is sent
+ *
+ * @return A SDLResponseHandler
+ */
- (nullable SDLResponseHandler)audioPassThruEndedHandler {
if (!_audioPassThruEndedHandler) {
__weak typeof(self) weakSelf = self;
@@ -155,7 +172,13 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Audio Data Conversion
-- (AVAudioPCMBuffer *)sdlex_convertDataToPCMFormattedAudio:(NSMutableData *)data {
+/**
+ * Converts the audio data to PCM formatted audio that can be passed, if desired, to the iOS SFSpeech framework (SDL does not provide speech recognition, however the SFSpeech framework or another third party library can be used for speech recognition). The audio format and sample rate should match those set in the `SDLPerformAudioPassThru`.
+ *
+ * @param data The audio data
+ * @return An AVAudioPCMBuffer object
+ */
+- (AVAudioPCMBuffer *)sdlex_createPCMBufferWithData:(NSMutableData *)data {
[self.audioData appendData:data];
AVAudioFormat *audioFormat = [[AVAudioFormat alloc] initWithCommonFormat:AVAudioPCMFormatInt16 sampleRate:16000 channels:1 interleaved:NO];
@@ -169,6 +192,10 @@ NS_ASSUME_NONNULL_BEGIN
}
#pragma mark - Speech Recognition
+
+/**
+ * Configures speech recognition
+ */
- (void)sdlex_startSpeechRecognitionTask {
self.speechRecognitionRequest = [[SFSpeechAudioBufferRecognitionRequest alloc] init];
@@ -193,6 +220,9 @@ NS_ASSUME_NONNULL_BEGIN
}];
}
+/**
+ * Cleans up a speech detection session that has ended
+ */
- (void)sdlex_stopSpeechRecognitionTask {
self.audioRecordingState = AudioRecordingStateNotListening;
self.audioData = [NSMutableData data];
@@ -209,6 +239,12 @@ NS_ASSUME_NONNULL_BEGIN
self.speechRecognitionAuthState = [AudioManager sdlex_checkSpeechRecognizerAuth:speechRecognizer];
}
+/**
+ * Checks the current authorization status of the Speech Recognition API. The user can change this status via the native Settings app.
+ *
+ * @param speechRecognizer The SFSpeechRecognizer
+ * @return The current authorization status
+ */
+ (SpeechRecognitionAuthState)sdlex_checkSpeechRecognizerAuth:(SFSpeechRecognizer *)speechRecognizer {
if (speechRecognizer == nil) {
return SpeechRecognitionAuthStateBadRegion;
@@ -221,6 +257,9 @@ NS_ASSUME_NONNULL_BEGIN
}
}
+/**
+ * Asks the user via an alert if they want to authorize this app to access the Speech Recognition API.
+ */
- (void)sdlex_requestSFSpeechRecognizerAuthorization {
[SFSpeechRecognizer requestAuthorization:^(SFSpeechRecognizerAuthorizationStatus status) {
dispatch_async(dispatch_get_main_queue(), ^{
diff --git a/SmartDeviceLink_Example/AudioManager.swift b/SmartDeviceLink_Example/AudioManager.swift
index 3e0bdd7b3..d1a1f07d2 100644
--- a/SmartDeviceLink_Example/AudioManager.swift
+++ b/SmartDeviceLink_Example/AudioManager.swift
@@ -49,6 +49,7 @@ class AudioManager: NSObject {
}
}
+ /// Resets the manager to its default values
func stopManager() {
audioRecordingState = .notListening
audioData = Data()
@@ -75,7 +76,7 @@ class AudioManager: NSObject {
sdlManager.send(request: performAudioPassThru, responseHandler: audioPassThruEndedHandler)
}
- /// Manually stop an on-going audio recording.
+ /// Manually stop an ongoing audio recording.
func stopRecording() {
guard audioRecordingState == .listening else { return }
audioRecordingState = .notListening
@@ -103,8 +104,6 @@ private extension AudioManager {
}
/// Called when `PerformAudioPassThru` request times out or when a `EndAudioPassThru` request is sent
- ///
- /// - Parameter response: A SDLRPCNotificationNotification notification
var audioPassThruEndedHandler: SDLResponseHandler? {
return { [weak self] (request, response, error) in
guard let response = response else { return }
@@ -148,6 +147,7 @@ private extension AudioManager {
@available(iOS 10.0, *)
private extension AudioManager {
+ /// Configures speech recognition
func startSpeechRecognitionTask() {
speechRecognitionRequest = SFSpeechAudioBufferRecognitionRequest()
guard let speechRecognitionRequest = speechRecognitionRequest, let speechRecognizer = speechRecognizer else {
diff --git a/SmartDeviceLink_Example/Classes/ProxyManager.m b/SmartDeviceLink_Example/Classes/ProxyManager.m
index 974eece25..6137aeb33 100644
--- a/SmartDeviceLink_Example/Classes/ProxyManager.m
+++ b/SmartDeviceLink_Example/Classes/ProxyManager.m
@@ -3,6 +3,7 @@
// SmartDeviceLink-iOS
#import "AppConstants.h"
+#import "AlertManager.h"
#import "AudioManager.h"
#import "Preferences.h"
#import "ProxyManager.h"
@@ -240,66 +241,44 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - RPC builders
-+ (SDLSpeak *)sdlex_appNameSpeak {
- SDLSpeak *speak = [[SDLSpeak alloc] init];
- speak.ttsChunks = [SDLTTSChunk textChunksFromString:ExampleAppNameTTS];
+#pragma mark Perform Interaction Choice Sets
+static UInt32 choiceSetId = 100;
- return speak;
++ (NSArray<SDLChoice *> *)sdlex_createChoiceSet {
+ SDLChoice *firstChoice = [[SDLChoice alloc] initWithId:1 menuName:PICSFirstChoice vrCommands:@[PICSFirstChoice]];
+ SDLChoice *secondChoice = [[SDLChoice alloc] initWithId:2 menuName:PICSSecondChoice vrCommands:@[PICSSecondChoice]];
+ SDLChoice *thirdChoice = [[SDLChoice alloc] initWithId:3 menuName:PICSThirdChoice vrCommands:@[PICSThirdChoice]];
+ return @[firstChoice, secondChoice, thirdChoice];
}
-+ (SDLSpeak *)sdlex_goodJobSpeak {
- SDLSpeak *speak = [[SDLSpeak alloc] init];
- speak.ttsChunks = [SDLTTSChunk textChunksFromString:TTSGoodJob];
-
- return speak;
++ (SDLPerformInteraction *)sdlex_createPerformInteraction {
+ SDLPerformInteraction *performInteraction = [[SDLPerformInteraction alloc] initWithInitialPrompt:PICSInitialPrompt initialText:PICSInitialText interactionChoiceSetIDList:@[@(choiceSetId)] helpPrompt:PICSHelpPrompt timeoutPrompt:PICSTimeoutPrompt interactionMode:SDLInteractionModeBoth timeout:10000];
+ performInteraction.interactionLayout = SDLLayoutModeListOnly;
+ return performInteraction;
}
-+ (SDLSpeak *)sdlex_youMissedItSpeak {
- SDLSpeak *speak = [[SDLSpeak alloc] init];
- speak.ttsChunks = [SDLTTSChunk textChunksFromString:TTSYouMissed];
++ (void)sdlex_showPerformInteractionChoiceSetWithManager:(SDLManager *)manager {
+ [manager sendRequest:[self sdlex_createPerformInteraction] withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) {
+ if (response.resultCode != SDLResultSuccess) {
+ SDLLogE(@"The Show Perform Interaction Choice Set request failed: %@", error.localizedDescription);
+ return;
+ }
- return speak;
+ if ([response.resultCode isEqualToEnum:SDLResultTimedOut]) {
+ // The menu timed out before the user could select an item
+ [manager sendRequest:[[SDLSpeak alloc] initWithTTS:TTSGoodJob]];
+ } else if ([response.resultCode isEqualToEnum:SDLResultSuccess]) {
+ // The user selected an item in the menu
+ [manager sendRequest:[[SDLSpeak alloc] initWithTTS:TTSYouMissed]];
+ }
+ }];
}
+ (SDLCreateInteractionChoiceSet *)sdlex_createOnlyChoiceInteractionSet {
- SDLCreateInteractionChoiceSet *createInteractionSet = [[SDLCreateInteractionChoiceSet alloc] init];
- createInteractionSet.interactionChoiceSetID = @0;
-
- NSString *theOnlyChoiceName = @"The Only Choice";
- SDLChoice *theOnlyChoice = [[SDLChoice alloc] init];
- theOnlyChoice.choiceID = @0;
- theOnlyChoice.menuName = theOnlyChoiceName;
- theOnlyChoice.vrCommands = @[theOnlyChoiceName];
-
- createInteractionSet.choiceSet = @[theOnlyChoice];
-
- return createInteractionSet;
+ return [[SDLCreateInteractionChoiceSet alloc] initWithId:choiceSetId choiceSet:[self sdlex_createChoiceSet]];
}
-+ (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"];
- performOnlyChoiceInteraction.interactionMode = SDLInteractionModeBoth;
- performOnlyChoiceInteraction.interactionChoiceSetIDList = @[@0];
- performOnlyChoiceInteraction.helpPrompt = [SDLTTSChunk textChunksFromString:@"Do it"];
- performOnlyChoiceInteraction.timeoutPrompt = [SDLTTSChunk textChunksFromString:@"Too late"];
- performOnlyChoiceInteraction.timeout = @5000;
- performOnlyChoiceInteraction.interactionLayout = SDLLayoutModeListOnly;
-
- [manager sendRequest:performOnlyChoiceInteraction withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLPerformInteractionResponse * _Nullable response, NSError * _Nullable error) {
- SDLLogD(@"Perform Interaction fired");
- if ((response == nil) || (error != nil)) {
- SDLLogE(@"Something went wrong, no perform interaction response: %@", error);
- }
-
- if ([response.choiceID isEqualToNumber:@0]) {
- [manager sendRequest:[self sdlex_goodJobSpeak]];
- } else {
- [manager sendRequest:[self sdlex_youMissedItSpeak]];
- }
- }];
-}
+# pragma mark Soft buttons
- (NSArray<SDLSoftButtonObject *> *)sdlex_softButtons {
SDLSoftButtonState *alertImageAndTextState = [[SDLSoftButtonState alloc] initWithStateName:AlertSoftButtonImageState text:AlertSoftButtonText image:[UIImage imageNamed:CarIconImageName]];
@@ -309,9 +288,7 @@ NS_ASSUME_NONNULL_BEGIN
SDLSoftButtonObject *alertSoftButton = [[SDLSoftButtonObject alloc] initWithName:AlertSoftButton states:@[alertImageAndTextState, alertTextState] initialStateName:alertImageAndTextState.name handler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent) {
if (buttonPress == nil) { return; }
- SDLAlert* alert = [[SDLAlert alloc] init];
- alert.alertText1 = @"You pushed the soft button!";
- [weakself.sdlManager sendRequest:alert];
+ [weakself.sdlManager sendRequest:[AlertManager alertWithMessageAndCloseButton:@"You pushed the soft button!" textField2:nil]];
SDLLogD(@"Star icon soft button press fired");
}];
@@ -357,36 +334,21 @@ NS_ASSUME_NONNULL_BEGIN
return @[alertSoftButton, toggleButton, textButton, imagesButton];
}
-+ (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) {
- SDLLogD(@"vehicle data response: %@", response);
- }];
-}
-
-+ (void)sdlex_sendDialNumberWithManager:(SDLManager *)manager {
- SDLDialNumber *dialNumber = [[SDLDialNumber alloc] initWithNumber:@"5555555555"];
- [manager sendRequest:dialNumber withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) {
- SDLLogD(@"Dial number response: %@", response);
- }];
-}
-
- (void)sdlex_prepareRemoteSystem {
SDLCreateInteractionChoiceSet *choiceSet = [self.class sdlex_createOnlyChoiceInteractionSet];
[self.sdlManager sendRequest:choiceSet];
__weak typeof(self) weakself = self;
SDLMenuCell *speakCell = [[SDLMenuCell alloc] initWithTitle:ACSpeakAppNameMenuName icon:[SDLArtwork artworkWithImage:[UIImage imageNamed:SpeakBWIconImageName] asImageFormat:SDLArtworkImageFormatPNG] voiceCommands:@[ACSpeakAppNameMenuName] handler:^(SDLTriggerSource _Nonnull triggerSource) {
- [weakself.sdlManager sendRequest:[ProxyManager sdlex_appNameSpeak]];
+ [weakself.sdlManager sendRequest:[[SDLSpeak alloc] initWithTTS:ExampleAppNameTTS]];
}];
SDLMenuCell *interactionSetCell = [[SDLMenuCell alloc] initWithTitle:ACShowChoiceSetMenuName icon:[SDLArtwork artworkWithImage:[UIImage imageNamed:MenuBWIconImageName] asImageFormat:SDLArtworkImageFormatPNG] voiceCommands:@[ACShowChoiceSetMenuName] handler:^(SDLTriggerSource _Nonnull triggerSource) {
- [ProxyManager sdlex_sendPerformOnlyChoiceInteractionWithManager:weakself.sdlManager];
+ [ProxyManager sdlex_showPerformInteractionChoiceSetWithManager:weakself.sdlManager];
}];
SDLMenuCell *getVehicleDataCell = [[SDLMenuCell alloc] initWithTitle:ACGetVehicleDataMenuName icon:[SDLArtwork artworkWithImage:[UIImage imageNamed:CarBWIconImageName] asImageFormat:SDLArtworkImageFormatPNG] voiceCommands:@[ACGetVehicleDataMenuName] handler:^(SDLTriggerSource _Nonnull triggerSource) {
- [ProxyManager sdlex_sendGetVehicleDataWithManager:weakself.sdlManager];
+ [VehicleDataManager getVehicleSpeedWithManager:weakself.sdlManager];
}];
SDLMenuCell *recordInCarMicrophoneAudio = [[SDLMenuCell alloc] initWithTitle:ACRecordInCarMicrophoneAudioMenuName icon:[SDLArtwork artworkWithImage:[UIImage imageNamed:SpeakBWIconImageName] asImageFormat:SDLArtworkImageFormatPNG] voiceCommands:@[ACRecordInCarMicrophoneAudioMenuName] handler:^(SDLTriggerSource _Nonnull triggerSource) {
@@ -434,17 +396,17 @@ NS_ASSUME_NONNULL_BEGIN
}
if ([newLevel isEqualToEnum:SDLHMILevelFull]) {
-
+ SDLLogD(@"The HMI level is full");
} else if ([newLevel isEqualToEnum:SDLHMILevelLimited]) {
-
+ SDLLogD(@"The HMI level is limited");
} else if ([newLevel isEqualToEnum:SDLHMILevelBackground]) {
-
+ SDLLogD(@"The HMI level is background");
} else if ([newLevel isEqualToEnum:SDLHMILevelNone]) {
-
+ SDLLogD(@"The HMI level is none");
}
if ([newLevel isEqualToEnum:SDLHMILevelFull]) {
- // 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
+ // 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 sdlex_showInitialData];
}
}
diff --git a/SmartDeviceLink_Example/MenuManager.swift b/SmartDeviceLink_Example/MenuManager.swift
index a843b8d98..5e4abbb10 100644
--- a/SmartDeviceLink_Example/MenuManager.swift
+++ b/SmartDeviceLink_Example/MenuManager.swift
@@ -153,7 +153,7 @@ private extension MenuManager {
class func showPerformInteractionChoiceSet(with manager: SDLManager) {
manager.send(request: createPerformInteraction()) { (_, response, error) in
guard response?.resultCode == .success else {
- SDLLog.e("The Show Perform Interaction Choice Set request failed: \(String(describing: error?.localizedDescription))")
+ SDLLog.e("The Show Perform Interaction Choice Set request failed: \(error?.localizedDescription ?? "no error")")
return
}
diff --git a/SmartDeviceLink_Example/ProxyManager.swift b/SmartDeviceLink_Example/ProxyManager.swift
index e74ccac3b..9f5e2eacb 100644
--- a/SmartDeviceLink_Example/ProxyManager.swift
+++ b/SmartDeviceLink_Example/ProxyManager.swift
@@ -166,6 +166,18 @@ extension ProxyManager: SDLManagerDelegate {
}
}
+ func systemContext(_ oldContext: SDLSystemContext?, didChangeToContext newContext: SDLSystemContext) {
+ switch newContext {
+ case SDLSystemContext.alert: break
+ case SDLSystemContext.hmiObscured: break
+ case SDLSystemContext.main: break
+ case SDLSystemContext.menu: break
+ case SDLSystemContext.voiceRecognitionSession: break
+ case SDLSystemContext.hmiObscured: break
+ default: break
+ }
+ }
+
/// Called when the audio state of the SDL app has changed. The audio state only needs to be monitored if the app is streaming audio.
///
/// - Parameters:
diff --git a/SmartDeviceLink_Example/VehicleDataManager.m b/SmartDeviceLink_Example/VehicleDataManager.m
index dd6bc1a41..7d8706b0c 100644
--- a/SmartDeviceLink_Example/VehicleDataManager.m
+++ b/SmartDeviceLink_Example/VehicleDataManager.m
@@ -42,12 +42,18 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
+/**
+ * Resets the manager to its default values
+ */
- (void)stopManager {
[self sdlex_resetOdometer];
}
#pragma mark - Subscribe Vehicle Data
+/**
+ * Subscribes to odometer data. You must subscribe to a notification with name `SDLDidReceiveVehicleData` to get the new data when the odometer data changes.
+ */
- (void)subscribeToVehicleOdometer {
SDLLogD(@"Subscribing to odometer vehicle data");
SDLSubscribeVehicleData *subscribeToVehicleOdometer = [[SDLSubscribeVehicleData alloc] init];
@@ -89,6 +95,9 @@ NS_ASSUME_NONNULL_BEGIN
}];
}
+/**
+ * Unsubscribes to vehicle odometer data.
+ */
- (void)unsubscribeToVehicleOdometer {
SDLUnsubscribeVehicleData *unsubscribeToVehicleOdometer = [[SDLUnsubscribeVehicleData alloc] init];
unsubscribeToVehicleOdometer.odometer = @YES;
@@ -98,7 +107,11 @@ NS_ASSUME_NONNULL_BEGIN
}];
}
-
+/**
+ * Notification containing the updated vehicle data.
+ *
+ * @param notification A SDLOnVehicleData notification
+ */
- (void)vehicleDataNotification:(SDLRPCNotificationNotification *)notification {
if (![notification.notification isKindOfClass:SDLOnVehicleData.class]) {
return;
@@ -111,12 +124,20 @@ NS_ASSUME_NONNULL_BEGIN
self.refreshUIHandler();
}
+/**
+ * Resets the odometer data
+ */
- (void)sdlex_resetOdometer {
self.vehicleOdometerData = [NSString stringWithFormat:@"%@: Unsubscribed", VehicleDataOdometerName];
}
#pragma mark - Get Vehicle Data
+/**
+ * Retreives the current vehicle speed
+ *
+ * @param manager The SDL manager
+ */
+ (void)getVehicleSpeedWithManager:(SDLManager *)manager {
SDLLogD(@"Checking if app has permission to access vehicle data...");
if (![manager.permissionManager isRPCAllowed:@"GetVehicleData"]) {
@@ -160,6 +181,12 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Phone Calls
+/**
+ * Checks if the head unit has the ability and/or permissions to make a phone call. If it does, the phone number is dialed.
+ *
+ * @param manager The SDL manager
+ * @param phoneNumber A phone number to dial
+ */
+ (void)checkPhoneCallCapabilityWithManager:(SDLManager *)manager phoneNumber:(NSString *)phoneNumber {
SDLLogD(@"Checking phone call capability");
[manager.systemCapabilityManager updateCapabilityType:SDLSystemCapabilityTypePhoneCall completionHandler:^(NSError * _Nullable error, SDLSystemCapabilityManager * _Nonnull systemCapabilityManager) {
@@ -170,14 +197,20 @@ NS_ASSUME_NONNULL_BEGIN
if (systemCapabilityManager.phoneCapability.dialNumberEnabled.boolValue) {
SDLLogD(@"Dialing phone number %@", phoneNumber);
- [self sdlex_dialPhoneNumberWithManager:manager phoneNumber:phoneNumber];
+ [self sdlex_dialPhoneNumber:phoneNumber manager:manager];
} else {
[manager sendRequest:[AlertManager alertWithMessageAndCloseButton:@"The dial number feature is unavailable for this head unit" textField2:nil]];
}
}];
}
-+ (void)sdlex_dialPhoneNumberWithManager:(SDLManager *)manager phoneNumber:(NSString *)phoneNumber {
+/**
+ * Dials a phone number.
+ *
+ * @param phoneNumber A phone number to dial
+ * @param manager The SDL manager
+ */
++ (void)sdlex_dialPhoneNumber:(NSString *)phoneNumber manager:(SDLManager *)manager {
SDLDialNumber *dialNumber = [[SDLDialNumber alloc] initWithNumber:phoneNumber];
[manager sendRequest:dialNumber withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) {
if (!response.resultCode) { return; }
diff --git a/SmartDeviceLink_Example/VehicleDataManager.swift b/SmartDeviceLink_Example/VehicleDataManager.swift
index 6d682e148..21361bdb6 100644
--- a/SmartDeviceLink_Example/VehicleDataManager.swift
+++ b/SmartDeviceLink_Example/VehicleDataManager.swift
@@ -33,7 +33,7 @@ class VehicleDataManager: NSObject {
// MARK: - Subscribe Vehicle Data
extension VehicleDataManager {
- /// Subscribes to odometer data. You must subscribe to notification with name `SDLDidReceiveVehicleData` to get the new data when the odometer data changes.
+ /// Subscribes to odometer data. You must subscribe to a notification with name `SDLDidReceiveVehicleData` to get the new data when the odometer data changes.
func subscribeToVehicleOdometer() {
let subscribeToVehicleOdometer = SDLSubscribeVehicleData()
subscribeToVehicleOdometer.odometer = true
@@ -69,7 +69,7 @@ extension VehicleDataManager {
}
}
- /// Unsubscribes to odometer data.
+ /// Unsubscribes to vehicle odometer data.
func unsubscribeToVehicleOdometer() {
let unsubscribeToVehicleOdometer = SDLUnsubscribeVehicleData()
unsubscribeToVehicleOdometer.odometer = true
@@ -79,9 +79,9 @@ extension VehicleDataManager {
}
}
- /// Notification with the updated vehicle data
+ /// Notification containing the updated vehicle data.
///
- /// - Parameter notification: SDLOnVehicleData notification
+ /// - Parameter notification: A SDLOnVehicleData notification
func vehicleDataNotification(_ notification: SDLRPCNotificationNotification) {
guard let handler = refreshUIHandler, let onVehicleData = notification.notification as? SDLOnVehicleData, let odometer = onVehicleData.odometer else {
return
@@ -91,12 +91,12 @@ extension VehicleDataManager {
handler()
}
+ /// Resets the odometer data
fileprivate func resetOdometer() {
vehicleOdometerData = "\(VehicleDataOdometerName): Unsubscribed"
}
}
-
// MARK: - Get Vehicle Data
extension VehicleDataManager {
@@ -152,6 +152,7 @@ extension VehicleDataManager {
/// Checks if the head unit has the ability and/or permissions to make a phone call. If it does, the phone number is dialed.
///
/// - Parameter manager: The SDL manager
+ /// - phoneNumber: A phone number to dial
class func checkPhoneCallCapability(manager: SDLManager, phoneNumber: String) {
SDLLog.d("Checking phone call capability")
manager.systemCapabilityManager.updateCapabilityType(.phoneCall, completionHandler: { (error, systemCapabilityManager) in
@@ -171,7 +172,7 @@ extension VehicleDataManager {
/// Dials a phone number.
///
/// - Parameters:
- /// - phoneNumber: A phone number
+ /// - phoneNumber: A phone number to dial
/// - manager: The SDL manager
private class func dialPhoneNumber(_ phoneNumber: String, manager: SDLManager) {
let dialNumber = SDLDialNumber(number: phoneNumber)