diff --git a/config/telink/chip-module/CMakeLists.txt b/config/telink/chip-module/CMakeLists.txt index 1b148476f3e0d8..ade2bd310f8a02 100644 --- a/config/telink/chip-module/CMakeLists.txt +++ b/config/telink/chip-module/CMakeLists.txt @@ -155,6 +155,10 @@ set_property(GLOBAL APPEND PROPERTY ZEPHYR_INTERFACE_LIBS chip) include(${TELINK_COMMON}/common.cmake) +if (CONFIG_CHIP_APP_LOG_LEVEL GREATER_EQUAL 4) + include(${TELINK_COMMON}/build_info.cmake) +endif() + # ============================================================================== # Define 'process_binaries' target for collecting final binary to flash # ============================================================================== diff --git a/examples/lighting-app/tizen/src/DBusInterface.cpp b/examples/lighting-app/tizen/src/DBusInterface.cpp index 5484c7daff3793..4a2aa18122c39c 100644 --- a/examples/lighting-app/tizen/src/DBusInterface.cpp +++ b/examples/lighting-app/tizen/src/DBusInterface.cpp @@ -203,7 +203,8 @@ gboolean DBusInterface::OnColorTemperatureChanged(LightAppColorControl * colorCo data.colorTemperatureMireds = light_app_color_control_get_color_temperature_mireds(colorControl); chip::DeviceLayer::StackLock lock; - ColorControlServer::Instance().moveToColorTempCommand(&handler, path, data); + auto status = ColorControlServer::Instance().moveToColorTempCommand(self->mEndpointId, data); + handler.AddStatus(path, status); return G_DBUS_METHOD_INVOCATION_HANDLED; } diff --git a/examples/platform/telink/build_info.cmake b/examples/platform/telink/build_info.cmake new file mode 100644 index 00000000000000..f6a7ccfaee34f3 --- /dev/null +++ b/examples/platform/telink/build_info.cmake @@ -0,0 +1,148 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Matter git info +execute_process( + COMMAND git rev-parse HEAD + OUTPUT_VARIABLE MATTER_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +execute_process( + COMMAND git diff --quiet + RESULT_VARIABLE MATTER_LOCAL_STATUS +) + +if(MATTER_LOCAL_STATUS) + set(MATTER_LOCAL_STATUS "-dirty") +else() + set(MATTER_LOCAL_STATUS "") +endif() + +execute_process( + COMMAND git rev-parse --abbrev-ref HEAD + OUTPUT_VARIABLE MATTER_BRANCH_NAME + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +execute_process( + COMMAND python3 -c "from datetime import datetime; print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))" + OUTPUT_VARIABLE BUILD_TIMESTAMP + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +execute_process( + COMMAND git show -s --format=%cd --date=format:%Y-%m-%d + OUTPUT_VARIABLE MATTER_COMMIT_DATE + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +execute_process( + COMMAND git remote get-url origin + OUTPUT_VARIABLE MATTER_REMOTE_URL + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +# Zephyr git info +execute_process( + COMMAND git -C ${ZEPHYR_BASE} rev-parse HEAD + OUTPUT_VARIABLE ZEPHYR_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +execute_process( + COMMAND git -C ${ZEPHYR_BASE} rev-parse --abbrev-ref HEAD + OUTPUT_VARIABLE ZEPHYR_BRANCH_NAME + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +execute_process( + COMMAND git -C ${ZEPHYR_BASE} show -s --format=%cd --date=format:%Y-%m-%d HEAD + OUTPUT_VARIABLE ZEPHYR_COMMIT_DATE + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +execute_process( + COMMAND bash -c "git -C ${ZEPHYR_BASE} remote get-url \$(git -C ${ZEPHYR_BASE} remote | head -n 1)" + OUTPUT_VARIABLE ZEPHYR_REMOTE_URL + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +execute_process( + COMMAND git -C ${ZEPHYR_BASE} diff --quiet + RESULT_VARIABLE ZEPHYR_LOCAL_STATUS +) + +if(ZEPHYR_LOCAL_STATUS) + set(ZEPHYR_LOCAL_STATUS "-dirty") +else() + set(ZEPHYR_LOCAL_STATUS "") +endif() + +# Telink HAL info +execute_process( + COMMAND git -C ${ZEPHYR_BASE}/../modules/hal/telink rev-parse HEAD + OUTPUT_VARIABLE TELINK_HAL_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +execute_process( + COMMAND git -C ${ZEPHYR_BASE}/../modules/hal/telink diff --quiet + RESULT_VARIABLE HAL_LOCAL_STATUS +) + +if(TELINK_HAL_LOCAL_STATUS) + set(TELINK_HAL_LOCAL_STATUS "-dirty") +else() + set(TELINK_HAL_LOCAL_STATUS "") +endif() + +execute_process( + COMMAND git -C ${ZEPHYR_BASE}/../modules/hal/telink show -s --format=%cd --date=format:%Y-%m-%d + OUTPUT_VARIABLE TELINK_HAL_COMMIT_DATE + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +target_compile_definitions(app PRIVATE + MATTER_COMMIT_HASH="${MATTER_COMMIT_HASH}" + MATTER_BRANCH="${MATTER_BRANCH_NAME}" + BUILD_TIMESTAMP="${BUILD_TIMESTAMP}" + MATTER_COMMIT_DATE="${MATTER_COMMIT_DATE}" + MATTER_REMOTE_URL="${MATTER_REMOTE_URL}" + MATTER_LOCAL_STATUS="${MATTER_LOCAL_STATUS}" + + ZEPHYR_COMMIT_HASH="${ZEPHYR_COMMIT_HASH}" + ZEPHYR_BRANCH="${ZEPHYR_BRANCH_NAME}" + ZEPHYR_COMMIT_DATE="${ZEPHYR_COMMIT_DATE}" + ZEPHYR_REMOTE_URL="${ZEPHYR_REMOTE_URL}" + ZEPHYR_LOCAL_STATUS="${ZEPHYR_LOCAL_STATUS}" + + TELINK_HAL_COMMIT_HASH="${TELINK_HAL_COMMIT_HASH}" + TELINK_HAL_LOCAL_STATUS="${TELINK_HAL_LOCAL_STATUS}" + TELINK_HAL_COMMIT_DATE="${TELINK_HAL_COMMIT_DATE}" +) + +message(STATUS "Matter revision:") +message(STATUS " board: ${CONFIG_BOARD}") +message(STATUS " branch: ${MATTER_BRANCH_NAME} ${MATTER_COMMIT_HASH} ${MATTER_COMMIT_DATE}") +message(STATUS " remote: ${MATTER_REMOTE_URL}") +message(STATUS " build timestamp: ${BUILD_TIMESTAMP}") + +message(STATUS "Zephyr revision:") +message(STATUS " branch: ${ZEPHYR_BRANCH_NAME} ${ZEPHYR_COMMIT_HASH} ${ZEPHYR_COMMIT_DATE}") +message(STATUS " remote: ${ZEPHYR_REMOTE_URL}") + +message(STATUS "HAL revision:") +message(STATUS " commit: ${TELINK_HAL_COMMIT_HASH} ${TELINK_HAL_COMMIT_DATE}") diff --git a/examples/platform/telink/common/include/AppTaskCommon.h b/examples/platform/telink/common/include/AppTaskCommon.h index 22c5f51a937dcc..ac10ef587d2be9 100644 --- a/examples/platform/telink/common/include/AppTaskCommon.h +++ b/examples/platform/telink/common/include/AppTaskCommon.h @@ -84,6 +84,7 @@ class AppTaskCommon protected: CHIP_ERROR InitCommonParts(void); + void PrintFirmwareInfo(void); void DispatchEvent(AppEvent * event); void GetEvent(AppEvent * aEvent); diff --git a/examples/platform/telink/common/src/AppTaskCommon.cpp b/examples/platform/telink/common/src/AppTaskCommon.cpp index 858334aaa72dd7..de5faa974a4847 100644 --- a/examples/platform/telink/common/src/AppTaskCommon.cpp +++ b/examples/platform/telink/common/src/AppTaskCommon.cpp @@ -240,11 +240,28 @@ CHIP_ERROR AppTaskCommon::StartApp(void) DispatchEvent(&event); } } +void AppTaskCommon::PrintFirmwareInfo(void) +{ + LOG_INF("SW Version: %u, %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); +#if CONFIG_CHIP_APP_LOG_LEVEL > 3 + LOG_DBG("Matter revision: "); + LOG_DBG("\t board: %s", CONFIG_BOARD); + LOG_DBG("\t branch: %s %.8s%s %s", MATTER_BRANCH, MATTER_COMMIT_HASH, MATTER_LOCAL_STATUS, MATTER_COMMIT_DATE); + LOG_DBG("\t remote: %s", MATTER_REMOTE_URL); + LOG_DBG("\t build timestamp: %s", BUILD_TIMESTAMP); + + LOG_DBG("Zephyr revision: "); + LOG_DBG("\t branch: %s %.8s%s %s", ZEPHYR_BRANCH, ZEPHYR_COMMIT_HASH, ZEPHYR_LOCAL_STATUS, ZEPHYR_COMMIT_DATE); + LOG_DBG("\t remote: %s", ZEPHYR_REMOTE_URL); + LOG_DBG("\t HAL commit: %.8s%s %s", TELINK_HAL_COMMIT_HASH, TELINK_HAL_LOCAL_STATUS, TELINK_HAL_COMMIT_DATE); +#endif +} CHIP_ERROR AppTaskCommon::InitCommonParts(void) { CHIP_ERROR err; - LOG_INF("SW Version: %u, %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); + + PrintFirmwareInfo(); InitLeds(); UpdateStatusLED(); diff --git a/src/app/clusters/color-control-server/color-control-server.cpp b/src/app/clusters/color-control-server/color-control-server.cpp index b43c95c7b23ddb..a01de7fad22dcb 100644 --- a/src/app/clusters/color-control-server/color-control-server.cpp +++ b/src/app/clusters/color-control-server/color-control-server.cpp @@ -2431,12 +2431,12 @@ ColorControlServer::Color16uTransitionState * ColorControlServer::getTempTransit } /** - * @brief executes move to color temp logic + * @brief Executes move to color temp logic. * * @param aEndpoint * @param colorTemperature * @param transitionTime - * @return Status::Success if successful, Status::UnsupportedEndpoint if the endpoint doesn't support color temperature + * @return Status::Success if successful, Status::UnsupportedEndpoint if the endpoint doesn't support color temperature. */ Status ColorControlServer::moveToColorTemp(EndpointId aEndpoint, uint16_t colorTemperature, uint16_t transitionTime) { @@ -2632,49 +2632,28 @@ void ColorControlServer::updateTempCommand(EndpointId endpoint) } /** - * @brief move color temp command - * - * @param moveMode - * @param rate - * @param colorTemperatureMinimum - * @param colorTemperatureMaximum - * @param optionsMask - * @param optionsOverride - * @return true - * @return false + * @brief Executes move color temp command. + * @param endpoint EndpointId of the recipient Color control cluster. + * @param commandData Struct containing the parameters of the command. + * @return Status::Success when successful, + * Status::InvalidCommand when a rate of 0 for a non-stop move or an unknown HueMoveMode is provided + * Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a color temp transition state. */ -bool ColorControlServer::moveColorTempCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, - const Commands::MoveColorTemperature::DecodableType & commandData) -{ - auto moveMode = commandData.moveMode; - uint16_t rate = commandData.rate; - uint16_t colorTemperatureMinimum = commandData.colorTemperatureMinimumMireds; - uint16_t colorTemperatureMaximum = commandData.colorTemperatureMaximumMireds; - BitMask optionsMask = commandData.optionsMask; - BitMask optionsOverride = commandData.optionsOverride; - EndpointId endpoint = commandPath.mEndpointId; - Status status = Status::Success; - uint16_t tempPhysicalMin = MIN_TEMPERATURE_VALUE; - uint16_t tempPhysicalMax = MAX_TEMPERATURE_VALUE; - uint16_t transitionTime; - - Color16uTransitionState * colorTempTransitionState = getTempTransitionState(endpoint); - VerifyOrExit(colorTempTransitionState != nullptr, status = Status::UnsupportedEndpoint); - +Status ColorControlServer::moveColorTempCommand(EndpointId endpoint, + const Commands::MoveColorTemperature::DecodableType & commandData) +{ // check moveMode and rate before any operation is done on the transition states // rate value is ignored if the MoveMode is stop - if (moveMode == HueMoveMode::kUnknownEnumValue || (rate == 0 && moveMode != HueMoveMode::kStop)) - { - commandObj->AddStatus(commandPath, Status::InvalidCommand); - return true; - } + VerifyOrReturnValue(commandData.moveMode != HueMoveMode::kUnknownEnumValue, Status::InvalidCommand); + VerifyOrReturnValue((commandData.rate != 0 || commandData.moveMode == HueMoveMode::kStop), Status::InvalidCommand); - if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) - { - commandObj->AddStatus(commandPath, Status::Success); - return true; - } + Color16uTransitionState * colorTempTransitionState = getTempTransitionState(endpoint); + VerifyOrReturnValue(colorTempTransitionState != nullptr, Status::UnsupportedEndpoint); + VerifyOrReturnValue(shouldExecuteIfOff(endpoint, commandData.optionsMask, commandData.optionsOverride), Status::Success); + + uint16_t tempPhysicalMin = MIN_TEMPERATURE_VALUE; + uint16_t tempPhysicalMax = MAX_TEMPERATURE_VALUE; Attributes::ColorTempPhysicalMinMireds::Get(endpoint, &tempPhysicalMin); Attributes::ColorTempPhysicalMaxMireds::Get(endpoint, &tempPhysicalMax); @@ -2683,15 +2662,12 @@ bool ColorControlServer::moveColorTempCommand(app::CommandHandler * commandObj, // New command. Need to stop any active transitions. stopAllColorTransitions(endpoint); - - if (moveMode == HueMoveMode::kStop) - { - commandObj->AddStatus(commandPath, Status::Success); - return true; - } + // For HueMoveMode::kStop we are done here. + VerifyOrReturnValue(commandData.moveMode != HueMoveMode::kStop, Status::Success); // Per spec, colorTemperatureMinimumMireds field is limited to ColorTempPhysicalMinMireds and // when colorTemperatureMinimumMireds field is 0, ColorTempPhysicalMinMireds shall be used (always > 0) + uint16_t colorTemperatureMinimum = commandData.colorTemperatureMinimumMireds; if (colorTemperatureMinimum < tempPhysicalMin) { colorTemperatureMinimum = tempPhysicalMin; @@ -2699,6 +2675,7 @@ bool ColorControlServer::moveColorTempCommand(app::CommandHandler * commandObj, // Per spec, colorTemperatureMaximumMireds field is limited to ColorTempPhysicalMaxMireds and // when colorTemperatureMaximumMireds field is 0, ColorTempPhysicalMaxMireds shall be used + uint16_t colorTemperatureMaximum = commandData.colorTemperatureMaximumMireds; if ((colorTemperatureMaximum == 0) || (colorTemperatureMaximum > tempPhysicalMax)) { colorTemperatureMaximum = tempPhysicalMax; @@ -2712,7 +2689,7 @@ bool ColorControlServer::moveColorTempCommand(app::CommandHandler * commandObj, Attributes::ColorTemperatureMireds::Get(endpoint, &colorTempTransitionState->initialValue); colorTempTransitionState->currentValue = colorTempTransitionState->initialValue; - if (moveMode == HueMoveMode::kUp) + if (commandData.moveMode == HueMoveMode::kUp) { if (tempPhysicalMax > colorTemperatureMaximum) { @@ -2734,7 +2711,8 @@ bool ColorControlServer::moveColorTempCommand(app::CommandHandler * commandObj, colorTempTransitionState->finalValue = tempPhysicalMin; } } - transitionTime = computeTransitionTimeFromStateAndRate(colorTempTransitionState, rate); + + uint16_t transitionTime = computeTransitionTimeFromStateAndRate(colorTempTransitionState, commandData.rate); colorTempTransitionState->stepsRemaining = transitionTime; colorTempTransitionState->stepsTotal = transitionTime; colorTempTransitionState->timeRemaining = transitionTime; @@ -2747,63 +2725,54 @@ bool ColorControlServer::moveColorTempCommand(app::CommandHandler * commandObj, // kick off the state machine: scheduleTimerCallbackMs(configureTempEventControl(endpoint), TRANSITION_UPDATE_TIME_MS.count()); - -exit: - commandObj->AddStatus(commandPath, status); - return true; + return Status::Success; } -bool ColorControlServer::moveToColorTempCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, - const Commands::MoveToColorTemperature::DecodableType & commandData) +/** + * @brief Executes move to color temp command. + * @param endpoint EndpointId of the recipient Color control cluster. + * @param commandData Struct containing the parameters of the command. + * @return Status::Success when successful, + * Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a color XY transition state (verified in + * moveToColorTemp function). + */ +Status ColorControlServer::moveToColorTempCommand(EndpointId endpoint, + const Commands::MoveToColorTemperature::DecodableType & commandData) { - if (!shouldExecuteIfOff(commandPath.mEndpointId, commandData.optionsMask, commandData.optionsOverride)) - { - commandObj->AddStatus(commandPath, Status::Success); - return true; - } + VerifyOrReturnValue(shouldExecuteIfOff(endpoint, commandData.optionsMask, commandData.optionsOverride), Status::Success); - Status status = moveToColorTemp(commandPath.mEndpointId, commandData.colorTemperatureMireds, commandData.transitionTime); + Status status = moveToColorTemp(endpoint, commandData.colorTemperatureMireds, commandData.transitionTime); #ifdef MATTER_DM_PLUGIN_SCENES_MANAGEMENT - ScenesManagement::ScenesServer::Instance().MakeSceneInvalidForAllFabrics(commandPath.mEndpointId); + ScenesManagement::ScenesServer::Instance().MakeSceneInvalidForAllFabrics(endpoint); #endif // MATTER_DM_PLUGIN_SCENES_MANAGEMENT - commandObj->AddStatus(commandPath, status); - return true; + return status; } -bool ColorControlServer::stepColorTempCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, - const Commands::StepColorTemperature::DecodableType & commandData) +/** + * @brief Executes step color temp command. + * @param endpoint EndpointId of the recipient Color control cluster. + * @param commandData Struct containing the parameters of the command + * @return Status::Success when successful, + * Status::InvalidCommand when stepSize is 0 or an unknown stepMode is provided + * Status::UnsupportedEndpoint when the provided endpoint doesn't correspond with a color temp transition state. + */ +Status ColorControlServer::stepColorTempCommand(EndpointId endpoint, + const Commands::StepColorTemperature::DecodableType & commandData) { - auto stepMode = commandData.stepMode; - uint16_t stepSize = commandData.stepSize; - uint16_t transitionTime = commandData.transitionTime; - uint16_t colorTemperatureMinimum = commandData.colorTemperatureMinimumMireds; - uint16_t colorTemperatureMaximum = commandData.colorTemperatureMaximumMireds; - BitMask optionsMask = commandData.optionsMask; - BitMask optionsOverride = commandData.optionsOverride; - EndpointId endpoint = commandPath.mEndpointId; - Status status = Status::Success; - uint16_t tempPhysicalMin = MIN_TEMPERATURE_VALUE; - uint16_t tempPhysicalMax = MAX_TEMPERATURE_VALUE; + // Confirm validity of the step mode and step size received + VerifyOrReturnValue(commandData.stepMode != HueStepMode::kUnknownEnumValue, Status::InvalidCommand); + VerifyOrReturnValue(commandData.stepSize != 0, Status::InvalidCommand); Color16uTransitionState * colorTempTransitionState = getTempTransitionState(endpoint); - VerifyOrExit(colorTempTransitionState != nullptr, status = Status::UnsupportedEndpoint); + VerifyOrReturnValue(colorTempTransitionState != nullptr, Status::UnsupportedEndpoint); - // Confirm validity of the step mode and step size received - if (stepMode == HueStepMode::kUnknownEnumValue || stepSize == 0) - { - commandObj->AddStatus(commandPath, Status::InvalidCommand); - return true; - } - - if (!shouldExecuteIfOff(endpoint, optionsMask, optionsOverride)) - { - commandObj->AddStatus(commandPath, Status::Success); - return true; - } + VerifyOrReturnValue(shouldExecuteIfOff(endpoint, commandData.optionsMask, commandData.optionsOverride), Status::Success); // New command. Need to stop any active transitions. stopAllColorTransitions(endpoint); + uint16_t tempPhysicalMin = MIN_TEMPERATURE_VALUE; + uint16_t tempPhysicalMax = MAX_TEMPERATURE_VALUE; Attributes::ColorTempPhysicalMinMireds::Get(endpoint, &tempPhysicalMin); Attributes::ColorTempPhysicalMaxMireds::Get(endpoint, &tempPhysicalMax); @@ -2812,6 +2781,7 @@ bool ColorControlServer::stepColorTempCommand(app::CommandHandler * commandObj, // Per spec, colorTemperatureMinimumMireds field is limited to ColorTempPhysicalMinMireds and // when colorTemperatureMinimumMireds field is 0, ColorTempPhysicalMinMireds shall be used (always > 0) + uint16_t colorTemperatureMinimum = commandData.colorTemperatureMinimumMireds; if (colorTemperatureMinimum < tempPhysicalMin) { colorTemperatureMinimum = tempPhysicalMin; @@ -2819,6 +2789,7 @@ bool ColorControlServer::stepColorTempCommand(app::CommandHandler * commandObj, // Per spec, colorTemperatureMaximumMireds field is limited to ColorTempPhysicalMaxMireds and // when colorTemperatureMaximumMireds field is 0, ColorTempPhysicalMaxMireds shall be used + uint16_t colorTemperatureMaximum = commandData.colorTemperatureMaximumMireds; if ((colorTemperatureMaximum == 0) || (colorTemperatureMaximum > tempPhysicalMax)) { colorTemperatureMaximum = tempPhysicalMax; @@ -2834,9 +2805,10 @@ bool ColorControlServer::stepColorTempCommand(app::CommandHandler * commandObj, colorTempTransitionState->currentValue = colorTempTransitionState->initialValue; - if (stepMode == HueStepMode::kUp) + if (commandData.stepMode == HueStepMode::kUp) { - uint32_t finalValue32u = static_cast(colorTempTransitionState->initialValue) + static_cast(stepSize); + uint32_t finalValue32u = + static_cast(colorTempTransitionState->initialValue) + static_cast(commandData.stepSize); if (finalValue32u > UINT16_MAX) { colorTempTransitionState->finalValue = UINT16_MAX; @@ -2846,9 +2818,10 @@ bool ColorControlServer::stepColorTempCommand(app::CommandHandler * commandObj, colorTempTransitionState->finalValue = static_cast(finalValue32u); } } - else if (stepMode == HueStepMode::kDown) + else if (commandData.stepMode == HueStepMode::kDown) { - uint32_t finalValue32u = static_cast(colorTempTransitionState->initialValue) - static_cast(stepSize); + uint32_t finalValue32u = + static_cast(colorTempTransitionState->initialValue) - static_cast(commandData.stepSize); if (finalValue32u > UINT16_MAX) { colorTempTransitionState->finalValue = 0; @@ -2858,22 +2831,20 @@ bool ColorControlServer::stepColorTempCommand(app::CommandHandler * commandObj, colorTempTransitionState->finalValue = static_cast(finalValue32u); } } - colorTempTransitionState->stepsRemaining = std::max(transitionTime, 1); + colorTempTransitionState->stepsRemaining = std::max(commandData.transitionTime, 1); colorTempTransitionState->stepsTotal = colorTempTransitionState->stepsRemaining; - colorTempTransitionState->timeRemaining = transitionTime; - colorTempTransitionState->transitionTime = transitionTime; + colorTempTransitionState->timeRemaining = commandData.transitionTime; + colorTempTransitionState->transitionTime = commandData.transitionTime; colorTempTransitionState->endpoint = endpoint; colorTempTransitionState->lowLimit = colorTemperatureMinimum; colorTempTransitionState->highLimit = colorTemperatureMaximum; - SetQuietReportRemainingTime(endpoint, transitionTime, true /* isNewTransition */); + SetQuietReportRemainingTime(endpoint, commandData.transitionTime, true /* isNewTransition */); // kick off the state machine: - scheduleTimerCallbackMs(configureTempEventControl(endpoint), transitionTime ? TRANSITION_UPDATE_TIME_MS.count() : 0); - -exit: - commandObj->AddStatus(commandPath, status); - return true; + scheduleTimerCallbackMs(configureTempEventControl(endpoint), + commandData.transitionTime ? TRANSITION_UPDATE_TIME_MS.count() : 0); + return Status::Success; } void ColorControlServer::levelControlColorTempChangeCommand(EndpointId endpoint) @@ -3220,21 +3191,27 @@ bool emberAfColorControlClusterMoveToColorTemperatureCallback(app::CommandHandle const app::ConcreteCommandPath & commandPath, const Commands::MoveToColorTemperature::DecodableType & commandData) { - return ColorControlServer::Instance().moveToColorTempCommand(commandObj, commandPath, commandData); + Status status = ColorControlServer::Instance().moveToColorTempCommand(commandPath.mEndpointId, commandData); + commandObj->AddStatus(commandPath, status); + return true; } bool emberAfColorControlClusterMoveColorTemperatureCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::MoveColorTemperature::DecodableType & commandData) { - return ColorControlServer::Instance().moveColorTempCommand(commandObj, commandPath, commandData); + Status status = ColorControlServer::Instance().moveColorTempCommand(commandPath.mEndpointId, commandData); + commandObj->AddStatus(commandPath, status); + return true; } bool emberAfColorControlClusterStepColorTemperatureCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::StepColorTemperature::DecodableType & commandData) { - return ColorControlServer::Instance().stepColorTempCommand(commandObj, commandPath, commandData); + Status status = ColorControlServer::Instance().stepColorTempCommand(commandPath.mEndpointId, commandData); + commandObj->AddStatus(commandPath, status); + return true; } void emberAfPluginLevelControlCoupledColorTempChangeCallback(EndpointId endpoint) diff --git a/src/app/clusters/color-control-server/color-control-server.h b/src/app/clusters/color-control-server/color-control-server.h index 210df4c16635f0..40ae30aeb2224f 100644 --- a/src/app/clusters/color-control-server/color-control-server.h +++ b/src/app/clusters/color-control-server/color-control-server.h @@ -197,13 +197,15 @@ class ColorControlServer #endif // MATTER_DM_PLUGIN_COLOR_CONTROL_SERVER_XY #ifdef MATTER_DM_PLUGIN_COLOR_CONTROL_SERVER_TEMP - bool moveColorTempCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - const chip::app::Clusters::ColorControl::Commands::MoveColorTemperature::DecodableType & commandData); - bool - moveToColorTempCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + chip::Protocols::InteractionModel::Status + moveColorTempCommand(const chip::EndpointId endpoint, + const chip::app::Clusters::ColorControl::Commands::MoveColorTemperature::DecodableType & commandData); + chip::Protocols::InteractionModel::Status + moveToColorTempCommand(const chip::EndpointId endpoint, const chip::app::Clusters::ColorControl::Commands::MoveToColorTemperature::DecodableType & commandData); - bool stepColorTempCommand(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - const chip::app::Clusters::ColorControl::Commands::StepColorTemperature::DecodableType & commandData); + chip::Protocols::InteractionModel::Status + stepColorTempCommand(const chip::EndpointId endpoint, + const chip::app::Clusters::ColorControl::Commands::StepColorTemperature::DecodableType & commandData); void levelControlColorTempChangeCommand(chip::EndpointId endpoint); void startUpColorTempCommand(chip::EndpointId endpoint); void updateTempCommand(chip::EndpointId endpoint);