Skip to content

Commit

Permalink
Addressed comments by sharadb-amazon
Browse files Browse the repository at this point in the history
  • Loading branch information
pgregorr-amazon committed Sep 27, 2024
1 parent 7891bd3 commit 747c096
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
android:layout_height="wrap_content"
android:text="@string/matter_connection_next_button_text" />

<!-- TextView for CommissionerDeclaration errors -->
<TextView
android:id="@+id/commissionerDeclarationErrorTextView"
android:layout_width="wrap_content"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct MCConnectionExampleView: View {
Spacer() // Push the error code to the bottom
if let errorCode = viewModel.errorCodeDescription {

Text("CastingPlayer/Commissioner Error: \(errorCode)")
Text("\(errorCode)")
.foregroundColor(.red)
.padding()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MCConnectionExampleViewModel: ObservableObject {

@Published var connectionStatus: String?;

@Published var errorCodeDescription: String? // New published variable for error code
@Published var errorCodeDescription: String?

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

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

Expand Down Expand Up @@ -169,7 +169,6 @@ class MCConnectionExampleViewModel: ObservableObject {
} else {
identificationDeclarationOptions = MCIdentificationDeclarationOptions()
targetAppInfo = MCTargetAppInfo(vendorId: kDesiredEndpointVendorId)
//
connectionCallbacks = MCConnectionCallbacks(
callbacks: connectionCompleteCallback,
commissionerDeclarationCallback: commissionerDeclarationCallback
Expand Down

0 comments on commit 747c096

Please sign in to comment.