diff --git a/examples/darwin-framework-tool/commands/delay/WaitForCommissioneeCommand.h b/examples/darwin-framework-tool/commands/delay/WaitForCommissioneeCommand.h index 053d8c04247493..a262c1a3537c33 100644 --- a/examples/darwin-framework-tool/commands/delay/WaitForCommissioneeCommand.h +++ b/examples/darwin-framework-tool/commands/delay/WaitForCommissioneeCommand.h @@ -22,24 +22,15 @@ #include #include -NS_ASSUME_NONNULL_BEGIN -@interface MTRDeviceTestDelegate : NSObject -@property CHIPCommandBridge * commandBridge; -- (instancetype)initWithCommandBridge:(CHIPCommandBridge *)commandBridge; -- (instancetype)init NS_UNAVAILABLE; -@end -NS_ASSUME_NONNULL_END - -class WaitForCommissioneeCommand : public CHIPCommandBridge { +class WaitForCommissioneeCommand : public CHIPCommandBridge +{ public: - WaitForCommissioneeCommand() - : CHIPCommandBridge("wait-for-commissionee") - , mDeviceDelegate([[MTRDeviceTestDelegate alloc] initWithCommandBridge:this]) + WaitForCommissioneeCommand() : CHIPCommandBridge("wait-for-commissionee") { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); AddArgument("expire-existing-session", 0, 1, &mExpireExistingSession); - AddArgument( - "timeout", 0, UINT64_MAX, &mTimeoutSecs, "Time, in seconds, before this command is considered to have timed out."); + AddArgument("timeout", 0, UINT64_MAX, &mTimeoutSecs, + "Time, in seconds, before this command is considered to have timed out."); } /////////// CHIPCommandBridge Interface ///////// @@ -53,5 +44,4 @@ class WaitForCommissioneeCommand : public CHIPCommandBridge { chip::NodeId mNodeId; chip::Optional mTimeoutSecs; chip::Optional mExpireExistingSession; - id _Nullable mDeviceDelegate; }; diff --git a/examples/darwin-framework-tool/commands/delay/WaitForCommissioneeCommand.mm b/examples/darwin-framework-tool/commands/delay/WaitForCommissioneeCommand.mm index a806757ac1eb85..6bc25defa21d1a 100644 --- a/examples/darwin-framework-tool/commands/delay/WaitForCommissioneeCommand.mm +++ b/examples/darwin-framework-tool/commands/delay/WaitForCommissioneeCommand.mm @@ -20,43 +20,10 @@ #import "MTRDevice_Externs.h" -@implementation MTRDeviceTestDelegate -- (instancetype)initWithCommandBridge:(CHIPCommandBridge *)commandBridge -{ - if (!(self = [super init])) { - return nil; - } - - _commandBridge = commandBridge; - return self; -} - -- (void)device:(MTRDevice *)device stateChanged:(MTRDeviceState)state -{ - if (state == MTRDeviceStateReachable) { - _commandBridge->SetCommandExitStatus(CHIP_NO_ERROR); - } else if (state == MTRDeviceStateUnreachable) { - _commandBridge->SetCommandExitStatus(CHIP_ERROR_NOT_FOUND); - } else if (state == MTRDeviceStateUnknown) { - _commandBridge->SetCommandExitStatus(CHIP_ERROR_NOT_FOUND); - } else { - // This should not happens. - chipDie(); - } -} - -- (void)device:(MTRDevice *)device receivedAttributeReport:(NSArray *> *)attributeReport -{ -} - -- (void)device:(MTRDevice *)device receivedEventReport:(NSArray *> *)eventReport -{ -} -@end - CHIP_ERROR WaitForCommissioneeCommand::RunCommand() { MTRDeviceController * commissioner = CurrentCommissioner(); + VerifyOrReturnError(nil != commissioner, CHIP_ERROR_INCORRECT_STATE); auto * base_device = [MTRBaseDevice deviceWithNodeID:@(mNodeId) controller:commissioner]; VerifyOrReturnError(base_device != nil, CHIP_ERROR_INCORRECT_STATE); @@ -64,13 +31,7 @@ - (void)device:(MTRDevice *)device receivedEventReport:(NSArray