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

Support write operation of user label list for User Label Cluster #13065

Merged
merged 5 commits into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
41 changes: 40 additions & 1 deletion src/app/clusters/user-label-server/user-label-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ class UserLabelAttrAccess : public AttributeAccessInterface
UserLabelAttrAccess() : AttributeAccessInterface(Optional<EndpointId>::Missing(), UserLabel::Id) {}

CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override;
CHIP_ERROR Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) override;

private:
CHIP_ERROR ReadLabelList(EndpointId endpoint, AttributeValueEncoder & aEncoder);
CHIP_ERROR WriteLabelList(EndpointId endpoint, AttributeValueDecoder & aDecoder);
};

UserLabelAttrAccess gAttrAccess;

CHIP_ERROR UserLabelAttrAccess::ReadLabelList(EndpointId endpoint, AttributeValueEncoder & aEncoder)
{
CHIP_ERROR err = CHIP_NO_ERROR;
Expand All @@ -74,7 +78,27 @@ CHIP_ERROR UserLabelAttrAccess::ReadLabelList(EndpointId endpoint, AttributeValu
return err;
}

UserLabelAttrAccess gAttrAccess;
CHIP_ERROR UserLabelAttrAccess::WriteLabelList(EndpointId endpoint, AttributeValueDecoder & aDecoder)
{
DeviceLayer::LabelList<app::Clusters::UserLabel::Structs::LabelStruct::Type, DeviceLayer::kMaxUserLabels> labelList;
yufengwangca marked this conversation as resolved.
Show resolved Hide resolved
LabelList::TypeInfo::DecodableType decodablelist;

ReturnErrorOnFailure(aDecoder.Decode(decodablelist));

uint8_t index = 0;
auto iter = decodablelist.begin();
while (iter.Next())
{
auto & entry = iter.GetValue();

VerifyOrReturnError(index < DeviceLayer::kMaxUserLabels, CHIP_ERROR_BUFFER_TOO_SMALL);
yufengwangca marked this conversation as resolved.
Show resolved Hide resolved
labelList.add(entry);
}

ReturnErrorOnFailure(DeviceLayer::PlatformMgr().SetUserLabelList(endpoint, labelList));
yufengwangca marked this conversation as resolved.
Show resolved Hide resolved

return iter.GetStatus();
}

CHIP_ERROR UserLabelAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
{
Expand All @@ -89,6 +113,21 @@ CHIP_ERROR UserLabelAttrAccess::Read(const ConcreteReadAttributePath & aPath, At
}
return CHIP_NO_ERROR;
}

CHIP_ERROR UserLabelAttrAccess::Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder)
{
VerifyOrDie(aPath.mClusterId == UserLabel::Id);

switch (aPath.mAttributeId)
{
case LabelList::Id:
return WriteLabelList(aPath.mEndpointId, aDecoder);
default:
break;
}
return CHIP_NO_ERROR;
}

} // anonymous namespace

void MatterUserLabelPluginServerInitCallback(void)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ limitations under the License.
<code>0x0041</code>
<define>USER_LABEL_CLUSTER</define>
<description>The User Label Cluster provides a feature to tag an endpoint with zero or more labels.</description>
<attribute side="server" code="0x0000" define="LABEL_LIST" type="ARRAY" entryType="LabelStruct" length="254" writable="false" optional="false">label list</attribute>
<attribute side="server" code="0x0000" define="LABEL_LIST" type="ARRAY" entryType="LabelStruct" length="254" writable="true" optional="false">label list</attribute>
</cluster>
</configurator>
1 change: 1 addition & 0 deletions src/controller/python/chip/clusters/CHIPClusters.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 0 additions & 42 deletions src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.mm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions src/darwin/Framework/CHIPTests/CHIPClustersTests.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/include/platform/PlatformManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ class PlatformManager

CHIP_ERROR GetFixedLabelList(EndpointId endpoint,
LabelList<app::Clusters::FixedLabel::Structs::LabelStruct::Type, kMaxFixedLabels> & labelList);
CHIP_ERROR SetUserLabelList(EndpointId endpoint,
LabelList<app::Clusters::UserLabel::Structs::LabelStruct::Type, kMaxUserLabels> & labelList);
CHIP_ERROR GetUserLabelList(EndpointId endpoint,
LabelList<app::Clusters::UserLabel::Structs::LabelStruct::Type, kMaxUserLabels> & labelList);

Expand Down Expand Up @@ -434,6 +436,13 @@ PlatformManager::GetFixedLabelList(EndpointId endpoint,
return static_cast<ImplClass *>(this)->_GetFixedLabelList(endpoint, labelList);
}

