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

Add default initializers to cluster-objects structs. #13678

Merged
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
4 changes: 1 addition & 3 deletions src/app/clusters/test-cluster-server/test-cluster-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ uint8_t gListUint8Data[kAttributeListLength];
OctetStringData gListOctetStringData[kAttributeListLength];
OctetStringData gListOperationalCert[kAttributeListLength];
Structs::TestListStructOctet::Type listStructOctetStringData[kAttributeListLength];
Structs::SimpleStruct::Type gStructAttributeValue = { 0, false, SimpleEnum::kValueA,
ByteSpan(), CharSpan(), BitFlags<SimpleBitmap>(),
0, 0 };
Structs::SimpleStruct::Type gStructAttributeValue;
NullableStruct::TypeInfo::Type gNullableStructAttributeValue;

// We don't actually support any interesting bits in the struct for now, except
Expand Down
4 changes: 2 additions & 2 deletions src/app/zap-templates/partials/cluster-objects-struct.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace {{asUpperCamelCase name}} {
struct Type {
public:
{{#zcl_struct_items}}
{{zapTypeToEncodableClusterObjectType type}} {{asLowerCamelCase label}};
{{zapTypeToEncodableClusterObjectType type}} {{asLowerCamelCase label}}{{> cluster_objects_field_init}};
{{/zcl_struct_items}}

CHIP_ERROR Encode(TLV::TLVWriter &writer, TLV::Tag tag) const;
Expand All @@ -27,7 +27,7 @@ namespace {{asUpperCamelCase name}} {
struct DecodableType {
public:
{{#zcl_struct_items}}
{{zapTypeToDecodableClusterObjectType type}} {{asLowerCamelCase label}};
{{zapTypeToDecodableClusterObjectType type}} {{asLowerCamelCase label}}{{> cluster_objects_field_init}};
{{/zcl_struct_items}}
CHIP_ERROR Decode(TLV::TLVReader &reader);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,12 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_WriteThreadNetw
ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type securityPolicy;
static_assert(sizeof(securityPolicy) == sizeof(activeDataset.mSecurityPolicy),
"securityPolicy Struct do not match otSecurityPolicy");
memcpy(&securityPolicy, &activeDataset.mSecurityPolicy, sizeof(securityPolicy));
uint16_t policyAsInts[2];
static_assert(sizeof(policyAsInts) == sizeof(activeDataset.mSecurityPolicy),
"We're missing some members of otSecurityPolicy?");
memcpy(&policyAsInts, &activeDataset.mSecurityPolicy, sizeof(policyAsInts));
securityPolicy.rotationTime = policyAsInts[0];
securityPolicy.flags = policyAsInts[1];

err = encoder.EncodeList([securityPolicy](const auto & aEncoder) -> CHIP_ERROR {
ReturnErrorOnFailure(aEncoder.Encode(securityPolicy));
Expand Down
Loading