diff --git a/docs/ERROR_CODES.md b/docs/ERROR_CODES.md index bf3e252369efb3..03bf49fe4b3ccb 100644 --- a/docs/ERROR_CODES.md +++ b/docs/ERROR_CODES.md @@ -110,6 +110,7 @@ This file was **AUTOMATICALLY** generated by | 159 | 0x9F | `CHIP_ERROR_PERSISTED_STORAGE_FAILED` | | 160 | 0xA0 | `CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND` | | 161 | 0xA1 | `CHIP_ERROR_IM_FABRIC_DELETED` | +| 164 | 0xA4 | `CHIP_ERROR_IN_PROGRESS` | | 165 | 0xA5 | `CHIP_ERROR_ACCESS_DENIED` | | 166 | 0xA6 | `CHIP_ERROR_UNKNOWN_RESOURCE_ID` | | 167 | 0xA7 | `CHIP_ERROR_VERSION_MISMATCH` | diff --git a/src/app/clusters/window-covering-server/window-covering-server.cpp b/src/app/clusters/window-covering-server/window-covering-server.cpp index 29e8b7070ad5b9..7e9661f6fecd46 100644 --- a/src/app/clusters/window-covering-server/window-covering-server.cpp +++ b/src/app/clusters/window-covering-server/window-covering-server.cpp @@ -735,26 +735,39 @@ bool emberAfWindowCoveringClusterStopMotionCallback(app::CommandHandler * comman return true; } + bool changeTarget = true; + Delegate * delegate = GetDelegate(endpoint); if (delegate) { - LogErrorOnFailure(delegate->HandleStopMotion()); + CHIP_ERROR err = delegate->HandleStopMotion(); + if (err == CHIP_ERROR_IN_PROGRESS) + { + changeTarget = false; + } + else + { + LogErrorOnFailure(err); + } } else { emberAfWindowCoveringClusterPrint("WindowCovering has no delegate set for endpoint:%u", endpoint); } - if (HasFeaturePaLift(endpoint)) + if (changeTarget) { - (void) Attributes::CurrentPositionLiftPercent100ths::Get(endpoint, current); - (void) Attributes::TargetPositionLiftPercent100ths::Set(endpoint, current); - } + if (HasFeaturePaLift(endpoint)) + { + (void) Attributes::CurrentPositionLiftPercent100ths::Get(endpoint, current); + (void) Attributes::TargetPositionLiftPercent100ths::Set(endpoint, current); + } - if (HasFeaturePaTilt(endpoint)) - { - (void) Attributes::CurrentPositionTiltPercent100ths::Get(endpoint, current); - (void) Attributes::TargetPositionTiltPercent100ths::Set(endpoint, current); + if (HasFeaturePaTilt(endpoint)) + { + (void) Attributes::CurrentPositionTiltPercent100ths::Get(endpoint, current); + (void) Attributes::TargetPositionTiltPercent100ths::Set(endpoint, current); + } } return CHIP_NO_ERROR == commandObj->AddStatus(commandPath, Status::Success); diff --git a/src/lib/core/CHIPError.cpp b/src/lib/core/CHIPError.cpp index d28242d8176723..e6985efc890146 100644 --- a/src/lib/core/CHIPError.cpp +++ b/src/lib/core/CHIPError.cpp @@ -344,6 +344,9 @@ bool FormatCHIPError(char * buf, uint16_t bufSize, CHIP_ERROR err) case CHIP_ERROR_IM_FABRIC_DELETED.AsInteger(): desc = "The fabric is deleted, and the corresponding IM resources are released"; break; + case CHIP_ERROR_IN_PROGRESS.AsInteger(): + desc = "The operation is still in progress"; + break; case CHIP_ERROR_ACCESS_DENIED.AsInteger(): desc = "The CHIP message is not granted access"; break; diff --git a/src/lib/core/CHIPError.h b/src/lib/core/CHIPError.h index 4faf0da397c063..fbc6ba4e88d8c1 100644 --- a/src/lib/core/CHIPError.h +++ b/src/lib/core/CHIPError.h @@ -1362,7 +1362,14 @@ using CHIP_ERROR = ::chip::ChipError; // AVAILABLE: 0xa2 // AVAILABLE: 0xa3 -// AVAILABLE: 0xa4 + +/** + * @def CHIP_ERROR_IN_PROGRESS + * + * @brief + * The operation is still in progress + */ +#define CHIP_ERROR_IN_PROGRESS CHIP_CORE_ERROR(0xa4) /** * @def CHIP_ERROR_ACCESS_DENIED diff --git a/src/lib/core/tests/TestCHIPErrorStr.cpp b/src/lib/core/tests/TestCHIPErrorStr.cpp index fcadcd6b543f16..b5fabd64afe145 100644 --- a/src/lib/core/tests/TestCHIPErrorStr.cpp +++ b/src/lib/core/tests/TestCHIPErrorStr.cpp @@ -170,6 +170,7 @@ static const CHIP_ERROR kTestElements[] = CHIP_ERROR_INVALID_FILE_IDENTIFIER, CHIP_ERROR_BUSY, CHIP_ERROR_HANDLER_NOT_SET, + CHIP_ERROR_IN_PROGRESS, }; // clang-format on