@matter/protocol 0.13.0-alpha.0-20250318-c1aa38b08 → 0.13.0-alpha.0-20250323-770919c6a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ble/BtpSessionHandler.js +2 -2
- package/dist/cjs/ble/BtpSessionHandler.js.map +1 -1
- package/dist/cjs/certificate/CertificateAuthority.d.ts +1 -0
- package/dist/cjs/certificate/CertificateAuthority.d.ts.map +1 -1
- package/dist/cjs/certificate/CertificateAuthority.js.map +1 -1
- package/dist/cjs/certificate/CertificateManager.d.ts.map +1 -1
- package/dist/cjs/certificate/CertificateManager.js +21 -19
- package/dist/cjs/certificate/CertificateManager.js.map +1 -1
- package/dist/cjs/cluster/client/ClusterClient.d.ts.map +1 -1
- package/dist/cjs/cluster/client/ClusterClient.js +3 -0
- package/dist/cjs/cluster/client/ClusterClient.js.map +1 -1
- package/dist/cjs/cluster/server/AttributeServer.d.ts.map +1 -1
- package/dist/cjs/cluster/server/AttributeServer.js +5 -5
- package/dist/cjs/cluster/server/AttributeServer.js.map +1 -1
- package/dist/cjs/cluster/server/CommandServer.js +2 -2
- package/dist/cjs/cluster/server/CommandServer.js.map +1 -1
- package/dist/cjs/common/FailsafeContext.js +1 -1
- package/dist/cjs/common/FailsafeContext.js.map +1 -1
- package/dist/cjs/endpoint/EndpointStructureLogger.js +1 -1
- package/dist/cjs/endpoint/EndpointStructureLogger.js.map +1 -1
- package/dist/cjs/events/OccurrenceManager.d.ts.map +1 -1
- package/dist/cjs/events/OccurrenceManager.js +2 -2
- package/dist/cjs/events/OccurrenceManager.js.map +1 -1
- package/dist/cjs/interaction/AttributeDataDecoder.d.ts +21 -4
- package/dist/cjs/interaction/AttributeDataDecoder.d.ts.map +1 -1
- package/dist/cjs/interaction/AttributeDataDecoder.js +41 -2
- package/dist/cjs/interaction/AttributeDataDecoder.js.map +1 -1
- package/dist/cjs/interaction/AttributeDataEncoder.d.ts.map +1 -1
- package/dist/cjs/interaction/AttributeDataEncoder.js +3 -3
- package/dist/cjs/interaction/AttributeDataEncoder.js.map +1 -1
- package/dist/cjs/interaction/DecodedDataReport.d.ts +4 -2
- package/dist/cjs/interaction/DecodedDataReport.d.ts.map +1 -1
- package/dist/cjs/interaction/DecodedDataReport.js +6 -2
- package/dist/cjs/interaction/DecodedDataReport.js.map +1 -1
- package/dist/cjs/interaction/EventDataDecoder.d.ts +15 -3
- package/dist/cjs/interaction/EventDataDecoder.d.ts.map +1 -1
- package/dist/cjs/interaction/EventDataDecoder.js +39 -2
- package/dist/cjs/interaction/EventDataDecoder.js.map +1 -1
- package/dist/cjs/interaction/InteractionClient.d.ts +44 -4
- package/dist/cjs/interaction/InteractionClient.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionClient.js +71 -18
- package/dist/cjs/interaction/InteractionClient.js.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.js +7 -4
- package/dist/cjs/interaction/InteractionMessenger.js.map +1 -1
- package/dist/cjs/interaction/InteractionServer.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionServer.js +7 -7
- package/dist/cjs/interaction/InteractionServer.js.map +1 -1
- package/dist/cjs/interaction/ServerSubscription.d.ts.map +1 -1
- package/dist/cjs/interaction/ServerSubscription.js +1 -1
- package/dist/cjs/interaction/ServerSubscription.js.map +1 -1
- package/dist/cjs/mdns/MdnsScanner.js +2 -2
- package/dist/cjs/mdns/MdnsScanner.js.map +1 -1
- package/dist/cjs/peer/ControllerCommissioner.d.ts +15 -3
- package/dist/cjs/peer/ControllerCommissioner.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerCommissioner.js +17 -6
- package/dist/cjs/peer/ControllerCommissioner.js.map +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.d.ts +47 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.js +136 -136
- package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/cjs/peer/ControllerDiscovery.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerDiscovery.js +4 -4
- package/dist/cjs/peer/ControllerDiscovery.js.map +1 -1
- package/dist/cjs/peer/PeerSet.d.ts +2 -2
- package/dist/cjs/peer/PeerSet.d.ts.map +1 -1
- package/dist/cjs/peer/PeerSet.js +6 -1
- package/dist/cjs/peer/PeerSet.js.map +1 -1
- package/dist/cjs/protocol/ChannelManager.d.ts.map +1 -1
- package/dist/cjs/protocol/ChannelManager.js +11 -4
- package/dist/cjs/protocol/ChannelManager.js.map +1 -1
- package/dist/cjs/protocol/ExchangeManager.d.ts.map +1 -1
- package/dist/cjs/protocol/ExchangeManager.js +1 -2
- package/dist/cjs/protocol/ExchangeManager.js.map +1 -1
- package/dist/esm/ble/BtpSessionHandler.js +2 -2
- package/dist/esm/ble/BtpSessionHandler.js.map +1 -1
- package/dist/esm/certificate/CertificateAuthority.d.ts +1 -0
- package/dist/esm/certificate/CertificateAuthority.d.ts.map +1 -1
- package/dist/esm/certificate/CertificateAuthority.js.map +1 -1
- package/dist/esm/certificate/CertificateManager.d.ts.map +1 -1
- package/dist/esm/certificate/CertificateManager.js +22 -19
- package/dist/esm/certificate/CertificateManager.js.map +1 -1
- package/dist/esm/cluster/client/ClusterClient.d.ts.map +1 -1
- package/dist/esm/cluster/client/ClusterClient.js +3 -0
- package/dist/esm/cluster/client/ClusterClient.js.map +1 -1
- package/dist/esm/cluster/server/AttributeServer.d.ts.map +1 -1
- package/dist/esm/cluster/server/AttributeServer.js +15 -6
- package/dist/esm/cluster/server/AttributeServer.js.map +1 -1
- package/dist/esm/cluster/server/CommandServer.js +3 -3
- package/dist/esm/cluster/server/CommandServer.js.map +1 -1
- package/dist/esm/common/FailsafeContext.js +1 -1
- package/dist/esm/common/FailsafeContext.js.map +1 -1
- package/dist/esm/endpoint/EndpointStructureLogger.js +1 -1
- package/dist/esm/endpoint/EndpointStructureLogger.js.map +1 -1
- package/dist/esm/events/OccurrenceManager.d.ts.map +1 -1
- package/dist/esm/events/OccurrenceManager.js +3 -2
- package/dist/esm/events/OccurrenceManager.js.map +1 -1
- package/dist/esm/interaction/AttributeDataDecoder.d.ts +21 -4
- package/dist/esm/interaction/AttributeDataDecoder.d.ts.map +1 -1
- package/dist/esm/interaction/AttributeDataDecoder.js +41 -2
- package/dist/esm/interaction/AttributeDataDecoder.js.map +1 -1
- package/dist/esm/interaction/AttributeDataEncoder.d.ts.map +1 -1
- package/dist/esm/interaction/AttributeDataEncoder.js +4 -4
- package/dist/esm/interaction/AttributeDataEncoder.js.map +1 -1
- package/dist/esm/interaction/DecodedDataReport.d.ts +4 -2
- package/dist/esm/interaction/DecodedDataReport.d.ts.map +1 -1
- package/dist/esm/interaction/DecodedDataReport.js +12 -4
- package/dist/esm/interaction/DecodedDataReport.js.map +1 -1
- package/dist/esm/interaction/EventDataDecoder.d.ts +15 -3
- package/dist/esm/interaction/EventDataDecoder.d.ts.map +1 -1
- package/dist/esm/interaction/EventDataDecoder.js +39 -2
- package/dist/esm/interaction/EventDataDecoder.js.map +1 -1
- package/dist/esm/interaction/InteractionClient.d.ts +44 -4
- package/dist/esm/interaction/InteractionClient.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionClient.js +74 -18
- package/dist/esm/interaction/InteractionClient.js.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.js +8 -4
- package/dist/esm/interaction/InteractionMessenger.js.map +1 -1
- package/dist/esm/interaction/InteractionServer.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionServer.js +17 -8
- package/dist/esm/interaction/InteractionServer.js.map +1 -1
- package/dist/esm/interaction/ServerSubscription.d.ts.map +1 -1
- package/dist/esm/interaction/ServerSubscription.js +2 -1
- package/dist/esm/interaction/ServerSubscription.js.map +1 -1
- package/dist/esm/mdns/MdnsScanner.js +2 -2
- package/dist/esm/mdns/MdnsScanner.js.map +1 -1
- package/dist/esm/peer/ControllerCommissioner.d.ts +15 -3
- package/dist/esm/peer/ControllerCommissioner.d.ts.map +1 -1
- package/dist/esm/peer/ControllerCommissioner.js +18 -6
- package/dist/esm/peer/ControllerCommissioner.js.map +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.d.ts +47 -1
- package/dist/esm/peer/ControllerCommissioningFlow.d.ts.map +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.js +147 -137
- package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/esm/peer/ControllerDiscovery.d.ts.map +1 -1
- package/dist/esm/peer/ControllerDiscovery.js +5 -5
- package/dist/esm/peer/ControllerDiscovery.js.map +1 -1
- package/dist/esm/peer/PeerSet.d.ts +2 -2
- package/dist/esm/peer/PeerSet.d.ts.map +1 -1
- package/dist/esm/peer/PeerSet.js +7 -2
- package/dist/esm/peer/PeerSet.js.map +1 -1
- package/dist/esm/protocol/ChannelManager.d.ts.map +1 -1
- package/dist/esm/protocol/ChannelManager.js +11 -4
- package/dist/esm/protocol/ChannelManager.js.map +1 -1
- package/dist/esm/protocol/ExchangeManager.d.ts.map +1 -1
- package/dist/esm/protocol/ExchangeManager.js +2 -2
- package/dist/esm/protocol/ExchangeManager.js.map +1 -1
- package/package.json +6 -6
- package/src/ble/BtpSessionHandler.ts +2 -2
- package/src/certificate/CertificateAuthority.ts +1 -0
- package/src/certificate/CertificateManager.ts +22 -19
- package/src/cluster/client/ClusterClient.ts +3 -0
- package/src/cluster/server/AttributeServer.ts +15 -6
- package/src/cluster/server/CommandServer.ts +3 -3
- package/src/common/FailsafeContext.ts +1 -1
- package/src/endpoint/EndpointStructureLogger.ts +1 -1
- package/src/events/OccurrenceManager.ts +3 -2
- package/src/interaction/AttributeDataDecoder.ts +67 -7
- package/src/interaction/AttributeDataEncoder.ts +4 -4
- package/src/interaction/DecodedDataReport.ts +24 -5
- package/src/interaction/EventDataDecoder.ts +57 -5
- package/src/interaction/InteractionClient.ts +112 -18
- package/src/interaction/InteractionMessenger.ts +8 -4
- package/src/interaction/InteractionServer.ts +19 -9
- package/src/interaction/ServerSubscription.ts +2 -1
- package/src/mdns/MdnsScanner.ts +2 -2
- package/src/peer/ControllerCommissioner.ts +32 -7
- package/src/peer/ControllerCommissioningFlow.ts +160 -146
- package/src/peer/ControllerDiscovery.ts +5 -5
- package/src/peer/PeerSet.ts +7 -2
- package/src/protocol/ChannelManager.ts +11 -4
- package/src/protocol/ExchangeManager.ts +2 -2
|
@@ -9,7 +9,17 @@ import { GeneralCommissioning } from "#clusters/general-commissioning";
|
|
|
9
9
|
import { NetworkCommissioning } from "#clusters/network-commissioning";
|
|
10
10
|
import { OperationalCredentials } from "#clusters/operational-credentials";
|
|
11
11
|
import { TimeSynchronizationCluster } from "#clusters/time-synchronization";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
Bytes,
|
|
14
|
+
ChannelType,
|
|
15
|
+
Crypto,
|
|
16
|
+
Diagnostic,
|
|
17
|
+
Logger,
|
|
18
|
+
MatterError,
|
|
19
|
+
repackErrorAs,
|
|
20
|
+
Time,
|
|
21
|
+
UnexpectedDataError
|
|
22
|
+
} from "#general";
|
|
13
23
|
import {
|
|
14
24
|
EndpointNumber,
|
|
15
25
|
StatusResponseError
|
|
@@ -31,27 +41,27 @@ class RecoverableCommissioningError extends CommissioningError {
|
|
|
31
41
|
}
|
|
32
42
|
const DEFAULT_FAILSAFE_TIME_MS = 6e4;
|
|
33
43
|
class ControllerCommissioningFlow {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
interactionClient;
|
|
45
|
+
ca;
|
|
46
|
+
fabric;
|
|
47
|
+
transitionToCase;
|
|
48
|
+
commissioningOptions;
|
|
49
|
+
commissioningSteps = new Array();
|
|
50
|
+
commissioningStepResults = /* @__PURE__ */ new Map();
|
|
41
51
|
#clusterClients = /* @__PURE__ */ new Map();
|
|
42
52
|
#commissioningStartedTime;
|
|
43
53
|
#commissioningExpiryTime;
|
|
44
54
|
#lastFailSafeTime;
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
lastBreadcrumb = 1;
|
|
56
|
+
collectedCommissioningData = {};
|
|
47
57
|
#failSafeTimeMs = DEFAULT_FAILSAFE_TIME_MS;
|
|
48
58
|
constructor(interactionClient, ca, fabric, commissioningOptions, transitionToCase) {
|
|
49
|
-
this
|
|
50
|
-
this
|
|
51
|
-
this
|
|
52
|
-
this
|
|
53
|
-
this
|
|
54
|
-
logger.debug(`Commissioning options: ${
|
|
59
|
+
this.interactionClient = interactionClient;
|
|
60
|
+
this.ca = ca;
|
|
61
|
+
this.fabric = fabric;
|
|
62
|
+
this.transitionToCase = transitionToCase;
|
|
63
|
+
this.commissioningOptions = commissioningOptions;
|
|
64
|
+
logger.debug(`Commissioning options: ${Diagnostic.json(commissioningOptions)}`);
|
|
55
65
|
this.#initializeCommissioningSteps();
|
|
56
66
|
}
|
|
57
67
|
/**
|
|
@@ -63,7 +73,7 @@ class ControllerCommissioningFlow {
|
|
|
63
73
|
async executeCommissioning() {
|
|
64
74
|
this.#sortSteps();
|
|
65
75
|
let failSafeTimerReArmedAfterPreviousStep = false;
|
|
66
|
-
for (const step of this
|
|
76
|
+
for (const step of this.commissioningSteps) {
|
|
67
77
|
logger.info(`Executing commissioning step ${step.stepNumber}.${step.subStepNumber}: ${step.name}`);
|
|
68
78
|
try {
|
|
69
79
|
if (step.reArmFailsafe && !failSafeTimerReArmedAfterPreviousStep) {
|
|
@@ -128,7 +138,7 @@ class ControllerCommissioningFlow {
|
|
|
128
138
|
logger.debug(
|
|
129
139
|
`Creating new cluster client for cluster ${cluster.name} (endpoint ${endpointId}, isFeatureSpecific ${isFeatureSpecific})`
|
|
130
140
|
);
|
|
131
|
-
const client = ClusterClient(cluster, endpointId, this
|
|
141
|
+
const client = ClusterClient(cluster, endpointId, this.interactionClient);
|
|
132
142
|
this.#clusterClients.set(cluster.id, client);
|
|
133
143
|
return client;
|
|
134
144
|
}
|
|
@@ -137,59 +147,59 @@ class ControllerCommissioningFlow {
|
|
|
137
147
|
* @see {@link MatterSpecification.v13.Core} § 5.5
|
|
138
148
|
*/
|
|
139
149
|
#initializeCommissioningSteps() {
|
|
140
|
-
this
|
|
150
|
+
this.commissioningSteps.push({
|
|
141
151
|
stepNumber: 0,
|
|
142
152
|
// Preparation
|
|
143
153
|
subStepNumber: 1,
|
|
144
154
|
name: "GetInitialData",
|
|
145
155
|
stepLogic: () => this.#getInitialData()
|
|
146
156
|
});
|
|
147
|
-
this
|
|
157
|
+
this.commissioningSteps.push({
|
|
148
158
|
stepNumber: 7,
|
|
149
159
|
subStepNumber: 1,
|
|
150
160
|
name: "GeneralCommissioning.ArmFailsafe",
|
|
151
161
|
stepLogic: () => this.#armFailsafe()
|
|
152
162
|
});
|
|
153
|
-
this
|
|
163
|
+
this.commissioningSteps.push({
|
|
154
164
|
stepNumber: 8,
|
|
155
165
|
subStepNumber: 1,
|
|
156
166
|
name: "GeneralCommissioning.ConfigureRegulatoryInformation",
|
|
157
167
|
stepLogic: () => this.#configureRegulatoryInformation()
|
|
158
168
|
});
|
|
159
|
-
this
|
|
169
|
+
this.commissioningSteps.push({
|
|
160
170
|
stepNumber: 8,
|
|
161
171
|
subStepNumber: 2,
|
|
162
172
|
name: "TimeSynchronization.SynchronizeTime",
|
|
163
173
|
stepLogic: () => this.#synchronizeTime()
|
|
164
174
|
});
|
|
165
|
-
this
|
|
175
|
+
this.commissioningSteps.push({
|
|
166
176
|
stepNumber: 10,
|
|
167
177
|
subStepNumber: 1,
|
|
168
178
|
name: "OperationalCredentials.DeviceAttestation",
|
|
169
179
|
stepLogic: () => this.#deviceAttestation()
|
|
170
180
|
});
|
|
171
|
-
this
|
|
181
|
+
this.commissioningSteps.push({
|
|
172
182
|
stepNumber: 11,
|
|
173
183
|
// includes 11-13
|
|
174
184
|
subStepNumber: 1,
|
|
175
185
|
name: "OperationalCredentials.Certificates",
|
|
176
186
|
stepLogic: () => this.#certificates()
|
|
177
187
|
});
|
|
178
|
-
this
|
|
188
|
+
this.commissioningSteps.push({
|
|
179
189
|
stepNumber: 15,
|
|
180
190
|
subStepNumber: 1,
|
|
181
191
|
name: "AccessControl",
|
|
182
192
|
stepLogic: () => this.#configureAccessControlLists()
|
|
183
193
|
});
|
|
184
|
-
if (this
|
|
185
|
-
this
|
|
194
|
+
if (this.interactionClient.channelType === ChannelType.BLE) {
|
|
195
|
+
this.commissioningSteps.push({
|
|
186
196
|
stepNumber: 16,
|
|
187
197
|
subStepNumber: 1,
|
|
188
198
|
name: "NetworkCommissioning.Validate",
|
|
189
199
|
stepLogic: () => this.#validateNetwork()
|
|
190
200
|
});
|
|
191
|
-
if (this
|
|
192
|
-
this
|
|
201
|
+
if (this.commissioningOptions.wifiNetwork !== void 0) {
|
|
202
|
+
this.commissioningSteps.push({
|
|
193
203
|
stepNumber: 16,
|
|
194
204
|
// includes step 17
|
|
195
205
|
subStepNumber: 2,
|
|
@@ -198,8 +208,8 @@ class ControllerCommissioningFlow {
|
|
|
198
208
|
stepLogic: () => this.#configureNetworkWifi()
|
|
199
209
|
});
|
|
200
210
|
}
|
|
201
|
-
if (this
|
|
202
|
-
this
|
|
211
|
+
if (this.commissioningOptions.threadNetwork !== void 0) {
|
|
212
|
+
this.commissioningSteps.push({
|
|
203
213
|
stepNumber: 16,
|
|
204
214
|
// includes step 17
|
|
205
215
|
subStepNumber: 3,
|
|
@@ -210,10 +220,10 @@ class ControllerCommissioningFlow {
|
|
|
210
220
|
}
|
|
211
221
|
} else {
|
|
212
222
|
logger.info(
|
|
213
|
-
`Skipping NetworkCommissioning steps because the device is already on IP network (${this
|
|
223
|
+
`Skipping NetworkCommissioning steps because the device is already on IP network (${this.interactionClient.channelType})`
|
|
214
224
|
);
|
|
215
225
|
}
|
|
216
|
-
this
|
|
226
|
+
this.commissioningSteps.push({
|
|
217
227
|
stepNumber: 18,
|
|
218
228
|
// includes step 19 (CASE connection)
|
|
219
229
|
subStepNumber: 1,
|
|
@@ -221,13 +231,13 @@ class ControllerCommissioningFlow {
|
|
|
221
231
|
reArmFailsafe: true,
|
|
222
232
|
stepLogic: () => this.#reconnectWithDevice()
|
|
223
233
|
});
|
|
224
|
-
this
|
|
234
|
+
this.commissioningSteps.push({
|
|
225
235
|
stepNumber: 20,
|
|
226
236
|
subStepNumber: 1,
|
|
227
237
|
name: "GeneralCommissioning.Complete",
|
|
228
238
|
stepLogic: () => this.#completeCommissioning()
|
|
229
239
|
});
|
|
230
|
-
this
|
|
240
|
+
this.commissioningSteps.push({
|
|
231
241
|
stepNumber: 99,
|
|
232
242
|
// Should be allowed in Step 13, but Tasmota is not supporting this
|
|
233
243
|
subStepNumber: 1,
|
|
@@ -236,16 +246,16 @@ class ControllerCommissioningFlow {
|
|
|
236
246
|
});
|
|
237
247
|
}
|
|
238
248
|
#sortSteps() {
|
|
239
|
-
this
|
|
249
|
+
this.commissioningSteps.sort((a, b) => {
|
|
240
250
|
if (a.stepNumber !== b.stepNumber) return a.stepNumber - b.stepNumber;
|
|
241
251
|
return a.subStepNumber - b.subStepNumber;
|
|
242
252
|
});
|
|
243
253
|
}
|
|
244
254
|
#setCommissioningStepResult(step, result) {
|
|
245
|
-
this
|
|
255
|
+
this.commissioningStepResults.set(`${step.stepNumber}-${step.subStepNumber}`, result);
|
|
246
256
|
}
|
|
247
257
|
getCommissioningStepResult(stepNumber, subStepNumber) {
|
|
248
|
-
return this
|
|
258
|
+
return this.commissioningStepResults.get(`${stepNumber}-${subStepNumber}`);
|
|
249
259
|
}
|
|
250
260
|
/** Helper method to check for errorCode/debugTest responses and throw error on failure */
|
|
251
261
|
#ensureOperationalCredentialsSuccess(context, { statusCode, debugText, fabricIndex }) {
|
|
@@ -275,9 +285,9 @@ class ControllerCommissioningFlow {
|
|
|
275
285
|
*/
|
|
276
286
|
async #getInitialData() {
|
|
277
287
|
const descriptorClient = this.#getClusterClient(Descriptor.Cluster);
|
|
278
|
-
this
|
|
279
|
-
this
|
|
280
|
-
const networkData = await this
|
|
288
|
+
this.collectedCommissioningData.rootPartsList = await descriptorClient.getPartsListAttribute();
|
|
289
|
+
this.collectedCommissioningData.rootServerList = await descriptorClient.getServerListAttribute();
|
|
290
|
+
const networkData = await this.interactionClient.getMultipleAttributes({
|
|
281
291
|
attributes: [
|
|
282
292
|
{
|
|
283
293
|
clusterId: NetworkCommissioning.Complete.id,
|
|
@@ -301,17 +311,17 @@ class ControllerCommissioningFlow {
|
|
|
301
311
|
networkStatus.push({ endpointId, value });
|
|
302
312
|
}
|
|
303
313
|
}
|
|
304
|
-
this
|
|
305
|
-
this
|
|
314
|
+
this.collectedCommissioningData.networkFeatures = networkFeatures;
|
|
315
|
+
this.collectedCommissioningData.networkStatus = networkStatus;
|
|
306
316
|
const basicInfoClient = this.#getClusterClient(BasicInformation.Cluster);
|
|
307
|
-
this
|
|
308
|
-
this
|
|
309
|
-
this
|
|
317
|
+
this.collectedCommissioningData.vendorId = await basicInfoClient.getVendorIdAttribute();
|
|
318
|
+
this.collectedCommissioningData.productId = await basicInfoClient.getProductIdAttribute();
|
|
319
|
+
this.collectedCommissioningData.productName = await basicInfoClient.getProductNameAttribute();
|
|
310
320
|
const generalCommissioningClient = this.#getClusterClient(GeneralCommissioning.Cluster);
|
|
311
|
-
this
|
|
321
|
+
this.collectedCommissioningData.supportsConcurrentConnection = await generalCommissioningClient.getSupportsConcurrentConnectionAttribute();
|
|
312
322
|
return {
|
|
313
323
|
code: 0 /* Success */,
|
|
314
|
-
breadcrumb: this
|
|
324
|
+
breadcrumb: this.lastBreadcrumb
|
|
315
325
|
};
|
|
316
326
|
}
|
|
317
327
|
/**
|
|
@@ -325,9 +335,9 @@ class ControllerCommissioningFlow {
|
|
|
325
335
|
*/
|
|
326
336
|
async #armFailsafe() {
|
|
327
337
|
const client = this.#getClusterClient(GeneralCommissioning.Cluster);
|
|
328
|
-
if (this
|
|
338
|
+
if (this.collectedCommissioningData.basicCommissioningInfo === void 0) {
|
|
329
339
|
const basicCommissioningInfo = await client.getBasicCommissioningInfoAttribute();
|
|
330
|
-
this
|
|
340
|
+
this.collectedCommissioningData.basicCommissioningInfo = basicCommissioningInfo;
|
|
331
341
|
this.#failSafeTimeMs = basicCommissioningInfo.failSafeExpiryLengthSeconds * 1e3;
|
|
332
342
|
this.#commissioningStartedTime = Time.nowMs();
|
|
333
343
|
this.#commissioningExpiryTime = this.#commissioningStartedTime + basicCommissioningInfo.maxCumulativeFailsafeSeconds * 1e3;
|
|
@@ -335,14 +345,14 @@ class ControllerCommissioningFlow {
|
|
|
335
345
|
this.#ensureGeneralCommissioningSuccess(
|
|
336
346
|
"armFailSafe",
|
|
337
347
|
await client.armFailSafe({
|
|
338
|
-
breadcrumb: this
|
|
339
|
-
expiryLengthSeconds: this
|
|
348
|
+
breadcrumb: this.lastBreadcrumb,
|
|
349
|
+
expiryLengthSeconds: this.collectedCommissioningData.basicCommissioningInfo?.failSafeExpiryLengthSeconds
|
|
340
350
|
})
|
|
341
351
|
);
|
|
342
352
|
this.#lastFailSafeTime = Time.nowMs();
|
|
343
353
|
return {
|
|
344
354
|
code: 0 /* Success */,
|
|
345
|
-
breadcrumb: this
|
|
355
|
+
breadcrumb: this.lastBreadcrumb
|
|
346
356
|
};
|
|
347
357
|
}
|
|
348
358
|
async #resetFailsafeTimer() {
|
|
@@ -350,7 +360,7 @@ class ControllerCommissioningFlow {
|
|
|
350
360
|
try {
|
|
351
361
|
const client = this.#getClusterClient(GeneralCommissioning.Cluster);
|
|
352
362
|
await client.armFailSafe({
|
|
353
|
-
breadcrumb: this
|
|
363
|
+
breadcrumb: this.lastBreadcrumb,
|
|
354
364
|
expiryLengthSeconds: 0
|
|
355
365
|
});
|
|
356
366
|
this.#lastFailSafeTime = void 0;
|
|
@@ -366,26 +376,26 @@ class ControllerCommissioningFlow {
|
|
|
366
376
|
* Commissionee using the SetRegulatoryConfig command.
|
|
367
377
|
*/
|
|
368
378
|
async #configureRegulatoryInformation() {
|
|
369
|
-
if (this
|
|
379
|
+
if (this.collectedCommissioningData.networkFeatures === void 0) {
|
|
370
380
|
throw new CommissioningError("No network features collected. This should never happen.");
|
|
371
381
|
}
|
|
372
|
-
const hasRadioNetwork = this
|
|
382
|
+
const hasRadioNetwork = this.collectedCommissioningData.networkFeatures.some(
|
|
373
383
|
({ value: { wiFiNetworkInterface, threadNetworkInterface } }) => wiFiNetworkInterface || threadNetworkInterface
|
|
374
384
|
);
|
|
375
385
|
if (hasRadioNetwork) {
|
|
376
386
|
const client = this.#getClusterClient(GeneralCommissioning.Cluster);
|
|
377
387
|
let locationCapability = await client.getLocationCapabilityAttribute();
|
|
378
388
|
if (locationCapability === GeneralCommissioning.RegulatoryLocationType.IndoorOutdoor) {
|
|
379
|
-
locationCapability = this
|
|
389
|
+
locationCapability = this.commissioningOptions.regulatoryLocation;
|
|
380
390
|
} else {
|
|
381
391
|
logger.debug(
|
|
382
392
|
`Device does not support a configurable regulatory location type. Location is set to "${locationCapability === GeneralCommissioning.RegulatoryLocationType.Indoor ? "Indoor" : "Outdoor"}"`
|
|
383
393
|
);
|
|
384
394
|
}
|
|
385
|
-
let countryCode = this
|
|
395
|
+
let countryCode = this.commissioningOptions.regulatoryCountryCode;
|
|
386
396
|
const regulatoryResult = await client.setRegulatoryConfig(
|
|
387
397
|
{
|
|
388
|
-
breadcrumb: this
|
|
398
|
+
breadcrumb: this.lastBreadcrumb++,
|
|
389
399
|
newRegulatoryConfig: locationCapability,
|
|
390
400
|
countryCode
|
|
391
401
|
},
|
|
@@ -400,7 +410,7 @@ class ControllerCommissioningFlow {
|
|
|
400
410
|
"setRegulatoryConfig",
|
|
401
411
|
await client.setRegulatoryConfig(
|
|
402
412
|
{
|
|
403
|
-
breadcrumb: this
|
|
413
|
+
breadcrumb: this.lastBreadcrumb,
|
|
404
414
|
newRegulatoryConfig: locationCapability,
|
|
405
415
|
countryCode
|
|
406
416
|
},
|
|
@@ -412,12 +422,12 @@ class ControllerCommissioningFlow {
|
|
|
412
422
|
}
|
|
413
423
|
return {
|
|
414
424
|
code: 0 /* Success */,
|
|
415
|
-
breadcrumb: this
|
|
425
|
+
breadcrumb: this.lastBreadcrumb
|
|
416
426
|
};
|
|
417
427
|
}
|
|
418
428
|
return {
|
|
419
429
|
code: 2 /* Skipped */,
|
|
420
|
-
breadcrumb: this
|
|
430
|
+
breadcrumb: this.lastBreadcrumb
|
|
421
431
|
};
|
|
422
432
|
}
|
|
423
433
|
/**
|
|
@@ -430,14 +440,14 @@ class ControllerCommissioningFlow {
|
|
|
430
440
|
* ▪ The Commissioner SHOULD set a Default NTP server using the SetDefaultNTP command if the NTPClient Feature is supported and the DefaultNTP attribute is null. If the current value is non-null, Commissioners MAY opt to overwrite the current value.
|
|
431
441
|
*/
|
|
432
442
|
async #synchronizeTime() {
|
|
433
|
-
if (this
|
|
443
|
+
if (this.collectedCommissioningData.rootServerList !== void 0 && this.collectedCommissioningData.rootServerList.find(
|
|
434
444
|
(clusterId) => clusterId === TimeSynchronizationCluster.id
|
|
435
445
|
)) {
|
|
436
446
|
logger.debug("TimeSynchronization cluster is supported");
|
|
437
447
|
}
|
|
438
448
|
return {
|
|
439
449
|
code: 2 /* Skipped */,
|
|
440
|
-
breadcrumb: this
|
|
450
|
+
breadcrumb: this.lastBreadcrumb
|
|
441
451
|
};
|
|
442
452
|
}
|
|
443
453
|
/**
|
|
@@ -470,7 +480,7 @@ class ControllerCommissioningFlow {
|
|
|
470
480
|
}
|
|
471
481
|
return {
|
|
472
482
|
code: 0 /* Success */,
|
|
473
|
-
breadcrumb: this
|
|
483
|
+
breadcrumb: this.lastBreadcrumb
|
|
474
484
|
};
|
|
475
485
|
}
|
|
476
486
|
/**
|
|
@@ -502,31 +512,31 @@ class ControllerCommissioningFlow {
|
|
|
502
512
|
const operationalPublicKey = CertificateManager.getPublicKeyFromCsr(certSigningRequest);
|
|
503
513
|
await operationalCredentialsClusterClient.addTrustedRootCertificate(
|
|
504
514
|
{
|
|
505
|
-
rootCaCertificate: this
|
|
515
|
+
rootCaCertificate: this.ca.rootCert
|
|
506
516
|
},
|
|
507
517
|
{ useExtendedFailSafeMessageResponseTimeout: true }
|
|
508
518
|
);
|
|
509
|
-
const peerOperationalCert = this
|
|
519
|
+
const peerOperationalCert = this.ca.generateNoc(
|
|
510
520
|
operationalPublicKey,
|
|
511
|
-
this
|
|
512
|
-
this
|
|
521
|
+
this.fabric.fabricId,
|
|
522
|
+
this.interactionClient.address.nodeId
|
|
513
523
|
);
|
|
514
524
|
const addNocResponse = await operationalCredentialsClusterClient.addNoc(
|
|
515
525
|
{
|
|
516
526
|
nocValue: peerOperationalCert,
|
|
517
527
|
icacValue: new Uint8Array(0),
|
|
518
|
-
ipkValue: this
|
|
519
|
-
adminVendorId: this
|
|
520
|
-
caseAdminSubject: this
|
|
528
|
+
ipkValue: this.fabric.identityProtectionKey,
|
|
529
|
+
adminVendorId: this.fabric.rootVendorId,
|
|
530
|
+
caseAdminSubject: this.fabric.rootNodeId
|
|
521
531
|
},
|
|
522
532
|
{ useExtendedFailSafeMessageResponseTimeout: true }
|
|
523
533
|
);
|
|
524
534
|
this.#ensureOperationalCredentialsSuccess("addNoc", addNocResponse);
|
|
525
535
|
const { fabricIndex } = addNocResponse;
|
|
526
|
-
this
|
|
536
|
+
this.collectedCommissioningData.fabricIndex = fabricIndex;
|
|
527
537
|
return {
|
|
528
538
|
code: 0 /* Success */,
|
|
529
|
-
breadcrumb: this
|
|
539
|
+
breadcrumb: this.lastBreadcrumb
|
|
530
540
|
};
|
|
531
541
|
}
|
|
532
542
|
/**
|
|
@@ -537,12 +547,12 @@ class ControllerCommissioningFlow {
|
|
|
537
547
|
* the commissioning process.
|
|
538
548
|
*/
|
|
539
549
|
async #updateFabricLabel() {
|
|
540
|
-
const { fabricIndex } = this
|
|
550
|
+
const { fabricIndex } = this.collectedCommissioningData;
|
|
541
551
|
if (fabricIndex === void 0) {
|
|
542
552
|
logger.error("No fabric index available after addNoc. This should never happen.");
|
|
543
553
|
return {
|
|
544
554
|
code: 1 /* Failure */,
|
|
545
|
-
breadcrumb: this
|
|
555
|
+
breadcrumb: this.lastBreadcrumb
|
|
546
556
|
};
|
|
547
557
|
}
|
|
548
558
|
const operationalCredentialCluster = this.#getClusterClient(OperationalCredentials.Cluster);
|
|
@@ -550,7 +560,7 @@ class ControllerCommissioningFlow {
|
|
|
550
560
|
this.#ensureOperationalCredentialsSuccess(
|
|
551
561
|
"updateFabricLabel",
|
|
552
562
|
await operationalCredentialCluster.updateFabricLabel({
|
|
553
|
-
label: this
|
|
563
|
+
label: this.fabric.label,
|
|
554
564
|
fabricIndex
|
|
555
565
|
})
|
|
556
566
|
);
|
|
@@ -559,7 +569,7 @@ class ControllerCommissioningFlow {
|
|
|
559
569
|
}
|
|
560
570
|
return {
|
|
561
571
|
code: 0 /* Success */,
|
|
562
|
-
breadcrumb: this
|
|
572
|
+
breadcrumb: this.lastBreadcrumb
|
|
563
573
|
};
|
|
564
574
|
}
|
|
565
575
|
/**
|
|
@@ -572,7 +582,7 @@ class ControllerCommissioningFlow {
|
|
|
572
582
|
async #configureAccessControlLists() {
|
|
573
583
|
return {
|
|
574
584
|
code: 2 /* Skipped */,
|
|
575
|
-
breadcrumb: this
|
|
585
|
+
breadcrumb: this.lastBreadcrumb
|
|
576
586
|
};
|
|
577
587
|
}
|
|
578
588
|
/**
|
|
@@ -589,14 +599,14 @@ class ControllerCommissioningFlow {
|
|
|
589
599
|
* operational network.
|
|
590
600
|
*/
|
|
591
601
|
async #validateNetwork() {
|
|
592
|
-
if (this
|
|
602
|
+
if (this.collectedCommissioningData.networkFeatures === void 0 || this.collectedCommissioningData.networkStatus === void 0) {
|
|
593
603
|
throw new CommissioningError("No network features or status collected. This should never happen.");
|
|
594
604
|
}
|
|
595
|
-
if (this
|
|
596
|
-
const anyEthernetInterface = this
|
|
605
|
+
if ((this.commissioningOptions.wifiNetwork === void 0 || !this.commissioningOptions.wifiNetwork.wifiSsid || !this.commissioningOptions.wifiNetwork.wifiCredentials) && (this.commissioningOptions.threadNetwork === void 0 || !this.commissioningOptions.threadNetwork.networkName || !this.commissioningOptions.threadNetwork.operationalDataset)) {
|
|
606
|
+
const anyEthernetInterface = this.collectedCommissioningData.networkFeatures.length === 0 || this.collectedCommissioningData.networkFeatures.some(
|
|
597
607
|
({ value: { ethernetNetworkInterface } }) => ethernetNetworkInterface === true
|
|
598
608
|
);
|
|
599
|
-
const anyInterfaceConnected = this
|
|
609
|
+
const anyInterfaceConnected = this.collectedCommissioningData.networkStatus.length === 0 || this.collectedCommissioningData.networkStatus.some(
|
|
600
610
|
({ value }) => value.some(({ connected }) => connected)
|
|
601
611
|
);
|
|
602
612
|
if (!anyEthernetInterface && !anyInterfaceConnected) {
|
|
@@ -607,40 +617,40 @@ class ControllerCommissioningFlow {
|
|
|
607
617
|
}
|
|
608
618
|
return {
|
|
609
619
|
code: 0 /* Success */,
|
|
610
|
-
breadcrumb: this
|
|
620
|
+
breadcrumb: this.lastBreadcrumb
|
|
611
621
|
};
|
|
612
622
|
}
|
|
613
623
|
async #configureNetworkWifi() {
|
|
614
|
-
if (this
|
|
624
|
+
if (this.commissioningOptions.wifiNetwork === void 0) {
|
|
615
625
|
logger.debug("WiFi network is not configured");
|
|
616
626
|
return {
|
|
617
627
|
code: 2 /* Skipped */,
|
|
618
|
-
breadcrumb: this
|
|
628
|
+
breadcrumb: this.lastBreadcrumb
|
|
619
629
|
};
|
|
620
630
|
}
|
|
621
|
-
if (this
|
|
622
|
-
const rootNetworkFeatures = this
|
|
631
|
+
if (this.collectedCommissioningData.networkFeatures !== void 0 && this.collectedCommissioningData.networkStatus !== void 0) {
|
|
632
|
+
const rootNetworkFeatures = this.collectedCommissioningData.networkFeatures.find(
|
|
623
633
|
({ endpointId }) => endpointId === 0
|
|
624
634
|
)?.value;
|
|
625
|
-
const rootNetworkStatus = this
|
|
635
|
+
const rootNetworkStatus = this.collectedCommissioningData.networkStatus.find(
|
|
626
636
|
({ endpointId }) => endpointId === 0
|
|
627
637
|
)?.value;
|
|
628
638
|
logger.debug(
|
|
629
|
-
`Root Networks found: ${
|
|
639
|
+
`Root Networks found: ${Diagnostic.json(rootNetworkFeatures)} - ${Diagnostic.json(rootNetworkStatus)}`
|
|
630
640
|
);
|
|
631
641
|
if (rootNetworkFeatures?.wiFiNetworkInterface !== true) {
|
|
632
642
|
logger.debug("Commissionee does not support any WiFi network interface");
|
|
633
643
|
return {
|
|
634
644
|
code: 2 /* Skipped */,
|
|
635
|
-
breadcrumb: this
|
|
645
|
+
breadcrumb: this.lastBreadcrumb
|
|
636
646
|
};
|
|
637
647
|
}
|
|
638
648
|
if (rootNetworkStatus !== void 0 && rootNetworkStatus.length > 0 && rootNetworkStatus[0].connected) {
|
|
639
649
|
logger.debug("Commissionee is already connected to the WiFi network");
|
|
640
|
-
this
|
|
650
|
+
this.collectedCommissioningData.successfullyConnectedToNetwork = true;
|
|
641
651
|
return {
|
|
642
652
|
code: 2 /* Skipped */,
|
|
643
|
-
breadcrumb: this
|
|
653
|
+
breadcrumb: this.lastBreadcrumb
|
|
644
654
|
};
|
|
645
655
|
}
|
|
646
656
|
}
|
|
@@ -650,12 +660,12 @@ class ControllerCommissioningFlow {
|
|
|
650
660
|
EndpointNumber(0),
|
|
651
661
|
true
|
|
652
662
|
);
|
|
653
|
-
const ssid = Bytes.fromString(this
|
|
654
|
-
const credentials = Bytes.fromString(this
|
|
663
|
+
const ssid = Bytes.fromString(this.commissioningOptions.wifiNetwork.wifiSsid);
|
|
664
|
+
const credentials = Bytes.fromString(this.commissioningOptions.wifiNetwork.wifiCredentials);
|
|
655
665
|
const { networkingStatus, wiFiScanResults, debugText } = await networkCommissioningClusterClient.scanNetworks(
|
|
656
666
|
{
|
|
657
667
|
ssid,
|
|
658
|
-
breadcrumb: this
|
|
668
|
+
breadcrumb: this.lastBreadcrumb++
|
|
659
669
|
},
|
|
660
670
|
{ useExtendedFailSafeMessageResponseTimeout: true }
|
|
661
671
|
);
|
|
@@ -664,7 +674,7 @@ class ControllerCommissioningFlow {
|
|
|
664
674
|
}
|
|
665
675
|
if (wiFiScanResults === void 0 || wiFiScanResults.length === 0) {
|
|
666
676
|
throw new CommissioningError(
|
|
667
|
-
`Commissionee did not return any WiFi networks for the requested SSID ${this
|
|
677
|
+
`Commissionee did not return any WiFi networks for the requested SSID ${this.commissioningOptions.wifiNetwork.wifiSsid}`
|
|
668
678
|
);
|
|
669
679
|
}
|
|
670
680
|
const {
|
|
@@ -675,7 +685,7 @@ class ControllerCommissioningFlow {
|
|
|
675
685
|
{
|
|
676
686
|
ssid,
|
|
677
687
|
credentials,
|
|
678
|
-
breadcrumb: this
|
|
688
|
+
breadcrumb: this.lastBreadcrumb++
|
|
679
689
|
},
|
|
680
690
|
{ useExtendedFailSafeMessageResponseTimeout: true }
|
|
681
691
|
);
|
|
@@ -686,7 +696,7 @@ class ControllerCommissioningFlow {
|
|
|
686
696
|
throw new CommissioningError(`Commissionee did not return network index`);
|
|
687
697
|
}
|
|
688
698
|
logger.debug(
|
|
689
|
-
`Commissionee added WiFi network ${this
|
|
699
|
+
`Commissionee added WiFi network ${this.commissioningOptions.wifiNetwork.wifiSsid} with network index ${networkIndex}`
|
|
690
700
|
);
|
|
691
701
|
const updatedNetworks = await networkCommissioningClusterClient.getNetworksAttribute();
|
|
692
702
|
if (updatedNetworks[networkIndex] === void 0) {
|
|
@@ -694,71 +704,71 @@ class ControllerCommissioningFlow {
|
|
|
694
704
|
}
|
|
695
705
|
const { networkId, connected } = updatedNetworks[networkIndex];
|
|
696
706
|
if (connected) {
|
|
697
|
-
this
|
|
707
|
+
this.collectedCommissioningData.successfullyConnectedToNetwork = true;
|
|
698
708
|
logger.debug(
|
|
699
|
-
`Commissionee is already connected to WiFi network ${this
|
|
709
|
+
`Commissionee is already connected to WiFi network ${this.commissioningOptions.wifiNetwork.wifiSsid} (networkId ${Bytes.toHex(networkId)})`
|
|
700
710
|
);
|
|
701
711
|
return {
|
|
702
712
|
code: 0 /* Success */,
|
|
703
|
-
breadcrumb: this
|
|
713
|
+
breadcrumb: this.lastBreadcrumb
|
|
704
714
|
};
|
|
705
715
|
}
|
|
706
716
|
const connectResult = await networkCommissioningClusterClient.connectNetwork(
|
|
707
717
|
{
|
|
708
718
|
networkId,
|
|
709
|
-
breadcrumb: this
|
|
719
|
+
breadcrumb: this.lastBreadcrumb++
|
|
710
720
|
},
|
|
711
721
|
{ useExtendedFailSafeMessageResponseTimeout: true }
|
|
712
722
|
);
|
|
713
723
|
if (connectResult.networkingStatus !== NetworkCommissioning.NetworkCommissioningStatus.Success) {
|
|
714
724
|
throw new CommissioningError(`Commissionee failed to connect to WiFi network: ${connectResult.debugText}`);
|
|
715
725
|
}
|
|
716
|
-
this
|
|
726
|
+
this.collectedCommissioningData.successfullyConnectedToNetwork = true;
|
|
717
727
|
logger.debug(
|
|
718
|
-
`Commissionee successfully connected to WiFi network ${this
|
|
728
|
+
`Commissionee successfully connected to WiFi network ${this.commissioningOptions.wifiNetwork.wifiSsid} (networkId ${Bytes.toHex(networkId)})`
|
|
719
729
|
);
|
|
720
730
|
return {
|
|
721
731
|
code: 0 /* Success */,
|
|
722
|
-
breadcrumb: this
|
|
732
|
+
breadcrumb: this.lastBreadcrumb
|
|
723
733
|
};
|
|
724
734
|
}
|
|
725
735
|
async #configureNetworkThread() {
|
|
726
|
-
if (this
|
|
727
|
-
logger.
|
|
736
|
+
if (this.collectedCommissioningData.successfullyConnectedToNetwork) {
|
|
737
|
+
logger.info("Node is already connected to a network. Skipping Thread configuration.");
|
|
728
738
|
return {
|
|
729
739
|
code: 2 /* Skipped */,
|
|
730
|
-
breadcrumb: this
|
|
740
|
+
breadcrumb: this.lastBreadcrumb
|
|
731
741
|
};
|
|
732
742
|
}
|
|
733
|
-
if (this
|
|
743
|
+
if (this.commissioningOptions.threadNetwork === void 0) {
|
|
734
744
|
logger.debug("Thread network is not configured");
|
|
735
745
|
return {
|
|
736
746
|
code: 2 /* Skipped */,
|
|
737
|
-
breadcrumb: this
|
|
747
|
+
breadcrumb: this.lastBreadcrumb
|
|
738
748
|
};
|
|
739
749
|
}
|
|
740
|
-
if (this
|
|
741
|
-
const rootNetworkFeatures = this
|
|
750
|
+
if (this.collectedCommissioningData.networkFeatures !== void 0 && this.collectedCommissioningData.networkStatus !== void 0) {
|
|
751
|
+
const rootNetworkFeatures = this.collectedCommissioningData.networkFeatures.find(
|
|
742
752
|
({ endpointId }) => endpointId === 0
|
|
743
753
|
)?.value;
|
|
744
|
-
const rootNetworkStatus = this
|
|
754
|
+
const rootNetworkStatus = this.collectedCommissioningData.networkStatus.find(
|
|
745
755
|
({ endpointId }) => endpointId === 0
|
|
746
756
|
)?.value;
|
|
747
757
|
logger.debug(
|
|
748
|
-
`Root Networks found: ${
|
|
758
|
+
`Root Networks found: ${Diagnostic.json(rootNetworkFeatures)} - ${Diagnostic.json(rootNetworkStatus)}`
|
|
749
759
|
);
|
|
750
760
|
if (rootNetworkFeatures?.threadNetworkInterface !== true) {
|
|
751
761
|
logger.debug("Commissionee does not support any Thread network interface");
|
|
752
762
|
return {
|
|
753
763
|
code: 2 /* Skipped */,
|
|
754
|
-
breadcrumb: this
|
|
764
|
+
breadcrumb: this.lastBreadcrumb
|
|
755
765
|
};
|
|
756
766
|
}
|
|
757
767
|
if (rootNetworkStatus !== void 0 && rootNetworkStatus.length > 0 && rootNetworkStatus[0].connected) {
|
|
758
768
|
logger.debug("Commissionee is already connected to the Thread network");
|
|
759
769
|
return {
|
|
760
770
|
code: 2 /* Skipped */,
|
|
761
|
-
breadcrumb: this
|
|
771
|
+
breadcrumb: this.lastBreadcrumb
|
|
762
772
|
};
|
|
763
773
|
}
|
|
764
774
|
}
|
|
@@ -769,7 +779,7 @@ class ControllerCommissioningFlow {
|
|
|
769
779
|
true
|
|
770
780
|
);
|
|
771
781
|
const { networkingStatus, threadScanResults, debugText } = await networkCommissioningClusterClient.scanNetworks(
|
|
772
|
-
{ breadcrumb: this
|
|
782
|
+
{ breadcrumb: this.lastBreadcrumb++ },
|
|
773
783
|
{ useExtendedFailSafeMessageResponseTimeout: true }
|
|
774
784
|
);
|
|
775
785
|
if (networkingStatus !== NetworkCommissioning.NetworkCommissioningStatus.Success) {
|
|
@@ -777,19 +787,19 @@ class ControllerCommissioningFlow {
|
|
|
777
787
|
}
|
|
778
788
|
if (threadScanResults === void 0 || threadScanResults.length === 0) {
|
|
779
789
|
throw new CommissioningError(
|
|
780
|
-
`Commissionee did not return any Thread networks for the requested Network ${this
|
|
790
|
+
`Commissionee did not return any Thread networks for the requested Network ${this.commissioningOptions.threadNetwork.networkName}`
|
|
781
791
|
);
|
|
782
792
|
}
|
|
783
793
|
const wantedNetworkFound = threadScanResults.find(
|
|
784
|
-
({ networkName }) => networkName === this
|
|
794
|
+
({ networkName }) => networkName === this.commissioningOptions.threadNetwork?.networkName
|
|
785
795
|
);
|
|
786
796
|
if (wantedNetworkFound === void 0) {
|
|
787
797
|
throw new CommissioningError(
|
|
788
|
-
`Commissionee did not return the requested Network ${this
|
|
798
|
+
`Commissionee did not return the requested Network ${this.commissioningOptions.threadNetwork.networkName}: ${Diagnostic.json(threadScanResults)}`
|
|
789
799
|
);
|
|
790
800
|
}
|
|
791
801
|
logger.debug(
|
|
792
|
-
`Commissionee found wanted Thread network ${this
|
|
802
|
+
`Commissionee found wanted Thread network ${this.commissioningOptions.threadNetwork.networkName}: ${Diagnostic.json(wantedNetworkFound)}`
|
|
793
803
|
);
|
|
794
804
|
const {
|
|
795
805
|
networkingStatus: addNetworkingStatus,
|
|
@@ -797,8 +807,8 @@ class ControllerCommissioningFlow {
|
|
|
797
807
|
networkIndex
|
|
798
808
|
} = await networkCommissioningClusterClient.addOrUpdateThreadNetwork(
|
|
799
809
|
{
|
|
800
|
-
operationalDataset: Bytes.fromHex(this
|
|
801
|
-
breadcrumb: this
|
|
810
|
+
operationalDataset: Bytes.fromHex(this.commissioningOptions.threadNetwork.operationalDataset),
|
|
811
|
+
breadcrumb: this.lastBreadcrumb++
|
|
802
812
|
},
|
|
803
813
|
{ useExtendedFailSafeMessageResponseTimeout: true }
|
|
804
814
|
);
|
|
@@ -809,7 +819,7 @@ class ControllerCommissioningFlow {
|
|
|
809
819
|
throw new CommissioningError(`Commissionee did not return network index`);
|
|
810
820
|
}
|
|
811
821
|
logger.debug(
|
|
812
|
-
`Commissionee added Thread network ${this
|
|
822
|
+
`Commissionee added Thread network ${this.commissioningOptions.threadNetwork.networkName} with network index ${networkIndex}`
|
|
813
823
|
);
|
|
814
824
|
const updatedNetworks = await networkCommissioningClusterClient.getNetworksAttribute();
|
|
815
825
|
if (updatedNetworks[networkIndex] === void 0) {
|
|
@@ -818,17 +828,17 @@ class ControllerCommissioningFlow {
|
|
|
818
828
|
const { networkId, connected } = updatedNetworks[networkIndex];
|
|
819
829
|
if (connected) {
|
|
820
830
|
logger.debug(
|
|
821
|
-
`Commissionee is already connected to Thread network ${this
|
|
831
|
+
`Commissionee is already connected to Thread network ${this.commissioningOptions.threadNetwork.networkName} (networkId ${Bytes.toHex(networkId)})`
|
|
822
832
|
);
|
|
823
833
|
return {
|
|
824
834
|
code: 0 /* Success */,
|
|
825
|
-
breadcrumb: this
|
|
835
|
+
breadcrumb: this.lastBreadcrumb
|
|
826
836
|
};
|
|
827
837
|
}
|
|
828
838
|
const connectResult = await networkCommissioningClusterClient.connectNetwork(
|
|
829
839
|
{
|
|
830
840
|
networkId,
|
|
831
|
-
breadcrumb: this
|
|
841
|
+
breadcrumb: this.lastBreadcrumb++
|
|
832
842
|
},
|
|
833
843
|
{ useExtendedFailSafeMessageResponseTimeout: true }
|
|
834
844
|
);
|
|
@@ -838,11 +848,11 @@ class ControllerCommissioningFlow {
|
|
|
838
848
|
);
|
|
839
849
|
}
|
|
840
850
|
logger.debug(
|
|
841
|
-
`Commissionee successfully connected to Thread network ${this
|
|
851
|
+
`Commissionee successfully connected to Thread network ${this.commissioningOptions.threadNetwork.networkName} (networkId ${Bytes.toHex(networkId)})`
|
|
842
852
|
);
|
|
843
853
|
return {
|
|
844
854
|
code: 0 /* Success */,
|
|
845
|
-
breadcrumb: this
|
|
855
|
+
breadcrumb: this.lastBreadcrumb
|
|
846
856
|
};
|
|
847
857
|
}
|
|
848
858
|
/**
|
|
@@ -854,7 +864,7 @@ class ControllerCommissioningFlow {
|
|
|
854
864
|
* (CASE)”) session with the Commissionee over the operational network.
|
|
855
865
|
*/
|
|
856
866
|
async #reconnectWithDevice() {
|
|
857
|
-
const isConcurrentFlow = this
|
|
867
|
+
const isConcurrentFlow = this.collectedCommissioningData.supportsConcurrentConnection !== false;
|
|
858
868
|
logger.debug(`Reconnecting with device with ${isConcurrentFlow ? "concurrent" : "non-concurrent"} flow ...`);
|
|
859
869
|
const reArmFailsafeInterval = Time.getPeriodicTimer(
|
|
860
870
|
"Re-Arm Failsafe during reconnect",
|
|
@@ -877,8 +887,8 @@ class ControllerCommissioningFlow {
|
|
|
877
887
|
if (isConcurrentFlow) {
|
|
878
888
|
reArmFailsafeInterval.start();
|
|
879
889
|
}
|
|
880
|
-
const transitionResult = await this
|
|
881
|
-
this
|
|
890
|
+
const transitionResult = await this.transitionToCase(
|
|
891
|
+
this.interactionClient.address,
|
|
882
892
|
// Assume concurrent connections are supported if not know (which should not be the case when we came here)
|
|
883
893
|
isConcurrentFlow
|
|
884
894
|
);
|
|
@@ -887,15 +897,15 @@ class ControllerCommissioningFlow {
|
|
|
887
897
|
logger.debug("CASE commissioning handled externally, terminating commissioning flow");
|
|
888
898
|
return {
|
|
889
899
|
code: 3 /* Stop */,
|
|
890
|
-
breadcrumb: this
|
|
900
|
+
breadcrumb: this.lastBreadcrumb
|
|
891
901
|
};
|
|
892
902
|
}
|
|
893
|
-
this
|
|
903
|
+
this.interactionClient = transitionResult;
|
|
894
904
|
this.#clusterClients.clear();
|
|
895
905
|
logger.debug("Successfully reconnected with device ...");
|
|
896
906
|
return {
|
|
897
907
|
code: 0 /* Success */,
|
|
898
|
-
breadcrumb: this
|
|
908
|
+
breadcrumb: this.lastBreadcrumb
|
|
899
909
|
};
|
|
900
910
|
}
|
|
901
911
|
/**
|
|
@@ -916,7 +926,7 @@ class ControllerCommissioningFlow {
|
|
|
916
926
|
this.#lastFailSafeTime = void 0;
|
|
917
927
|
return {
|
|
918
928
|
code: 0 /* Success */,
|
|
919
|
-
breadcrumb: this
|
|
929
|
+
breadcrumb: this.lastBreadcrumb
|
|
920
930
|
};
|
|
921
931
|
}
|
|
922
932
|
}
|