From c3483a04def2456c1aceb06cc18791a0a5e8b325 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 7 Jun 2022 22:27:07 -0400 Subject: [PATCH] Fix commissioning error handling in darwin-framework-tool to be more like chip-tool. For some reason, we sometimes get OnPairingComplete with an error in cases where the same code (same YAML test) running on a different system gets a OnStatusUpdate instead. chip-tool handles OnPairingComplete with an error by calling OnStatusUpdate, which steps through the test to the next test. darwin-framework-tool should do the same, when running YAML tests. Fixes https://github.com/project-chip/connectedhomeip/issues/19276 --- .../commands/tests/TestCommandBridge.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h b/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h index c9e4b236e1d7f5..23d5e9d52db3d6 100644 --- a/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h +++ b/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h @@ -190,20 +190,14 @@ class TestCommandBridge : public CHIPCommandBridge, Exit("Unexpected deletion of pairing"); } - void PairingComplete(chip::NodeId nodeId, NSError * _Nullable error) + void PairingComplete(chip::NodeId nodeId) { - CHIP_ERROR err = [CHIPError errorToCHIPErrorCode:error]; - if (err != CHIP_NO_ERROR) { - Exit("Pairing completed with error", err); - return; - } - CHIPDeviceController * controller = CurrentCommissioner(); VerifyOrReturn(controller != nil, Exit("No current commissioner")); NSError * commissionError = nil; [controller commissionDevice:nodeId commissioningParams:[[CHIPCommissioningParameters alloc] init] error:&commissionError]; - err = [CHIPError errorToCHIPErrorCode:commissionError]; + CHIP_ERROR err = [CHIPError errorToCHIPErrorCode:commissionError]; if (err != CHIP_NO_ERROR) { Exit("Failed to kick off commissioning", err); return; @@ -460,7 +454,14 @@ NS_ASSUME_NONNULL_BEGIN - (void)onPairingComplete:(NSError * _Nullable)error { if (_active) { - _commandBridge->PairingComplete(_deviceId, error); + if (error != nil) { + _active = NO; + NSLog(@"Pairing complete with error"); + CHIP_ERROR err = [CHIPError errorToCHIPErrorCode:error]; + _commandBridge->OnStatusUpdate([self convertToStatusIB:err]); + } else { + _commandBridge->PairingComplete(_deviceId); + } } }