Skip to content

Commit c1aa769

Browse files
committed
Support Semantic Tags
1 parent 036d482 commit c1aa769

File tree

4 files changed

+72
-2
lines changed

4 files changed

+72
-2
lines changed

Generator/ClusterGenerator.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,9 @@ private static void WriteType(string type, string? entryType, StreamWriter write
491491
case "double":
492492
writer.Write($"{type}");
493493
break;
494+
case "ref_SemTag":
495+
writer.Write("SemanticTag");
496+
break;
494497
default:
495498
writer.Write(GeneratorUtil.SanitizeName(type));
496499
break;

Generator/Generator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ internal class Generator
1717
static void Main(string[] args)
1818
{
1919
Directory.CreateDirectory("outputs");
20+
ClusterGenerator.Generate();
2021
foreach (string file in Directory.EnumerateFiles("..\\..\\..\\Structures"))
2122
{
2223
Tag[] structs;
@@ -29,7 +30,7 @@ static void Main(string[] args)
2930
foreach (Tag tag in structs)
3031
{
3132
if (tag.Namespace != null && !Directory.Exists($"outputs\\{tag.Namespace}\\"))
32-
Directory.CreateDirectory($"outputs\\{tag.Namespace}\\");
33+
Directory.CreateDirectory($"outputs\\{tag.Namespace}\\");
3334

3435
string path = $"outputs\\{((tag.Namespace != null) ? tag.Namespace + "\\" : "")}" + tag.Name + ".cs";
3536
if (File.Exists(path))
@@ -43,7 +44,6 @@ static void Main(string[] args)
4344
}
4445
}
4546
}
46-
Console.ReadLine();
4747
}
4848

4949

MatterDotNet/Constants.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,12 @@ public class Constants
1717
public const int MATTER_10_REVISION = 10;
1818
public const int MATTER_12_REVISION = 11;
1919
public const int MATTER_13_REVISION = 12;
20+
21+
/// <summary>
22+
/// The current limit of 900 bytes was chosen to accommodate the maximum size of IPv6 frames, transport headers,
23+
/// message layer headers and integrity protection and Interaction Model protocol encoding,
24+
/// while accounting for sufficient remaining space for signatures and to allow extensions to larger key and digest sizes in the future.
25+
/// </summary>
26+
public const int RESP_MAX = 900;
2027
}
2128
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// MatterDotNet Copyright (C) 2024
2+
//
3+
// This program is free software: you can redistribute it and/or modify
4+
// it under the terms of the GNU Affero General Public License as published by
5+
// the Free Software Foundation, either version 3 of the License, or any later version.
6+
// This program is distributed in the hope that it will be useful,
7+
// but WITHOUT ANY WARRANTY, without even the implied warranty of
8+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9+
// See the GNU Affero General Public License for more details.
10+
// You should have received a copy of the GNU Affero General Public License
11+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
12+
//
13+
// WARNING: This file was auto-generated. Do not edit.
14+
15+
using MatterDotNet.Protocol.Parsers;
16+
using MatterDotNet.Protocol.Payloads;
17+
using System.Diagnostics.CodeAnalysis;
18+
19+
namespace MatterDotNet.Messages
20+
{
21+
public record SemanticTag : TLVPayload
22+
{
23+
/// <inheritdoc />
24+
public SemanticTag() {}
25+
26+
/// <inheritdoc />
27+
[SetsRequiredMembers]
28+
public SemanticTag(Memory<byte> data) : this(new TLVReader(data)) {}
29+
30+
public ushort? MfgCode { get; set; }
31+
public required byte NamespaceID { get; set; }
32+
public required byte Tag { get; set; }
33+
public string? Label { get; set; }
34+
35+
/// <inheritdoc />
36+
[SetsRequiredMembers]
37+
public SemanticTag(TLVReader reader, long structNumber = -1) {
38+
reader.StartStructure(structNumber);
39+
if (reader.IsTag(0))
40+
MfgCode = reader.GetUShort(0, true);
41+
NamespaceID = reader.GetByte(1)!.Value;
42+
Tag = reader.GetByte(2)!.Value;
43+
if (reader.IsTag(3))
44+
Label = reader.GetString(3);
45+
reader.EndContainer();
46+
}
47+
48+
/// <inheritdoc />
49+
public override void Serialize(TLVWriter writer, long structNumber = -1) {
50+
writer.StartStructure(structNumber);
51+
if (MfgCode != null)
52+
writer.WriteUShort(0, MfgCode);
53+
writer.WriteByte(1, NamespaceID);
54+
writer.WriteByte(2, Tag);
55+
if (Label != null)
56+
writer.WriteString(3, Label);
57+
writer.EndContainer();
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)