From e575cbea2cf8e37c13b9d549af6dd0df7ddb4726 Mon Sep 17 00:00:00 2001 From: jdomnitz <380352+jdomnitz@users.noreply.github.com> Date: Sun, 12 Jan 2025 15:48:04 -0500 Subject: [PATCH] Add default value to bitmasks --- Generator/ClusterGenerator.cs | 4 +-- .../Clusters/Application/ActionsCluster.cs | 4 +++ .../BallastConfigurationCluster.cs | 8 ++++++ .../BooleanStateConfigurationCluster.cs | 8 ++++++ .../Clusters/Application/ChannelCluster.cs | 4 +++ .../Application/ContentControlCluster.cs | 4 +++ .../Application/ContentLauncherCluster.cs | 4 +++ .../Clusters/Application/DoorLockCluster.cs | 28 +++++++++++++++++++ .../Clusters/Application/EnergyEVSECluster.cs | 4 +++ .../Clusters/Application/FanControlCluster.cs | 8 ++++++ .../Application/LevelControlCluster.cs | 4 +++ .../Clusters/Application/MessagesCluster.cs | 2 +- .../Clusters/Application/On-OffCluster.cs | 4 +++ .../PumpConfigurationandControlCluster.cs | 4 +++ .../Application/ScenesManagementCluster.cs | 4 +++ .../ValveConfigurationandControlCluster.cs | 4 +++ .../Application/WindowCoveringCluster.cs | 16 +++++++++++ .../Utility/GroupKeyManagementCluster.cs | 4 +-- .../Clusters/Utility/GroupsCluster.cs | 4 +++ .../Utility/NetworkCommissioningCluster.cs | 16 ++++++++--- .../Utility/TimeSynchronizationCluster.cs | 2 +- 21 files changed, 130 insertions(+), 10 deletions(-) diff --git a/Generator/ClusterGenerator.cs b/Generator/ClusterGenerator.cs index e255a06..6f5ee40 100644 --- a/Generator/ClusterGenerator.cs +++ b/Generator/ClusterGenerator.cs @@ -237,7 +237,7 @@ private static void WriteStruct(clusterCommand command, bool toServer, TextWrite writer.Write(" " + GeneratorUtil.SanitizeName(field.name) + " { get; set; }"); if (field.@default != null && DefaultValid(field.@default)) { - if (field.type.EndsWith("Enum")) + if (field.type.EndsWith("Enum") && field.@default != "0") writer.WriteLine(" = " + field.type + "." + field.@default + ";"); else writer.WriteLine(" = " + SanitizeDefault(field.@default, field.type, field.entry?.type) + ";"); @@ -317,7 +317,7 @@ private static void WriteStructType(bool optional, bool nullable, string type, s switch (type) { case "list": //Actually an array - if (optional || nullable) + if (nullable) writer.WriteLine($"{totalIndent}if ({name} != null)"); writer.WriteLine($"{totalIndent}{{"); if (from != null || to != null) diff --git a/MatterDotNet/Clusters/Application/ActionsCluster.cs b/MatterDotNet/Clusters/Application/ActionsCluster.cs index 711cf29..35f7c3f 100644 --- a/MatterDotNet/Clusters/Application/ActionsCluster.cs +++ b/MatterDotNet/Clusters/Application/ActionsCluster.cs @@ -130,6 +130,10 @@ public enum EndpointListTypeEnum { /// [Flags] public enum CommandBits { + /// + /// Nothing Set + /// + None = 0, /// /// Indicate support for InstantAction command /// diff --git a/MatterDotNet/Clusters/Application/BallastConfigurationCluster.cs b/MatterDotNet/Clusters/Application/BallastConfigurationCluster.cs index 7a883eb..406683e 100644 --- a/MatterDotNet/Clusters/Application/BallastConfigurationCluster.cs +++ b/MatterDotNet/Clusters/Application/BallastConfigurationCluster.cs @@ -38,6 +38,10 @@ protected BallastConfigurationCluster(uint cluster, ushort endPoint) : base(clus /// [Flags] public enum BallastStatusBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Operational state of the ballast. /// @@ -53,6 +57,10 @@ public enum BallastStatusBitmap { /// [Flags] public enum LampAlarmModeBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// State of LampBurnHours alarm generation /// diff --git a/MatterDotNet/Clusters/Application/BooleanStateConfigurationCluster.cs b/MatterDotNet/Clusters/Application/BooleanStateConfigurationCluster.cs index baee52d..d6da67c 100644 --- a/MatterDotNet/Clusters/Application/BooleanStateConfigurationCluster.cs +++ b/MatterDotNet/Clusters/Application/BooleanStateConfigurationCluster.cs @@ -64,6 +64,10 @@ public enum Feature { /// [Flags] public enum AlarmModeBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Visual alarming /// @@ -79,6 +83,10 @@ public enum AlarmModeBitmap { /// [Flags] public enum SensorFaultBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Unspecified fault detected /// diff --git a/MatterDotNet/Clusters/Application/ChannelCluster.cs b/MatterDotNet/Clusters/Application/ChannelCluster.cs index 14a6138..19a6a45 100644 --- a/MatterDotNet/Clusters/Application/ChannelCluster.cs +++ b/MatterDotNet/Clusters/Application/ChannelCluster.cs @@ -116,6 +116,10 @@ public enum StatusEnum { /// [Flags] public enum RecordingFlagBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// The program is scheduled for recording. /// diff --git a/MatterDotNet/Clusters/Application/ContentControlCluster.cs b/MatterDotNet/Clusters/Application/ContentControlCluster.cs index f403579..adbc6fe 100644 --- a/MatterDotNet/Clusters/Application/ContentControlCluster.cs +++ b/MatterDotNet/Clusters/Application/ContentControlCluster.cs @@ -81,6 +81,10 @@ public enum Feature { /// [Flags] public enum DayOfWeekBitmapType { + /// + /// Nothing Set + /// + None = 0, /// /// Sunday /// diff --git a/MatterDotNet/Clusters/Application/ContentLauncherCluster.cs b/MatterDotNet/Clusters/Application/ContentLauncherCluster.cs index a834830..7cdbd40 100644 --- a/MatterDotNet/Clusters/Application/ContentLauncherCluster.cs +++ b/MatterDotNet/Clusters/Application/ContentLauncherCluster.cs @@ -183,6 +183,10 @@ public enum StatusEnum { /// [Flags] public enum SupportedProtocolsBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Device supports Dynamic Adaptive Streaming over HTTP (DASH) /// diff --git a/MatterDotNet/Clusters/Application/DoorLockCluster.cs b/MatterDotNet/Clusters/Application/DoorLockCluster.cs index ef27fdf..162ecf3 100644 --- a/MatterDotNet/Clusters/Application/DoorLockCluster.cs +++ b/MatterDotNet/Clusters/Application/DoorLockCluster.cs @@ -620,6 +620,10 @@ public enum UserTypeEnum { /// [Flags] public enum AlarmMaskBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Locking Mechanism Jammed /// @@ -655,6 +659,10 @@ public enum AlarmMaskBitmap { /// [Flags] public enum ConfigurationRegisterBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// The state of local programming functionality /// @@ -686,6 +694,10 @@ public enum ConfigurationRegisterBitmap { /// [Flags] public enum CredentialRulesBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Only one credential is required for lock operation /// @@ -705,6 +717,10 @@ public enum CredentialRulesBitmap { /// [Flags] public enum DaysMaskBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Schedule is applied on Sunday /// @@ -740,6 +756,10 @@ public enum DaysMaskBitmap { /// [Flags] public enum EventMaskBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// State of bit 0 /// @@ -811,6 +831,10 @@ public enum EventMaskBitmap { /// [Flags] public enum LocalProgrammingFeaturesBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// The state of the ability to add users, credentials or schedules on the device /// @@ -834,6 +858,10 @@ public enum LocalProgrammingFeaturesBitmap { /// [Flags] public enum OperatingModesBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Normal operation mode /// diff --git a/MatterDotNet/Clusters/Application/EnergyEVSECluster.cs b/MatterDotNet/Clusters/Application/EnergyEVSECluster.cs index c426009..2c77e45 100644 --- a/MatterDotNet/Clusters/Application/EnergyEVSECluster.cs +++ b/MatterDotNet/Clusters/Application/EnergyEVSECluster.cs @@ -222,6 +222,10 @@ public enum SupplyStateEnum { /// [Flags] public enum TargetDayOfWeekBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Sunday /// diff --git a/MatterDotNet/Clusters/Application/FanControlCluster.cs b/MatterDotNet/Clusters/Application/FanControlCluster.cs index cf9e478..7266be3 100644 --- a/MatterDotNet/Clusters/Application/FanControlCluster.cs +++ b/MatterDotNet/Clusters/Application/FanControlCluster.cs @@ -161,6 +161,10 @@ public enum StepDirectionEnum { /// [Flags] public enum RockBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Indicate rock left to right /// @@ -180,6 +184,10 @@ public enum RockBitmap { /// [Flags] public enum WindBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Indicate sleep wind /// diff --git a/MatterDotNet/Clusters/Application/LevelControlCluster.cs b/MatterDotNet/Clusters/Application/LevelControlCluster.cs index 9d53573..7cfc8d7 100644 --- a/MatterDotNet/Clusters/Application/LevelControlCluster.cs +++ b/MatterDotNet/Clusters/Application/LevelControlCluster.cs @@ -88,6 +88,10 @@ public enum StepModeEnum { /// [Flags] public enum OptionsBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Dependency on On/Off cluster /// diff --git a/MatterDotNet/Clusters/Application/MessagesCluster.cs b/MatterDotNet/Clusters/Application/MessagesCluster.cs index 54c6c5a..6f1a4ca 100644 --- a/MatterDotNet/Clusters/Application/MessagesCluster.cs +++ b/MatterDotNet/Clusters/Application/MessagesCluster.cs @@ -222,7 +222,7 @@ internal override void Serialize(TLVWriter writer, long structNumber = -1) { #region Payloads private record PresentMessagesRequestPayload : TLVPayload { public required Guid MessageID { get; set; } - public required MessagePriorityEnum Priority { get; set; } = MessagePriorityEnum.0; + public required MessagePriorityEnum Priority { get; set; } = 0; public required MessageControlBitmap MessageControl { get; set; } = 0; public required DateTime? StartTime { get; set; } = TimeUtil.EPOCH; public required ulong? Duration { get; set; } = 0; diff --git a/MatterDotNet/Clusters/Application/On-OffCluster.cs b/MatterDotNet/Clusters/Application/On-OffCluster.cs index ec846ef..40b683a 100644 --- a/MatterDotNet/Clusters/Application/On-OffCluster.cs +++ b/MatterDotNet/Clusters/Application/On-OffCluster.cs @@ -120,6 +120,10 @@ public enum StartUpOnOffEnum { /// [Flags] public enum OnOffControlBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Indicates a command is only accepted when in On state. /// diff --git a/MatterDotNet/Clusters/Application/PumpConfigurationandControlCluster.cs b/MatterDotNet/Clusters/Application/PumpConfigurationandControlCluster.cs index 8dad3a7..8fc0aa9 100644 --- a/MatterDotNet/Clusters/Application/PumpConfigurationandControlCluster.cs +++ b/MatterDotNet/Clusters/Application/PumpConfigurationandControlCluster.cs @@ -125,6 +125,10 @@ public enum OperationModeEnum { /// [Flags] public enum PumpStatusBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// A fault related to the system or pump device is detected. /// diff --git a/MatterDotNet/Clusters/Application/ScenesManagementCluster.cs b/MatterDotNet/Clusters/Application/ScenesManagementCluster.cs index fcfcda3..4000acd 100644 --- a/MatterDotNet/Clusters/Application/ScenesManagementCluster.cs +++ b/MatterDotNet/Clusters/Application/ScenesManagementCluster.cs @@ -54,6 +54,10 @@ public enum Feature { /// [Flags] public enum CopyModeBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Copy all scenes in the scene table /// diff --git a/MatterDotNet/Clusters/Application/ValveConfigurationandControlCluster.cs b/MatterDotNet/Clusters/Application/ValveConfigurationandControlCluster.cs index 59a1e99..a895320 100644 --- a/MatterDotNet/Clusters/Application/ValveConfigurationandControlCluster.cs +++ b/MatterDotNet/Clusters/Application/ValveConfigurationandControlCluster.cs @@ -75,6 +75,10 @@ public enum ValveStateEnum { /// [Flags] public enum ValveFaultBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Unspecified fault detected /// diff --git a/MatterDotNet/Clusters/Application/WindowCoveringCluster.cs b/MatterDotNet/Clusters/Application/WindowCoveringCluster.cs index a681ae4..8710713 100644 --- a/MatterDotNet/Clusters/Application/WindowCoveringCluster.cs +++ b/MatterDotNet/Clusters/Application/WindowCoveringCluster.cs @@ -224,6 +224,10 @@ public enum TypeEnum { /// [Flags] public enum ConfigStatusBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Device is operational. /// @@ -259,6 +263,10 @@ public enum ConfigStatusBitmap { /// [Flags] public enum ModeBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Reverse the lift direction. /// @@ -282,6 +290,10 @@ public enum ModeBitmap { /// [Flags] public enum OperationalStatusBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Global operational state. /// @@ -301,6 +313,10 @@ public enum OperationalStatusBitmap { /// [Flags] public enum SafetyStatusBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Movement commands are ignored (locked out). e.g. not granted authorization, outside some time/date range. /// diff --git a/MatterDotNet/Clusters/Utility/GroupKeyManagementCluster.cs b/MatterDotNet/Clusters/Utility/GroupKeyManagementCluster.cs index 4859493..8a36b0f 100644 --- a/MatterDotNet/Clusters/Utility/GroupKeyManagementCluster.cs +++ b/MatterDotNet/Clusters/Utility/GroupKeyManagementCluster.cs @@ -174,7 +174,7 @@ public GroupKeySet(object[] fields) { EpochStartTime1 = TimeUtil.FromEpochUS(reader.GetULong(5, true)); EpochKey2 = reader.GetBytes(6, false)!; EpochStartTime2 = TimeUtil.FromEpochUS(reader.GetULong(7, true)); - GroupKeyMulticastPolicy = (GroupKeyMulticastPolicyEnum)reader.GetUShort(8, true)!.Value; + GroupKeyMulticastPolicy = (GroupKeyMulticastPolicyEnum?)reader.GetUShort(8, true); } public required ushort GroupKeySetID { get; set; } public required GroupKeySecurityPolicyEnum GroupKeySecurityPolicy { get; set; } @@ -205,7 +205,7 @@ internal override void Serialize(TLVWriter writer, long structNumber = -1) { else writer.WriteULong(7, TimeUtil.ToEpochUS(EpochStartTime2!.Value)); if (GroupKeyMulticastPolicy != null) - writer.WriteUShort(8, (ushort?)GroupKeyMulticastPolicy); + writer.WriteUShort(8, (ushort)GroupKeyMulticastPolicy); writer.EndContainer(); } } diff --git a/MatterDotNet/Clusters/Utility/GroupsCluster.cs b/MatterDotNet/Clusters/Utility/GroupsCluster.cs index cdf5daa..49395c2 100644 --- a/MatterDotNet/Clusters/Utility/GroupsCluster.cs +++ b/MatterDotNet/Clusters/Utility/GroupsCluster.cs @@ -53,6 +53,10 @@ public enum Feature { /// [Flags] public enum NameSupportBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// The ability to store a name for a group. /// diff --git a/MatterDotNet/Clusters/Utility/NetworkCommissioningCluster.cs b/MatterDotNet/Clusters/Utility/NetworkCommissioningCluster.cs index 8e38855..9d6f990 100644 --- a/MatterDotNet/Clusters/Utility/NetworkCommissioningCluster.cs +++ b/MatterDotNet/Clusters/Utility/NetworkCommissioningCluster.cs @@ -150,6 +150,10 @@ public enum WiFiBandEnum { /// [Flags] public enum ThreadCapabilitiesBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Thread Border Router functionality is present /// @@ -177,6 +181,10 @@ public enum ThreadCapabilitiesBitmap { /// [Flags] public enum WiFiSecurityBitmap { + /// + /// Nothing Set + /// + None = 0, /// /// Supports unencrypted Wi-Fi /// @@ -299,11 +307,11 @@ public WiFiInterfaceScanResult() { } [SetsRequiredMembers] public WiFiInterfaceScanResult(object[] fields) { FieldReader reader = new FieldReader(fields); - Security = (WiFiSecurityBitmap)reader.GetUShort(0, true)!.Value; + Security = (WiFiSecurityBitmap?)reader.GetUShort(0, true); SSID = reader.GetBytes(1, true); BSSID = reader.GetBytes(2, true); Channel = reader.GetUShort(3, true); - WiFiBand = (WiFiBandEnum)reader.GetUShort(4, true)!.Value; + WiFiBand = (WiFiBandEnum?)reader.GetUShort(4, true); RSSI = reader.GetSByte(5, true); } public required WiFiSecurityBitmap? Security { get; set; } @@ -315,7 +323,7 @@ public WiFiInterfaceScanResult(object[] fields) { internal override void Serialize(TLVWriter writer, long structNumber = -1) { writer.StartStructure(structNumber); if (Security != null) - writer.WriteUShort(0, (ushort?)Security); + writer.WriteUShort(0, (ushort)Security); if (SSID != null) writer.WriteBytes(1, SSID, 32); if (BSSID != null) @@ -323,7 +331,7 @@ internal override void Serialize(TLVWriter writer, long structNumber = -1) { if (Channel != null) writer.WriteUShort(3, Channel); if (WiFiBand != null) - writer.WriteUShort(4, (ushort?)WiFiBand); + writer.WriteUShort(4, (ushort)WiFiBand); if (RSSI != null) writer.WriteSByte(5, RSSI); writer.EndContainer(); diff --git a/MatterDotNet/Clusters/Utility/TimeSynchronizationCluster.cs b/MatterDotNet/Clusters/Utility/TimeSynchronizationCluster.cs index 8790dc0..770ff53 100644 --- a/MatterDotNet/Clusters/Utility/TimeSynchronizationCluster.cs +++ b/MatterDotNet/Clusters/Utility/TimeSynchronizationCluster.cs @@ -317,7 +317,7 @@ internal override void Serialize(TLVWriter writer, long structNumber = -1) { writer.WriteULong(0, TimeUtil.ToEpochUS(UTCTime)); writer.WriteUShort(1, (ushort)Granularity); if (TimeSource != null) - writer.WriteUShort(2, (ushort?)TimeSource); + writer.WriteUShort(2, (ushort)TimeSource); writer.EndContainer(); } }