├── MatterDotNet
├── logo.png
├── Clusters
│ ├── ClusterRevision.cs
│ ├── UnknownCluster.cs
│ ├── GlobalEnums.cs
│ ├── General
│ │ ├── ProxyValidCluster.cs
│ │ ├── ProxyDiscoveryCluster.cs
│ │ ├── ProxyConfigurationCluster.cs
│ │ ├── PulseWidthModulationCluster.cs
│ │ ├── BooleanStateCluster.cs
│ │ ├── LowPowerCluster.cs
│ │ └── UserLabelCluster.cs
│ └── CHIP
│ │ └── PowerSourceConfigurationCluster.cs
├── Attributes
│ ├── IWriteAttribute.cs
│ ├── IReportAttribute.cs
│ ├── AllAttribute.cs
│ └── ReadWriteAttribute.cs
├── Protocol
│ ├── Payloads
│ │ ├── ProtocolType.cs
│ │ ├── Flags
│ │ │ ├── BTPFlags.cs
│ │ │ ├── ExchangeFlags.cs
│ │ │ ├── MessageFlags.cs
│ │ │ └── SecurityFlags.cs
│ │ ├── IPayload.cs
│ │ ├── OpCodes
│ │ │ ├── BTPManagementOpcode.cs
│ │ │ ├── BDXOpCodes.cs
│ │ │ ├── IMOpCodes.cs
│ │ │ ├── SecureOpCodes.cs
│ │ │ └── UDCOpCodes.cs
│ │ └── Status
│ │ │ ├── SecureStatusCodes.cs
│ │ │ └── IMStatusCode.cs
│ ├── Sessions
│ │ ├── MessageState.cs
│ │ └── Exchange.cs
│ ├── Connection
│ │ ├── Retransmission.cs
│ │ ├── IConnection.cs
│ │ └── BLEEndPoint.cs
│ └── TLV
│ │ ├── TLVControl.cs
│ │ └── ElementType.cs
├── Util
│ ├── StringUtil.cs
│ ├── BigIntUtil.cs
│ └── Checksum.cs
├── PKI
│ ├── CASEAuthenticatedTag.cs
│ └── VerificationLevel.cs
├── Messages
│ ├── MCSP
│ │ ├── MessageCounterSyncRequest.cs
│ │ └── MessageCounterSyncResponse.cs
│ ├── PASE
│ │ ├── Pake1.cs
│ │ ├── Pake3.cs
│ │ ├── Pake2.cs
│ │ └── Crypto_PBKDFParameterSet.cs
│ ├── CASE
│ │ ├── Sigma3.cs
│ │ ├── Sigma3Tbedata.cs
│ │ ├── Sigma2Tbedata.cs
│ │ ├── Sigma2Tbsdata.cs
│ │ ├── Sigma3Tbsdata.cs
│ │ └── Sigma2Resume.cs
│ ├── InteractionModel
│ │ ├── EventFilterIB.cs
│ │ ├── EventStatusIB.cs
│ │ ├── AttributeStatusIB.cs
│ │ ├── StatusIB.cs
│ │ ├── StatusResponseMessage.cs
│ │ ├── TimedRequestMessage.cs
│ │ ├── CommandPathIB.cs
│ │ ├── DataVersionFilterIB.cs
│ │ ├── InvokeResponseIB.cs
│ │ ├── EventReportIB.cs
│ │ ├── AttributeReportIB.cs
│ │ ├── CommandStatusIB.cs
│ │ ├── SubscribeResponseMessage.cs
│ │ ├── AttributeDataIB.cs
│ │ ├── ClusterPathIB.cs
│ │ ├── CommandDataIB.cs
│ │ └── WriteResponseMessage.cs
│ └── Certificates
│ │ ├── BasicConstraints.cs
│ │ └── AttestationElements.cs
├── OperationalDiscovery
│ ├── CommissioningMode.cs
│ ├── SupportedTransportMode.cs
│ └── FabricInterface.cs
└── Constants.cs
├── ExampleConsole
├── ExampleConsole.csproj
└── Program.cs
├── .github
└── workflows
│ └── dotnet.yml
├── Generator
├── Clusters
│ ├── proxy-valid-cluster.xml
│ ├── proxy-discovery-cluster.xml
│ ├── proxy-configuration-cluster.xml
│ ├── clusters-extensions.xml
│ ├── pwm-cluster.xml
│ ├── low-power-cluster.xml
│ ├── global-bitmaps.xml
│ ├── user-label-cluster.xml
│ ├── power-source-configuration-cluster.xml
│ ├── fixed-label-cluster.xml
│ ├── access-control-definitions.xml
│ ├── global-attributes.xml
│ ├── boolean-state-cluster.xml
│ ├── wake-on-lan-cluster.xml
│ ├── Binding-Cluster.xml
│ ├── global-enums.xml
│ ├── flow-measurement-cluster.xml
│ ├── global-structs.xml
│ ├── localization-configuration-cluster.xml
│ ├── temperature-measurement-cluster.xml
│ ├── laundry-dryer-controls-cluster.xml
│ ├── refrigerator-alarm.xml
│ ├── relative-humidity-measurement-cluster.xml
│ ├── unit-localization-cluster.xml
│ ├── chime-cluster.xml
│ ├── fault-injection-cluster.xml
│ ├── wifi-network-management-cluster.xml
│ ├── air-quality-cluster.xml
│ ├── power-topology-cluster.xml
│ ├── Descriptor-Cluster.xml
│ ├── sample-mei-cluster.xml
│ └── illuminance-measurement-cluster.xml
├── DataType.cs
├── Generator.csproj
├── Structures
│ ├── UC.txt
│ ├── PASE.txt
│ └── CASE.txt
├── Tag.cs
└── Generator.cs
├── Test
└── Test.csproj
├── README.md
└── MatterDotNet.sln
/MatterDotNet/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SmartHomeOS/MatterDotNet/HEAD/MatterDotNet/logo.png
--------------------------------------------------------------------------------
/MatterDotNet/Clusters/ClusterRevision.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | namespace MatterDotNet.Clusters
4 | {
5 | public sealed class ClusterRevision : Attribute
6 | {
7 | public ClusterRevision(uint clusterID, int revision)
8 | {
9 | Revision = revision;
10 | ClusterID = clusterID;
11 | }
12 |
13 | public int Revision { get; set; }
14 | public uint ClusterID { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ExampleConsole/ExampleConsole.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0-windows10.0.19041.0; net8.0
6 | true
7 | enable
8 | enable
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.github/workflows/dotnet.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a .NET project
2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3 |
4 | name: Build
5 |
6 | on:
7 | push:
8 | branches: [ "master" ]
9 | pull_request:
10 | branches: [ "master" ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v4
19 | - name: Setup .NET
20 | uses: actions/setup-dotnet@v4
21 | with:
22 | dotnet-version: 9.0.x
23 | - name: Restore dependencies
24 | run: dotnet restore
25 | - name: Build
26 | run: dotnet build --no-restore
27 | - name: Test
28 | run: dotnet test --no-build --verbosity normal
29 |
--------------------------------------------------------------------------------
/MatterDotNet/Attributes/IWriteAttribute.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | using MatterDotNet.Protocol.Sessions;
14 |
15 | namespace MatterDotNet.Attributes
16 | {
17 | public interface IWriteAttribute
18 | {
19 | Task Set(SecureSession session, T value, CancellationToken token = default);
20 | }
21 | }
--------------------------------------------------------------------------------
/Generator/Clusters/proxy-valid-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 | General
22 | Proxy Valid
23 | 0x0044
24 | PROXY_VALID_CLUSTER
25 | Cluster to control Proxy Valid
26 |
27 |
--------------------------------------------------------------------------------
/MatterDotNet/Attributes/IReportAttribute.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Attributes
14 | {
15 | public interface IReportAttribute
16 | {
17 | internal void Notify(object? data);
18 | ushort EndPoint { get; }
19 | uint ClusterId { get; }
20 | ushort AttributeId { get; }
21 | }
22 | }
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Payloads/ProtocolType.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Protocol.Payloads
14 | {
15 | public enum ProtocolType
16 | {
17 | SecureChannel = 0x0,
18 | InteractionModel = 0x1,
19 | BDX = 0x2,
20 | UserDirectedCommissioning = 0x3,
21 | Testing = 0x4,
22 | }
23 | }
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Sessions/MessageState.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Protocol.Sessions
14 | {
15 | public struct MessageState
16 | {
17 | public bool Initialized { get; set; }
18 | public uint CounterWindow { get; set; }
19 | public uint MaxMessageCounter { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Generator/Clusters/proxy-discovery-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 | General
22 | Proxy Discovery
23 | 0x0043
24 | PROXY_DISCOVERY_CLUSTER
25 | Cluster to control Proxy Discovery
26 |
27 |
--------------------------------------------------------------------------------
/Generator/Clusters/proxy-configuration-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 | General
22 | Proxy Configuration
23 | 0x0042
24 | PROXY_CONFIGURATION_CLUSTER
25 | Cluster to control Proxy Configuration
26 |
27 |
--------------------------------------------------------------------------------
/Generator/Clusters/clusters-extensions.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/MatterDotNet/Util/StringUtil.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Util
14 | {
15 | public static class StringUtil
16 | {
17 | public static string Truncate(this string value, int maxLength)
18 | {
19 | if (string.IsNullOrEmpty(value)) { return value; }
20 |
21 | return value.Substring(0, Math.Min(value.Length, maxLength));
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Payloads/Flags/BTPFlags.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Protocol.Payloads.Flags
14 | {
15 | [Flags]
16 | internal enum BTPFlags : byte
17 | {
18 | Beginning = 0x1,
19 | Continuing = 0x2,
20 | Ending = 0x4,
21 | Acknowledgement = 0x8,
22 | Reserved = 0x10,
23 | Management = 0x20,
24 | Handshake = 0x40,
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Generator/DataType.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace Generator
14 | {
15 | public enum DataType
16 | {
17 | Any,
18 | Array,
19 | Boolean,
20 | Bytes,
21 | Choice,
22 | Enum,
23 | FloatingPoint,
24 | Integer,
25 | List,
26 | Null,
27 | Reference,
28 | String,
29 | Structure,
30 | UnsignedInteger,
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Generator/Clusters/pwm-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 | General
23 | Pulse Width Modulation
24 | 0x001c
25 | PWM_CLUSTER
26 | Cluster to control pulse width modulation
27 |
28 |
29 |
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Connection/Retransmission.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | using MatterDotNet.Protocol.Payloads;
14 | using MatterDotNet.Protocol.Sessions;
15 |
16 | namespace MatterDotNet.Protocol.Connection
17 | {
18 | internal record Retransmission (Exchange Exchange, uint Counter, PayloadWriter data)
19 | {
20 | public SemaphoreSlim Ack { get; init; } = new SemaphoreSlim(0);
21 | public int SendCount { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Payloads/IPayload.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Protocol.Payloads
14 | {
15 | ///
16 | /// Class is serializable by the PayloadWriter
17 | ///
18 | public interface IPayload
19 | {
20 | ///
21 | /// Serialize the class
22 | ///
23 | ///
24 | public void Serialize(PayloadWriter stream);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Payloads/OpCodes/BTPManagementOpcode.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Protocol.Payloads.OpCodes
14 | {
15 | internal enum BTPManagementOpcode : byte
16 | {
17 | ///
18 | /// No OpCode
19 | ///
20 | None = 0x0,
21 | ///
22 | /// Request and response for BTP session establishment
23 | ///
24 | Handshake = 0x6C
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/MatterDotNet/Clusters/UnknownCluster.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Clusters
14 | {
15 | public class UnknownCluster : ClusterBase
16 | {
17 | public UnknownCluster(uint cluster, ushort endPoint) : base(cluster, endPoint)
18 | {
19 | }
20 |
21 | public uint ClusterID { get { return cluster; } }
22 |
23 | public override string ToString()
24 | {
25 | return $"Unknown Cluster: 0x{cluster:X4}";
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Generator/Generator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | enable
7 | enable
8 | 0.1.0
9 | jdomnitz
10 | SmartHomeOS and Contributors
11 | AGPL-3.0-or-later
12 | MatterDotNet Code Generator
13 | A C# implementation of the Matter 1.3 Standard (Formally known as project chip)
14 | Copyright MatterDotNet Contributors
15 | README.md
16 | https://github.com/SmartHomeOS/MatterDotNet/
17 | matter; matter-controller; smarthome; project-chip; dotnet;
18 | Library is not yet functional. See README for details.
19 | logo.png
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Connection/IConnection.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | using MatterDotNet.Protocol.Payloads;
14 | using MatterDotNet.Protocol.Sessions;
15 | using System.Net;
16 |
17 | namespace MatterDotNet.Protocol.Connection
18 | {
19 | internal interface IConnection : IDisposable
20 | {
21 | Task SendFrame(Exchange exchange, Frame frame, bool reliable, CancellationToken token);
22 | Task CloseExchange(Exchange exchange);
23 | bool Connected { get; }
24 | EndPoint EndPoint { get; }
25 | }
26 | }
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Payloads/OpCodes/BDXOpCodes.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Protocol.Payloads.OpCodes
14 | {
15 | internal enum BDXOpCodes
16 | {
17 | SendInit = 0x01,
18 | SendAccept = 0x02,
19 | Reserved = 0x03,
20 | ReceiveInit = 0x04,
21 | ReceiveAccept = 0x05,
22 | BlockQuery = 0x10,
23 | Block = 0x11,
24 | BlockEOF = 0x12,
25 | BlockAck = 0x13,
26 | BlockAckEOF = 0x14,
27 | BlockQueryWithSkip = 0x15,
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Payloads/OpCodes/IMOpCodes.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Protocol.Payloads.OpCodes
14 | {
15 | internal enum IMOpCodes
16 | {
17 | StatusResponse = 0x01,
18 | ReadRequest = 0x02,
19 | SubscribeRequest = 0x03,
20 | SubscribeResponse = 0x04,
21 | ReportData = 0x05,
22 | WriteRequest = 0x06,
23 | WriteResponse = 0x07,
24 | InvokeRequest = 0x08,
25 | InvokeResponse = 0x09,
26 | TimedRequest = 0x0A,
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Test/Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | enable
6 | enable
7 | 0.1.0
8 | jdomnitz
9 | SmartHomeOS and Contributors
10 | AGPL-3.0-or-later
11 | false
12 | true
13 |
14 |
15 |
16 |
17 |
18 |
19 | all
20 | runtime; build; native; contentfiles; analyzers; buildtransitive
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/MatterDotNet/PKI/CASEAuthenticatedTag.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 | //
13 | // WARNING: This file was auto-generated. Do not edit.
14 |
15 | namespace MatterDotNet.PKI
16 | {
17 | ///
18 | /// CASE Authenticated Tag Payload
19 | ///
20 | public struct CASEAuthenticatedTag
21 | {
22 | public CASEAuthenticatedTag(uint val)
23 | {
24 | ID = (ushort)(val >> 16);
25 | Version = (ushort)(val & 0xFFFF);
26 | }
27 | public ushort ID { get; init; }
28 | public ushort Version { get; init; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/TLV/TLVControl.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Protocol.Parsers
14 | {
15 | internal enum TLVControl
16 | {
17 | ///
18 | /// 0 Byte Length
19 | ///
20 | Anonymous = 0,
21 | ///
22 | /// 1 Byte Length
23 | ///
24 | ContextSpecific = 1,
25 | CommonProfileShort = 2,
26 | CommonProfileInt = 3,
27 | ImplicitProfileShort = 4,
28 | ImplicitProfileInt = 5,
29 | FullyQualifiedShort = 6,
30 | FullyQualifiedInt = 7
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Generator/Clusters/low-power-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 | General
21 | Low Power
22 | 0x0508
23 | LOW_POWER_CLUSTER
24 | true
25 | true
26 | This cluster provides an interface for managing low power mode on a device.
27 |
28 | This command shall put the device into low power mode.
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Generator/Clusters/global-bitmaps.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
23 |
24 |
25 |
26 |
27 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/MatterDotNet/Messages/MCSP/MessageCounterSyncRequest.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | using MatterDotNet.Protocol.Payloads;
14 | using System.Buffers.Binary;
15 |
16 | namespace MatterDotNet.Messages.MCSP
17 | {
18 | public class MessageCounterSyncRequest : IPayload
19 | {
20 | public ulong Challenge { get; set; }
21 |
22 | public MessageCounterSyncRequest(Memory payload)
23 | {
24 | Challenge = BinaryPrimitives.ReadUInt64LittleEndian(payload.Span);
25 | }
26 | public void Serialize(PayloadWriter stream)
27 | {
28 | stream.Write(Challenge);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Generator/Clusters/user-label-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 | General
22 | User Label
23 | 0x0041
24 | USER_LABEL_CLUSTER
25 | The User Label Cluster provides a feature to tag an endpoint with zero or more labels.
26 |
27 | LabelList
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/ExampleConsole/Program.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | using MatterDotNet.Entities;
14 | using MatterDotNet.OperationalDiscovery;
15 |
16 | namespace ExampleConsole
17 | {
18 | internal class Program
19 | {
20 | static async Task Main(string[] args)
21 | {
22 | Console.WriteLine("Scanning for Devices....");
23 | ODNode[] discovered = await BTDiscoveryService.ScanAll();
24 | Console.Clear();
25 | Console.WriteLine("Devices Discovered: ");
26 | foreach (ODNode node in discovered)
27 | Console.WriteLine(node.ToString());
28 | Console.ReadLine();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/MatterDotNet/Clusters/GlobalEnums.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 | //
13 | // WARNING: This file was auto-generated. Do not edit.
14 |
15 | namespace MatterDotNet.Clusters
16 | {
17 | ///
18 | /// Atomic Request Type
19 | ///
20 | public enum AtomicRequestType : byte {
21 | BeginWrite = 0,
22 | CommitWrite = 1,
23 | RollbackWrite = 2,
24 | }
25 |
26 | ///
27 | /// Three Level Auto
28 | ///
29 | public enum ThreeLevelAuto : byte {
30 | Low = 0,
31 | Medium = 1,
32 | High = 2,
33 | Automatic = 3,
34 | }
35 | }
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Payloads/OpCodes/SecureOpCodes.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Protocol.Payloads.OpCodes
14 | {
15 | internal enum SecureOpCodes
16 | {
17 | MsgCounterSyncReq = 0x00,
18 | MsgCounterSyncRsp = 0x01,
19 | MRPStandaloneAcknowledgement = 0x10,
20 | PBKDFParamRequest = 0x20,
21 | PBKDFParamResponse = 0x21,
22 | PASEPake1 = 0x22,
23 | PASEPake2 = 0x23,
24 | PASEPake3 = 0x24,
25 | CASESigma1 = 0x30,
26 | CASESigma2 = 0x31,
27 | CASESigma3 = 0x32,
28 | CASESigma2_Resume = 0x33,
29 | StatusReport = 0x40,
30 | ICDCheckInMessage = 0x50
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/MatterDotNet/OperationalDiscovery/CommissioningMode.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.OperationalDiscovery
14 | {
15 | ///
16 | /// Device Commissioning Mode
17 | ///
18 | public enum CommissioningMode
19 | {
20 | ///
21 | /// Device cannot be commissioined
22 | ///
23 | None = 0,
24 | ///
25 | /// Device is in Basic Commissioning Mode
26 | ///
27 | Basic = 1,
28 | ///
29 | /// Device is in Dynamic Commissioning Mode (with dynamically generated PIN)
30 | ///
31 | Dynamic = 2,
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/MatterDotNet/OperationalDiscovery/SupportedTransportMode.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.OperationalDiscovery
14 | {
15 | ///
16 | /// Supported node IP transport
17 | ///
18 | [Flags]
19 | public enum SupportedTransportMode
20 | {
21 | ///
22 | /// MRP Only
23 | ///
24 | None = 0,
25 | ///
26 | /// Deprecated
27 | ///
28 | Reserved = 1,
29 | ///
30 | /// TCP in Client Mode
31 | ///
32 | TCPClient = 2,
33 | ///
34 | /// TCP in Server Mode
35 | ///
36 | TCPServer = 4
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Generator/Clusters/power-source-configuration-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 | Power Source Configuration
22 | CHIP
23 | This cluster is used to describe the configuration and capabilities of a Device's power system.
24 | 0x002E
25 | POWER_SOURCE_CONFIGURATION_CLUSTER
26 | true
27 | true
28 |
29 | Sources
30 |
31 |
32 |
--------------------------------------------------------------------------------
/MatterDotNet/PKI/VerificationLevel.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 | //
13 | // WARNING: This file was auto-generated. Do not edit.
14 |
15 | namespace MatterDotNet.PKI
16 | {
17 | ///
18 | /// The level of certificate verification requested
19 | ///
20 | public enum VerificationLevel
21 | {
22 | ///
23 | /// Only official Matter certified devices
24 | ///
25 | CertifiedDevicesOnly = 0x0,
26 | ///
27 | /// Matter certified devices and devices using the CHIP Tool Test Certificate
28 | ///
29 | CertifiedDevicesOrCHIPTest = 0x1,
30 | ///
31 | /// Allow any device
32 | ///
33 | AnyDevice = 0x2
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Connection/BLEEndPoint.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | using System.Net;
14 |
15 | namespace MatterDotNet.Protocol.Connection
16 | {
17 | ///
18 | /// Bluetooth End Point
19 | ///
20 | public class BLEEndPoint : EndPoint
21 | {
22 | private string address;
23 |
24 | ///
25 | /// Create a Bluetooth End Point
26 | ///
27 | ///
28 | public BLEEndPoint(string address)
29 | {
30 | this.address = address;
31 | }
32 |
33 | ///
34 | /// Get the BT Address associated with this endpoint
35 | ///
36 | public string Address { get { return address; } }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Generator/Clusters/fixed-label-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | General
29 | Fixed Label
30 | 0x0040
31 | FIXED_LABEL_CLUSTER
32 | The Fixed Label Cluster provides a feature for the device to tag an endpoint with zero or more read only
33 | labels.
34 | LabelList
35 |
36 |
37 |
--------------------------------------------------------------------------------
/Generator/Clusters/access-control-definitions.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://github.com/SmartHomeOS/MatterDotNet/actions/workflows/dotnet.yml)
2 | [](https://www.nuget.org/packages/MatterDotNet)
3 | # MatterDotNet
4 | ##### A C# implementation of the Matter 1.4 (formerly Project CHIP) standard
5 |
6 | #### What's Working
7 | * Automatic code generation (directly from the specification)
8 | * Operational discovery over IP or Bluetooth LE
9 | * Commissioning by QR code or PIN
10 | * Reading/Writing attributes
11 | * Executing cluster commands
12 | * All Matter 1.4 clusters generated
13 |
14 | #### In-Progress:
15 | * Events
16 |
17 | #### Coming Soon
18 | * Multicast/Group Control
19 | * Subscriptions
20 | * Over the Air Software Updates
21 |
22 | #### Other Projects:
23 | * Check out my other projects for [HomeKit](https://github.com/SmartHomeOS/HomeKitDotNet) and [ZWave](https://github.com/SmartHomeOS/ZWaveDotNet)
24 |
25 | ## Getting Started
26 | * See our [Examples Page](Examples.md)
27 | * **NOTE: When targeting Windows, you must target net8.0-windows10.0.19041.0 or net9.0-windows10.0.19041.0**
28 |
29 | **Financial Support will help the project achieve certification as an officially supported library:**
30 |
--------------------------------------------------------------------------------
/Generator/Clusters/global-attributes.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | ClusterRevision
20 | FeatureMap
21 | AttributeList
22 | EventList
23 | AcceptedCommandList
24 | GeneratedCommandList
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Generator/Structures/UC.txt:
--------------------------------------------------------------------------------
1 | namespace UserDirectedCommissioning
2 | {
3 | IdentificationDeclaration-struct => STRUCTURE [ tag-order ]
4 | {
5 | VendorId [1, optional] : UNSIGNED INTEGER [ range 16-bits ],
6 | ProductId [2, optional] : UNSIGNED INTEGER [ range 16-bits ],
7 | DeviceName [3, optional] : STRING [ length 0..32 ],
8 | DeviceType [4, optional] : UNSIGNED INTEGER [ range 32-bits ],
9 | PairingInstruction [5, optional] : STRING [ length 0..32 ],
10 | PairingHint [6, optional] : UNSIGNED INTEGER [ range 32-bits ],
11 | RotatingDeviceId [7, optional] : STRING [ length 0..100 ].
12 | Port [8, optional] : UNSIGNED INTEGER [ range 16-bits ],
13 | TargetAppList [9, optional] : ARRAY OF
14 | {
15 | TargetApp [10, optional] : STRUCTURE [ tag-order ]
16 | {
17 | AppVendorId [11, optional] : UNSIGNED INTEGER [ range 16-bits ],
18 | AppProductId [12, optional] : UNSIGNED INTEGER [ range 16-bits ],
19 | },
20 | },
21 | NoPasscode [13, optional] : BOOLEAN,
22 | CdUponPasscodeDialog [14, optional] : BOOLEAN,
23 | CommissionerPasscode [15, optional] : BOOLEAN,
24 | CommissionerPasscodeReady [16, optional] : BOOLEAN,
25 | CancelPasscode [17, optional] : BOOLEAN
26 | }
27 |
28 | CommissionerDeclaration-struct => STRUCTURE [ tag-order ]
29 | {
30 | ErrorCode [1, optional] : UNSIGNED INTEGER [ range 16-bits ],
31 | NeedsPasscode [2, optional] : BOOLEAN,
32 | NoAppsFound [3, optional] : BOOLEAN,
33 | PasscodeDialogDisplayed [4, optional] : BOOLEAN,
34 | CommissionerPasscode [5, optional] : BOOLEAN,
35 | QRCodeDisplayed [6, optional] : BOOLEAN
36 | }
37 | }
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Payloads/Flags/ExchangeFlags.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Protocol.Payloads.Flags
14 | {
15 | ///
16 | /// Frame exchange flags
17 | ///
18 | [Flags]
19 | public enum ExchangeFlags : byte
20 | {
21 | ///
22 | /// Sender is initiator
23 | ///
24 | Initiator = 0x1,
25 | ///
26 | /// Acknowledgement counter present
27 | ///
28 | Acknowledgement = 0x2,
29 | ///
30 | /// Reliability required
31 | ///
32 | Reliability = 0x4,
33 | ///
34 | /// Secure extensions present
35 | ///
36 | SecuredExtensions = 0x8,
37 | ///
38 | /// Vendor ID present
39 | ///
40 | VendorPresent = 0x10,
41 | }
42 | }
--------------------------------------------------------------------------------
/Generator/Clusters/boolean-state-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 | Boolean State
22 | General
23 | This cluster provides an interface to a boolean state called StateValue.
24 | 0x0045
25 | BOOLEAN_STATE_CLUSTER
26 | true
27 | true
28 |
29 | StateValue
30 |
31 |
32 | This event SHALL be generated when the StateValue attribute changes.
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Payloads/Flags/MessageFlags.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Protocol.Payloads.Flags
14 | {
15 | ///
16 | /// Frame message flags
17 | ///
18 | [Flags]
19 | public enum MessageFlags : byte
20 | {
21 | ///
22 | /// Version 1 Payload (currently the only option)
23 | ///
24 | Version1 = 0x00,
25 | ///
26 | /// Mask to expose version
27 | ///
28 | VersionMask = 0xF0,
29 | ///
30 | /// Destination ID is a Node ID
31 | ///
32 | DestinationNodeID = 0x01,
33 | ///
34 | /// Destination ID is a Group ID
35 | ///
36 | DestinationGroupID = 0x02,
37 | ///
38 | /// Source Node ID is present
39 | ///
40 | SourceNodeID = 0x04,
41 | }
42 | }
--------------------------------------------------------------------------------
/Generator/Clusters/wake-on-lan-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 | General
21 | Wake on LAN
22 | 0x0503
23 | WAKE_ON_LAN_CLUSTER
24 | true
25 | true
26 | This cluster provides an interface for managing low power mode on a device that supports the Wake On LAN protocol.
27 |
28 |
29 |
30 |
31 | MACAddress
32 | LinkLocalAddress
33 |
34 |
35 |
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Payloads/OpCodes/UDCOpCodes.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Protocol.Payloads.OpCodes
14 | {
15 | ///
16 | /// User Directed Commissioning (UDC) OpCodes
17 | ///
18 | internal enum UDCOpCodes
19 | {
20 | ///
21 | /// The Identification Declaration message provides the DNSSD Instance Name of the commissionee requesting commissioning to the commissioner selected by the user.
22 | /// It can also include information relating to the requested commissioning session.
23 | ///
24 | IdentificationDeclaration = 0,
25 | ///
26 | /// The Commissioner Declaration message provides information to a commissionee from the commissioner indicating its pre-commissioning state.
27 | /// This information can be used by the commissionee to simplify the Passcode entry flow for the user.
28 | ///
29 | CommissionerDeclaration = 1,
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/MatterDotNet/OperationalDiscovery/FabricInterface.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.OperationalDiscovery
14 | {
15 | ///
16 | /// Connectivity method between a node and a controller
17 | ///
18 | [Flags]
19 | public enum FabricInterface
20 | {
21 | ///
22 | /// No connectivity Type
23 | ///
24 | None = 0x0,
25 | ///
26 | /// WiFi Connection
27 | ///
28 | WiFi = 0x1,
29 | ///
30 | /// Thread 802.11.4
31 | ///
32 | Thread = 0x2,
33 | ///
34 | /// Ethernet
35 | ///
36 | Ethernet = 0x4,
37 | ///
38 | /// One or more IP protocols (aka anything but bluetooth)
39 | ///
40 | IP = 0x8,
41 | ///
42 | /// Bluetooth LE
43 | ///
44 | Bluetooth = 0x10
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Payloads/Flags/SecurityFlags.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Protocol.Payloads.Flags
14 | {
15 | ///
16 | /// Frame Security Flags present
17 | ///
18 | [Flags]
19 | public enum SecurityFlags : byte
20 | {
21 | ///
22 | /// Session is unicast
23 | ///
24 | UnicastSession = 0x0,
25 | ///
26 | /// Session is multicast
27 | ///
28 | GroupSession = 0x1,
29 | ///
30 | /// Mask session type
31 | ///
32 | SessionMask = 0x3,
33 | ///
34 | /// Message extensions present
35 | ///
36 | MessageExtensions = 0x20,
37 | ///
38 | /// Message is a control message
39 | ///
40 | ControlMessage = 0x40,
41 | ///
42 | /// Privacy encryption enabled
43 | ///
44 | Privacy = 0x80,
45 | }
46 | }
--------------------------------------------------------------------------------
/Generator/Clusters/Binding-Cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | General
30 | Binding
31 | 0x001e
32 | BINDING_CLUSTER
33 | The Binding Cluster is meant to replace the support from the Zigbee Device Object (ZDO) for supporting the binding table.
34 |
35 | Binding
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/MatterDotNet/Messages/MCSP/MessageCounterSyncResponse.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | using MatterDotNet.Protocol.Payloads;
14 | using System.Buffers.Binary;
15 |
16 | namespace MatterDotNet.Messages.MCSP
17 | {
18 | public class MessageCounterSyncResponse : IPayload
19 | {
20 | public uint SynchronizedCounter { get; set; }
21 | public ulong Response { get; set; }
22 |
23 | public MessageCounterSyncResponse(uint synchronizedCounter, ulong response)
24 | {
25 | SynchronizedCounter = synchronizedCounter;
26 | Response = response;
27 | }
28 |
29 | public MessageCounterSyncResponse(Memory payload)
30 | {
31 | SynchronizedCounter = BinaryPrimitives.ReadUInt32LittleEndian(payload.Span);
32 | Response = BinaryPrimitives.ReadUInt64LittleEndian(payload.Span.Slice(4, 8));
33 | }
34 | public void Serialize(PayloadWriter stream)
35 | {
36 | stream.Write(SynchronizedCounter);
37 | stream.Write(Response);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/MatterDotNet/Clusters/General/ProxyValidCluster.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 | //
13 | // WARNING: This file was auto-generated. Do not edit.
14 |
15 | using MatterDotNet.Protocol.Parsers;
16 | using MatterDotNet.Protocol.Sessions;
17 | using System.Diagnostics.CodeAnalysis;
18 |
19 | namespace MatterDotNet.Clusters.General
20 | {
21 | ///
22 | /// Cluster to control Proxy Valid
23 | ///
24 | [ClusterRevision(CLUSTER_ID, 1)]
25 | public class ProxyValid : ClusterBase
26 | {
27 | internal const uint CLUSTER_ID = 0x0044;
28 |
29 | ///
30 | /// Cluster to control Proxy Valid
31 | ///
32 | [SetsRequiredMembers]
33 | public ProxyValid(ushort endPoint) : this(CLUSTER_ID, endPoint) { }
34 | ///
35 | [SetsRequiredMembers]
36 | protected ProxyValid(uint cluster, ushort endPoint) : base(cluster, endPoint) {
37 | }
38 |
39 |
40 | ///
41 | public override string ToString() {
42 | return "Proxy Valid";
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/Generator/Clusters/global-enums.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/MatterDotNet/Clusters/General/ProxyDiscoveryCluster.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 | //
13 | // WARNING: This file was auto-generated. Do not edit.
14 |
15 | using MatterDotNet.Protocol.Parsers;
16 | using MatterDotNet.Protocol.Sessions;
17 | using System.Diagnostics.CodeAnalysis;
18 |
19 | namespace MatterDotNet.Clusters.General
20 | {
21 | ///
22 | /// Cluster to control Proxy Discovery
23 | ///
24 | [ClusterRevision(CLUSTER_ID, 1)]
25 | public class ProxyDiscovery : ClusterBase
26 | {
27 | internal const uint CLUSTER_ID = 0x0043;
28 |
29 | ///
30 | /// Cluster to control Proxy Discovery
31 | ///
32 | [SetsRequiredMembers]
33 | public ProxyDiscovery(ushort endPoint) : this(CLUSTER_ID, endPoint) { }
34 | ///
35 | [SetsRequiredMembers]
36 | protected ProxyDiscovery(uint cluster, ushort endPoint) : base(cluster, endPoint) {
37 | }
38 |
39 |
40 | ///
41 | public override string ToString() {
42 | return "Proxy Discovery";
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/MatterDotNet/Constants.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet
14 | {
15 | ///
16 | /// Assorted Matter Specification constant values
17 | ///
18 | public class Constants
19 | {
20 | ///
21 | /// Matter 1.0 Revision
22 | ///
23 | public const int MATTER_10_REVISION = 10;
24 | ///
25 | /// Matter 1.2 Revision
26 | ///
27 | public const int MATTER_12_REVISION = 11;
28 | ///
29 | /// Matter 1.3 Revision
30 | ///
31 | public const int MATTER_13_REVISION = 12;
32 |
33 | ///
34 | /// The current limit of 900 bytes was chosen to accommodate the maximum size of IPv6 frames, transport headers,
35 | /// message layer headers and integrity protection and Interaction Model protocol encoding,
36 | /// while accounting for sufficient remaining space for signatures and to allow extensions to larger key and digest sizes in the future.
37 | ///
38 | public const int RESP_MAX = 900;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/MatterDotNet/Messages/PASE/Pake1.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.PASE
20 | {
21 | public record Pake1 : TLVPayload
22 | {
23 | ///
24 | public Pake1() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public Pake1(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required byte[] PA { get; set; }
31 |
32 | [SetsRequiredMembers]
33 | internal Pake1(TLVReader reader, long structNumber = -1) {
34 | reader.StartStructure(structNumber);
35 | PA = reader.GetBytes(1, false, 65, 65)!;
36 | reader.EndContainer();
37 | }
38 |
39 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
40 | writer.StartStructure(structNumber);
41 | writer.WriteBytes(1, PA, 65, 65);
42 | writer.EndContainer();
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/MatterDotNet/Messages/PASE/Pake3.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.PASE
20 | {
21 | public record Pake3 : TLVPayload
22 | {
23 | ///
24 | public Pake3() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public Pake3(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required byte[] CA { get; set; }
31 |
32 | [SetsRequiredMembers]
33 | internal Pake3(TLVReader reader, long structNumber = -1) {
34 | reader.StartStructure(structNumber);
35 | CA = reader.GetBytes(1, false, 32, 32)!;
36 | reader.EndContainer();
37 | }
38 |
39 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
40 | writer.StartStructure(structNumber);
41 | writer.WriteBytes(1, CA, 32, 32);
42 | writer.EndContainer();
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/MatterDotNet/Clusters/General/ProxyConfigurationCluster.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 | //
13 | // WARNING: This file was auto-generated. Do not edit.
14 |
15 | using MatterDotNet.Protocol.Parsers;
16 | using MatterDotNet.Protocol.Sessions;
17 | using System.Diagnostics.CodeAnalysis;
18 |
19 | namespace MatterDotNet.Clusters.General
20 | {
21 | ///
22 | /// Cluster to control Proxy Configuration
23 | ///
24 | [ClusterRevision(CLUSTER_ID, 1)]
25 | public class ProxyConfiguration : ClusterBase
26 | {
27 | internal const uint CLUSTER_ID = 0x0042;
28 |
29 | ///
30 | /// Cluster to control Proxy Configuration
31 | ///
32 | [SetsRequiredMembers]
33 | public ProxyConfiguration(ushort endPoint) : this(CLUSTER_ID, endPoint) { }
34 | ///
35 | [SetsRequiredMembers]
36 | protected ProxyConfiguration(uint cluster, ushort endPoint) : base(cluster, endPoint) {
37 | }
38 |
39 |
40 | ///
41 | public override string ToString() {
42 | return "Proxy Configuration";
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/MatterDotNet/Clusters/General/PulseWidthModulationCluster.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 | //
13 | // WARNING: This file was auto-generated. Do not edit.
14 |
15 | using MatterDotNet.Protocol.Parsers;
16 | using MatterDotNet.Protocol.Sessions;
17 | using System.Diagnostics.CodeAnalysis;
18 |
19 | namespace MatterDotNet.Clusters.General
20 | {
21 | ///
22 | /// Cluster to control pulse width modulation
23 | ///
24 | [ClusterRevision(CLUSTER_ID, 1)]
25 | public class PulseWidthModulation : ClusterBase
26 | {
27 | internal const uint CLUSTER_ID = 0x001c;
28 |
29 | ///
30 | /// Cluster to control pulse width modulation
31 | ///
32 | [SetsRequiredMembers]
33 | public PulseWidthModulation(ushort endPoint) : this(CLUSTER_ID, endPoint) { }
34 | ///
35 | [SetsRequiredMembers]
36 | protected PulseWidthModulation(uint cluster, ushort endPoint) : base(cluster, endPoint) {
37 | }
38 |
39 |
40 | ///
41 | public override string ToString() {
42 | return "Pulse Width Modulation";
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/Generator/Clusters/flow-measurement-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 | Flow Measurement
21 | Measurement & Sensing
22 | Attributes and commands for configuring the measurement of flow, and reporting flow measurements.
23 | 0x0404
24 | FLOW_MEASUREMENT_CLUSTER
25 | true
26 | true
27 | MeasuredValue
28 | MinMeasuredValue
29 | MaxMeasuredValue
30 | Tolerance
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Generator/Clusters/global-structs.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/MatterDotNet/Messages/CASE/Sigma3.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.CASE
20 | {
21 | ///
22 | /// Sigma3 Payload
23 | ///
24 | public record Sigma3 : TLVPayload
25 | {
26 | ///
27 | public Sigma3() {}
28 |
29 | ///
30 | [SetsRequiredMembers]
31 | public Sigma3(Memory data) : this(new TLVReader(data)) {}
32 |
33 | public required byte[] Encrypted3 { get; set; }
34 |
35 | [SetsRequiredMembers]
36 | internal Sigma3(TLVReader reader, long structNumber = -1) {
37 | reader.StartStructure(structNumber);
38 | Encrypted3 = reader.GetBytes(1)!;
39 | reader.EndContainer();
40 | }
41 |
42 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
43 | writer.StartStructure(structNumber);
44 | writer.WriteBytes(1, Encrypted3);
45 | writer.EndContainer();
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Payloads/Status/SecureStatusCodes.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Protocol.Payloads.Status
14 | {
15 | ///
16 | /// Status Reports specific to the Secure Channel are designated by embedding the PROTOCOL_ID_SECURE_CHANNEL in the ProtocolId field of the StatusReport body
17 | ///
18 | public enum SecureStatusCodes
19 | {
20 | ///
21 | /// Indication that the last session establishment message was successfully processed.
22 | ///
23 | SESSION_ESTABLISHMENT_SUCCESS = 0x0,
24 | ///
25 | /// Failure to find a common set of shared roots.
26 | ///
27 | NO_SHARED_TRUST_ROOTS = 0x1,
28 | ///
29 | /// Generic failure during session establishment.
30 | ///
31 | INVALID_PARAMETER = 0x2,
32 | ///
33 | /// Indication that the sender will close the current session.
34 | ///
35 | CLOSE_SESSION = 0x3,
36 | ///
37 | /// Indication that the sender cannot currently fulfill the request.
38 | ///
39 | BUSY = 0x4
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/MatterDotNet/Attributes/AllAttribute.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | using MatterDotNet.Protocol.Sessions;
14 | using MatterDotNet.Protocol.Subprotocols;
15 | using System.Data;
16 |
17 | namespace MatterDotNet.Attributes
18 | {
19 | public class AllAttribute : ReportAttribute, IWriteAttribute
20 | {
21 | internal AllAttribute(uint clusterId, ushort endPoint, ushort attributeId, bool nullable = false) : base(clusterId, endPoint, attributeId, nullable) { }
22 |
23 | ///
24 | /// Set the attribute to the provided value
25 | ///
26 | ///
27 | ///
28 | ///
29 | ///
30 | ///
31 | public async Task Set(SecureSession session, T value, CancellationToken token = default)
32 | {
33 | if (!nullable && value == null)
34 | throw new ConstraintException("Attribute " + AttributeId + " was null");
35 | Value = value;
36 | await InteractionManager.SetAttribute(session, EndPoint, ClusterId, AttributeId, Value, token);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Generator/Clusters/localization-configuration-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 | General
21 | Localization Configuration
22 | 0x002b
23 | LOCALIZATION_CONFIGURATION_CLUSTER
24 | true
25 | true
26 | Nodes should be expected to be deployed to any and all regions of the world. These global regions
27 | may have differing common languages, units of measurements, and numerical formatting
28 | standards. As such, Nodes that visually or audibly convey information need a mechanism by which
29 | they can be configured to use a user’s preferred language, units, etc
30 |
31 |
32 | ActiveLocale
33 |
34 |
35 | SupportedLocales
36 |
37 |
38 |
--------------------------------------------------------------------------------
/MatterDotNet/Messages/PASE/Pake2.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.PASE
20 | {
21 | public record Pake2 : TLVPayload
22 | {
23 | ///
24 | public Pake2() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public Pake2(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required byte[] PB { get; set; }
31 | public required byte[] CB { get; set; }
32 |
33 | [SetsRequiredMembers]
34 | internal Pake2(TLVReader reader, long structNumber = -1) {
35 | reader.StartStructure(structNumber);
36 | PB = reader.GetBytes(1, false, 65, 65)!;
37 | CB = reader.GetBytes(2, false, 32, 32)!;
38 | reader.EndContainer();
39 | }
40 |
41 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
42 | writer.StartStructure(structNumber);
43 | writer.WriteBytes(1, PB, 65, 65);
44 | writer.WriteBytes(2, CB, 32, 32);
45 | writer.EndContainer();
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/MatterDotNet/Util/BigIntUtil.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Microsoft Corporation. All rights reserved.
3 | * Licensed under the MIT License.
4 | */
5 |
6 | using MatterDotNet.Protocol.Cryptography;
7 | using System.Numerics;
8 |
9 | namespace MatterDotNet.Security
10 | {
11 | ///
12 | /// Big Integer Math
13 | ///
14 | public class BigIntUtil
15 | {
16 | private static BigIntegerPoint Mul(BigIntegerPoint a, BigIntegerPoint b, BigInteger p, BigInteger w2)
17 | {
18 | return new BigIntegerPoint((a.X * b.X + a.Y * b.Y * w2) % p, (a.X * b.Y + b.X * a.Y) % p);
19 | }
20 |
21 | ///
22 | /// Impplements Cipolla's algorithm
23 | ///
24 | ///
25 | ///
26 | ///
27 | public static BigInteger ModSqrt(BigInteger N, BigInteger p)
28 | {
29 | BigInteger a = 0,
30 | w2 = 0;
31 | BigInteger ls = 0;
32 |
33 | // Pick up any value 'a' such that 'w^2 = a^2 - N' is a non-quadratic residue in Fp
34 | do
35 | {
36 | ++a;
37 | w2 = (a * a + p - N) % p;
38 | ls = BigInteger.ModPow(w2, (p - 1) / 2, p);
39 | } while (ls != p - 1);
40 |
41 | // In Fp^2, compute '(a + w)^((p + 1)/2) (mod p)'
42 | var r = new BigIntegerPoint(1, 0);
43 | var s = new BigIntegerPoint(a, 1);
44 | for (var n = (p + 1) / 2 % p; n > 0; n >>= 1)
45 | {
46 | if (!n.IsEven)
47 | r = Mul(r, s, p, w2);
48 | s = Mul(s, s, p, w2);
49 | }
50 |
51 | // Check for errors
52 | if (r.X * r.X % p != N)
53 | return 0;
54 | if (r.Y != 0)
55 | return 0;
56 |
57 | return r.X;
58 | }
59 |
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Generator/Clusters/temperature-measurement-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 | Temperature Measurement
21 | Measurement & Sensing
22 | Attributes and commands for configuring the measurement of temperature, and reporting temperature measurements.
23 | 0x0402
24 | TEMPERATURE_MEASUREMENT_CLUSTER
25 | true
26 | true
27 | MeasuredValue
28 | MinMeasuredValue
29 | MaxMeasuredValue
30 | Tolerance
31 |
32 |
33 |
--------------------------------------------------------------------------------
/MatterDotNet/Messages/InteractionModel/EventFilterIB.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.InteractionModel
20 | {
21 | public record EventFilterIB : TLVPayload
22 | {
23 | ///
24 | public EventFilterIB() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public EventFilterIB(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required ulong Node { get; set; }
31 | public required ulong EventMin { get; set; }
32 |
33 | [SetsRequiredMembers]
34 | internal EventFilterIB(TLVReader reader, long structNumber = -1) {
35 | reader.StartStructure(structNumber);
36 | Node = reader.GetULong(0)!.Value;
37 | EventMin = reader.GetULong(1)!.Value;
38 | reader.EndContainer();
39 | }
40 |
41 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
42 | writer.StartStructure(structNumber);
43 | writer.WriteULong(0, Node);
44 | writer.WriteULong(1, EventMin);
45 | writer.EndContainer();
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/MatterDotNet/Messages/InteractionModel/EventStatusIB.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.InteractionModel
20 | {
21 | public record EventStatusIB : TLVPayload
22 | {
23 | ///
24 | public EventStatusIB() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public EventStatusIB(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required EventPathIB Path { get; set; }
31 | public required StatusIB Status { get; set; }
32 |
33 | [SetsRequiredMembers]
34 | internal EventStatusIB(TLVReader reader, long structNumber = -1) {
35 | reader.StartStructure(structNumber);
36 | Path = new EventPathIB(reader, 0);
37 | Status = new StatusIB(reader, 1);
38 | reader.EndContainer();
39 | }
40 |
41 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
42 | writer.StartStructure(structNumber);
43 | Path.Serialize(writer, 0);
44 | Status.Serialize(writer, 1);
45 | writer.EndContainer();
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/MatterDotNet/Messages/InteractionModel/AttributeStatusIB.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.InteractionModel
20 | {
21 | public record AttributeStatusIB : TLVPayload
22 | {
23 | ///
24 | public AttributeStatusIB() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public AttributeStatusIB(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required AttributePathIB Path { get; set; }
31 | public required StatusIB Status { get; set; }
32 |
33 | [SetsRequiredMembers]
34 | internal AttributeStatusIB(TLVReader reader, long structNumber = -1) {
35 | reader.StartStructure(structNumber);
36 | Path = new AttributePathIB(reader, 0);
37 | Status = new StatusIB(reader, 1);
38 | reader.EndContainer();
39 | }
40 |
41 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
42 | writer.StartStructure(structNumber);
43 | Path.Serialize(writer, 0);
44 | Status.Serialize(writer, 1);
45 | writer.EndContainer();
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/Generator/Clusters/laundry-dryer-controls-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | Appliances
31 | Laundry Dryer Controls
32 | 0x004A
33 | LAUNDRY_DRYER_CONTROLS_CLUSTER
34 | true
35 | true
36 | This cluster provides a way to access options associated with the operation of
37 | a laundry dryer device type.
38 |
39 |
40 |
41 | SupportedDrynessLevels
42 | SelectedDrynessLevel
43 |
44 |
45 |
--------------------------------------------------------------------------------
/MatterDotNet/Attributes/ReadWriteAttribute.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | using MatterDotNet.Protocol.Sessions;
14 | using MatterDotNet.Protocol.Subprotocols;
15 | using System.Data;
16 |
17 | namespace MatterDotNet.Attributes
18 | {
19 | ///
20 | /// Create a Readable and Writable Attribute
21 | ///
22 | ///
23 | public class ReadWriteAttribute : ReadAttribute, IWriteAttribute
24 | {
25 | internal ReadWriteAttribute(uint clusterId, ushort endPoint, ushort attributeId, bool nullable = false) : base(clusterId, endPoint, attributeId, nullable) { }
26 |
27 | ///
28 | /// Set the attribute to the provided value
29 | ///
30 | ///
31 | ///
32 | ///
33 | ///
34 | ///
35 | public async Task Set(SecureSession session, T value, CancellationToken token = default)
36 | {
37 | if (!nullable && value == null)
38 | throw new ConstraintException("Attribute " + AttributeId + " was null");
39 | Value = value;
40 | await InteractionManager.SetAttribute(session, EndPoint, ClusterId, AttributeId, Value, token);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/MatterDotNet/Messages/PASE/Crypto_PBKDFParameterSet.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.PASE
20 | {
21 | public record Crypto_PBKDFParameterSet : TLVPayload
22 | {
23 | ///
24 | public Crypto_PBKDFParameterSet() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public Crypto_PBKDFParameterSet(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required uint Iterations { get; set; }
31 | public required byte[] Salt { get; set; }
32 |
33 | [SetsRequiredMembers]
34 | internal Crypto_PBKDFParameterSet(TLVReader reader, long structNumber = -1) {
35 | reader.StartStructure(structNumber);
36 | Iterations = reader.GetUInt(1)!.Value;
37 | Salt = reader.GetBytes(2, false, 32, 16)!;
38 | reader.EndContainer();
39 | }
40 |
41 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
42 | writer.StartStructure(structNumber);
43 | writer.WriteUInt(1, Iterations);
44 | writer.WriteBytes(2, Salt, 32, 16);
45 | writer.EndContainer();
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/MatterDotNet/Messages/InteractionModel/StatusIB.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.InteractionModel
20 | {
21 | public record StatusIB : TLVPayload
22 | {
23 | ///
24 | public StatusIB() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public StatusIB(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required byte Status { get; set; }
31 | public byte? ClusterStatus { get; set; }
32 |
33 | [SetsRequiredMembers]
34 | internal StatusIB(TLVReader reader, long structNumber = -1) {
35 | reader.StartStructure(structNumber);
36 | Status = reader.GetByte(0)!.Value;
37 | if (reader.IsTag(1))
38 | ClusterStatus = reader.GetByte(1);
39 | reader.EndContainer();
40 | }
41 |
42 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
43 | writer.StartStructure(structNumber);
44 | writer.WriteByte(0, Status);
45 | if (ClusterStatus != null)
46 | writer.WriteByte(1, ClusterStatus);
47 | writer.EndContainer();
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/MatterDotNet/Messages/InteractionModel/StatusResponseMessage.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.InteractionModel
20 | {
21 | public record StatusResponseMessage : TLVPayload
22 | {
23 | ///
24 | public StatusResponseMessage() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public StatusResponseMessage(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required byte Status { get; set; }
31 | public required byte InteractionModelRevision { get; set; }
32 |
33 | [SetsRequiredMembers]
34 | internal StatusResponseMessage(TLVReader reader, long structNumber = -1) {
35 | reader.StartStructure(structNumber);
36 | Status = reader.GetByte(0)!.Value;
37 | InteractionModelRevision = reader.GetByte(255)!.Value;
38 | reader.EndContainer();
39 | }
40 |
41 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
42 | writer.StartStructure(structNumber);
43 | writer.WriteByte(0, Status);
44 | writer.WriteByte(255, InteractionModelRevision);
45 | writer.EndContainer();
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/MatterDotNet/Messages/InteractionModel/TimedRequestMessage.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.InteractionModel
20 | {
21 | public record TimedRequestMessage : TLVPayload
22 | {
23 | ///
24 | public TimedRequestMessage() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public TimedRequestMessage(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required ushort Timeout { get; set; }
31 | public required byte InteractionModelRevision { get; set; }
32 |
33 | [SetsRequiredMembers]
34 | internal TimedRequestMessage(TLVReader reader, long structNumber = -1) {
35 | reader.StartStructure(structNumber);
36 | Timeout = reader.GetUShort(0)!.Value;
37 | InteractionModelRevision = reader.GetByte(255)!.Value;
38 | reader.EndContainer();
39 | }
40 |
41 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
42 | writer.StartStructure(structNumber);
43 | writer.WriteUShort(0, Timeout);
44 | writer.WriteByte(255, InteractionModelRevision);
45 | writer.EndContainer();
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/Generator/Clusters/refrigerator-alarm.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | Refrigerator Alarm
25 | Appliances
26 | Attributes and commands for configuring the Refrigerator alarm.
27 | 0x0057
28 | REFRIGERATOR_ALARM_CLUSTER
29 | true
30 | true
31 |
32 | Mask
33 | State
34 | Supported
35 |
36 |
37 | Notify
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/Generator/Clusters/relative-humidity-measurement-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 | Relative Humidity Measurement
21 | Measurement & Sensing
22 | Attributes and commands for configuring the measurement of relative humidity, and reporting relative humidity measurements.
23 | 0x0405
24 | RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER
25 | true
26 | true
27 |
28 | MeasuredValue
29 | MinMeasuredValue
30 | MaxMeasuredValue
31 | Tolerance
32 |
33 |
34 |
--------------------------------------------------------------------------------
/MatterDotNet/Messages/Certificates/BasicConstraints.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.Certificates
20 | {
21 | public record BasicConstraints : TLVPayload
22 | {
23 | ///
24 | public BasicConstraints() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public BasicConstraints(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required bool IsCa { get; set; }
31 | public byte? PathLenConstraint { get; set; }
32 |
33 | [SetsRequiredMembers]
34 | internal BasicConstraints(TLVReader reader, long structNumber = -1) {
35 | reader.StartStructure(structNumber);
36 | IsCa = reader.GetBool(1)!.Value;
37 | if (reader.IsTag(2))
38 | PathLenConstraint = reader.GetByte(2);
39 | reader.EndContainer();
40 | }
41 |
42 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
43 | writer.StartStructure(structNumber);
44 | writer.WriteBool(1, IsCa);
45 | if (PathLenConstraint != null)
46 | writer.WriteByte(2, PathLenConstraint);
47 | writer.EndContainer();
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/MatterDotNet/Messages/InteractionModel/CommandPathIB.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.InteractionModel
20 | {
21 | public record CommandPathIB : TLVPayload
22 | {
23 | ///
24 | public CommandPathIB() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public CommandPathIB(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required ushort Endpoint { get; set; }
31 | public required uint Cluster { get; set; }
32 | public required uint Command { get; set; }
33 |
34 | [SetsRequiredMembers]
35 | internal CommandPathIB(TLVReader reader, long structNumber = -1) {
36 | reader.StartList(structNumber);
37 | Endpoint = reader.GetUShort(0)!.Value;
38 | Cluster = reader.GetUInt(1)!.Value;
39 | Command = reader.GetUInt(2)!.Value;
40 | reader.EndContainer();
41 | }
42 |
43 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
44 | writer.StartList(structNumber);
45 | writer.WriteUShort(0, Endpoint);
46 | writer.WriteUInt(1, Cluster);
47 | writer.WriteUInt(2, Command);
48 | writer.EndContainer();
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/Generator/Structures/PASE.txt:
--------------------------------------------------------------------------------
1 | namespace PASE
2 | {
3 | Crypto_PBKDFParameterSet => STRUCTURE [ tag-order ]
4 | {
5 | iterations [1] : UNSIGNED INTEGER [ range 32-bits ],
6 | salt [2] : OCTET STRING [ length 16..32 ],
7 | }
8 | // This struct was modified to add optional to 4-7. Very poor documentation.
9 | session-parameter-struct => STRUCTURE [ tag-order ]
10 | {
11 | SessionIdleInterval [1, optional] : UNSIGNED INTEGER [ range 32-bits ],
12 | SessionActiveInterval [2, optional] : UNSIGNED INTEGER [ range 32-bits ],
13 | SessionActiveThreshold [3, optional] : UNSIGNED INTEGER [ range 16-bits ],
14 | DataModelRevision [4, optional]] : UNSIGNED INTEGER [ range 16-bits ],
15 | InteractionModelRevision [5, optional]] : UNSIGNED INTEGER [ range 16-bits ],
16 | SpecificationVersion [6, optional]] : UNSIGNED INTEGER [ range 32-bits ],
17 | MaxPathsPerInvoke [7, optional]] : UNSIGNED INTEGER [ range 16-bits ],
18 | }
19 |
20 | PBKDFParamReq-struct => STRUCTURE [ tag-order ]
21 | {
22 | initiatorRandom [1] : OCTET STRING [ length 32 ],
23 | initiatorSessionId [2] : UNSIGNED INTEGER [ range 16-bits ],
24 | passcodeId [3] : UNSIGNED INTEGER [ length 16-bits ],
25 | hasPBKDFParameters [4] : BOOLEAN,
26 | initiatorSessionParams [5, optional] : session-parameter-struct
27 | }
28 |
29 | // Tag 4 is not marked optional in the spec, but it's description indicates it is optional
30 | PBKDFParamResp-struct => STRUCTURE [ tag-order ]
31 | {
32 | initiatorRandom [1] : OCTET STRING [ length 32 ],
33 | responderRandom [2] : OCTET STRING [ length 32 ],
34 | responderSessionId [3] : UNSIGNED INTEGER [ range 16-bits ],
35 | pbkdf_parameters [4, optional] : Crypto_PBKDFParameterSet,
36 | responderSessionParams [5, optional] : session-parameter-struct
37 | }
38 |
39 | pake-1-struct => STRUCTURE [ tag-order ]
40 | {
41 | pA [1] : OCTET STRING [ length CRYPTO_PUBLIC_KEY_SIZE_BYTES ],
42 | }
43 |
44 | pake-2-struct => STRUCTURE [ tag-order ]
45 | {
46 | pB [1] : OCTET STRING [ length CRYPTO_PUBLIC_KEY_SIZE_BYTES ],
47 | cB [2] : OCTET STRING [ length CRYPTO_HASH_LEN_BYTES],
48 | }
49 |
50 | pake-3-struct => STRUCTURE [ tag-order ]
51 | {
52 | cA [1] : OCTET STRING [length CRYPTO_HASH_LEN_BYTES],
53 | }
54 | }
--------------------------------------------------------------------------------
/Generator/Structures/CASE.txt:
--------------------------------------------------------------------------------
1 | namespace CASE
2 | {
3 | sigma-1-struct => STRUCTURE [ tag-order ]
4 | {
5 | initiatorRandom [1] : OCTET STRING [ length 32 ],
6 | initiatorSessionId [2] : UNSIGNED INTEGER [ range 16-bits ],
7 | destinationId [3] : destination-identifier,
8 | initiatorEphPubKey [4] : ec-pub-key,
9 | initiatorSessionParams [5, optional] : session-parameter-struct,
10 | resumptionId [6, optional] : OCTET STRING [ length 16 ],
11 | initiatorResumeMIC [7, optional] : OCTET STRING [ length CRYPTO_AEAD_MIC_LENGTH_BYTES ]
12 | }
13 |
14 | sigma-2-tbsdata => STRUCTURE [ tag-order ]
15 | {
16 | responderNOC [1] : OCTET STRING,
17 | responderICAC [2, optional] : OCTET STRING,
18 | responderEphPubKey [3] : ec-pub-key,
19 | initiatorEphPubKey [4] : ec-pub-key,
20 | }
21 |
22 | sigma-2-tbedata => STRUCTURE [ tag-order ]
23 | {
24 | responderNOC [1] : OCTET STRING,
25 | responderICAC [2, optional] : OCTET STRING,
26 | signature [3] : ec-signature,
27 | resumptionId [4] : OCTET STRING [ length 16 ],
28 | }
29 |
30 | sigma-2-struct => STRUCTURE [ tag-order ]
31 | {
32 | responderRandom [1] : OCTET STRING [ length 32 ],
33 | responderSessionId [2] : UNSIGNED INTEGER [ range 16-bits ],
34 | responderEphPubKey [3] : ec-pub-key,
35 | encrypted2 [4] : OCTET STRING,
36 | responderSessionParams [5, optional] : session-parameter-struct
37 | }
38 |
39 | sigma-3-tbsdata => STRUCTURE [ tag-order ]
40 | {
41 | initiatorNOC [1] : OCTET STRING,
42 | initiatorICAC [2, optional] : OCTET STRING,
43 | initiatorEphPubKey [3] : ec-pub-key,
44 | responderEphPubKey [4] : ec-pub-key,
45 | }
46 |
47 | sigma-3-tbedata => STRUCTURE [ tag-order ]
48 | {
49 | initiatorNOC [1] : OCTET STRING,
50 | initiatorICAC [2, optional] : OCTET STRING,
51 | signature [3] : ec-signature,
52 | }
53 |
54 | sigma-3-struct => STRUCTURE [ tag-order ]
55 | {
56 | encrypted3 [1] : OCTET STRING,
57 | }
58 |
59 | sigma-2-resume-struct => STRUCTURE [ tag-order ]
60 | {
61 | resumptionId [1] : OCTET STRING [ length 16 ],
62 | sigma2ResumeMIC [2] : OCTET STRING [ length 16 ],
63 | responderSessionId [3] : UNSIGNED INTEGER [ range 16-bits ],
64 | responderSessionParams [4, optional] : session-parameter-struct
65 | }
66 | }
--------------------------------------------------------------------------------
/MatterDotNet/Messages/InteractionModel/DataVersionFilterIB.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.InteractionModel
20 | {
21 | public record DataVersionFilterIB : TLVPayload
22 | {
23 | ///
24 | public DataVersionFilterIB() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public DataVersionFilterIB(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required uint DataVersion { get; set; }
31 | public required AttributePathIB Path { get; set; }
32 | public required object Data { get; set; }
33 |
34 | [SetsRequiredMembers]
35 | internal DataVersionFilterIB(TLVReader reader, long structNumber = -1) {
36 | reader.StartStructure(structNumber);
37 | DataVersion = reader.GetUInt(0)!.Value;
38 | Path = new AttributePathIB(reader, 1);
39 | Data = reader.GetAny(2)!;
40 | reader.EndContainer();
41 | }
42 |
43 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
44 | writer.StartStructure(structNumber);
45 | writer.WriteUInt(0, DataVersion);
46 | Path.Serialize(writer, 1);
47 | writer.WriteAny(2, Data);
48 | writer.EndContainer();
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/MatterDotNet/Messages/InteractionModel/InvokeResponseIB.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.InteractionModel
20 | {
21 | public record InvokeResponseIB : TLVPayload
22 | {
23 | ///
24 | public InvokeResponseIB() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public InvokeResponseIB(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public CommandDataIB? Command { get; set; }
31 | public CommandStatusIB? Status { get; set; }
32 |
33 | [SetsRequiredMembers]
34 | internal InvokeResponseIB(TLVReader reader, long structNumber = -1) {
35 | reader.StartStructure(structNumber);
36 | if (reader.IsTag(0))
37 | Command = new CommandDataIB(reader, 0);
38 | if (reader.IsTag(1))
39 | Status = new CommandStatusIB(reader, 1);
40 | reader.EndContainer();
41 | }
42 |
43 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
44 | writer.StartStructure(structNumber);
45 | if (Command != null)
46 | Command.Serialize(writer, 0);
47 | if (Status != null)
48 | Status.Serialize(writer, 1);
49 | writer.EndContainer();
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/MatterDotNet/Messages/InteractionModel/EventReportIB.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.InteractionModel
20 | {
21 | public record EventReportIB : TLVPayload
22 | {
23 | ///
24 | public EventReportIB() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public EventReportIB(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public EventStatusIB? EventStatus { get; set; }
31 | public EventDataIB? EventData { get; set; }
32 |
33 | [SetsRequiredMembers]
34 | internal EventReportIB(TLVReader reader, long structNumber = -1) {
35 | reader.StartStructure(structNumber);
36 | if (reader.IsTag(0))
37 | EventStatus = new EventStatusIB(reader, 0);
38 | if (reader.IsTag(1))
39 | EventData = new EventDataIB(reader, 1);
40 | reader.EndContainer();
41 | }
42 |
43 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
44 | writer.StartStructure(structNumber);
45 | if (EventStatus != null)
46 | EventStatus.Serialize(writer, 0);
47 | if (EventData != null)
48 | EventData.Serialize(writer, 1);
49 | writer.EndContainer();
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/TLV/ElementType.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Protocol.Parsers
14 | {
15 | internal enum ElementType
16 | {
17 | SByte = 0,
18 | Short = 1,
19 | Int = 2,
20 | Long = 3,
21 | Byte = 4,
22 | UShort = 5,
23 | UInt = 6,
24 | ULong = 7,
25 | False = 8,
26 | True = 9,
27 | Float = 10,
28 | Double = 11,
29 | ///
30 | /// 1 Byte Length UTF-8 String
31 | ///
32 | String8 = 12,
33 | ///
34 | /// 2 Byte Length UTF-8 String
35 | ///
36 | String16 = 13,
37 | ///
38 | /// 4 Byte Length UTF-8 String
39 | ///
40 | String32 = 14,
41 | ///
42 | /// 8 Byte Length UTF-8 String
43 | ///
44 | String64 = 15,
45 | ///
46 | /// 1 Byte Length Octet String
47 | ///
48 | Bytes8 = 16,
49 | ///
50 | /// 2 Byte Length Octet String
51 | ///
52 | Bytes16 = 17,
53 | ///
54 | /// 4 Byte Length Octet String
55 | ///
56 | Bytes32 = 18,
57 | ///
58 | /// 8 Byte Length Octet String
59 | ///
60 | Bytes64 = 19,
61 | Null = 20,
62 | Structure = 21,
63 | Array = 22,
64 | List = 23,
65 | EndOfContainer = 24,
66 | None = 0xFF
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/Generator/Tag.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | using System.Text;
14 |
15 | namespace Generator
16 | {
17 | public class Tag
18 | {
19 | public Tag()
20 | {
21 | Children = new List();
22 | }
23 |
24 | public DataType Type { get; set; }
25 | public string? Name { get; set; }
26 | public int LengthBytes { get; set; }
27 | public long Min { get; set; }
28 | public long Max { get; set; }
29 | public bool Nullable { get; set; }
30 | public bool Optional { get; set; }
31 | public List Children { get; set; }
32 | public Tag? Parent { get; set; }
33 | public int TagNumber { get; set; }
34 | public string? ReferenceName { get; set; }
35 | public string? Namespace { get; set; }
36 |
37 | public override string ToString()
38 | {
39 | StringBuilder sb = new StringBuilder();
40 | if (Type == DataType.Reference)
41 | sb.AppendLine(ReferenceName + " " + Name + ":");
42 | sb.AppendLine(Type + " " + Name);
43 | foreach (Tag child in Children)
44 | sb.Append(getPrefix() + child.ToString());
45 | return sb.ToString();
46 | }
47 |
48 | private string getPrefix()
49 | {
50 | string prefix = string.Empty;
51 | Tag tag = this;
52 | while (tag.Parent != null)
53 | {
54 | prefix += '\t';
55 | tag = tag.Parent;
56 | }
57 | return prefix;
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/MatterDotNet/Messages/CASE/Sigma3Tbedata.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.CASE
20 | {
21 | public record Sigma3Tbedata : TLVPayload
22 | {
23 | ///
24 | public Sigma3Tbedata() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public Sigma3Tbedata(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required byte[] InitiatorNOC { get; set; }
31 | public byte[]? InitiatorICAC { get; set; }
32 | public required byte[] Signature { get; set; }
33 |
34 | [SetsRequiredMembers]
35 | internal Sigma3Tbedata(TLVReader reader, long structNumber = -1) {
36 | reader.StartStructure(structNumber);
37 | InitiatorNOC = reader.GetBytes(1)!;
38 | if (reader.IsTag(2))
39 | InitiatorICAC = reader.GetBytes(2);
40 | Signature = reader.GetBytes(3, false, 64, 64)!;
41 | reader.EndContainer();
42 | }
43 |
44 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
45 | writer.StartStructure(structNumber);
46 | writer.WriteBytes(1, InitiatorNOC);
47 | if (InitiatorICAC != null)
48 | writer.WriteBytes(2, InitiatorICAC);
49 | writer.WriteBytes(3, Signature, 64, 64);
50 | writer.EndContainer();
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/MatterDotNet/Messages/InteractionModel/AttributeReportIB.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.InteractionModel
20 | {
21 | public record AttributeReportIB : TLVPayload
22 | {
23 | ///
24 | public AttributeReportIB() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public AttributeReportIB(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public AttributeStatusIB? AttributeStatus { get; set; }
31 | public AttributeDataIB? AttributeData { get; set; }
32 |
33 | [SetsRequiredMembers]
34 | internal AttributeReportIB(TLVReader reader, long structNumber = -1) {
35 | reader.StartStructure(structNumber);
36 | if (reader.IsTag(0))
37 | AttributeStatus = new AttributeStatusIB(reader, 0);
38 | if (reader.IsTag(1))
39 | AttributeData = new AttributeDataIB(reader, 1);
40 | reader.EndContainer();
41 | }
42 |
43 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
44 | writer.StartStructure(structNumber);
45 | if (AttributeStatus != null)
46 | AttributeStatus.Serialize(writer, 0);
47 | if (AttributeData != null)
48 | AttributeData.Serialize(writer, 1);
49 | writer.EndContainer();
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/MatterDotNet/Clusters/General/BooleanStateCluster.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 | //
13 | // WARNING: This file was auto-generated. Do not edit.
14 |
15 | using MatterDotNet.Attributes;
16 | using MatterDotNet.Protocol.Parsers;
17 | using MatterDotNet.Protocol.Sessions;
18 | using System.Diagnostics.CodeAnalysis;
19 |
20 | namespace MatterDotNet.Clusters.General
21 | {
22 | ///
23 | /// This cluster provides an interface to a boolean state called StateValue.
24 | ///
25 | [ClusterRevision(CLUSTER_ID, 1)]
26 | public class BooleanState : ClusterBase
27 | {
28 | internal const uint CLUSTER_ID = 0x0045;
29 |
30 | ///
31 | /// This cluster provides an interface to a boolean state called StateValue.
32 | ///
33 | [SetsRequiredMembers]
34 | public BooleanState(ushort endPoint) : this(CLUSTER_ID, endPoint) { }
35 | ///
36 | [SetsRequiredMembers]
37 | protected BooleanState(uint cluster, ushort endPoint) : base(cluster, endPoint) {
38 | StateValue = new ReportAttribute(cluster, endPoint, 0) {
39 | Deserialize = x => (bool)(dynamic?)x!
40 | };
41 | }
42 |
43 | #region Attributes
44 | ///
45 | /// State Value Attribute [Read/Event]
46 | ///
47 | public required ReportAttribute StateValue { get; init; }
48 | #endregion Attributes
49 |
50 | ///
51 | public override string ToString() {
52 | return "Boolean State";
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/MatterDotNet/Messages/InteractionModel/CommandStatusIB.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.InteractionModel
20 | {
21 | public record CommandStatusIB : TLVPayload
22 | {
23 | ///
24 | public CommandStatusIB() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public CommandStatusIB(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required CommandPathIB CommandPath { get; set; }
31 | public required StatusIB Status { get; set; }
32 | public ushort? CommandRef { get; set; }
33 |
34 | [SetsRequiredMembers]
35 | internal CommandStatusIB(TLVReader reader, long structNumber = -1) {
36 | reader.StartStructure(structNumber);
37 | CommandPath = new CommandPathIB(reader, 0);
38 | Status = new StatusIB(reader, 1);
39 | if (reader.IsTag(2))
40 | CommandRef = reader.GetUShort(2);
41 | reader.EndContainer();
42 | }
43 |
44 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
45 | writer.StartStructure(structNumber);
46 | CommandPath.Serialize(writer, 0);
47 | Status.Serialize(writer, 1);
48 | if (CommandRef != null)
49 | writer.WriteUShort(2, CommandRef);
50 | writer.EndContainer();
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/Generator/Clusters/unit-localization-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | CHIP
27 | Unit Localization
28 | 0x002d
29 | UNIT_LOCALIZATION_CLUSTER
30 | true
31 | true
32 | Nodes should be expected to be deployed to any and all regions of the world. These global regions
33 | may have differing preferences for the units in which values are conveyed in communication to a
34 | user. As such, Nodes that visually or audibly convey measurable values to the user need a
35 | mechanism by which they can be configured to use a user’s preferred unit.
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | TemperatureUnit
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/MatterDotNet/Util/Checksum.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace MatterDotNet.Security
14 | {
15 | internal static class Checksum
16 | {
17 | private static int[,] d = new int[,]
18 | {
19 | {0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
20 | {1, 2, 3, 4, 0, 6, 7, 8, 9, 5},
21 | {2, 3, 4, 0, 1, 7, 8, 9, 5, 6},
22 | {3, 4, 0, 1, 2, 8, 9, 5, 6, 7},
23 | {4, 0, 1, 2, 3, 9, 5, 6, 7, 8},
24 | {5, 9, 8, 7, 6, 0, 4, 3, 2, 1},
25 | {6, 5, 9, 8, 7, 1, 0, 4, 3, 2},
26 | {7, 6, 5, 9, 8, 2, 1, 0, 4, 3},
27 | {8, 7, 6, 5, 9, 3, 2, 1, 0, 4},
28 | {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}
29 | };
30 |
31 | private static int[,] p = new int[,]
32 | {
33 | {0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
34 | {1, 5, 7, 6, 2, 8, 3, 0, 9, 4},
35 | {5, 8, 0, 3, 7, 9, 6, 1, 4, 2},
36 | {8, 9, 1, 6, 0, 4, 3, 5, 2, 7},
37 | {9, 4, 5, 3, 1, 2, 6, 8, 7, 0},
38 | {4, 2, 8, 6, 5, 7, 3, 9, 0, 1},
39 | {2, 7, 9, 3, 8, 0, 6, 4, 1, 5},
40 | {7, 0, 4, 6, 9, 1, 3, 2, 5, 8}
41 | };
42 |
43 | private static int[] inv = { 0, 4, 3, 2, 1, 5, 6, 7, 8, 9 };
44 |
45 | public static int GenerateVerhoeff(string num)
46 | {
47 | int ret = 0;
48 | int[] myArray = num.ToCharArray().Select(x => int.Parse(x.ToString())).Reverse().ToArray();
49 |
50 | for (int i = 0; i < myArray.Length; i++)
51 | ret = d[ret, p[((i + 1) % 8), myArray[i]]];
52 |
53 | return inv[ret];
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/MatterDotNet/Messages/InteractionModel/SubscribeResponseMessage.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.InteractionModel
20 | {
21 | public record SubscribeResponseMessage : TLVPayload
22 | {
23 | ///
24 | public SubscribeResponseMessage() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public SubscribeResponseMessage(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required uint SubscriptionID { get; set; }
31 | public required ushort MaxInterval { get; set; }
32 | public required byte InteractionModelRevision { get; set; }
33 |
34 | [SetsRequiredMembers]
35 | internal SubscribeResponseMessage(TLVReader reader, long structNumber = -1) {
36 | reader.StartStructure(structNumber);
37 | SubscriptionID = reader.GetUInt(0)!.Value;
38 | MaxInterval = reader.GetUShort(2)!.Value;
39 | InteractionModelRevision = reader.GetByte(255)!.Value;
40 | reader.EndContainer();
41 | }
42 |
43 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
44 | writer.StartStructure(structNumber);
45 | writer.WriteUInt(0, SubscriptionID);
46 | writer.WriteUShort(2, MaxInterval);
47 | writer.WriteByte(255, InteractionModelRevision);
48 | writer.EndContainer();
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/Generator/Clusters/chime-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | Chime
34 | 0x0556
35 | CHIME_CLUSTER
36 | This cluster provides facilities to configure and play Chime sounds, such as those used in a doorbell.
37 | true
38 | true
39 |
40 | InstalledChimeSounds
41 | ActiveChimeID
42 | Enabled
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/Generator/Clusters/fault-injection-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | CHIP
29 | Fault Injection
30 | 0xFFF1FC06
31 | FAULT_INJECTION_CLUSTER
32 | The Fault Injection Cluster provide a means for a test harness to configure faults(for example triggering a fault in the system).
33 |
34 | Configure a fault to be triggered deterministically
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | Configure a fault to be triggered randomly, with a given probability defined as a percentage
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/MatterDotNet/Messages/InteractionModel/AttributeDataIB.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.InteractionModel
20 | {
21 | ///
22 | /// Attribute Data IB Payload
23 | ///
24 | public record AttributeDataIB : TLVPayload
25 | {
26 | ///
27 | public AttributeDataIB() {}
28 |
29 | ///
30 | [SetsRequiredMembers]
31 | public AttributeDataIB(Memory data) : this(new TLVReader(data)) {}
32 |
33 | public uint? DataVersion { get; set; }
34 | public required AttributePathIB Path { get; set; }
35 | public required object? Data { get; set; }
36 |
37 | [SetsRequiredMembers]
38 | internal AttributeDataIB(TLVReader reader, long structNumber = -1) {
39 | reader.StartStructure(structNumber);
40 | if (reader.IsTag(0))
41 | DataVersion = reader.GetUInt(0);
42 | Path = new AttributePathIB(reader, 1);
43 | Data = reader.GetAny(2, true);
44 | reader.EndContainer();
45 | }
46 |
47 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
48 | writer.StartStructure(structNumber);
49 | if (DataVersion != null)
50 | writer.WriteUInt(0, DataVersion);
51 | Path.Serialize(writer, 1);
52 | writer.WriteAny(2, Data);
53 | writer.EndContainer();
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/MatterDotNet/Messages/InteractionModel/ClusterPathIB.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.InteractionModel
20 | {
21 | public record ClusterPathIB : TLVPayload
22 | {
23 | ///
24 | public ClusterPathIB() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public ClusterPathIB(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public ulong? Node { get; set; }
31 | public ushort? Endpoint { get; set; }
32 | public uint? Cluster { get; set; }
33 |
34 | [SetsRequiredMembers]
35 | internal ClusterPathIB(TLVReader reader, long structNumber = -1) {
36 | reader.StartList(structNumber);
37 | if (reader.IsTag(0))
38 | Node = reader.GetULong(0);
39 | if (reader.IsTag(1))
40 | Endpoint = reader.GetUShort(1);
41 | if (reader.IsTag(2))
42 | Cluster = reader.GetUInt(2);
43 | reader.EndContainer();
44 | }
45 |
46 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
47 | writer.StartList(structNumber);
48 | if (Node != null)
49 | writer.WriteULong(0, Node);
50 | if (Endpoint != null)
51 | writer.WriteUShort(1, Endpoint);
52 | if (Cluster != null)
53 | writer.WriteUInt(2, Cluster);
54 | writer.EndContainer();
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/MatterDotNet/Messages/InteractionModel/CommandDataIB.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.InteractionModel
20 | {
21 | public record CommandDataIB : TLVPayload
22 | {
23 | ///
24 | public CommandDataIB() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public CommandDataIB(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required CommandPathIB CommandPath { get; set; }
31 | public object? CommandFields { get; set; }
32 | public ushort? CommandRef { get; set; }
33 |
34 | [SetsRequiredMembers]
35 | internal CommandDataIB(TLVReader reader, long structNumber = -1) {
36 | reader.StartStructure(structNumber);
37 | CommandPath = new CommandPathIB(reader, 0);
38 | if (reader.IsTag(1))
39 | CommandFields = reader.GetAny(1);
40 | if (reader.IsTag(2))
41 | CommandRef = reader.GetUShort(2);
42 | reader.EndContainer();
43 | }
44 |
45 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
46 | writer.StartStructure(structNumber);
47 | CommandPath.Serialize(writer, 0);
48 | if (CommandFields != null)
49 | writer.WriteAny(1, CommandFields);
50 | if (CommandRef != null)
51 | writer.WriteUShort(2, CommandRef);
52 | writer.EndContainer();
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/MatterDotNet/Clusters/General/LowPowerCluster.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 | //
13 | // WARNING: This file was auto-generated. Do not edit.
14 |
15 | using MatterDotNet.Messages.InteractionModel;
16 | using MatterDotNet.Protocol.Parsers;
17 | using MatterDotNet.Protocol.Sessions;
18 | using MatterDotNet.Protocol.Subprotocols;
19 | using System.Diagnostics.CodeAnalysis;
20 |
21 | namespace MatterDotNet.Clusters.General
22 | {
23 | ///
24 | /// This cluster provides an interface for managing low power mode on a device.
25 | ///
26 | [ClusterRevision(CLUSTER_ID, 1)]
27 | public class LowPower : ClusterBase
28 | {
29 | internal const uint CLUSTER_ID = 0x0508;
30 |
31 | ///
32 | /// This cluster provides an interface for managing low power mode on a device.
33 | ///
34 | [SetsRequiredMembers]
35 | public LowPower(ushort endPoint) : this(CLUSTER_ID, endPoint) { }
36 | ///
37 | [SetsRequiredMembers]
38 | protected LowPower(uint cluster, ushort endPoint) : base(cluster, endPoint) {
39 | }
40 |
41 | #region Payloads
42 | #endregion Payloads
43 |
44 | #region Commands
45 | ///
46 | /// Sleep
47 | ///
48 | public async Task Sleep(SecureSession session, CancellationToken token = default) {
49 | InvokeResponseIB resp = await InteractionManager.ExecCommand(session, endPoint, cluster, 0x00, null, token);
50 | return ValidateResponse(resp);
51 | }
52 | #endregion Commands
53 |
54 |
55 | ///
56 | public override string ToString() {
57 | return "Low Power";
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/Generator/Clusters/wifi-network-management-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 | Network Infrastructure
22 | Wi-Fi Network Management
23 | 0x0451
24 | WIFI_NETWORK_MANAGEMENT_CLUSTER
25 | Functionality to retrieve operational information about a managed Wi-Fi network.
26 |
27 | true
28 | true
29 |
30 |
31 |
32 |
33 | SSID
34 |
35 | PassphraseSurrogate
36 |
37 |
38 |
39 |
40 | Request the current WPA-Personal passphrase or PSK associated with the managed Wi-Fi network.
41 |
42 |
43 |
44 | This is the response to a NetworkPassphraseRequest.
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/MatterDotNet/Messages/CASE/Sigma2Tbedata.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.CASE
20 | {
21 | public record Sigma2Tbedata : TLVPayload
22 | {
23 | ///
24 | public Sigma2Tbedata() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public Sigma2Tbedata(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required byte[] ResponderNOC { get; set; }
31 | public byte[]? ResponderICAC { get; set; }
32 | public required byte[] Signature { get; set; }
33 | public required byte[] ResumptionId { get; set; }
34 |
35 | [SetsRequiredMembers]
36 | internal Sigma2Tbedata(TLVReader reader, long structNumber = -1) {
37 | reader.StartStructure(structNumber);
38 | ResponderNOC = reader.GetBytes(1)!;
39 | if (reader.IsTag(2))
40 | ResponderICAC = reader.GetBytes(2);
41 | Signature = reader.GetBytes(3, false, 64, 64)!;
42 | ResumptionId = reader.GetBytes(4, false, 16, 16)!;
43 | reader.EndContainer();
44 | }
45 |
46 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
47 | writer.StartStructure(structNumber);
48 | writer.WriteBytes(1, ResponderNOC);
49 | if (ResponderICAC != null)
50 | writer.WriteBytes(2, ResponderICAC);
51 | writer.WriteBytes(3, Signature, 64, 64);
52 | writer.WriteBytes(4, ResumptionId, 16, 16);
53 | writer.EndContainer();
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/Generator/Clusters/air-quality-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 | Air Quality
21 | Measurement & Sensing
22 | Attributes for reporting air quality classification
23 | 0x005B
24 | AIR_QUALITY_CLUSTER
25 | true
26 | true
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | AirQuality
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/Generator/Clusters/power-topology-cluster.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 | Measurement & Sensing
22 | Power Topology
23 | 0x009C
24 | POWER_TOPOLOGY_CLUSTER
25 | The Power Topology Cluster provides a mechanism for expressing how power is flowing between endpoints.
26 | true
27 | true
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | AvailableEndpoints
48 | ActiveEndpoints
49 |
50 |
51 |
--------------------------------------------------------------------------------
/MatterDotNet/Messages/CASE/Sigma2Tbsdata.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.CASE
20 | {
21 | public record Sigma2Tbsdata : TLVPayload
22 | {
23 | ///
24 | public Sigma2Tbsdata() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public Sigma2Tbsdata(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required byte[] ResponderNOC { get; set; }
31 | public byte[]? ResponderICAC { get; set; }
32 | public required byte[] ResponderEphPubKey { get; set; }
33 | public required byte[] InitiatorEphPubKey { get; set; }
34 |
35 | [SetsRequiredMembers]
36 | internal Sigma2Tbsdata(TLVReader reader, long structNumber = -1) {
37 | reader.StartStructure(structNumber);
38 | ResponderNOC = reader.GetBytes(1)!;
39 | if (reader.IsTag(2))
40 | ResponderICAC = reader.GetBytes(2);
41 | ResponderEphPubKey = reader.GetBytes(3, false, 65, 65)!;
42 | InitiatorEphPubKey = reader.GetBytes(4, false, 65, 65)!;
43 | reader.EndContainer();
44 | }
45 |
46 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
47 | writer.StartStructure(structNumber);
48 | writer.WriteBytes(1, ResponderNOC);
49 | if (ResponderICAC != null)
50 | writer.WriteBytes(2, ResponderICAC);
51 | writer.WriteBytes(3, ResponderEphPubKey, 65, 65);
52 | writer.WriteBytes(4, InitiatorEphPubKey, 65, 65);
53 | writer.EndContainer();
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/MatterDotNet/Messages/CASE/Sigma3Tbsdata.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.CASE
20 | {
21 | public record Sigma3Tbsdata : TLVPayload
22 | {
23 | ///
24 | public Sigma3Tbsdata() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public Sigma3Tbsdata(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required byte[] InitiatorNOC { get; set; }
31 | public byte[]? InitiatorICAC { get; set; }
32 | public required byte[] InitiatorEphPubKey { get; set; }
33 | public required byte[] ResponderEphPubKey { get; set; }
34 |
35 | [SetsRequiredMembers]
36 | internal Sigma3Tbsdata(TLVReader reader, long structNumber = -1) {
37 | reader.StartStructure(structNumber);
38 | InitiatorNOC = reader.GetBytes(1)!;
39 | if (reader.IsTag(2))
40 | InitiatorICAC = reader.GetBytes(2);
41 | InitiatorEphPubKey = reader.GetBytes(3, false, 65, 65)!;
42 | ResponderEphPubKey = reader.GetBytes(4, false, 65, 65)!;
43 | reader.EndContainer();
44 | }
45 |
46 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
47 | writer.StartStructure(structNumber);
48 | writer.WriteBytes(1, InitiatorNOC);
49 | if (InitiatorICAC != null)
50 | writer.WriteBytes(2, InitiatorICAC);
51 | writer.WriteBytes(3, InitiatorEphPubKey, 65, 65);
52 | writer.WriteBytes(4, ResponderEphPubKey, 65, 65);
53 | writer.EndContainer();
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/MatterDotNet.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.12.35506.116
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MatterDotNet", "MatterDotNet\MatterDotNet.csproj", "{EA1A2183-F755-48C1-A431-29C280D5D493}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExampleConsole", "ExampleConsole\ExampleConsole.csproj", "{FB0B84C4-A10C-4911-9D79-36134B311B07}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{DDE2325B-62EF-460A-8A4B-6ED3311AEFAF}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Generator", "Generator\Generator.csproj", "{014FD19C-98D5-4CB0-8FE0-332CA37C1BA1}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Any CPU = Debug|Any CPU
17 | Release|Any CPU = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {EA1A2183-F755-48C1-A431-29C280D5D493}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {EA1A2183-F755-48C1-A431-29C280D5D493}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {EA1A2183-F755-48C1-A431-29C280D5D493}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {EA1A2183-F755-48C1-A431-29C280D5D493}.Release|Any CPU.Build.0 = Release|Any CPU
24 | {FB0B84C4-A10C-4911-9D79-36134B311B07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {FB0B84C4-A10C-4911-9D79-36134B311B07}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {FB0B84C4-A10C-4911-9D79-36134B311B07}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {FB0B84C4-A10C-4911-9D79-36134B311B07}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {DDE2325B-62EF-460A-8A4B-6ED3311AEFAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {DDE2325B-62EF-460A-8A4B-6ED3311AEFAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {DDE2325B-62EF-460A-8A4B-6ED3311AEFAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {DDE2325B-62EF-460A-8A4B-6ED3311AEFAF}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {014FD19C-98D5-4CB0-8FE0-332CA37C1BA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {014FD19C-98D5-4CB0-8FE0-332CA37C1BA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {014FD19C-98D5-4CB0-8FE0-332CA37C1BA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 | {014FD19C-98D5-4CB0-8FE0-332CA37C1BA1}.Release|Any CPU.Build.0 = Release|Any CPU
36 | EndGlobalSection
37 | GlobalSection(SolutionProperties) = preSolution
38 | HideSolutionNode = FALSE
39 | EndGlobalSection
40 | EndGlobal
41 |
--------------------------------------------------------------------------------
/MatterDotNet/Protocol/Sessions/Exchange.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | using MatterDotNet.Protocol.Payloads;
14 | using MatterDotNet.Protocol.Payloads.Flags;
15 | using System.Threading.Channels;
16 |
17 | namespace MatterDotNet.Protocol.Sessions
18 | {
19 | internal class Exchange : IDisposable
20 | {
21 | public ushort ID { get; init; }
22 | public SessionContext Session {get; init;}
23 | internal Channel Messages { get; init;}
24 |
25 | internal Exchange(SessionContext session, ushort id)
26 | {
27 | Session = session;
28 | ID = id;
29 | Messages = Channel.CreateBounded(10);
30 | }
31 |
32 | public async Task SendFrame(Frame frame, bool reliable = true, CancellationToken token = default)
33 | {
34 | try
35 | {
36 | frame.SessionID = Session.RemoteSessionID;
37 | if (Session.Initiator)
38 | frame.Message.Flags |= ExchangeFlags.Initiator;
39 | frame.Message.ExchangeID = ID;
40 | frame.Counter = Session.GetSessionCounter();
41 | await Session.Connection.SendFrame(this, frame, reliable, token);
42 | }
43 | catch(OperationCanceledException e)
44 | {
45 | Console.WriteLine("Failed to send frame: " + e.ToString());
46 | }
47 | }
48 |
49 | public async Task Read(CancellationToken token = default)
50 | {
51 | return await Messages.Reader.ReadAsync(token);
52 | }
53 |
54 | ///
55 | public void Dispose()
56 | {
57 | Console.WriteLine("Closing Exchange: " + ID);
58 | Session.DeleteExchange(this).Wait();
59 | GC.SuppressFinalize(this);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/MatterDotNet/Messages/Certificates/AttestationElements.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
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.Certificates
20 | {
21 | public record AttestationElements : TLVPayload
22 | {
23 | ///
24 | public AttestationElements() {}
25 |
26 | ///
27 | [SetsRequiredMembers]
28 | public AttestationElements(Memory data) : this(new TLVReader(data)) {}
29 |
30 | public required byte[] Certification_declaration { get; set; }
31 | public required byte[] Attestation_nonce { get; set; }
32 | public required uint Timestamp { get; set; }
33 | public byte[]? Firmware_information { get; set; }
34 |
35 | [SetsRequiredMembers]
36 | internal AttestationElements(TLVReader reader, long structNumber = -1) {
37 | reader.StartStructure(structNumber);
38 | Certification_declaration = reader.GetBytes(1)!;
39 | Attestation_nonce = reader.GetBytes(2, false, 32, 32)!;
40 | Timestamp = reader.GetUInt(3)!.Value;
41 | if (reader.IsTag(4))
42 | Firmware_information = reader.GetBytes(4);
43 | reader.EndContainer();
44 | }
45 |
46 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
47 | writer.StartStructure(structNumber);
48 | writer.WriteBytes(1, Certification_declaration);
49 | writer.WriteBytes(2, Attestation_nonce, 32, 32);
50 | writer.WriteUInt(3, Timestamp);
51 | if (Firmware_information != null)
52 | writer.WriteBytes(4, Firmware_information);
53 | writer.EndContainer();
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/MatterDotNet/Messages/CASE/Sigma2Resume.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 | //
13 | // WARNING: This file was auto-generated. Do not edit.
14 |
15 | using MatterDotNet.Messages.PASE;
16 | using MatterDotNet.Protocol.Parsers;
17 | using MatterDotNet.Protocol.Payloads;
18 | using System.Diagnostics.CodeAnalysis;
19 |
20 | namespace MatterDotNet.Messages.CASE
21 | {
22 | public record Sigma2Resume : TLVPayload
23 | {
24 | ///
25 | public Sigma2Resume() {}
26 |
27 | ///
28 | [SetsRequiredMembers]
29 | public Sigma2Resume(Memory data) : this(new TLVReader(data)) {}
30 |
31 | public required byte[] ResumptionId { get; set; }
32 | public required byte[] Sigma2ResumeMIC { get; set; }
33 | public required ushort ResponderSessionId { get; set; }
34 | public SessionParameter? ResponderSessionParams { get; set; }
35 |
36 | [SetsRequiredMembers]
37 | internal Sigma2Resume(TLVReader reader, long structNumber = -1) {
38 | reader.StartStructure(structNumber);
39 | ResumptionId = reader.GetBytes(1, false, 16, 16)!;
40 | Sigma2ResumeMIC = reader.GetBytes(2, false, 16, 16)!;
41 | ResponderSessionId = reader.GetUShort(3)!.Value;
42 | if (reader.IsTag(4))
43 | ResponderSessionParams = new SessionParameter(reader, 4);
44 | reader.EndContainer();
45 | }
46 |
47 | internal override void Serialize(TLVWriter writer, long structNumber = -1) {
48 | writer.StartStructure(structNumber);
49 | writer.WriteBytes(1, ResumptionId, 16, 16);
50 | writer.WriteBytes(2, Sigma2ResumeMIC, 16, 16);
51 | writer.WriteUShort(3, ResponderSessionId);
52 | if (ResponderSessionParams != null)
53 | ResponderSessionParams.Serialize(writer, 4);
54 | writer.EndContainer();
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/Generator/Generator.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 |
13 | namespace Generator
14 | {
15 | internal class Generator
16 | {
17 | static void Main(string[] args)
18 | {
19 | Directory.CreateDirectory("outputs");
20 | CommentGenerator.Generate();
21 | ClusterGenerator.Generate();
22 | DeviceTypeGenerator.Generate();
23 | foreach (string file in Directory.EnumerateFiles("..\\..\\..\\Structures"))
24 | {
25 | Tag[] structs;
26 | using (FileStream fs = File.OpenRead(file))
27 | structs = StructParser.ParseStruct(fs);
28 | if (structs.Length == 0)
29 | Console.WriteLine("Failed to parse structure");
30 | else
31 | Console.WriteLine("Read Structure Successfully: \n******************************************************\n" + string.Join('\n', (object[])structs) + "\n*************************************");
32 | foreach (Tag tag in structs)
33 | {
34 | if (tag.Namespace != null && !Directory.Exists($"outputs\\{tag.Namespace}\\"))
35 | Directory.CreateDirectory($"outputs\\{tag.Namespace}\\");
36 |
37 | string path = $"outputs\\{((tag.Namespace != null) ? tag.Namespace + "\\" : "")}" + tag.Name + ".cs";
38 | if (File.Exists(path))
39 | File.Delete(path);
40 | using (FileStream outstream = File.OpenWrite(path))
41 | {
42 | if (ClassGenerator.Emit(outstream, tag))
43 | Console.WriteLine(tag.Name + " Written Successfully!");
44 | else
45 | Console.WriteLine("Write Failed");
46 | }
47 | }
48 | }
49 | }
50 |
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/MatterDotNet/Clusters/General/UserLabelCluster.cs:
--------------------------------------------------------------------------------
1 | // MatterDotNet Copyright (C) 2025
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 .
12 | //
13 | // WARNING: This file was auto-generated. Do not edit.
14 |
15 | using MatterDotNet.Attributes;
16 | using MatterDotNet.Protocol.Parsers;
17 | using System.Diagnostics.CodeAnalysis;
18 |
19 | namespace MatterDotNet.Clusters.General
20 | {
21 | ///
22 | /// The User Label Cluster provides a feature to tag an endpoint with zero or more labels.
23 | ///
24 | [ClusterRevision(CLUSTER_ID, 1)]
25 | public class UserLabel : ClusterBase
26 | {
27 | internal const uint CLUSTER_ID = 0x0041;
28 |
29 | ///
30 | /// The User Label Cluster provides a feature to tag an endpoint with zero or more labels.
31 | ///
32 | [SetsRequiredMembers]
33 | public UserLabel(ushort endPoint) : this(CLUSTER_ID, endPoint) { }
34 | ///
35 | [SetsRequiredMembers]
36 | protected UserLabel(uint cluster, ushort endPoint) : base(cluster, endPoint) {
37 | LabelList = new ReadWriteAttribute(cluster, endPoint, 0) {
38 | Deserialize = x => {
39 | FieldReader reader = new FieldReader((IList