inline CHIP_ERROR
PlatformManager::SetUserLabelList(EndpointId endpoint,
LabelList<app::Clusters::UserLabel::Structs::LabelStruct::Type, kMaxUserLabels> & labelList)
{
return static_cast<ImplClass *>(this)->_SetUserLabelList(endpoint, labelList);
}

inline CHIP_ERROR
PlatformManager::GetUserLabelList(EndpointId endpoint,
LabelList<app::Clusters::UserLabel::Structs::LabelStruct::Type, kMaxUserLabels> & labelList)
Expand Down
9 changes: 9 additions & 0 deletions src/include/platform/internal/GenericPlatformManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class GenericPlatformManagerImpl

CHIP_ERROR _GetFixedLabelList(EndpointId endpoint,
LabelList<app::Clusters::FixedLabel::Structs::LabelStruct::Type, kMaxFixedLabels> & labelList);
CHIP_ERROR _SetUserLabelList(EndpointId endpoint,
LabelList<app::Clusters::UserLabel::Structs::LabelStruct::Type, kMaxUserLabels> & labelList);
CHIP_ERROR _GetUserLabelList(EndpointId endpoint,
LabelList<app::Clusters::UserLabel::Structs::LabelStruct::Type, kMaxUserLabels> & labelList);

Expand All @@ -85,6 +87,13 @@ inline CHIP_ERROR GenericPlatformManagerImpl<ImplClass>::_GetFixedLabelList(
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}

template <class ImplClass>
inline CHIP_ERROR GenericPlatformManagerImpl<ImplClass>::_SetUserLabelList(
EndpointId endpoint, LabelList<app::Clusters::UserLabel::Structs::LabelStruct::Type, kMaxUserLabels> & labelList)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}

template <class ImplClass>
inline CHIP_ERROR GenericPlatformManagerImpl<ImplClass>::_GetUserLabelList(
EndpointId endpoint, LabelList<app::Clusters::UserLabel::Structs::LabelStruct::Type, kMaxUserLabels> & labelList)
Expand Down
8 changes: 8 additions & 0 deletions src/platform/Linux/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,14 @@ CHIP_ERROR PlatformManagerImpl::_GetFixedLabelList(
return CHIP_NO_ERROR;
}

CHIP_ERROR
PlatformManagerImpl::_SetUserLabelList(EndpointId endpoint,
LabelList<app::Clusters::UserLabel::Structs::LabelStruct::Type, kMaxUserLabels> & labelList)
{
// TODO:: store the user labelList, and read back stored user labelList if it has been set. Add yaml test to verify this.
return CHIP_NO_ERROR;
}

CHIP_ERROR
PlatformManagerImpl::_GetUserLabelList(EndpointId endpoint,
LabelList<app::Clusters::UserLabel::Structs::LabelStruct::Type, kMaxUserLabels> & labelList)
Expand Down
2 changes: 2 additions & 0 deletions src/platform/Linux/PlatformManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener
CHIP_ERROR _Shutdown();
CHIP_ERROR _GetFixedLabelList(EndpointId endpoint,
LabelList<app::Clusters::FixedLabel::Structs::LabelStruct::Type, kMaxFixedLabels> & labelList);
CHIP_ERROR _SetUserLabelList(EndpointId endpoint,
LabelList<app::Clusters::UserLabel::Structs::LabelStruct::Type, kMaxUserLabels> & labelList);
CHIP_ERROR _GetUserLabelList(EndpointId endpoint,
LabelList<app::Clusters::UserLabel::Structs::LabelStruct::Type, kMaxUserLabels> & labelList);

Expand Down
6 changes: 6 additions & 0 deletions src/platform/fake/PlatformManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ class PlatformManagerImpl final : public PlatformManager
return CHIP_ERROR_NOT_IMPLEMENTED;
}

CHIP_ERROR _SetUserLabelList(EndpointId endpoint,
LabelList<app::Clusters::UserLabel::Structs::LabelStruct::Type, kMaxUserLabels> & labelList)
{
return CHIP_ERROR_NOT_IMPLEMENTED;
}

CHIP_ERROR _GetUserLabelList(EndpointId endpoint,
LabelList<app::Clusters::UserLabel::Structs::LabelStruct::Type, kMaxUserLabels> & labelList)
{
Expand Down
10 changes: 6 additions & 4 deletions zzz_generated/all-clusters-app/zap-generated/endpoint_config.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions zzz_generated/bridge-app/zap-generated/endpoint_config.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading