From 747c096685f30a8886111c9be88bb5ff12c0495b Mon Sep 17 00:00:00 2001 From: Philip Gregor Date: Fri, 27 Sep 2024 16:39:43 -0700 Subject: [PATCH] Addressed comments by sharadb-amazon --- .../casting/ConnectionExampleFragment.java | 4 +- .../support/CommissionerDeclaration.java | 60 ++++++++++++------- .../fragment_matter_connection_example.xml | 1 - .../TvCasting/MCConnectionExampleView.swift | 2 +- .../MCConnectionExampleViewModel.swift | 5 +- 5 files changed, 45 insertions(+), 27 deletions(-) diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java index f87dfc31264d11..fc3ba6cd1da90a 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java @@ -234,8 +234,8 @@ public void handle(CommissionerDeclaration cd) { } if (cd.getErrorCode() != CommissionerDeclaration.CdError.noError) { commissionerDeclarationErrorTextView.setText( - "CastingPlayer/Commissioner Error: " - + cd.getErrorCode().toString()); + "CommissionerDeclaration error from CastingPlayer: " + + cd.getErrorCode().getDescription()); } }); } diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/support/CommissionerDeclaration.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/support/CommissionerDeclaration.java index 9ce25820494c35..401c948d04a2a2 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/support/CommissionerDeclaration.java +++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/support/CommissionerDeclaration.java @@ -27,34 +27,54 @@ public class CommissionerDeclaration { * commissioning. */ public enum CdError { - noError(0), - commissionableDiscoveryFailed(1), - paseConnectionFailed(2), - paseAuthFailed(3), - dacValidationFailed(4), - alreadyOnFabric(5), - operationalDiscoveryFailed(6), - caseConnectionFailed(7), - caseAuthFailed(8), - configurationFailed(9), - bindingConfigurationFailed(10), - commissionerPasscodeNotSupported(11), - invalidIdentificationDeclarationParams(12), - appInstallConsentPending(13), - appInstalling(14), - appInstallFailed(15), - appInstalledRetryNeeded(16), - commissionerPasscodeDisabled(17), - unexpectedCommissionerPasscodeReady(18); + noError(0, "No error"), + commissionableDiscoveryFailed(1, "Commissionable Node discovery failed"), + paseConnectionFailed(2, "PASE connection failed"), + paseAuthFailed(3, "PASE authentication failed (bad Passcode)"), + dacValidationFailed(4, "DAC validation failed"), + alreadyOnFabric(5, "Already on fabric"), + operationalDiscoveryFailed(6, "Operational Node discovery failed"), + caseConnectionFailed(7, "CASE connection failed"), + caseAuthFailed(8, "CASE authentication failed"), + configurationFailed(9, "Configuration failed"), + bindingConfigurationFailed(10, "Binding Configuration failed"), + commissionerPasscodeNotSupported(11, "Commissioner Passcode not supported"), + invalidIdentificationDeclarationParams(12, "Invalid UDC Identification Declaration parameters"), + appInstallConsentPending(13, "App Install Consent Pending"), + appInstalling(14, "App Installing"), + appInstallFailed(15, "App Install Failed"), + appInstalledRetryNeeded(16, "App Installed, Retry Needed"), + commissionerPasscodeDisabled(17, "Commissioner Passcode disabled"), + unexpectedCommissionerPasscodeReady(18, "Unexpected Commissioner Passcode ready"); + private final int value; + private final String description; - CdError(int value) { + private CdError(int value, String description) { this.value = value; + this.description = description; + } + + private static String getDefaultDescription(int value) { + for (CdError error : CdError.values()) { + if (error.value == value) { + return error.name(); + } + } + return "Unknown Error"; + } + + CdError(int value) { + this(value, getDefaultDescription(value)); } public int getValue() { return value; } + + public String getDescription() { + return description; + } } /** Feature: All - Indicates errors incurred during commissioning. */ private CdError errorCode = CdError.noError; diff --git a/examples/tv-casting-app/android/App/app/src/main/res/layout/fragment_matter_connection_example.xml b/examples/tv-casting-app/android/App/app/src/main/res/layout/fragment_matter_connection_example.xml index c320b9b014758a..1e6862268a6d60 100644 --- a/examples/tv-casting-app/android/App/app/src/main/res/layout/fragment_matter_connection_example.xml +++ b/examples/tv-casting-app/android/App/app/src/main/res/layout/fragment_matter_connection_example.xml @@ -29,7 +29,6 @@ android:layout_height="wrap_content" android:text="@string/matter_connection_next_button_text" /> -