Skip to content

Commit 52213a8

Browse files
authored
Disable ABS feature in windowcovering (project-chip#37853)
* Disable ABS feature in windowcovering * Add ZAP Generated * Add files for window covering chef delegate * Fix compilation * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * Review comments
1 parent d0ae88d commit 52213a8

File tree

7 files changed

+217
-9
lines changed

7 files changed

+217
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
*
3+
* Copyright (c) 2022 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include "chef-window-covering.h"
20+
#include "app/clusters/window-covering-server/window-covering-server.h"
21+
#include <app-common/zap-generated/attributes/Accessors.h>
22+
#include <app/reporting/reporting.h>
23+
#include <app/util/attribute-storage.h>
24+
#include <app/util/config.h>
25+
#include <app/util/endpoint-config-api.h>
26+
#include <lib/support/logging/CHIPLogging.h>
27+
28+
using namespace chip;
29+
using namespace chip::app::Clusters;
30+
using chip::Protocols::InteractionModel::Status;
31+
32+
constexpr size_t kWindowCoveringDelegateTableSize = MATTER_DM_WINDOW_COVERING_CLUSTER_SERVER_ENDPOINT_COUNT;
33+
static_assert(kWindowCoveringDelegateTableSize <= kEmberInvalidEndpointIndex, "WindowCovering Delegate table size error");
34+
35+
std::unique_ptr<WindowCovering::ChefDelegate> gDelegateTable[kWindowCoveringDelegateTableSize];
36+
37+
WindowCovering::ChefDelegate * GetDelegate(EndpointId endpoint)
38+
{
39+
uint16_t ep =
40+
emberAfGetClusterServerEndpointIndex(endpoint, WindowCovering::Id, MATTER_DM_WINDOW_COVERING_CLUSTER_SERVER_ENDPOINT_COUNT);
41+
return (ep >= kWindowCoveringDelegateTableSize ? nullptr : gDelegateTable[ep].get());
42+
}
43+
44+
void InitChefWindowCoveringCluster()
45+
{
46+
const uint16_t endpointCount = emberAfEndpointCount();
47+
48+
for (uint16_t endpointIndex = 0; endpointIndex < endpointCount; endpointIndex++)
49+
{
50+
EndpointId endpointId = emberAfEndpointFromIndex(endpointIndex);
51+
if (endpointId == kInvalidEndpointId)
52+
{
53+
continue;
54+
}
55+
56+
// Check if endpoint has WindowCovering cluster enabled
57+
uint16_t epIndex = emberAfGetClusterServerEndpointIndex(endpointId, WindowCovering::Id,
58+
MATTER_DM_WINDOW_COVERING_CLUSTER_SERVER_ENDPOINT_COUNT);
59+
if (epIndex >= kWindowCoveringDelegateTableSize)
60+
continue;
61+
62+
// Skip if delegate was already initialized.
63+
if (gDelegateTable[epIndex])
64+
continue;
65+
66+
gDelegateTable[epIndex] = std::make_unique<WindowCovering::ChefDelegate>();
67+
gDelegateTable[epIndex]->SetEndpoint(endpointId);
68+
WindowCovering::SetDefaultDelegate(endpointId, gDelegateTable[epIndex].get());
69+
}
70+
}
71+
72+
CHIP_ERROR WindowCovering::ChefDelegate::HandleMovement(WindowCoveringType type)
73+
{
74+
Status status;
75+
app::DataModel::Nullable<Percent100ths> current;
76+
77+
if (type == WindowCoveringType::Lift)
78+
{
79+
status = WindowCovering::Attributes::TargetPositionLiftPercent100ths::Get(mEndpoint, current);
80+
if (status != Status::Success)
81+
{
82+
ChipLogError(DeviceLayer, "HandleMovement: Failed to get TargetPositionLiftPercent100ths with error code %d",
83+
to_underlying(status));
84+
return CHIP_ERROR_READ_FAILED;
85+
}
86+
87+
// Instant update. No transition for now.
88+
status = WindowCovering::Attributes::CurrentPositionLiftPercent100ths::Set(mEndpoint, current);
89+
if (status != Status::Success)
90+
{
91+
ChipLogError(DeviceLayer, "HandleMovement: Failed to set CurrentPositionLiftPercent100ths with error code %d",
92+
to_underlying(status));
93+
return CHIP_ERROR_WRITE_FAILED;
94+
}
95+
96+
MatterReportingAttributeChangeCallback(mEndpoint, WindowCovering::Id,
97+
WindowCovering::Attributes::CurrentPositionLiftPercent100ths::Id);
98+
99+
return CHIP_NO_ERROR;
100+
}
101+
else if (type == WindowCoveringType::Tilt)
102+
{
103+
status = WindowCovering::Attributes::TargetPositionTiltPercent100ths::Get(mEndpoint, current);
104+
if (status != Status::Success)
105+
{
106+
ChipLogError(DeviceLayer, "HandleMovement: Failed to get TargetPositionTiltPercent100ths - %d", to_underlying(status));
107+
return CHIP_ERROR_READ_FAILED;
108+
}
109+
110+
// Instant update. No transition for now.
111+
status = WindowCovering::Attributes::CurrentPositionTiltPercent100ths::Set(mEndpoint, current);
112+
if (status != Status::Success)
113+
{
114+
ChipLogError(DeviceLayer, "HandleMovement: Failed to set CurrentPositionTiltPercent100ths - %d", to_underlying(status));
115+
return CHIP_ERROR_WRITE_FAILED;
116+
}
117+
118+
MatterReportingAttributeChangeCallback(mEndpoint, WindowCovering::Id,
119+
WindowCovering::Attributes::CurrentPositionTiltPercent100ths::Id);
120+
121+
return CHIP_NO_ERROR;
122+
}
123+
return CHIP_NO_ERROR;
124+
}
125+
126+
CHIP_ERROR WindowCovering::ChefDelegate::HandleStopMotion()
127+
{
128+
return CHIP_NO_ERROR;
129+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
*
3+
* Copyright (c) 2025 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include <app/clusters/window-covering-server/window-covering-delegate.h>
20+
21+
#pragma once
22+
23+
#include <app-common/zap-generated/cluster-objects.h>
24+
#include <app/CommandResponseHelper.h>
25+
26+
namespace chip {
27+
namespace app {
28+
namespace Clusters {
29+
namespace WindowCovering {
30+
31+
/** @brief
32+
* Defines methods for implementing application-specific logic for the WindowCovering Cluster.
33+
*/
34+
class ChefDelegate : public Delegate
35+
{
36+
public:
37+
/**
38+
* @brief
39+
* This method adjusts window covering position so the physical lift/slide and tilt is at the target
40+
* open/up position set before calling this method. This will happen as fast as possible.
41+
*
42+
* @param[in] type window covering type.
43+
*
44+
* @return CHIP_NO_ERROR On success.
45+
* @return Other Value indicating it failed to adjust window covering position.
46+
*/
47+
CHIP_ERROR HandleMovement(WindowCoveringType type);
48+
49+
/**
50+
* @brief
51+
* This method stops any adjusting to the physical tilt and lift/slide that is currently occurring.
52+
*
53+
* @return CHIP_NO_ERROR On success.
54+
* @return Other Value indicating it failed to stop any adjusting to the physical tilt and lift/slide that is currently
55+
* occurring..
56+
*/
57+
CHIP_ERROR HandleStopMotion();
58+
59+
~ChefDelegate() = default;
60+
ChefDelegate() = default;
61+
};
62+
63+
} // namespace WindowCovering
64+
} // namespace Clusters
65+
} // namespace app
66+
} // namespace chip
67+
68+
void InitChefWindowCoveringCluster();

examples/chef/common/stubs.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ const Clusters::Descriptor::Structs::SemanticTagStruct::Type freezerTagList[]
8181
#include "temperature-control/static-supported-temperature-levels.h"
8282
#endif // MATTER_DM_PLUGIN_TEMPERATURE_CONTROL_SERVER
8383

84+
#ifdef MATTER_DM_PLUGIN_WINDOW_COVERING_SERVER
85+
#include "window-covering/chef-window-covering.h"
86+
#endif // MATTER_DM_PLUGIN_WINDOW_COVERING_SERVER
87+
8488
Protocols::InteractionModel::Status emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
8589
const EmberAfAttributeMetadata * attributeMetadata,
8690
uint8_t * buffer, uint16_t maxReadLength)
@@ -350,6 +354,11 @@ void ApplicationInit()
350354
SetTagList(kColdCabinetEndpointId, Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(refrigeratorTagList));
351355
SetTagList(kFreezeCabinetEndpointId, Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(freezerTagList));
352356
#endif // MATTER_DM_PLUGIN_REFRIGERATOR_ALARM_SERVER
357+
358+
#ifdef MATTER_DM_PLUGIN_WINDOW_COVERING_SERVER
359+
ChipLogProgress(NotSpecified, "Initializing WindowCovering cluster delegate.");
360+
InitChefWindowCoveringCluster();
361+
#endif // MATTER_DM_PLUGIN_WINDOW_COVERING_SERVER
353362
}
354363

