diff --git a/src/app/clusters/scenes/scenes.cpp b/src/app/clusters/scenes/scenes.cpp index 72393ff7f42b61..2d21912a3153df 100644 --- a/src/app/clusters/scenes/scenes.cpp +++ b/src/app/clusters/scenes/scenes.cpp @@ -206,7 +206,10 @@ void emAfPluginScenesServerPrintInfo(void) emberAfCorePrint(" door %x", entry.lockStateValue); #endif #ifdef ZCL_USING_WINDOW_COVERING_CLUSTER_SERVER - emberAfCorePrint(" window %x %x", entry.currentPositionLiftPercentageValue, entry.currentPositionTiltPercentageValue); + emberAfCorePrint(" Window percentage Lift %3u, Tilt %3u", entry.currentPositionLiftPercentageValue, + entry.currentPositionTiltPercentageValue); + emberAfCorePrint(" Window percent100ths Lift %5u, Tilt %5u", entry.targetPositionLiftPercent100thsValue, + entry.targetPositionTiltPercent100thsValue); #endif } emberAfCorePrintln(""); @@ -538,12 +541,20 @@ EmberAfStatus emberAfScenesClusterStoreCurrentSceneCallback(EndpointId endpoint, #ifdef ZCL_USING_WINDOW_COVERING_CLUSTER_SERVER entry.hasCurrentPositionLiftPercentageValue = readServerAttribute(endpoint, ZCL_WINDOW_COVERING_CLUSTER_ID, ZCL_WC_CURRENT_POSITION_LIFT_PERCENTAGE_ATTRIBUTE_ID, - "current position lift percentage", (uint8_t *) &entry.currentPositionLiftPercentageValue, + "currentPositionLiftPercentage", (uint8_t *) &entry.currentPositionLiftPercentageValue, sizeof(entry.currentPositionLiftPercentageValue)); entry.hasCurrentPositionTiltPercentageValue = readServerAttribute(endpoint, ZCL_WINDOW_COVERING_CLUSTER_ID, ZCL_WC_CURRENT_POSITION_TILT_PERCENTAGE_ATTRIBUTE_ID, - "current position tilt percentage", (uint8_t *) &entry.currentPositionTiltPercentageValue, + "currentPositionTiltPercentage", (uint8_t *) &entry.currentPositionTiltPercentageValue, sizeof(entry.currentPositionTiltPercentageValue)); + entry.hasTargetPositionLiftPercent100thsValue = + readServerAttribute(endpoint, ZCL_WINDOW_COVERING_CLUSTER_ID, ZCL_WC_TARGET_POSITION_LIFT_PERCENT100_THS_ATTRIBUTE_ID, + "targetPositionLiftPercent100ths", (uint8_t *) &entry.targetPositionLiftPercent100thsValue, + sizeof(entry.targetPositionLiftPercent100thsValue)); + entry.hasTargetPositionTiltPercent100thsValue = + readServerAttribute(endpoint, ZCL_WINDOW_COVERING_CLUSTER_ID, ZCL_WC_TARGET_POSITION_TILT_PERCENT100_THS_ATTRIBUTE_ID, + "targetPositionTiltPercent100ths", (uint8_t *) &entry.targetPositionTiltPercent100thsValue, + sizeof(entry.targetPositionTiltPercent100thsValue)); #endif // When creating a new entry, the name is set to the null string (i.e., the @@ -676,15 +687,27 @@ EmberAfStatus emberAfScenesClusterRecallSavedSceneCallback(EndpointId endpoint, if (entry.hasCurrentPositionLiftPercentageValue) { writeServerAttribute(endpoint, ZCL_WINDOW_COVERING_CLUSTER_ID, - ZCL_WC_CURRENT_POSITION_LIFT_PERCENTAGE_ATTRIBUTE_ID, "current position lift percentage", + ZCL_WC_CURRENT_POSITION_LIFT_PERCENTAGE_ATTRIBUTE_ID, "CurrentPositionLiftPercentage", (uint8_t *) &entry.currentPositionLiftPercentageValue, ZCL_INT8U_ATTRIBUTE_TYPE); } if (entry.hasCurrentPositionTiltPercentageValue) { writeServerAttribute(endpoint, ZCL_WINDOW_COVERING_CLUSTER_ID, - ZCL_WC_CURRENT_POSITION_TILT_PERCENTAGE_ATTRIBUTE_ID, "current position tilt percentage", + ZCL_WC_CURRENT_POSITION_TILT_PERCENTAGE_ATTRIBUTE_ID, "CurrentPositionTiltPercentage", (uint8_t *) &entry.currentPositionTiltPercentageValue, ZCL_INT8U_ATTRIBUTE_TYPE); } + if (entry.hasTargetPositionLiftPercent100thsValue) + { + writeServerAttribute(endpoint, ZCL_WINDOW_COVERING_CLUSTER_ID, + ZCL_WC_TARGET_POSITION_LIFT_PERCENT100_THS_ATTRIBUTE_ID, "TargetPositionLiftPercent100ths", + (uint8_t *) &entry.targetPositionLiftPercent100thsValue, ZCL_INT16U_ATTRIBUTE_TYPE); + } + if (entry.hasTargetPositionTiltPercent100thsValue) + { + writeServerAttribute(endpoint, ZCL_WINDOW_COVERING_CLUSTER_ID, + ZCL_WC_TARGET_POSITION_TILT_PERCENT100_THS_ATTRIBUTE_ID, "TargetPositionTiltPercent100ths", + (uint8_t *) &entry.targetPositionTiltPercent100thsValue, ZCL_INT16U_ATTRIBUTE_TYPE); + } #endif emberAfScenesMakeValid(endpoint, sceneId, groupId); return EMBER_ZCL_STATUS_SUCCESS; @@ -793,8 +816,10 @@ bool emberAfPluginScenesServerParseAddScene(chip::app::Command * commandObj, con entry.hasLockStateValue = false; #endif #ifdef ZCL_USING_WINDOW_COVERING_CLUSTER_SERVER - entry.hasCurrentPositionLiftPercentageValue = false; - entry.hasCurrentPositionTiltPercentageValue = false; + entry.hasCurrentPositionLiftPercentageValue = false; + entry.hasCurrentPositionTiltPercentageValue = false; + entry.hasTargetPositionLiftPercent100thsValue = false; + entry.hasTargetPositionTiltPercent100thsValue = false; #endif } @@ -978,6 +1003,24 @@ bool emberAfPluginScenesServerParseAddScene(chip::app::Command * commandObj, con entry.hasCurrentPositionTiltPercentageValue = true; entry.currentPositionTiltPercentageValue = emberAfGetInt8u(extensionFieldSets, extensionFieldSetsIndex, extensionFieldSetsLen); + extensionFieldSetsIndex++; + length--; + if (length < 2) + { + break; + } + entry.hasTargetPositionLiftPercent100thsValue = true; + entry.targetPositionLiftPercent100thsValue = + emberAfGetInt16u(extensionFieldSets, extensionFieldSetsIndex, extensionFieldSetsLen); + extensionFieldSetsIndex = static_cast(extensionFieldSetsIndex + 2); + length = static_cast(length - 2); + if (length < 2) + { + break; + } + entry.hasTargetPositionTiltPercent100thsValue = true; + entry.targetPositionTiltPercent100thsValue = + emberAfGetInt16u(extensionFieldSets, extensionFieldSetsIndex, extensionFieldSetsLen); // If additional Window Covering extensions are added, adjust the index // and length variables here. break; @@ -1210,6 +1253,16 @@ bool emberAfPluginScenesServerParseViewScene(chip::app::Command * commandObj, co { emberAfPutInt8uInResp(entry.currentPositionTiltPercentageValue); (*length)++; + if (entry.hasTargetPositionLiftPercent100thsValue) + { + emberAfPutInt16uInResp(entry.targetPositionLiftPercent100thsValue); + *length = static_cast(*length + 2); + if (entry.hasTargetPositionTiltPercent100thsValue) + { + emberAfPutInt16uInResp(entry.targetPositionTiltPercent100thsValue); + *length = static_cast(*length + 2); + } + } } } #endif diff --git a/src/app/util/af-types.h b/src/app/util/af-types.h index 23df492ff91e77..0db1d517f8b4c7 100644 --- a/src/app/util/af-types.h +++ b/src/app/util/af-types.h @@ -943,6 +943,10 @@ typedef struct uint8_t currentPositionLiftPercentageValue; bool hasCurrentPositionTiltPercentageValue; uint8_t currentPositionTiltPercentageValue; + bool hasTargetPositionLiftPercent100thsValue; + uint16_t targetPositionLiftPercent100thsValue; + bool hasTargetPositionTiltPercent100thsValue; + uint16_t targetPositionTiltPercent100thsValue; #endif } EmberAfSceneTableEntry;