Skip to content

Commit

Permalink
Add default value to bitmasks
Browse files Browse the repository at this point in the history
  • Loading branch information
jdomnitz committed Jan 12, 2025
1 parent b7b1990 commit e575cbe
Show file tree
Hide file tree
Showing 21 changed files with 130 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Generator/ClusterGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) + ";");
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions MatterDotNet/Clusters/Application/ActionsCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ public enum EndpointListTypeEnum {
/// </summary>
[Flags]
public enum CommandBits {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Indicate support for InstantAction command
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ protected BallastConfigurationCluster(uint cluster, ushort endPoint) : base(clus
/// </summary>
[Flags]
public enum BallastStatusBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Operational state of the ballast.
/// </summary>
Expand All @@ -53,6 +57,10 @@ public enum BallastStatusBitmap {
/// </summary>
[Flags]
public enum LampAlarmModeBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// State of LampBurnHours alarm generation
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public enum Feature {
/// </summary>
[Flags]
public enum AlarmModeBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Visual alarming
/// </summary>
Expand All @@ -79,6 +83,10 @@ public enum AlarmModeBitmap {
/// </summary>
[Flags]
public enum SensorFaultBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Unspecified fault detected
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions MatterDotNet/Clusters/Application/ChannelCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ public enum StatusEnum {
/// </summary>
[Flags]
public enum RecordingFlagBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// The program is scheduled for recording.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions MatterDotNet/Clusters/Application/ContentControlCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public enum Feature {
/// </summary>
[Flags]
public enum DayOfWeekBitmapType {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Sunday
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions MatterDotNet/Clusters/Application/ContentLauncherCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ public enum StatusEnum {
/// </summary>
[Flags]
public enum SupportedProtocolsBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Device supports Dynamic Adaptive Streaming over HTTP (DASH)
/// </summary>
Expand Down
28 changes: 28 additions & 0 deletions MatterDotNet/Clusters/Application/DoorLockCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,10 @@ public enum UserTypeEnum {
/// </summary>
[Flags]
public enum AlarmMaskBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Locking Mechanism Jammed
/// </summary>
Expand Down Expand Up @@ -655,6 +659,10 @@ public enum AlarmMaskBitmap {
/// </summary>
[Flags]
public enum ConfigurationRegisterBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// The state of local programming functionality
/// </summary>
Expand Down Expand Up @@ -686,6 +694,10 @@ public enum ConfigurationRegisterBitmap {
/// </summary>
[Flags]
public enum CredentialRulesBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Only one credential is required for lock operation
/// </summary>
Expand All @@ -705,6 +717,10 @@ public enum CredentialRulesBitmap {
/// </summary>
[Flags]
public enum DaysMaskBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Schedule is applied on Sunday
/// </summary>
Expand Down Expand Up @@ -740,6 +756,10 @@ public enum DaysMaskBitmap {
/// </summary>
[Flags]
public enum EventMaskBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// State of bit 0
/// </summary>
Expand Down Expand Up @@ -811,6 +831,10 @@ public enum EventMaskBitmap {
/// </summary>
[Flags]
public enum LocalProgrammingFeaturesBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// The state of the ability to add users, credentials or schedules on the device
/// </summary>
Expand All @@ -834,6 +858,10 @@ public enum LocalProgrammingFeaturesBitmap {
/// </summary>
[Flags]
public enum OperatingModesBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Normal operation mode
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions MatterDotNet/Clusters/Application/EnergyEVSECluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ public enum SupplyStateEnum {
/// </summary>
[Flags]
public enum TargetDayOfWeekBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Sunday
/// </summary>
Expand Down
8 changes: 8 additions & 0 deletions MatterDotNet/Clusters/Application/FanControlCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ public enum StepDirectionEnum {
/// </summary>
[Flags]
public enum RockBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Indicate rock left to right
/// </summary>
Expand All @@ -180,6 +184,10 @@ public enum RockBitmap {
/// </summary>
[Flags]
public enum WindBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Indicate sleep wind
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions MatterDotNet/Clusters/Application/LevelControlCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public enum StepModeEnum {
/// </summary>
[Flags]
public enum OptionsBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Dependency on On/Off cluster
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion MatterDotNet/Clusters/Application/MessagesCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions MatterDotNet/Clusters/Application/On-OffCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ public enum StartUpOnOffEnum {
/// </summary>
[Flags]
public enum OnOffControlBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Indicates a command is only accepted when in On state.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ public enum OperationModeEnum {
/// </summary>
[Flags]
public enum PumpStatusBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// A fault related to the system or pump device is detected.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions MatterDotNet/Clusters/Application/ScenesManagementCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public enum Feature {
/// </summary>
[Flags]
public enum CopyModeBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Copy all scenes in the scene table
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public enum ValveStateEnum {
/// </summary>
[Flags]
public enum ValveFaultBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Unspecified fault detected
/// </summary>
Expand Down
16 changes: 16 additions & 0 deletions MatterDotNet/Clusters/Application/WindowCoveringCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ public enum TypeEnum {
/// </summary>
[Flags]
public enum ConfigStatusBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Device is operational.
/// </summary>
Expand Down Expand Up @@ -259,6 +263,10 @@ public enum ConfigStatusBitmap {
/// </summary>
[Flags]
public enum ModeBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Reverse the lift direction.
/// </summary>
Expand All @@ -282,6 +290,10 @@ public enum ModeBitmap {
/// </summary>
[Flags]
public enum OperationalStatusBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Global operational state.
/// </summary>
Expand All @@ -301,6 +313,10 @@ public enum OperationalStatusBitmap {
/// </summary>
[Flags]
public enum SafetyStatusBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// Movement commands are ignored (locked out). e.g. not granted authorization, outside some time/date range.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions MatterDotNet/Clusters/Utility/GroupKeyManagementCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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();
}
}
Expand Down
4 changes: 4 additions & 0 deletions MatterDotNet/Clusters/Utility/GroupsCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public enum Feature {
/// </summary>
[Flags]
public enum NameSupportBitmap {
/// <summary>
/// Nothing Set
/// </summary>
None = 0,
/// <summary>
/// The ability to store a name for a group.
/// </summary>
Expand Down
Loading

0 comments on commit e575cbe

Please sign in to comment.