From 9d7faef2b8e8fbf524a1f553856c1d00037fff45 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Tue, 16 Nov 2021 05:13:14 -0800 Subject: [PATCH] Add event definitions for basic info cluster (#11813) * Add event definitions for basic info clusters * Run codegen --- .../chip/basic-information-cluster.xml | 18 ++- .../zap-generated/cluster-objects.cpp | 128 ++++++++++++++++++ .../zap-generated/cluster-objects.h | 124 +++++++++++++++++ 3 files changed, 267 insertions(+), 3 deletions(-) diff --git a/src/app/zap-templates/zcl/data-model/chip/basic-information-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/basic-information-cluster.xml index 0505e831946f89..2c61530d2fbab4 100644 --- a/src/app/zap-templates/zcl/data-model/chip/basic-information-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/basic-information-cluster.xml @@ -42,18 +42,30 @@ limitations under the License. SerialNumber LocalConfigDisabled Reachable - The StartUp event SHALL be emitted by a Node as soon as reasonable after completing a boot or reboot process. - The ShutDown event SHOULD be emitted by a Node prior to any orderly shutdown sequence on a best-effort basis. - The Leave event SHOULD be emitted by a Node prior to permanently leaving the Fabric. + + The StartUp event SHALL be emitted by a Node as soon as reasonable after completing a boot or reboot process. + + + + The ShutDown event SHOULD be emitted by a Node prior to any orderly shutdown sequence on a best-effort basis. + + + The Leave event SHOULD be emitted by a Node prior to permanently leaving the Fabric. + + + This event (when supported) SHALL be generated when there is a change in the Reachable attribute. + + + diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp index 3514b952973300..4a580dc5c7d7a6 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp @@ -4622,6 +4622,134 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } // namespace Commands namespace Events { +namespace StartUp { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kSoftwareVersion)), softwareVersion)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kSoftwareVersion): + ReturnErrorOnFailure(DataModel::Decode(reader, softwareVersion)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace StartUp. +namespace ShutDown { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); + switch (TLV::TagNumFromTag(reader.GetTag())) + { + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace ShutDown. +namespace Leave { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); + switch (TLV::TagNumFromTag(reader.GetTag())) + { + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace Leave. +namespace ReachableChanged { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kReachableNewValue)), reachableNewValue)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kReachableNewValue): + ReturnErrorOnFailure(DataModel::Decode(reader, reachableNewValue)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace ReachableChanged. } // namespace Events } // namespace Basic diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index 7827e2f86bdd36..9fef05046193e5 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -6843,6 +6843,130 @@ struct TypeInfo }; } // namespace ClusterRevision } // namespace Attributes +namespace Events { +namespace StartUp { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Critical; +static constexpr EventId kEventId = 0x00000000; + +enum class Fields +{ + kSoftwareVersion = 0, +}; + +struct Type +{ +public: + static constexpr PriorityLevel priorityLevel = PriorityLevel::Critical; + static constexpr EventId eventId = 0x00000000; + static constexpr ClusterId GetClusterId() { return Clusters::Basic::Id; } + + uint32_t softwareVersion; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return kEventId; } + static constexpr ClusterId GetClusterId() { return Clusters::Basic::Id; } + + uint32_t softwareVersion; + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace StartUp +namespace ShutDown { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; +static constexpr EventId kEventId = 0x00000001; + +enum class Fields +{ +}; + +struct Type +{ +public: + static constexpr PriorityLevel priorityLevel = PriorityLevel::Info; + static constexpr EventId eventId = 0x00000001; + static constexpr ClusterId GetClusterId() { return Clusters::Basic::Id; } + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return kEventId; } + static constexpr ClusterId GetClusterId() { return Clusters::Basic::Id; } + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace ShutDown +namespace Leave { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; +static constexpr EventId kEventId = 0x00000002; + +enum class Fields +{ +}; + +struct Type +{ +public: + static constexpr PriorityLevel priorityLevel = PriorityLevel::Info; + static constexpr EventId eventId = 0x00000002; + static constexpr ClusterId GetClusterId() { return Clusters::Basic::Id; } + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return kEventId; } + static constexpr ClusterId GetClusterId() { return Clusters::Basic::Id; } + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace Leave +namespace ReachableChanged { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; +static constexpr EventId kEventId = 0x00000003; + +enum class Fields +{ + kReachableNewValue = 0, +}; + +struct Type +{ +public: + static constexpr PriorityLevel priorityLevel = PriorityLevel::Info; + static constexpr EventId eventId = 0x00000003; + static constexpr ClusterId GetClusterId() { return Clusters::Basic::Id; } + + bool reachableNewValue; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return kEventId; } + static constexpr ClusterId GetClusterId() { return Clusters::Basic::Id; } + + bool reachableNewValue; + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace ReachableChanged +} // namespace Events } // namespace Basic namespace OtaSoftwareUpdateProvider { // Need to convert consumers to using the new enum classes, so we