Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable ABS feature in windowcovering #37853

Merged
merged 32 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions examples/chef/common/clusters/window-covering/chef-window-covering.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
*
* Copyright (c) 2022 Project CHIP Authors
* All rights reserved.
*
* 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.
*/

#include "chef-window-covering.h"
#include "app/clusters/window-covering-server/window-covering-server.h"
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/reporting/reporting.h>
#include <app/util/attribute-storage.h>
#include <app/util/config.h>
#include <app/util/endpoint-config-api.h>
#include <lib/support/logging/CHIPLogging.h>

using namespace chip;
using namespace chip::app::Clusters;
using chip::Protocols::InteractionModel::Status;

constexpr size_t kWindowCoveringDelegateTableSize = MATTER_DM_WINDOW_COVERING_CLUSTER_SERVER_ENDPOINT_COUNT;
static_assert(kWindowCoveringDelegateTableSize <= kEmberInvalidEndpointIndex, "WindowCovering Delegate table size error");

std::unique_ptr<WindowCovering::ChefDelegate> gDelegateTable[kWindowCoveringDelegateTableSize];

WindowCovering::ChefDelegate * GetDelegate(EndpointId endpoint)
{
uint16_t ep =
emberAfGetClusterServerEndpointIndex(endpoint, WindowCovering::Id, MATTER_DM_WINDOW_COVERING_CLUSTER_SERVER_ENDPOINT_COUNT);
return (ep >= kWindowCoveringDelegateTableSize ? nullptr : gDelegateTable[ep].get());
}

void InitChefWindowCoveringCluster()
{
const uint16_t endpointCount = emberAfEndpointCount();

for (uint16_t endpointIndex = 0; endpointIndex < endpointCount; endpointIndex++)
{
EndpointId endpointId = emberAfEndpointFromIndex(endpointIndex);
if (endpointId == kInvalidEndpointId)
{
continue;
}

// Check if endpoint has WindowCovering cluster enabled
uint16_t epIndex = emberAfGetClusterServerEndpointIndex(endpointId, WindowCovering::Id,
MATTER_DM_WINDOW_COVERING_CLUSTER_SERVER_ENDPOINT_COUNT);
if (epIndex >= kWindowCoveringDelegateTableSize)
continue;

// Skip if delegate was already initialized.
if (gDelegateTable[epIndex])
continue;

gDelegateTable[epIndex] = std::make_unique<WindowCovering::ChefDelegate>();
gDelegateTable[epIndex]->SetEndpoint(endpointId);
WindowCovering::SetDefaultDelegate(endpointId, gDelegateTable[epIndex].get());
}
}

CHIP_ERROR WindowCovering::ChefDelegate::HandleMovement(WindowCoveringType type)
{
Status status;
app::DataModel::Nullable<Percent100ths> current;

if (type == WindowCoveringType::Lift)
{
status = WindowCovering::Attributes::TargetPositionLiftPercent100ths::Get(mEndpoint, current);
if (status != Status::Success)
{
ChipLogError(DeviceLayer, "HandleMovement: Failed to get TargetPositionLiftPercent100ths with error code %d",
to_underlying(status));
return CHIP_ERROR_READ_FAILED;
}

// Instant update. No transition for now.
status = WindowCovering::Attributes::CurrentPositionLiftPercent100ths::Set(mEndpoint, current);
if (status != Status::Success)
{
ChipLogError(DeviceLayer, "HandleMovement: Failed to set CurrentPositionLiftPercent100ths with error code %d",
to_underlying(status));
return CHIP_ERROR_WRITE_FAILED;
}

MatterReportingAttributeChangeCallback(mEndpoint, WindowCovering::Id,
WindowCovering::Attributes::CurrentPositionLiftPercent100ths::Id);

return CHIP_NO_ERROR;
}
else if (type == WindowCoveringType::Tilt)
{
status = WindowCovering::Attributes::TargetPositionTiltPercent100ths::Get(mEndpoint, current);
if (status != Status::Success)
{
ChipLogError(DeviceLayer, "HandleMovement: Failed to get TargetPositionTiltPercent100ths - %d", to_underlying(status));
return CHIP_ERROR_READ_FAILED;
}

// Instant update. No transition for now.
status = WindowCovering::Attributes::CurrentPositionTiltPercent100ths::Set(mEndpoint, current);
if (status != Status::Success)
{
ChipLogError(DeviceLayer, "HandleMovement: Failed to set CurrentPositionTiltPercent100ths - %d", to_underlying(status));
return CHIP_ERROR_WRITE_FAILED;
}

MatterReportingAttributeChangeCallback(mEndpoint, WindowCovering::Id,
WindowCovering::Attributes::CurrentPositionTiltPercent100ths::Id);

return CHIP_NO_ERROR;
}
return CHIP_NO_ERROR;
}

