@matter/protocol 0.16.0-alpha.0-20251213-e83db3732 → 0.16.0-alpha.0-20251217-038f88085
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/LICENSE +1 -1
- package/dist/cjs/action/client/ClientInteraction.d.ts +12 -5
- package/dist/cjs/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/cjs/action/client/ClientInteraction.js +39 -15
- package/dist/cjs/action/client/ClientInteraction.js.map +1 -1
- package/dist/cjs/action/client/ClientRead.d.ts +10 -0
- package/dist/cjs/action/client/ClientRead.d.ts.map +1 -0
- package/dist/cjs/action/client/ClientRead.js +22 -0
- package/dist/cjs/action/client/ClientRead.js.map +6 -0
- package/dist/cjs/action/client/ClientRequest.d.ts +20 -0
- package/dist/cjs/action/client/ClientRequest.d.ts.map +1 -0
- package/dist/cjs/action/client/ClientRequest.js +22 -0
- package/dist/cjs/action/client/ClientRequest.js.map +6 -0
- package/dist/cjs/action/client/ClientWrite.d.ts +10 -0
- package/dist/cjs/action/client/ClientWrite.d.ts.map +1 -0
- package/dist/cjs/action/client/ClientWrite.js +22 -0
- package/dist/cjs/action/client/ClientWrite.js.map +6 -0
- package/dist/cjs/action/client/QueuedClientInteraction.d.ts +49 -0
- package/dist/cjs/action/client/QueuedClientInteraction.d.ts.map +1 -0
- package/dist/cjs/action/client/QueuedClientInteraction.js +160 -0
- package/dist/cjs/action/client/QueuedClientInteraction.js.map +6 -0
- package/dist/cjs/action/client/index.d.ts +4 -0
- package/dist/cjs/action/client/index.d.ts.map +1 -1
- package/dist/cjs/action/client/index.js +4 -0
- package/dist/cjs/action/client/index.js.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscribe.d.ts +2 -1
- package/dist/cjs/action/client/subscription/ClientSubscribe.d.ts.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.d.ts.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.js +14 -3
- package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.js.map +1 -1
- package/dist/cjs/action/client/subscription/SustainedSubscription.d.ts +1 -1
- package/dist/cjs/action/client/subscription/SustainedSubscription.d.ts.map +1 -1
- package/dist/cjs/action/client/subscription/SustainedSubscription.js +1 -4
- package/dist/cjs/action/client/subscription/SustainedSubscription.js.map +1 -1
- package/dist/cjs/action/request/Invoke.d.ts +7 -1
- package/dist/cjs/action/request/Invoke.d.ts.map +1 -1
- package/dist/cjs/action/request/Invoke.js +0 -3
- package/dist/cjs/action/request/Invoke.js.map +1 -1
- package/dist/cjs/action/request/Read.d.ts.map +1 -1
- package/dist/cjs/action/request/Read.js +3 -2
- package/dist/cjs/action/request/Read.js.map +1 -1
- package/dist/cjs/action/request/Specifier.d.ts +1 -1
- package/dist/cjs/action/request/Specifier.d.ts.map +1 -1
- package/dist/cjs/action/request/Specifier.js +3 -0
- package/dist/cjs/action/request/Specifier.js.map +1 -1
- package/dist/cjs/action/request/Write.d.ts +1 -0
- package/dist/cjs/action/request/Write.d.ts.map +1 -1
- package/dist/cjs/action/request/Write.js +10 -2
- package/dist/cjs/action/request/Write.js.map +1 -1
- package/dist/cjs/action/response/ReadResult.d.ts +1 -1
- package/dist/cjs/action/response/ReadResult.d.ts.map +1 -1
- package/dist/cjs/cluster/client/ClusterClientTypes.d.ts +37 -8
- package/dist/cjs/cluster/client/ClusterClientTypes.d.ts.map +1 -1
- package/dist/cjs/cluster/client/index.d.ts +0 -3
- package/dist/cjs/cluster/client/index.d.ts.map +1 -1
- package/dist/cjs/cluster/client/index.js +0 -3
- package/dist/cjs/cluster/client/index.js.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.js +3 -2
- package/dist/cjs/interaction/InteractionMessenger.js.map +1 -1
- package/dist/cjs/interaction/SubscriptionClient.d.ts.map +1 -1
- package/dist/cjs/interaction/SubscriptionClient.js +2 -1
- package/dist/cjs/interaction/SubscriptionClient.js.map +1 -1
- package/dist/cjs/interaction/index.d.ts +1 -1
- package/dist/cjs/interaction/index.d.ts.map +1 -1
- package/dist/cjs/interaction/index.js +1 -1
- package/dist/cjs/interaction/index.js.map +1 -1
- package/dist/cjs/peer/CommissioningError.d.ts +13 -0
- package/dist/cjs/peer/CommissioningError.d.ts.map +1 -0
- package/dist/cjs/peer/CommissioningError.js +32 -0
- package/dist/cjs/peer/CommissioningError.js.map +6 -0
- package/dist/cjs/peer/ControllerCommissioner.d.ts +2 -3
- package/dist/cjs/peer/ControllerCommissioner.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerCommissioner.js +20 -13
- package/dist/cjs/peer/ControllerCommissioner.js.map +2 -2
- package/dist/cjs/peer/ControllerCommissioningFlow.d.ts +7 -16
- package/dist/cjs/peer/ControllerCommissioningFlow.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.js +395 -178
- package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/cjs/peer/ControllerDiscovery.d.ts +4 -0
- package/dist/cjs/peer/ControllerDiscovery.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerDiscovery.js +6 -3
- package/dist/cjs/peer/ControllerDiscovery.js.map +1 -1
- package/dist/cjs/peer/InteractionQueue.d.ts +2 -2
- package/dist/cjs/peer/InteractionQueue.d.ts.map +1 -1
- package/dist/cjs/peer/InteractionQueue.js +1 -1
- package/dist/cjs/peer/InteractionQueue.js.map +1 -1
- package/dist/cjs/peer/PeerAddressStore.d.ts +0 -9
- package/dist/cjs/peer/PeerAddressStore.d.ts.map +1 -1
- package/dist/cjs/peer/PeerAddressStore.js.map +1 -1
- package/dist/cjs/peer/PeerSet.d.ts +0 -2
- package/dist/cjs/peer/PeerSet.d.ts.map +1 -1
- package/dist/cjs/peer/PeerSet.js +32 -18
- package/dist/cjs/peer/PeerSet.js.map +1 -1
- package/dist/cjs/peer/PhysicalDeviceProperties.js +1 -1
- package/dist/cjs/peer/PhysicalDeviceProperties.js.map +1 -1
- package/dist/cjs/peer/index.d.ts +1 -0
- package/dist/cjs/peer/index.d.ts.map +1 -1
- package/dist/cjs/peer/index.js +1 -0
- package/dist/cjs/peer/index.js.map +1 -1
- package/dist/cjs/protocol/DeviceCommissioner.d.ts.map +1 -1
- package/dist/cjs/protocol/DeviceCommissioner.js.map +1 -1
- package/dist/cjs/protocol/ExchangeManager.js +2 -2
- package/dist/cjs/protocol/ExchangeManager.js.map +1 -1
- package/dist/cjs/protocol/ExchangeProvider.d.ts +13 -4
- package/dist/cjs/protocol/ExchangeProvider.d.ts.map +1 -1
- package/dist/cjs/protocol/ExchangeProvider.js +5 -3
- package/dist/cjs/protocol/ExchangeProvider.js.map +1 -1
- package/dist/cjs/session/NodeSession.d.ts +5 -2
- package/dist/cjs/session/NodeSession.d.ts.map +1 -1
- package/dist/cjs/session/NodeSession.js +5 -4
- package/dist/cjs/session/NodeSession.js.map +1 -1
- package/dist/cjs/session/Session.d.ts +5 -3
- package/dist/cjs/session/Session.d.ts.map +1 -1
- package/dist/cjs/session/Session.js +8 -4
- package/dist/cjs/session/Session.js.map +1 -1
- package/dist/cjs/session/SessionManager.d.ts +8 -0
- package/dist/cjs/session/SessionManager.d.ts.map +1 -1
- package/dist/cjs/session/SessionManager.js +16 -2
- package/dist/cjs/session/SessionManager.js.map +1 -1
- package/dist/esm/action/client/ClientInteraction.d.ts +12 -5
- package/dist/esm/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/esm/action/client/ClientInteraction.js +42 -16
- package/dist/esm/action/client/ClientInteraction.js.map +1 -1
- package/dist/esm/action/client/ClientRead.d.ts +10 -0
- package/dist/esm/action/client/ClientRead.d.ts.map +1 -0
- package/dist/esm/action/client/ClientRead.js +6 -0
- package/dist/esm/action/client/ClientRead.js.map +6 -0
- package/dist/esm/action/client/ClientRequest.d.ts +20 -0
- package/dist/esm/action/client/ClientRequest.d.ts.map +1 -0
- package/dist/esm/action/client/ClientRequest.js +6 -0
- package/dist/esm/action/client/ClientRequest.js.map +6 -0
- package/dist/esm/action/client/ClientWrite.d.ts +10 -0
- package/dist/esm/action/client/ClientWrite.d.ts.map +1 -0
- package/dist/esm/action/client/ClientWrite.js +6 -0
- package/dist/esm/action/client/ClientWrite.js.map +6 -0
- package/dist/esm/action/client/QueuedClientInteraction.d.ts +49 -0
- package/dist/esm/action/client/QueuedClientInteraction.d.ts.map +1 -0
- package/dist/esm/action/client/QueuedClientInteraction.js +140 -0
- package/dist/esm/action/client/QueuedClientInteraction.js.map +6 -0
- package/dist/esm/action/client/index.d.ts +4 -0
- package/dist/esm/action/client/index.d.ts.map +1 -1
- package/dist/esm/action/client/index.js +4 -0
- package/dist/esm/action/client/index.js.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscribe.d.ts +2 -1
- package/dist/esm/action/client/subscription/ClientSubscribe.d.ts.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscriptionHandler.d.ts.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscriptionHandler.js +14 -3
- package/dist/esm/action/client/subscription/ClientSubscriptionHandler.js.map +1 -1
- package/dist/esm/action/client/subscription/SustainedSubscription.d.ts +1 -1
- package/dist/esm/action/client/subscription/SustainedSubscription.d.ts.map +1 -1
- package/dist/esm/action/client/subscription/SustainedSubscription.js +1 -4
- package/dist/esm/action/client/subscription/SustainedSubscription.js.map +1 -1
- package/dist/esm/action/request/Invoke.d.ts +7 -1
- package/dist/esm/action/request/Invoke.d.ts.map +1 -1
- package/dist/esm/action/request/Invoke.js +0 -3
- package/dist/esm/action/request/Invoke.js.map +1 -1
- package/dist/esm/action/request/Read.d.ts.map +1 -1
- package/dist/esm/action/request/Read.js +3 -2
- package/dist/esm/action/request/Read.js.map +1 -1
- package/dist/esm/action/request/Specifier.d.ts +1 -1
- package/dist/esm/action/request/Specifier.d.ts.map +1 -1
- package/dist/esm/action/request/Specifier.js +3 -0
- package/dist/esm/action/request/Specifier.js.map +1 -1
- package/dist/esm/action/request/Write.d.ts +1 -0
- package/dist/esm/action/request/Write.d.ts.map +1 -1
- package/dist/esm/action/request/Write.js +10 -2
- package/dist/esm/action/request/Write.js.map +1 -1
- package/dist/esm/action/response/ReadResult.d.ts +1 -1
- package/dist/esm/action/response/ReadResult.d.ts.map +1 -1
- package/dist/esm/cluster/client/ClusterClientTypes.d.ts +37 -8
- package/dist/esm/cluster/client/ClusterClientTypes.d.ts.map +1 -1
- package/dist/esm/cluster/client/index.d.ts +0 -3
- package/dist/esm/cluster/client/index.d.ts.map +1 -1
- package/dist/esm/cluster/client/index.js +0 -3
- package/dist/esm/cluster/client/index.js.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.js +4 -3
- package/dist/esm/interaction/InteractionMessenger.js.map +1 -1
- package/dist/esm/interaction/SubscriptionClient.d.ts.map +1 -1
- package/dist/esm/interaction/SubscriptionClient.js +2 -1
- package/dist/esm/interaction/SubscriptionClient.js.map +1 -1
- package/dist/esm/interaction/index.d.ts +1 -1
- package/dist/esm/interaction/index.d.ts.map +1 -1
- package/dist/esm/interaction/index.js +1 -1
- package/dist/esm/peer/CommissioningError.d.ts +13 -0
- package/dist/esm/peer/CommissioningError.d.ts.map +1 -0
- package/dist/esm/peer/CommissioningError.js +12 -0
- package/dist/esm/peer/CommissioningError.js.map +6 -0
- package/dist/esm/peer/ControllerCommissioner.d.ts +2 -3
- package/dist/esm/peer/ControllerCommissioner.d.ts.map +1 -1
- package/dist/esm/peer/ControllerCommissioner.js +19 -13
- package/dist/esm/peer/ControllerCommissioner.js.map +2 -2
- package/dist/esm/peer/ControllerCommissioningFlow.d.ts +7 -16
- package/dist/esm/peer/ControllerCommissioningFlow.d.ts.map +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.js +380 -162
- package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/esm/peer/ControllerDiscovery.d.ts +4 -0
- package/dist/esm/peer/ControllerDiscovery.d.ts.map +1 -1
- package/dist/esm/peer/ControllerDiscovery.js +4 -1
- package/dist/esm/peer/ControllerDiscovery.js.map +1 -1
- package/dist/esm/peer/InteractionQueue.d.ts +2 -2
- package/dist/esm/peer/InteractionQueue.d.ts.map +1 -1
- package/dist/esm/peer/InteractionQueue.js +2 -2
- package/dist/esm/peer/InteractionQueue.js.map +1 -1
- package/dist/esm/peer/PeerAddressStore.d.ts +0 -9
- package/dist/esm/peer/PeerAddressStore.d.ts.map +1 -1
- package/dist/esm/peer/PeerAddressStore.js.map +1 -1
- package/dist/esm/peer/PeerSet.d.ts +0 -2
- package/dist/esm/peer/PeerSet.d.ts.map +1 -1
- package/dist/esm/peer/PeerSet.js +32 -18
- package/dist/esm/peer/PeerSet.js.map +1 -1
- package/dist/esm/peer/PhysicalDeviceProperties.js +1 -1
- package/dist/esm/peer/PhysicalDeviceProperties.js.map +1 -1
- package/dist/esm/peer/index.d.ts +1 -0
- package/dist/esm/peer/index.d.ts.map +1 -1
- package/dist/esm/peer/index.js +1 -0
- package/dist/esm/peer/index.js.map +1 -1
- package/dist/esm/protocol/DeviceCommissioner.d.ts.map +1 -1
- package/dist/esm/protocol/DeviceCommissioner.js.map +1 -1
- package/dist/esm/protocol/ExchangeManager.js +2 -2
- package/dist/esm/protocol/ExchangeManager.js.map +1 -1
- package/dist/esm/protocol/ExchangeProvider.d.ts +13 -4
- package/dist/esm/protocol/ExchangeProvider.d.ts.map +1 -1
- package/dist/esm/protocol/ExchangeProvider.js +5 -3
- package/dist/esm/protocol/ExchangeProvider.js.map +1 -1
- package/dist/esm/session/NodeSession.d.ts +5 -2
- package/dist/esm/session/NodeSession.d.ts.map +1 -1
- package/dist/esm/session/NodeSession.js +5 -4
- package/dist/esm/session/NodeSession.js.map +1 -1
- package/dist/esm/session/Session.d.ts +5 -3
- package/dist/esm/session/Session.d.ts.map +1 -1
- package/dist/esm/session/Session.js +8 -4
- package/dist/esm/session/Session.js.map +1 -1
- package/dist/esm/session/SessionManager.d.ts +8 -0
- package/dist/esm/session/SessionManager.d.ts.map +1 -1
- package/dist/esm/session/SessionManager.js +17 -2
- package/dist/esm/session/SessionManager.js.map +1 -1
- package/package.json +6 -6
- package/src/action/client/ClientInteraction.ts +58 -19
- package/src/action/client/ClientRead.ts +10 -0
- package/src/action/client/ClientRequest.ts +20 -0
- package/src/action/client/ClientWrite.ts +10 -0
- package/src/action/client/QueuedClientInteraction.ts +91 -0
- package/src/action/client/index.ts +4 -0
- package/src/action/client/subscription/ClientSubscribe.ts +2 -1
- package/src/action/client/subscription/ClientSubscriptionHandler.ts +14 -3
- package/src/action/client/subscription/SustainedSubscription.ts +6 -9
- package/src/action/request/Invoke.ts +11 -4
- package/src/action/request/Read.ts +3 -2
- package/src/action/request/Specifier.ts +4 -1
- package/src/action/request/Write.ts +11 -2
- package/src/action/response/ReadResult.ts +1 -1
- package/src/cluster/client/ClusterClientTypes.ts +47 -7
- package/src/cluster/client/index.ts +0 -3
- package/src/interaction/InteractionMessenger.ts +5 -4
- package/src/interaction/SubscriptionClient.ts +2 -1
- package/src/interaction/index.ts +1 -1
- package/src/peer/CommissioningError.ts +13 -0
- package/src/peer/ControllerCommissioner.ts +21 -13
- package/src/peer/ControllerCommissioningFlow.ts +418 -186
- package/src/peer/ControllerDiscovery.ts +4 -1
- package/src/peer/InteractionQueue.ts +2 -2
- package/src/peer/PeerAddressStore.ts +0 -9
- package/src/peer/PeerSet.ts +56 -23
- package/src/peer/PhysicalDeviceProperties.ts +1 -1
- package/src/peer/index.ts +1 -0
- package/src/protocol/DeviceCommissioner.ts +0 -1
- package/src/protocol/ExchangeManager.ts +2 -2
- package/src/protocol/ExchangeProvider.ts +9 -7
- package/src/session/NodeSession.ts +5 -4
- package/src/session/Session.ts +8 -4
- package/src/session/SessionManager.ts +19 -2
- package/dist/cjs/cluster/client/AttributeClient.d.ts +0 -75
- package/dist/cjs/cluster/client/AttributeClient.d.ts.map +0 -1
- package/dist/cjs/cluster/client/AttributeClient.js +0 -209
- package/dist/cjs/cluster/client/AttributeClient.js.map +0 -6
- package/dist/cjs/cluster/client/ClusterClient.d.ts +0 -11
- package/dist/cjs/cluster/client/ClusterClient.d.ts.map +0 -1
- package/dist/cjs/cluster/client/ClusterClient.js +0 -335
- package/dist/cjs/cluster/client/ClusterClient.js.map +0 -6
- package/dist/cjs/cluster/client/EventClient.d.ts +0 -33
- package/dist/cjs/cluster/client/EventClient.d.ts.map +0 -1
- package/dist/cjs/cluster/client/EventClient.js +0 -89
- package/dist/cjs/cluster/client/EventClient.js.map +0 -6
- package/dist/cjs/interaction/InteractionClient.d.ts +0 -375
- package/dist/cjs/interaction/InteractionClient.d.ts.map +0 -1
- package/dist/cjs/interaction/InteractionClient.js +0 -1046
- package/dist/cjs/interaction/InteractionClient.js.map +0 -6
- package/dist/esm/cluster/client/AttributeClient.d.ts +0 -75
- package/dist/esm/cluster/client/AttributeClient.d.ts.map +0 -1
- package/dist/esm/cluster/client/AttributeClient.js +0 -189
- package/dist/esm/cluster/client/AttributeClient.js.map +0 -6
- package/dist/esm/cluster/client/ClusterClient.d.ts +0 -11
- package/dist/esm/cluster/client/ClusterClient.d.ts.map +0 -1
- package/dist/esm/cluster/client/ClusterClient.js +0 -320
- package/dist/esm/cluster/client/ClusterClient.js.map +0 -6
- package/dist/esm/cluster/client/EventClient.d.ts +0 -33
- package/dist/esm/cluster/client/EventClient.d.ts.map +0 -1
- package/dist/esm/cluster/client/EventClient.js +0 -69
- package/dist/esm/cluster/client/EventClient.js.map +0 -6
- package/dist/esm/interaction/InteractionClient.d.ts +0 -375
- package/dist/esm/interaction/InteractionClient.d.ts.map +0 -1
- package/dist/esm/interaction/InteractionClient.js +0 -1047
- package/dist/esm/interaction/InteractionClient.js.map +0 -6
- package/src/cluster/client/AttributeClient.ts +0 -230
- package/src/cluster/client/ClusterClient.ts +0 -433
- package/src/cluster/client/EventClient.ts +0 -99
- package/src/interaction/InteractionClient.ts +0 -1614
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* Copyright 2022-2025 Matter.js Authors
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import { Invoke } from "#action/request/Invoke.js";
|
|
7
|
+
import { Read } from "#action/request/Read.js";
|
|
6
8
|
import { Certificate } from "#certificate/kinds/Certificate.js";
|
|
7
9
|
import { BasicInformation } from "#clusters/basic-information";
|
|
8
10
|
import { Descriptor } from "#clusters/descriptor";
|
|
@@ -15,9 +17,9 @@ import {
|
|
|
15
17
|
ChannelType,
|
|
16
18
|
Diagnostic,
|
|
17
19
|
Duration,
|
|
20
|
+
ImplementationError,
|
|
18
21
|
Instant,
|
|
19
22
|
Logger,
|
|
20
|
-
MatterError,
|
|
21
23
|
Millis,
|
|
22
24
|
Minutes,
|
|
23
25
|
repackErrorAs,
|
|
@@ -29,10 +31,11 @@ import {
|
|
|
29
31
|
} from "#general";
|
|
30
32
|
import {
|
|
31
33
|
EndpointNumber,
|
|
34
|
+
Status,
|
|
32
35
|
StatusResponseError
|
|
33
36
|
} from "#types";
|
|
34
|
-
import { ClusterClient } from "../cluster/client/ClusterClient.js";
|
|
35
37
|
import { TlvCertSigningRequest } from "../common/OperationalCredentialsTypes.js";
|
|
38
|
+
import { CommissioningError } from "./CommissioningError.js";
|
|
36
39
|
const logger = Logger.get("ControllerCommissioner");
|
|
37
40
|
var CommissioningStepResultCode = /* @__PURE__ */ ((CommissioningStepResultCode2) => {
|
|
38
41
|
CommissioningStepResultCode2[CommissioningStepResultCode2["Success"] = 0] = "Success";
|
|
@@ -41,8 +44,6 @@ var CommissioningStepResultCode = /* @__PURE__ */ ((CommissioningStepResultCode2
|
|
|
41
44
|
CommissioningStepResultCode2[CommissioningStepResultCode2["Stop"] = 3] = "Stop";
|
|
42
45
|
return CommissioningStepResultCode2;
|
|
43
46
|
})(CommissioningStepResultCode || {});
|
|
44
|
-
class CommissioningError extends MatterError {
|
|
45
|
-
}
|
|
46
47
|
class MaximumCommissionedFabricsReachedError extends CommissioningError {
|
|
47
48
|
}
|
|
48
49
|
class CommissioningTimeoutError extends CommissioningError {
|
|
@@ -59,15 +60,14 @@ class ThreadNetworkSetupFailedError extends CommissioningError {
|
|
|
59
60
|
}
|
|
60
61
|
class NodeIdConflictError extends CommissioningError {
|
|
61
62
|
}
|
|
62
|
-
class CommissionableDeviceDiscoveryFailedError extends CommissioningError {
|
|
63
|
-
}
|
|
64
63
|
class OperativeConnectionFailedError extends CommissioningError {
|
|
65
64
|
}
|
|
66
65
|
class RecoverableCommissioningError extends CommissioningError {
|
|
67
66
|
}
|
|
68
67
|
const DEFAULT_FAILSAFE_TIME = Minutes.one;
|
|
68
|
+
const RootEndpointNumber = EndpointNumber(0);
|
|
69
69
|
class ControllerCommissioningFlow {
|
|
70
|
-
|
|
70
|
+
interaction;
|
|
71
71
|
ca;
|
|
72
72
|
fabric;
|
|
73
73
|
transitionToCase;
|
|
@@ -81,8 +81,8 @@ class ControllerCommissioningFlow {
|
|
|
81
81
|
lastBreadcrumb = 1;
|
|
82
82
|
collectedCommissioningData = {};
|
|
83
83
|
#defaultFailSafeTime = DEFAULT_FAILSAFE_TIME;
|
|
84
|
-
constructor(
|
|
85
|
-
this.
|
|
84
|
+
constructor(interaction, ca, fabric, commissioningOptions, transitionToCase) {
|
|
85
|
+
this.interaction = interaction;
|
|
86
86
|
this.ca = ca;
|
|
87
87
|
this.fabric = fabric;
|
|
88
88
|
this.transitionToCase = transitionToCase;
|
|
@@ -150,24 +150,58 @@ class ControllerCommissioningFlow {
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
|
-
*
|
|
153
|
+
* Convenience method to get a number of attributes in a read and return exactly these values in the order as
|
|
154
|
+
* defined in the request
|
|
154
155
|
*/
|
|
155
|
-
#
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
156
|
+
async #readConcreteAttributeValues(request) {
|
|
157
|
+
const attributeMap = /* @__PURE__ */ new Map();
|
|
158
|
+
if (request.attributeRequests === void 0) {
|
|
159
|
+
throw new ImplementationError("Can only handle Attribute reads");
|
|
160
|
+
}
|
|
161
|
+
for (const { endpointId, clusterId, attributeId } of request.attributeRequests) {
|
|
162
|
+
if (endpointId === void 0 || clusterId === void 0) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
attributeMap.set(`${endpointId}-${clusterId}-${attributeId}`, void 0);
|
|
166
|
+
}
|
|
167
|
+
for await (const data of this.interaction.read(request)) {
|
|
168
|
+
for (const entry of data) {
|
|
169
|
+
if (entry.kind !== "attr-value") {
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const {
|
|
173
|
+
path: { endpointId, clusterId, attributeId },
|
|
174
|
+
value
|
|
175
|
+
} = entry;
|
|
176
|
+
const key = `${endpointId}-${clusterId}-${attributeId}`;
|
|
177
|
+
if (!attributeMap.has(key)) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
attributeMap.set(key, value);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return [...attributeMap.values()];
|
|
184
|
+
}
|
|
185
|
+
// TODO improve response typing
|
|
186
|
+
async #invokeCommand(request, options = {}) {
|
|
187
|
+
for await (const data of this.interaction.invoke(
|
|
188
|
+
Invoke({
|
|
189
|
+
commands: [request],
|
|
190
|
+
...options
|
|
191
|
+
})
|
|
192
|
+
)) {
|
|
193
|
+
for (const entry of data) {
|
|
194
|
+
switch (entry.kind) {
|
|
195
|
+
case "cmd-status":
|
|
196
|
+
if (entry.status !== Status.Success) {
|
|
197
|
+
throw StatusResponseError.create(entry.status, void 0, entry.clusterStatus);
|
|
198
|
+
}
|
|
199
|
+
return;
|
|
200
|
+
case "cmd-response":
|
|
201
|
+
return entry.data;
|
|
202
|
+
}
|
|
163
203
|
}
|
|
164
204
|
}
|
|
165
|
-
logger.debug(
|
|
166
|
-
`Creating new cluster client for cluster ${cluster.name} (endpoint ${endpointId}, isFeatureSpecific ${isFeatureSpecific})`
|
|
167
|
-
);
|
|
168
|
-
const client = ClusterClient(cluster, endpointId, this.interactionClient);
|
|
169
|
-
this.#clusterClients.set(cluster.id, client);
|
|
170
|
-
return client;
|
|
171
205
|
}
|
|
172
206
|
/**
|
|
173
207
|
* Initialize commissioning steps and add them in the default order as defined by
|
|
@@ -218,7 +252,7 @@ class ControllerCommissioningFlow {
|
|
|
218
252
|
name: "AccessControl",
|
|
219
253
|
stepLogic: () => this.#configureAccessControlLists()
|
|
220
254
|
});
|
|
221
|
-
if (this.
|
|
255
|
+
if (this.interaction.channelType === ChannelType.BLE) {
|
|
222
256
|
this.commissioningSteps.push({
|
|
223
257
|
stepNumber: 16,
|
|
224
258
|
subStepNumber: 1,
|
|
@@ -247,7 +281,7 @@ class ControllerCommissioningFlow {
|
|
|
247
281
|
}
|
|
248
282
|
} else {
|
|
249
283
|
logger.info(
|
|
250
|
-
`Skipping NetworkCommissioning steps because the device is already on IP network (${this.
|
|
284
|
+
`Skipping NetworkCommissioning steps because the device is already on IP network (${this.interaction.channelType})`
|
|
251
285
|
);
|
|
252
286
|
}
|
|
253
287
|
this.commissioningSteps.push({
|
|
@@ -321,49 +355,84 @@ class ControllerCommissioningFlow {
|
|
|
321
355
|
* Initial Step to receive some common data used by other steps
|
|
322
356
|
*/
|
|
323
357
|
async #getInitialData() {
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
|
|
358
|
+
const [
|
|
359
|
+
supportedFabrics,
|
|
360
|
+
commissionedFabrics,
|
|
361
|
+
rootPartsList,
|
|
362
|
+
rootServerList,
|
|
363
|
+
vendorId,
|
|
364
|
+
productId,
|
|
365
|
+
productName,
|
|
366
|
+
supportsConcurrentConnection
|
|
367
|
+
] = await this.#readConcreteAttributeValues(
|
|
368
|
+
Read(
|
|
369
|
+
Read.Attribute({
|
|
370
|
+
endpoint: RootEndpointNumber,
|
|
371
|
+
cluster: OperationalCredentials.Complete,
|
|
372
|
+
attributes: ["supportedFabrics", "commissionedFabrics"]
|
|
373
|
+
}),
|
|
374
|
+
Read.Attribute({
|
|
375
|
+
endpoint: RootEndpointNumber,
|
|
376
|
+
cluster: Descriptor.Complete,
|
|
377
|
+
attributes: ["partsList", "serverList"]
|
|
378
|
+
}),
|
|
379
|
+
Read.Attribute({
|
|
380
|
+
endpoint: RootEndpointNumber,
|
|
381
|
+
cluster: BasicInformation.Complete,
|
|
382
|
+
attributes: ["vendorId", "productId", "productName"]
|
|
383
|
+
}),
|
|
384
|
+
Read.Attribute({
|
|
385
|
+
endpoint: RootEndpointNumber,
|
|
386
|
+
cluster: GeneralCommissioning.Complete,
|
|
387
|
+
attributes: ["supportsConcurrentConnection"]
|
|
388
|
+
})
|
|
389
|
+
)
|
|
390
|
+
);
|
|
327
391
|
if (commissionedFabrics >= supportedFabrics) {
|
|
328
392
|
throw new MaximumCommissionedFabricsReachedError(
|
|
329
393
|
`Commissioned fabrics (${commissionedFabrics}) exceed supported fabrics (${supportedFabrics}). Please remove some fabrics before commissioning.`
|
|
330
394
|
);
|
|
331
395
|
}
|
|
332
|
-
|
|
333
|
-
this.collectedCommissioningData.
|
|
334
|
-
this.collectedCommissioningData.
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
});
|
|
396
|
+
this.collectedCommissioningData.rootPartsList = rootPartsList;
|
|
397
|
+
this.collectedCommissioningData.rootServerList = rootServerList;
|
|
398
|
+
this.collectedCommissioningData.vendorId = vendorId;
|
|
399
|
+
this.collectedCommissioningData.productId = productId;
|
|
400
|
+
this.collectedCommissioningData.productName = productName;
|
|
401
|
+
this.collectedCommissioningData.supportsConcurrentConnection = supportsConcurrentConnection;
|
|
402
|
+
const networkData = this.interaction.read(
|
|
403
|
+
Read(
|
|
404
|
+
Read.Attribute({
|
|
405
|
+
cluster: NetworkCommissioning.Complete,
|
|
406
|
+
attributes: ["featureMap", "networks"]
|
|
407
|
+
})
|
|
408
|
+
)
|
|
409
|
+
);
|
|
347
410
|
const networkFeatures = new Array();
|
|
348
411
|
const networkStatus = new Array();
|
|
349
|
-
for (const {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
412
|
+
for await (const data of networkData) {
|
|
413
|
+
for (const entry of data) {
|
|
414
|
+
if (entry.kind !== "attr-value") {
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
const {
|
|
418
|
+
path: { endpointId, attributeId },
|
|
419
|
+
value
|
|
420
|
+
} = entry;
|
|
421
|
+
if (attributeId === NetworkCommissioning.Complete.attributes.featureMap.id) {
|
|
422
|
+
networkFeatures.push({
|
|
423
|
+
endpointId,
|
|
424
|
+
value
|
|
425
|
+
});
|
|
426
|
+
} else if (attributeId === NetworkCommissioning.Complete.attributes.networks.id) {
|
|
427
|
+
networkStatus.push({
|
|
428
|
+
endpointId,
|
|
429
|
+
value
|
|
430
|
+
});
|
|
431
|
+
}
|
|
357
432
|
}
|
|
358
433
|
}
|
|
359
434
|
this.collectedCommissioningData.networkFeatures = networkFeatures;
|
|
360
435
|
this.collectedCommissioningData.networkStatus = networkStatus;
|
|
361
|
-
const basicInfoClient = this.#getClusterClient(BasicInformation.Cluster);
|
|
362
|
-
this.collectedCommissioningData.vendorId = await basicInfoClient.getVendorIdAttribute();
|
|
363
|
-
this.collectedCommissioningData.productId = await basicInfoClient.getProductIdAttribute();
|
|
364
|
-
this.collectedCommissioningData.productName = await basicInfoClient.getProductNameAttribute();
|
|
365
|
-
const generalCommissioningClient = this.#getClusterClient(GeneralCommissioning.Cluster);
|
|
366
|
-
this.collectedCommissioningData.supportsConcurrentConnection = await generalCommissioningClient.getSupportsConcurrentConnectionAttribute();
|
|
367
436
|
return {
|
|
368
437
|
code: 0 /* Success */,
|
|
369
438
|
breadcrumb: this.lastBreadcrumb
|
|
@@ -379,9 +448,16 @@ class ControllerCommissioningFlow {
|
|
|
379
448
|
* Attribute”) prior to invoking the ArmFailSafe command.
|
|
380
449
|
*/
|
|
381
450
|
async #armFailsafe(time) {
|
|
382
|
-
const client = this.#getClusterClient(GeneralCommissioning.Cluster);
|
|
383
451
|
if (this.collectedCommissioningData.basicCommissioningInfo === void 0) {
|
|
384
|
-
const basicCommissioningInfo = await
|
|
452
|
+
const [basicCommissioningInfo] = await this.#readConcreteAttributeValues(
|
|
453
|
+
Read(
|
|
454
|
+
Read.Attribute({
|
|
455
|
+
endpoint: RootEndpointNumber,
|
|
456
|
+
cluster: GeneralCommissioning.Complete,
|
|
457
|
+
attributes: ["basicCommissioningInfo"]
|
|
458
|
+
})
|
|
459
|
+
)
|
|
460
|
+
);
|
|
385
461
|
this.collectedCommissioningData.basicCommissioningInfo = basicCommissioningInfo;
|
|
386
462
|
this.#defaultFailSafeTime = Seconds(basicCommissioningInfo.failSafeExpiryLengthSeconds);
|
|
387
463
|
this.#commissioningStartedTime = Time.nowMs;
|
|
@@ -392,9 +468,14 @@ class ControllerCommissioningFlow {
|
|
|
392
468
|
const expiryLength = time ?? this.#defaultFailSafeTime;
|
|
393
469
|
this.#ensureGeneralCommissioningSuccess(
|
|
394
470
|
"armFailSafe",
|
|
395
|
-
await
|
|
396
|
-
|
|
397
|
-
|
|
471
|
+
await this.#invokeCommand({
|
|
472
|
+
endpoint: RootEndpointNumber,
|
|
473
|
+
cluster: GeneralCommissioning.Complete,
|
|
474
|
+
command: "armFailSafe",
|
|
475
|
+
fields: {
|
|
476
|
+
breadcrumb: this.lastBreadcrumb,
|
|
477
|
+
expiryLengthSeconds: Seconds.of(expiryLength)
|
|
478
|
+
}
|
|
398
479
|
})
|
|
399
480
|
);
|
|
400
481
|
this.#currentFailSafeEndTime = Timestamp(Time.nowMs + expiryLength);
|
|
@@ -410,22 +491,26 @@ class ControllerCommissioningFlow {
|
|
|
410
491
|
return Duration.max(Timespan(Time.nowMs, this.#currentFailSafeEndTime).duration, 0);
|
|
411
492
|
}
|
|
412
493
|
async #ensureFailsafeTimerFor(maxProcessingTime) {
|
|
413
|
-
const minFailsafeTime = this.
|
|
494
|
+
const minFailsafeTime = this.interaction.maximumPeerResponseTime(maxProcessingTime);
|
|
414
495
|
const timeLeft = this.#failSafeTimeLeft;
|
|
415
496
|
if (timeLeft < minFailsafeTime) {
|
|
416
497
|
logger.debug(`Failsafe timer has only ${timeLeft}s left, re-arming for at least ${minFailsafeTime}`);
|
|
417
498
|
await this.#armFailsafe(Duration.max(minFailsafeTime, this.#defaultFailSafeTime));
|
|
418
499
|
} else {
|
|
419
|
-
logger.debug(`Failsafe timer is already set for at least ${timeLeft}s`);
|
|
500
|
+
logger.debug(`Failsafe timer is already set for at least ${Seconds.of(timeLeft)}s`);
|
|
420
501
|
}
|
|
421
502
|
}
|
|
422
503
|
async #resetFailsafeTimer() {
|
|
423
504
|
if (this.#currentFailSafeEndTime === void 0) return;
|
|
424
505
|
try {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
506
|
+
await this.#invokeCommand({
|
|
507
|
+
endpoint: RootEndpointNumber,
|
|
508
|
+
cluster: GeneralCommissioning.Complete,
|
|
509
|
+
command: "armFailSafe",
|
|
510
|
+
fields: {
|
|
511
|
+
breadcrumb: this.lastBreadcrumb,
|
|
512
|
+
expiryLengthSeconds: 0
|
|
513
|
+
}
|
|
429
514
|
});
|
|
430
515
|
this.#currentFailSafeEndTime = void 0;
|
|
431
516
|
} catch (error) {
|
|
@@ -449,8 +534,15 @@ class ControllerCommissioningFlow {
|
|
|
449
534
|
({ value: { wiFiNetworkInterface, threadNetworkInterface } }) => wiFiNetworkInterface || threadNetworkInterface
|
|
450
535
|
);
|
|
451
536
|
if (hasRadioNetwork) {
|
|
452
|
-
|
|
453
|
-
|
|
537
|
+
let [locationCapability] = await this.#readConcreteAttributeValues(
|
|
538
|
+
Read(
|
|
539
|
+
Read.Attribute({
|
|
540
|
+
endpoint: RootEndpointNumber,
|
|
541
|
+
cluster: GeneralCommissioning.Complete,
|
|
542
|
+
attributes: ["locationCapability"]
|
|
543
|
+
})
|
|
544
|
+
)
|
|
545
|
+
);
|
|
454
546
|
if (locationCapability === GeneralCommissioning.RegulatoryLocationType.IndoorOutdoor) {
|
|
455
547
|
locationCapability = this.commissioningOptions.regulatoryLocation;
|
|
456
548
|
} else {
|
|
@@ -459,13 +551,20 @@ class ControllerCommissioningFlow {
|
|
|
459
551
|
);
|
|
460
552
|
}
|
|
461
553
|
let countryCode = this.commissioningOptions.regulatoryCountryCode;
|
|
462
|
-
const regulatoryResult = await
|
|
554
|
+
const regulatoryResult = await this.#invokeCommand(
|
|
463
555
|
{
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
556
|
+
endpoint: RootEndpointNumber,
|
|
557
|
+
cluster: GeneralCommissioning.Complete,
|
|
558
|
+
command: "setRegulatoryConfig",
|
|
559
|
+
fields: {
|
|
560
|
+
breadcrumb: this.lastBreadcrumb++,
|
|
561
|
+
newRegulatoryConfig: locationCapability,
|
|
562
|
+
countryCode
|
|
563
|
+
}
|
|
467
564
|
},
|
|
468
|
-
{
|
|
565
|
+
{
|
|
566
|
+
useExtendedFailSafeMessageResponseTimeout: true
|
|
567
|
+
}
|
|
469
568
|
);
|
|
470
569
|
if (regulatoryResult.errorCode === GeneralCommissioning.CommissioningError.ValueOutsideRange && countryCode !== "XX") {
|
|
471
570
|
logger.debug(
|
|
@@ -474,13 +573,20 @@ class ControllerCommissioningFlow {
|
|
|
474
573
|
countryCode = "XX";
|
|
475
574
|
this.#ensureGeneralCommissioningSuccess(
|
|
476
575
|
"setRegulatoryConfig",
|
|
477
|
-
await
|
|
576
|
+
await this.#invokeCommand(
|
|
478
577
|
{
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
578
|
+
endpoint: RootEndpointNumber,
|
|
579
|
+
cluster: GeneralCommissioning.Complete,
|
|
580
|
+
command: "setRegulatoryConfig",
|
|
581
|
+
fields: {
|
|
582
|
+
breadcrumb: this.lastBreadcrumb,
|
|
583
|
+
newRegulatoryConfig: locationCapability,
|
|
584
|
+
countryCode
|
|
585
|
+
}
|
|
482
586
|
},
|
|
483
|
-
{
|
|
587
|
+
{
|
|
588
|
+
useExtendedFailSafeMessageResponseTimeout: true
|
|
589
|
+
}
|
|
484
590
|
)
|
|
485
591
|
);
|
|
486
592
|
} else {
|
|
@@ -522,24 +628,44 @@ class ControllerCommissioningFlow {
|
|
|
522
628
|
* (see Section 6.2.3, “Device Attestation Procedure”).
|
|
523
629
|
*/
|
|
524
630
|
async #deviceAttestation() {
|
|
525
|
-
const
|
|
526
|
-
const { certificate: deviceAttestation } = await operationalCredentialsClusterClient.certificateChainRequest(
|
|
631
|
+
const { certificate: deviceAttestation } = await this.#invokeCommand(
|
|
527
632
|
{
|
|
528
|
-
|
|
633
|
+
endpoint: RootEndpointNumber,
|
|
634
|
+
cluster: OperationalCredentials.Complete,
|
|
635
|
+
command: "certificateChainRequest",
|
|
636
|
+
fields: {
|
|
637
|
+
certificateType: OperationalCredentials.CertificateChainType.DacCertificate
|
|
638
|
+
}
|
|
529
639
|
},
|
|
530
|
-
{
|
|
640
|
+
{
|
|
641
|
+
useExtendedFailSafeMessageResponseTimeout: true
|
|
642
|
+
}
|
|
531
643
|
);
|
|
532
|
-
const { certificate: productAttestation } = await
|
|
644
|
+
const { certificate: productAttestation } = await this.#invokeCommand(
|
|
533
645
|
{
|
|
534
|
-
|
|
646
|
+
endpoint: RootEndpointNumber,
|
|
647
|
+
cluster: OperationalCredentials.Complete,
|
|
648
|
+
command: "certificateChainRequest",
|
|
649
|
+
fields: {
|
|
650
|
+
certificateType: OperationalCredentials.CertificateChainType.PaiCertificate
|
|
651
|
+
}
|
|
535
652
|
},
|
|
536
|
-
{
|
|
653
|
+
{
|
|
654
|
+
useExtendedFailSafeMessageResponseTimeout: true
|
|
655
|
+
}
|
|
537
656
|
);
|
|
538
|
-
const { attestationElements, attestationSignature } = await
|
|
657
|
+
const { attestationElements, attestationSignature } = await this.#invokeCommand(
|
|
539
658
|
{
|
|
540
|
-
|
|
659
|
+
endpoint: RootEndpointNumber,
|
|
660
|
+
cluster: OperationalCredentials.Complete,
|
|
661
|
+
command: "attestationRequest",
|
|
662
|
+
fields: {
|
|
663
|
+
attestationNonce: this.fabric.crypto.randomBytes(32)
|
|
664
|
+
}
|
|
541
665
|
},
|
|
542
|
-
{
|
|
666
|
+
{
|
|
667
|
+
useExtendedFailSafeMessageResponseTimeout: true
|
|
668
|
+
}
|
|
543
669
|
);
|
|
544
670
|
if (deviceAttestation.byteLength === 0 || productAttestation.byteLength === 0 || attestationElements.byteLength === 0 || attestationSignature.byteLength === 0) {
|
|
545
671
|
throw new CommissioningError("Device Attestation data missing from device");
|
|
@@ -566,36 +692,56 @@ class ControllerCommissioningFlow {
|
|
|
566
692
|
* DCL contains the name and other information of the Commissioner’s manufacturer.
|
|
567
693
|
*/
|
|
568
694
|
async #certificates() {
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
695
|
+
const { nocsrElements, attestationSignature: csrSignature } = await this.#invokeCommand(
|
|
696
|
+
{
|
|
697
|
+
endpoint: RootEndpointNumber,
|
|
698
|
+
cluster: OperationalCredentials.Complete,
|
|
699
|
+
command: "csrRequest",
|
|
700
|
+
fields: { csrNonce: this.fabric.crypto.randomBytes(32) }
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
useExtendedFailSafeMessageResponseTimeout: true
|
|
704
|
+
}
|
|
573
705
|
);
|
|
574
706
|
if (nocsrElements.byteLength === 0 || csrSignature.byteLength === 0) {
|
|
575
707
|
throw new UnexpectedDataError("Invalid response from device");
|
|
576
708
|
}
|
|
577
709
|
const { certSigningRequest } = TlvCertSigningRequest.decode(nocsrElements);
|
|
578
710
|
const operationalPublicKey = await Certificate.getPublicKeyFromCsr(this.ca.crypto, certSigningRequest);
|
|
579
|
-
await
|
|
711
|
+
await this.#invokeCommand(
|
|
580
712
|
{
|
|
581
|
-
|
|
713
|
+
endpoint: RootEndpointNumber,
|
|
714
|
+
cluster: OperationalCredentials.Complete,
|
|
715
|
+
command: "addTrustedRootCertificate",
|
|
716
|
+
fields: {
|
|
717
|
+
rootCaCertificate: this.ca.rootCert
|
|
718
|
+
}
|
|
582
719
|
},
|
|
583
|
-
{
|
|
720
|
+
{
|
|
721
|
+
useExtendedFailSafeMessageResponseTimeout: true
|
|
722
|
+
}
|
|
584
723
|
);
|
|
585
724
|
const peerOperationalCert = await this.ca.generateNoc(
|
|
586
725
|
operationalPublicKey,
|
|
587
726
|
this.fabric.fabricId,
|
|
588
|
-
this.
|
|
727
|
+
this.interaction.address.nodeId
|
|
589
728
|
);
|
|
590
|
-
const addNocResponse = await
|
|
729
|
+
const addNocResponse = await this.#invokeCommand(
|
|
591
730
|
{
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
731
|
+
endpoint: RootEndpointNumber,
|
|
732
|
+
cluster: OperationalCredentials.Complete,
|
|
733
|
+
command: "addNoc",
|
|
734
|
+
fields: {
|
|
735
|
+
nocValue: peerOperationalCert,
|
|
736
|
+
icacValue: this.ca.icacCert ?? new Uint8Array(0),
|
|
737
|
+
ipkValue: this.fabric.identityProtectionKey,
|
|
738
|
+
adminVendorId: this.fabric.rootVendorId,
|
|
739
|
+
caseAdminSubject: this.fabric.rootNodeId
|
|
740
|
+
}
|
|
597
741
|
},
|
|
598
|
-
{
|
|
742
|
+
{
|
|
743
|
+
useExtendedFailSafeMessageResponseTimeout: true
|
|
744
|
+
}
|
|
599
745
|
);
|
|
600
746
|
this.#ensureOperationalCredentialsSuccess("addNoc", addNocResponse);
|
|
601
747
|
const { fabricIndex } = addNocResponse;
|
|
@@ -621,13 +767,17 @@ class ControllerCommissioningFlow {
|
|
|
621
767
|
breadcrumb: this.lastBreadcrumb
|
|
622
768
|
};
|
|
623
769
|
}
|
|
624
|
-
const operationalCredentialCluster = this.#getClusterClient(OperationalCredentials.Cluster);
|
|
625
770
|
try {
|
|
626
771
|
this.#ensureOperationalCredentialsSuccess(
|
|
627
772
|
"updateFabricLabel",
|
|
628
|
-
await
|
|
629
|
-
|
|
630
|
-
|
|
773
|
+
await this.#invokeCommand({
|
|
774
|
+
endpoint: RootEndpointNumber,
|
|
775
|
+
cluster: OperationalCredentials.Complete,
|
|
776
|
+
command: "updateFabricLabel",
|
|
777
|
+
fields: {
|
|
778
|
+
label: this.fabric.label,
|
|
779
|
+
fabricIndex
|
|
780
|
+
}
|
|
631
781
|
})
|
|
632
782
|
);
|
|
633
783
|
} catch (error) {
|
|
@@ -723,22 +873,32 @@ class ControllerCommissioningFlow {
|
|
|
723
873
|
}
|
|
724
874
|
}
|
|
725
875
|
logger.debug("Configuring WiFi network ...");
|
|
726
|
-
const networkCommissioningClusterClient = this.#getClusterClient(
|
|
727
|
-
NetworkCommissioning.Cluster.with("WiFiNetworkInterface"),
|
|
728
|
-
EndpointNumber(0),
|
|
729
|
-
true
|
|
730
|
-
);
|
|
731
876
|
const ssid = Bytes.fromString(this.commissioningOptions.wifiNetwork.wifiSsid);
|
|
732
877
|
const credentials = Bytes.fromString(this.commissioningOptions.wifiNetwork.wifiCredentials);
|
|
878
|
+
const [scanMaxTimeSeconds, connectMaxTimeSeconds] = await this.#readConcreteAttributeValues(
|
|
879
|
+
Read(
|
|
880
|
+
Read.Attribute({
|
|
881
|
+
endpoint: RootEndpointNumber,
|
|
882
|
+
cluster: NetworkCommissioning.Complete,
|
|
883
|
+
attributes: ["scanMaxTimeSeconds", "connectMaxTimeSeconds"]
|
|
884
|
+
})
|
|
885
|
+
)
|
|
886
|
+
);
|
|
733
887
|
if (this.collectedCommissioningData.supportsConcurrentConnection !== false) {
|
|
734
|
-
|
|
735
|
-
await this.#
|
|
736
|
-
const { networkingStatus, wiFiScanResults, debugText } = await networkCommissioningClusterClient.scanNetworks(
|
|
888
|
+
await this.#ensureFailsafeTimerFor(Seconds(scanMaxTimeSeconds));
|
|
889
|
+
const { networkingStatus, wiFiScanResults, debugText } = await this.#invokeCommand(
|
|
737
890
|
{
|
|
738
|
-
|
|
739
|
-
|
|
891
|
+
endpoint: RootEndpointNumber,
|
|
892
|
+
cluster: NetworkCommissioning.Complete,
|
|
893
|
+
command: "scanNetworks",
|
|
894
|
+
fields: {
|
|
895
|
+
ssid,
|
|
896
|
+
breadcrumb: this.lastBreadcrumb++
|
|
897
|
+
}
|
|
740
898
|
},
|
|
741
|
-
{
|
|
899
|
+
{
|
|
900
|
+
expectedProcessingTime: Seconds(scanMaxTimeSeconds)
|
|
901
|
+
}
|
|
742
902
|
);
|
|
743
903
|
if (networkingStatus !== NetworkCommissioning.NetworkCommissioningStatus.Success) {
|
|
744
904
|
throw new WifiNetworkSetupFailedError(`Commissionee failed to scan for WiFi networks: ${debugText}`);
|
|
@@ -753,13 +913,20 @@ class ControllerCommissioningFlow {
|
|
|
753
913
|
networkingStatus: addNetworkingStatus,
|
|
754
914
|
debugText: addDebugText,
|
|
755
915
|
networkIndex
|
|
756
|
-
} = await
|
|
916
|
+
} = await this.#invokeCommand(
|
|
757
917
|
{
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
918
|
+
endpoint: RootEndpointNumber,
|
|
919
|
+
cluster: NetworkCommissioning.Complete,
|
|
920
|
+
command: "addOrUpdateWiFiNetwork",
|
|
921
|
+
fields: {
|
|
922
|
+
ssid,
|
|
923
|
+
credentials,
|
|
924
|
+
breadcrumb: this.lastBreadcrumb++
|
|
925
|
+
}
|
|
761
926
|
},
|
|
762
|
-
{
|
|
927
|
+
{
|
|
928
|
+
useExtendedFailSafeMessageResponseTimeout: true
|
|
929
|
+
}
|
|
763
930
|
);
|
|
764
931
|
if (addNetworkingStatus !== NetworkCommissioning.NetworkCommissioningStatus.Success) {
|
|
765
932
|
throw new WifiNetworkSetupFailedError(`Commissionee failed to add WiFi network: ${addDebugText}`);
|
|
@@ -770,7 +937,15 @@ class ControllerCommissioningFlow {
|
|
|
770
937
|
logger.debug(
|
|
771
938
|
`Commissionee added WiFi network ${this.commissioningOptions.wifiNetwork.wifiSsid} with network index ${networkIndex}`
|
|
772
939
|
);
|
|
773
|
-
const updatedNetworks = await
|
|
940
|
+
const [updatedNetworks] = await this.#readConcreteAttributeValues(
|
|
941
|
+
Read(
|
|
942
|
+
Read.Attribute({
|
|
943
|
+
endpoint: RootEndpointNumber,
|
|
944
|
+
cluster: NetworkCommissioning.Complete,
|
|
945
|
+
attributes: ["networks"]
|
|
946
|
+
})
|
|
947
|
+
)
|
|
948
|
+
);
|
|
774
949
|
if (updatedNetworks[networkIndex] === void 0) {
|
|
775
950
|
throw new WifiNetworkSetupFailedError(`Commissionee did not return network with index ${networkIndex}`);
|
|
776
951
|
}
|
|
@@ -785,14 +960,20 @@ class ControllerCommissioningFlow {
|
|
|
785
960
|
breadcrumb: this.lastBreadcrumb
|
|
786
961
|
};
|
|
787
962
|
}
|
|
788
|
-
|
|
789
|
-
await this.#
|
|
790
|
-
const connectResult = await networkCommissioningClusterClient.connectNetwork(
|
|
963
|
+
await this.#ensureFailsafeTimerFor(Seconds(connectMaxTimeSeconds));
|
|
964
|
+
const connectResult = await this.#invokeCommand(
|
|
791
965
|
{
|
|
792
|
-
|
|
793
|
-
|
|
966
|
+
endpoint: RootEndpointNumber,
|
|
967
|
+
cluster: NetworkCommissioning.Complete,
|
|
968
|
+
command: "connectNetwork",
|
|
969
|
+
fields: {
|
|
970
|
+
networkId,
|
|
971
|
+
breadcrumb: this.lastBreadcrumb++
|
|
972
|
+
}
|
|
794
973
|
},
|
|
795
|
-
{
|
|
974
|
+
{
|
|
975
|
+
expectedProcessingTime: Seconds(connectMaxTimeSeconds)
|
|
976
|
+
}
|
|
796
977
|
);
|
|
797
978
|
if (connectResult.networkingStatus !== NetworkCommissioning.NetworkCommissioningStatus.Success) {
|
|
798
979
|
throw new WifiNetworkSetupFailedError(
|
|
@@ -849,17 +1030,29 @@ class ControllerCommissioningFlow {
|
|
|
849
1030
|
}
|
|
850
1031
|
}
|
|
851
1032
|
logger.debug("Configuring Thread network ...");
|
|
852
|
-
const
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
1033
|
+
const [scanMaxTimeSeconds, connectMaxTimeSeconds] = await this.#readConcreteAttributeValues(
|
|
1034
|
+
Read(
|
|
1035
|
+
Read.Attribute({
|
|
1036
|
+
endpoint: RootEndpointNumber,
|
|
1037
|
+
cluster: NetworkCommissioning.Complete,
|
|
1038
|
+
attributes: ["scanMaxTimeSeconds", "connectMaxTimeSeconds"]
|
|
1039
|
+
})
|
|
1040
|
+
)
|
|
856
1041
|
);
|
|
857
|
-
if (this.
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
{
|
|
1042
|
+
if (!this.commissioningOptions.threadNetwork?.networkName) {
|
|
1043
|
+
logger.info("Thread network name is not configured. Skip scanning for it.");
|
|
1044
|
+
} else if (this.collectedCommissioningData.supportsConcurrentConnection !== false) {
|
|
1045
|
+
await this.#ensureFailsafeTimerFor(Seconds(scanMaxTimeSeconds));
|
|
1046
|
+
const { networkingStatus, threadScanResults, debugText } = await this.#invokeCommand(
|
|
1047
|
+
{
|
|
1048
|
+
endpoint: RootEndpointNumber,
|
|
1049
|
+
cluster: NetworkCommissioning.Complete,
|
|
1050
|
+
command: "scanNetworks",
|
|
1051
|
+
fields: { breadcrumb: this.lastBreadcrumb++ }
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
expectedProcessingTime: Seconds(scanMaxTimeSeconds)
|
|
1055
|
+
}
|
|
863
1056
|
);
|
|
864
1057
|
if (networkingStatus !== NetworkCommissioning.NetworkCommissioningStatus.Success) {
|
|
865
1058
|
throw new ThreadNetworkSetupFailedError(
|
|
@@ -887,12 +1080,19 @@ class ControllerCommissioningFlow {
|
|
|
887
1080
|
networkingStatus: addNetworkingStatus,
|
|
888
1081
|
debugText: addDebugText,
|
|
889
1082
|
networkIndex
|
|
890
|
-
} = await
|
|
1083
|
+
} = await this.#invokeCommand(
|
|
891
1084
|
{
|
|
892
|
-
|
|
893
|
-
|
|
1085
|
+
endpoint: RootEndpointNumber,
|
|
1086
|
+
cluster: NetworkCommissioning.Complete,
|
|
1087
|
+
command: "addOrUpdateThreadNetwork",
|
|
1088
|
+
fields: {
|
|
1089
|
+
operationalDataset: Bytes.fromHex(this.commissioningOptions.threadNetwork.operationalDataset),
|
|
1090
|
+
breadcrumb: this.lastBreadcrumb++
|
|
1091
|
+
}
|
|
894
1092
|
},
|
|
895
|
-
{
|
|
1093
|
+
{
|
|
1094
|
+
useExtendedFailSafeMessageResponseTimeout: true
|
|
1095
|
+
}
|
|
896
1096
|
);
|
|
897
1097
|
if (addNetworkingStatus !== NetworkCommissioning.NetworkCommissioningStatus.Success) {
|
|
898
1098
|
throw new ThreadNetworkSetupFailedError(`Commissionee failed to add Thread network: ${addDebugText}`);
|
|
@@ -903,7 +1103,15 @@ class ControllerCommissioningFlow {
|
|
|
903
1103
|
logger.debug(
|
|
904
1104
|
`Commissionee added Thread network ${this.commissioningOptions.threadNetwork.networkName} with network index ${networkIndex}`
|
|
905
1105
|
);
|
|
906
|
-
const updatedNetworks = await
|
|
1106
|
+
const updatedNetworks = await this.#readConcreteAttributeValues(
|
|
1107
|
+
Read(
|
|
1108
|
+
Read.Attribute({
|
|
1109
|
+
endpoint: RootEndpointNumber,
|
|
1110
|
+
cluster: NetworkCommissioning.Complete,
|
|
1111
|
+
attributes: ["networks"]
|
|
1112
|
+
})
|
|
1113
|
+
)
|
|
1114
|
+
);
|
|
907
1115
|
if (updatedNetworks[networkIndex] === void 0) {
|
|
908
1116
|
throw new ThreadNetworkSetupFailedError(`Commissionee did not return network with index ${networkIndex}`);
|
|
909
1117
|
}
|
|
@@ -917,14 +1125,20 @@ class ControllerCommissioningFlow {
|
|
|
917
1125
|
breadcrumb: this.lastBreadcrumb
|
|
918
1126
|
};
|
|
919
1127
|
}
|
|
920
|
-
|
|
921
|
-
await this.#
|
|
922
|
-
const connectResult = await networkCommissioningClusterClient.connectNetwork(
|
|
1128
|
+
await this.#ensureFailsafeTimerFor(Seconds(connectMaxTimeSeconds));
|
|
1129
|
+
const connectResult = await this.#invokeCommand(
|
|
923
1130
|
{
|
|
924
|
-
|
|
925
|
-
|
|
1131
|
+
endpoint: RootEndpointNumber,
|
|
1132
|
+
cluster: NetworkCommissioning.Complete,
|
|
1133
|
+
command: "connectNetwork",
|
|
1134
|
+
fields: {
|
|
1135
|
+
networkId,
|
|
1136
|
+
breadcrumb: this.lastBreadcrumb++
|
|
1137
|
+
}
|
|
926
1138
|
},
|
|
927
|
-
{
|
|
1139
|
+
{
|
|
1140
|
+
expectedProcessingTime: Seconds(connectMaxTimeSeconds)
|
|
1141
|
+
}
|
|
928
1142
|
);
|
|
929
1143
|
if (connectResult.networkingStatus !== NetworkCommissioning.NetworkCommissioningStatus.Success) {
|
|
930
1144
|
throw new ThreadNetworkSetupFailedError(
|
|
@@ -974,7 +1188,7 @@ class ControllerCommissioningFlow {
|
|
|
974
1188
|
let transitionResult;
|
|
975
1189
|
try {
|
|
976
1190
|
transitionResult = await this.transitionToCase(
|
|
977
|
-
this.
|
|
1191
|
+
this.interaction.address,
|
|
978
1192
|
// Assume concurrent connections are supported if not know (which should not be the case when we came here)
|
|
979
1193
|
isConcurrentFlow
|
|
980
1194
|
);
|
|
@@ -989,7 +1203,7 @@ class ControllerCommissioningFlow {
|
|
|
989
1203
|
breadcrumb: this.lastBreadcrumb
|
|
990
1204
|
};
|
|
991
1205
|
}
|
|
992
|
-
this.
|
|
1206
|
+
this.interaction = transitionResult;
|
|
993
1207
|
this.#clusterClients.clear();
|
|
994
1208
|
logger.debug("Successfully reconnected with device ...");
|
|
995
1209
|
return {
|
|
@@ -1005,12 +1219,18 @@ class ControllerCommissioningFlow {
|
|
|
1005
1219
|
* the commissioning process.
|
|
1006
1220
|
*/
|
|
1007
1221
|
async #completeCommissioning() {
|
|
1008
|
-
const generalCommissioningClusterClient = this.#getClusterClient(GeneralCommissioning.Cluster);
|
|
1009
1222
|
this.#ensureGeneralCommissioningSuccess(
|
|
1010
1223
|
"commissioningComplete",
|
|
1011
|
-
await
|
|
1012
|
-
|
|
1013
|
-
|
|
1224
|
+
await this.#invokeCommand(
|
|
1225
|
+
{
|
|
1226
|
+
endpoint: RootEndpointNumber,
|
|
1227
|
+
cluster: GeneralCommissioning.Complete,
|
|
1228
|
+
command: "commissioningComplete"
|
|
1229
|
+
},
|
|
1230
|
+
{
|
|
1231
|
+
useExtendedFailSafeMessageResponseTimeout: true
|
|
1232
|
+
}
|
|
1233
|
+
)
|
|
1014
1234
|
);
|
|
1015
1235
|
this.#currentFailSafeEndTime = void 0;
|
|
1016
1236
|
return {
|
|
@@ -1020,8 +1240,6 @@ class ControllerCommissioningFlow {
|
|
|
1020
1240
|
}
|
|
1021
1241
|
}
|
|
1022
1242
|
export {
|
|
1023
|
-
CommissionableDeviceDiscoveryFailedError,
|
|
1024
|
-
CommissioningError,
|
|
1025
1243
|
CommissioningTimeoutError,
|
|
1026
1244
|
ControllerCommissioningFlow,
|
|
1027
1245
|
DeviceAlreadyCommissionedToThisFabricError,
|