355364
void ApplicationShutdown()

examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter

+1-1
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,7 @@ endpoint 1 {
20142014
callback attribute generatedCommandList;
20152015
callback attribute acceptedCommandList;
20162016
callback attribute attributeList;
2017-
ram attribute featureMap default = 0x1f;
2017+
ram attribute featureMap default = 0x17;
20182018
ram attribute clusterRevision default = 5;
20192019

20202020
handle command UpOrOpen;

examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.zap

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717
}
1818
],
1919
"package": [
20-
{
21-
"pathRelativity": "relativeToZap",
22-
"path": "../../../src/app/zap-templates/app-templates.json",
23-
"type": "gen-templates-json",
24-
"category": "matter",
25-
"version": "chip-v1"
26-
},
2720
{
2821
"pathRelativity": "relativeToZap",
2922
"path": "../../../src/app/zap-templates/zcl/zcl.json",
3023
"type": "zcl-properties",
3124
"category": "matter",
3225
"version": 1,
3326
"description": "Matter SDK ZCL data"
27+
},
28+
{
29+
"pathRelativity": "relativeToZap",
30+
"path": "../../../src/app/zap-templates/app-templates.json",
31+
"type": "gen-templates-json",
32+
"category": "matter",
33+
"version": "chip-v1"
3434
}
3535
],
3636
"endpointTypes": [
@@ -3273,7 +3273,7 @@
32733273
"storageOption": "RAM",
32743274
"singleton": 0,
32753275
"bounded": 0,
3276-
"defaultValue": "0x1f",
3276+
"defaultValue": "0x17",
32773277
"reportable": 1,
32783278
"minInterval": 1,
32793279
"maxInterval": 65534,

examples/chef/linux/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ executable("${sample_name}") {
6767
"${project_dir}/common/clusters/target-navigator/TargetNavigatorManager.cpp",
6868
"${project_dir}/common/clusters/temperature-control/static-supported-temperature-levels.cpp",
6969
"${project_dir}/common/clusters/wake-on-lan/WakeOnLanManager.cpp",
70+
"${project_dir}/common/clusters/window-covering/chef-window-covering.cpp",
7071
"${project_dir}/common/stubs.cpp",
7172
"${project_dir}/linux/main.cpp",
7273
]

examples/chef/nrfconnect/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ target_sources(app PRIVATE
104104
${CHEF}/common/clusters/temperature-control/static-supported-temperature-levels.cpp
105105
${CHEF}/common/clusters/target-navigator/TargetNavigatorManager.cpp
106106
${CHEF}/common/clusters/wake-on-lan/WakeOnLanManager.cpp
107+
${CHEF}/common/clusters/window-covering/chef-window-covering.cpp
107108
${CHEF}/common/stubs.cpp
108109
${CHEF}/nrfconnect/main.cpp
109110
)

0 commit comments

Comments
 (0)