Skip to content

Commit

Permalink
Fix commissioning error handling in darwin-framework-tool to be more …
Browse files Browse the repository at this point in the history
…like chip-tool. (#19298)

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 #19276
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Nov 6, 2023
1 parent e08bc50 commit 1075314
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions examples/darwin-framework-tool/commands/tests/TestCommandBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 1075314

Please sign in to comment.