1- // MatterDotNet Copyright (C) 2024
1+ // MatterDotNet Copyright (C) 2025
22//
33// This program is free software: you can redistribute it and/or modify
44// it under the terms of the GNU Affero General Public License as published by
@@ -30,9 +30,20 @@ public class AdministratorCommissioningCluster : ClusterBase
3030 /// <summary>
3131 /// Administrator Commissioning Cluster
3232 /// </summary>
33- public AdministratorCommissioningCluster ( ushort endPoint ) : base ( endPoint ) { }
33+ public AdministratorCommissioningCluster ( ushort endPoint ) : base ( CLUSTER_ID , endPoint ) { }
3434
3535 #region Enums
36+ /// <summary>
37+ /// Supported Features
38+ /// </summary>
39+ [ Flags ]
40+ public enum Feature {
41+ /// <summary>
42+ /// Node supports Basic Commissioning Method.
43+ /// </summary>
44+ Basic = 1 ,
45+ }
46+
3647 /// <summary>
3748 /// Commissioning Window Status
3849 /// </summary>
@@ -65,7 +76,7 @@ internal override void Serialize(TLVWriter writer, long structNumber = -1) {
6576 writer . WriteBytes ( 1 , PAKEPasscodeVerifier ) ;
6677 writer . WriteUShort ( 2 , Discriminator ) ;
6778 writer . WriteUInt ( 3 , Iterations ) ;
68- writer . WriteBytes ( 4 , Salt ) ;
79+ writer . WriteBytes ( 4 , Salt , 32 , 16 ) ;
6980 writer . EndContainer ( ) ;
7081 }
7182 }
@@ -93,7 +104,7 @@ public async Task<bool> OpenCommissioningWindow(SecureSession session, ushort Co
93104 Salt = Salt ,
94105 } ;
95106 InvokeResponseIB resp = await InteractionManager . ExecCommand ( session , endPoint , CLUSTER_ID , 0x00 , requestFields ) ;
96- return validateResponse ( resp ) ;
107+ return ValidateResponse ( resp ) ;
97108 }
98109
99110 /// <summary>
@@ -104,24 +115,60 @@ public async Task<bool> OpenBasicCommissioningWindow(SecureSession session, usho
104115 CommissioningTimeout = CommissioningTimeout ,
105116 } ;
106117 InvokeResponseIB resp = await InteractionManager . ExecCommand ( session , endPoint , CLUSTER_ID , 0x01 , requestFields ) ;
107- return validateResponse ( resp ) ;
118+ return ValidateResponse ( resp ) ;
108119 }
109120
110121 /// <summary>
111122 /// Revoke Commissioning
112123 /// </summary>
113124 public async Task < bool > RevokeCommissioning ( SecureSession session ) {
114125 InvokeResponseIB resp = await InteractionManager . ExecCommand ( session , endPoint , CLUSTER_ID , 0x02 ) ;
115- return validateResponse ( resp ) ;
126+ return ValidateResponse ( resp ) ;
116127 }
117128 #endregion Commands
118129
119130 #region Attributes
120- public CommissioningWindowStatusEnum WindowStatus { get ; }
131+ /// <summary>
132+ /// Features supported by this cluster
133+ /// </summary>
134+ /// <param name="session"></param>
135+ /// <returns></returns>
136+ public async Task < Feature > GetSupportedFeatures ( SecureSession session )
137+ {
138+ return ( Feature ) ( byte ) ( await GetAttribute ( session , 0xFFFC ) ) ! ;
139+ }
121140
122- public byte AdminFabricIndex { get ; }
141+ /// <summary>
142+ /// Returns true when the feature is supported by the cluster
143+ /// </summary>
144+ /// <param name="session"></param>
145+ /// <param name="feature"></param>
146+ /// <returns></returns>
147+ public async Task < bool > Supports ( SecureSession session , Feature feature )
148+ {
149+ return ( ( feature & await GetSupportedFeatures ( session ) ) != 0 ) ;
150+ }
123151
124- public ushort AdminVendorId { get ; }
152+ /// <summary>
153+ /// Get the Window Status attribute
154+ /// </summary>
155+ public async Task < CommissioningWindowStatusEnum > GetWindowStatus ( SecureSession session ) {
156+ return ( CommissioningWindowStatusEnum ) await GetEnumAttribute ( session , 0 ) ;
157+ }
158+
159+ /// <summary>
160+ /// Get the Admin Fabric Index attribute
161+ /// </summary>
162+ public async Task < byte ? > GetAdminFabricIndex ( SecureSession session ) {
163+ return ( byte ? ) ( dynamic ? ) await GetAttribute ( session , 1 , true ) ;
164+ }
165+
166+ /// <summary>
167+ /// Get the Admin Vendor Id attribute
168+ /// </summary>
169+ public async Task < ushort ? > GetAdminVendorId ( SecureSession session ) {
170+ return ( ushort ? ) ( dynamic ? ) await GetAttribute ( session , 2 , true ) ;
171+ }
125172 #endregion Attributes
126173 }
127174}
0 commit comments