CHIP_ERROR WindowCovering::ChefDelegate::HandleStopMotion()
{
return CHIP_NO_ERROR;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
*
* Copyright (c) 2025 Project CHIP Authors
* All rights reserved.
*
* 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.
*/

#include <app/clusters/window-covering-server/window-covering-delegate.h>

#pragma once

#include <app-common/zap-generated/cluster-objects.h>
#include <app/CommandResponseHelper.h>

namespace chip {
namespace app {
namespace Clusters {
namespace WindowCovering {

/** @brief
* Defines methods for implementing application-specific logic for the WindowCovering Cluster.
*/
class ChefDelegate : public Delegate
{
public:
/**
* @brief
* This method adjusts window covering position so the physical lift/slide and tilt is at the target
* open/up position set before calling this method. This will happen as fast as possible.
*
* @param[in] type window covering type.
*
* @return CHIP_NO_ERROR On success.
* @return Other Value indicating it failed to adjust window covering position.
*/
CHIP_ERROR HandleMovement(WindowCoveringType type);

/**
* @brief
* This method stops any adjusting to the physical tilt and lift/slide that is currently occurring.
*
* @return CHIP_NO_ERROR On success.
* @return Other Value indicating it failed to stop any adjusting to the physical tilt and lift/slide that is currently
* occurring..
*/
CHIP_ERROR HandleStopMotion();

~ChefDelegate() = default;
ChefDelegate() = default;
};

} // namespace WindowCovering
} // namespace Clusters
} // namespace app
} // namespace chip

void InitChefWindowCoveringCluster();
9 changes: 9 additions & 0 deletions examples/chef/common/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ const Clusters::Descriptor::Structs::SemanticTagStruct::Type freezerTagList[]
#include "temperature-control/static-supported-temperature-levels.h"
#endif // MATTER_DM_PLUGIN_TEMPERATURE_CONTROL_SERVER

#ifdef MATTER_DM_PLUGIN_WINDOW_COVERING_SERVER
#include "window-covering/chef-window-covering.h"
#endif // MATTER_DM_PLUGIN_WINDOW_COVERING_SERVER

Protocols::InteractionModel::Status emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer, uint16_t maxReadLength)
Expand Down Expand Up @@ -350,6 +354,11 @@ void ApplicationInit()
SetTagList(kColdCabinetEndpointId, Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(refrigeratorTagList));
SetTagList(kFreezeCabinetEndpointId, Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(freezerTagList));
#endif // MATTER_DM_PLUGIN_REFRIGERATOR_ALARM_SERVER

#ifdef MATTER_DM_PLUGIN_WINDOW_COVERING_SERVER
ChipLogProgress(NotSpecified, "Initializing WindowCovering cluster delegate.");
InitChefWindowCoveringCluster();
#endif // MATTER_DM_PLUGIN_WINDOW_COVERING_SERVER
}

void ApplicationShutdown()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,7 @@ endpoint 1 {
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute attributeList;
ram attribute featureMap default = 0x1f;
ram attribute featureMap default = 0x17;
ram attribute clusterRevision default = 5;

handle command UpOrOpen;
Expand Down
16 changes: 8 additions & 8 deletions examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.zap
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
}
],
"package": [
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/app-templates.json",
"type": "gen-templates-json",
"category": "matter",
"version": "chip-v1"
},
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/zcl/zcl.json",
"type": "zcl-properties",
"category": "matter",
"version": 1,
"description": "Matter SDK ZCL data"
},
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/app-templates.json",
"type": "gen-templates-json",
"category": "matter",
"version": "chip-v1"
}
],
"endpointTypes": [
Expand Down Expand Up @@ -3273,7 +3273,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x1f",
"defaultValue": "0x17",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down
1 change: 1 addition & 0 deletions examples/chef/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ executable("${sample_name}") {
"${project_dir}/common/clusters/target-navigator/TargetNavigatorManager.cpp",
"${project_dir}/common/clusters/temperature-control/static-supported-temperature-levels.cpp",
"${project_dir}/common/clusters/wake-on-lan/WakeOnLanManager.cpp",
"${project_dir}/common/clusters/window-covering/chef-window-covering.cpp",
"${project_dir}/common/stubs.cpp",
"${project_dir}/linux/main.cpp",
]
Expand Down
1 change: 1 addition & 0 deletions examples/chef/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ target_sources(app PRIVATE
${CHEF}/common/clusters/temperature-control/static-supported-temperature-levels.cpp
${CHEF}/common/clusters/target-navigator/TargetNavigatorManager.cpp
${CHEF}/common/clusters/wake-on-lan/WakeOnLanManager.cpp
${CHEF}/common/clusters/window-covering/chef-window-covering.cpp
${CHEF}/common/stubs.cpp
${CHEF}/nrfconnect/main.cpp
)
Expand Down
Loading