Skip to content

Commit

Permalink
[MatterYamlTests][darwin-framework-tool] Ensure that WaitForCommissio…
Browse files Browse the repository at this point in the history
…nee works after a reboot
  • Loading branch information
vivien-apple committed Sep 14, 2023
1 parent 52caffd commit 67a0399
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ - (void)device:(MTRDevice *)device stateChanged:(MTRDeviceState)state
} else if (state == MTRDeviceStateUnreachable) {
_commandBridge->SetCommandExitStatus(CHIP_ERROR_NOT_FOUND);
} else if (state == MTRDeviceStateUnknown) {
_commandBridge->SetCommandExitStatus(CHIP_ERROR_NOT_FOUND);
// Just wait a little more until the state is set to reachable or unreachable.
} else {
// This should not happens.
chipDie();
Expand Down Expand Up @@ -69,6 +69,17 @@ - (void)device:(MTRDevice *)device receivedEventReport:(NSArray<NSDictionary<NSS
auto * device = [MTRDevice deviceWithNodeID:@(mNodeId) controller:commissioner];
VerifyOrReturnError(device != nil, CHIP_ERROR_INCORRECT_STATE);

auto state = [device state];
if (state == MTRDeviceStateReachable) {
SetCommandExitStatus(CHIP_NO_ERROR);
return CHIP_NO_ERROR;
}

if (state == MTRDeviceStateUnreachable) {
SetCommandExitStatus(CHIP_ERROR_NOT_FOUND);
return CHIP_ERROR_NOT_FOUND;
}

auto queue = dispatch_queue_create("com.chip.wait_for_commissionee", DISPATCH_QUEUE_SERIAL);
[device setDelegate:mDeviceDelegate queue:queue];

Expand Down

0 comments on commit 67a0399

Please sign in to comment.