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 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
37 changes: 36 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,23 @@ CHIP_ERROR UserLabelAttrAccess::ReadLabelList(EndpointId endpoint, AttributeValu
return err;
}

UserLabelAttrAccess gAttrAccess;
CHIP_ERROR UserLabelAttrAccess::WriteLabelList(EndpointId endpoint, AttributeValueDecoder & aDecoder)
{
DeviceLayer::LabelList<Structs::LabelStruct::Type, DeviceLayer::kMaxUserLabels> labelList;
LabelList::TypeInfo::DecodableType decodablelist;

ReturnErrorOnFailure(aDecoder.Decode(decodablelist));

auto iter = decodablelist.begin();
while (iter.Next())
{
auto & entry = iter.GetValue();
ReturnErrorOnFailure(labelList.add(entry));
}
ReturnErrorOnFailure(iter.GetStatus());

return DeviceLayer::PlatformMgr().SetUserLabelList(endpoint, labelList);
}

CHIP_ERROR UserLabelAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
{
Expand All @@ -89,6 +109,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
7 changes: 7 additions & 0 deletions src/platform/Darwin/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,12 @@ CHIP_ERROR PlatformManagerImpl::_PostEvent(const ChipDeviceEvent * event)
return CHIP_NO_ERROR;
}

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

} // namespace DeviceLayer
} // namespace chip
4 changes: 4 additions & 0 deletions src/platform/Darwin/PlatformManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener
CHIP_ERROR _StartChipTimer(System::Clock::Timeout delay) { return CHIP_ERROR_NOT_IMPLEMENTED; };
CHIP_ERROR _StartEventLoopTask();
CHIP_ERROR _StopEventLoopTask();

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

void _RunEventLoop();
void _LockChipStack(){};
bool _TryLockChipStack() { return false; };
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.

Loading