Skip to content

Commit 747c096

Browse files
Addressed comments by sharadb-amazon
1 parent 7891bd3 commit 747c096

File tree

5 files changed

+45
-27
lines changed

5 files changed

+45
-27
lines changed

examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ public void handle(CommissionerDeclaration cd) {
234234
}
235235
if (cd.getErrorCode() != CommissionerDeclaration.CdError.noError) {
236236
commissionerDeclarationErrorTextView.setText(
237-
"CastingPlayer/Commissioner Error: "
238-
+ cd.getErrorCode().toString());
237+
"CommissionerDeclaration error from CastingPlayer: "
238+
+ cd.getErrorCode().getDescription());
239239
}
240240
});
241241
}

examples/tv-casting-app/android/App/app/src/main/jni/com/matter/casting/support/CommissionerDeclaration.java

+40-20
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,54 @@ public class CommissionerDeclaration {
2727
* commissioning.
2828
*/
2929
public enum CdError {
30-
noError(0),
31-
commissionableDiscoveryFailed(1),
32-
paseConnectionFailed(2),
33-
paseAuthFailed(3),
34-
dacValidationFailed(4),
35-
alreadyOnFabric(5),
36-
operationalDiscoveryFailed(6),
37-
caseConnectionFailed(7),
38-
caseAuthFailed(8),
39-
configurationFailed(9),
40-
bindingConfigurationFailed(10),
41-
commissionerPasscodeNotSupported(11),
42-
invalidIdentificationDeclarationParams(12),
43-
appInstallConsentPending(13),
44-
appInstalling(14),
45-
appInstallFailed(15),
46-
appInstalledRetryNeeded(16),
47-
commissionerPasscodeDisabled(17),
48-
unexpectedCommissionerPasscodeReady(18);
30+
noError(0, "No error"),
31+
commissionableDiscoveryFailed(1, "Commissionable Node discovery failed"),
32+
paseConnectionFailed(2, "PASE connection failed"),
33+
paseAuthFailed(3, "PASE authentication failed (bad Passcode)"),
34+
dacValidationFailed(4, "DAC validation failed"),
35+
alreadyOnFabric(5, "Already on fabric"),
36+
operationalDiscoveryFailed(6, "Operational Node discovery failed"),
37+
caseConnectionFailed(7, "CASE connection failed"),
38+
caseAuthFailed(8, "CASE authentication failed"),
39+
configurationFailed(9, "Configuration failed"),
40+
bindingConfigurationFailed(10, "Binding Configuration failed"),
41+
commissionerPasscodeNotSupported(11, "Commissioner Passcode not supported"),
42+
invalidIdentificationDeclarationParams(12, "Invalid UDC Identification Declaration parameters"),
43+
appInstallConsentPending(13, "App Install Consent Pending"),
44+
appInstalling(14, "App Installing"),
45+
appInstallFailed(15, "App Install Failed"),
46+
appInstalledRetryNeeded(16, "App Installed, Retry Needed"),
47+
commissionerPasscodeDisabled(17, "Commissioner Passcode disabled"),
48+
unexpectedCommissionerPasscodeReady(18, "Unexpected Commissioner Passcode ready");
49+
4950
private final int value;
51+
private final String description;
5052

51-
CdError(int value) {
53+
private CdError(int value, String description) {
5254
this.value = value;
55+
this.description = description;
56+
}
57+
58+
private static String getDefaultDescription(int value) {
59+
for (CdError error : CdError.values()) {
60+
if (error.value == value) {
61+
return error.name();
62+
}
63+
}
64+
return "Unknown Error";
65+
}
66+
67+
CdError(int value) {
68+
this(value, getDefaultDescription(value));
5369
}
5470

5571
public int getValue() {
5672
return value;
5773
}
74+
75+
public String getDescription() {
76+
return description;
77+
}
5878
}
5979
/** Feature: All - Indicates errors incurred during commissioning. */
6080
private CdError errorCode = CdError.noError;

examples/tv-casting-app/android/App/app/src/main/res/layout/fragment_matter_connection_example.xml

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
android:layout_height="wrap_content"
3030
android:text="@string/matter_connection_next_button_text" />
3131

32-
<!-- TextView for CommissionerDeclaration errors -->
3332
<TextView
3433
android:id="@+id/commissionerDeclarationErrorTextView"
3534
android:layout_width="wrap_content"

examples/tv-casting-app/darwin/TvCasting/TvCasting/MCConnectionExampleView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct MCConnectionExampleView: View {
6868
Spacer() // Push the error code to the bottom
6969
if let errorCode = viewModel.errorCodeDescription {
7070

71-
Text("CastingPlayer/Commissioner Error: \(errorCode)")
71+
Text("\(errorCode)")
7272
.foregroundColor(.red)
7373
.padding()
7474
}

examples/tv-casting-app/darwin/TvCasting/TvCasting/MCConnectionExampleViewModel.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class MCConnectionExampleViewModel: ObservableObject {
4040

4141
@Published var connectionStatus: String?;
4242

43-
@Published var errorCodeDescription: String? // New published variable for error code
43+
@Published var errorCodeDescription: String?
4444

4545
func connect(selectedCastingPlayer: MCCastingPlayer?, useCommissionerGeneratedPasscode: Bool) {
4646
self.Log.info("MCConnectionExampleViewModel.connect() useCommissionerGeneratedPasscode: \(String(describing: useCommissionerGeneratedPasscode))")
@@ -70,7 +70,7 @@ class MCConnectionExampleViewModel: ObservableObject {
7070

7171
// Display CommissionerDeclaration error code if `errorCode` is not `kNoError`
7272
if commissionerDeclarationMessage.errorCode != CdError.noError {
73-
self.errorCodeDescription = commissionerDeclarationMessage.getErrorCodeString()
73+
self.errorCodeDescription = "CommissionerDeclaration error from CastingPlayer: \(commissionerDeclarationMessage.getErrorCodeString())"
7474
self.Log.error("MCConnectionExampleViewModel connect() Casting Player/Commissioner Error: \(self.errorCodeDescription ?? "Unknown Error")")
7575
}
7676

@@ -169,7 +169,6 @@ class MCConnectionExampleViewModel: ObservableObject {
169169
} else {
170170
identificationDeclarationOptions = MCIdentificationDeclarationOptions()
171171
targetAppInfo = MCTargetAppInfo(vendorId: kDesiredEndpointVendorId)
172-
//
173172
connectionCallbacks = MCConnectionCallbacks(
174173
callbacks: connectionCompleteCallback,
175174
commissionerDeclarationCallback: commissionerDeclarationCallback

0 commit comments

Comments
 (0)