@matter/node 0.16.0-alpha.0-20251212-4dde71be3 → 0.16.0-alpha.0-20251216-71c21f901
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/behavior/system/commissioning/CommissioningClient.d.ts +1 -1
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.js +31 -14
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.js.map +2 -2
- package/dist/cjs/behavior/system/network/ClientNetworkRuntime.d.ts.map +1 -1
- package/dist/cjs/behavior/system/network/ClientNetworkRuntime.js +12 -1
- package/dist/cjs/behavior/system/network/ClientNetworkRuntime.js.map +1 -1
- package/dist/cjs/behavior/system/network/NetworkClient.d.ts +8 -4
- package/dist/cjs/behavior/system/network/NetworkClient.d.ts.map +1 -1
- package/dist/cjs/behavior/system/network/NetworkClient.js +32 -4
- package/dist/cjs/behavior/system/network/NetworkClient.js.map +1 -1
- package/dist/cjs/endpoint/properties/Behaviors.d.ts.map +1 -1
- package/dist/cjs/endpoint/properties/Behaviors.js +31 -1
- package/dist/cjs/endpoint/properties/Behaviors.js.map +1 -1
- package/dist/cjs/node/ClientNode.d.ts +3 -3
- package/dist/cjs/node/ClientNode.d.ts.map +1 -1
- package/dist/cjs/node/ClientNode.js +5 -4
- package/dist/cjs/node/ClientNode.js.map +1 -1
- package/dist/cjs/node/Node.d.ts.map +1 -1
- package/dist/cjs/node/Node.js +14 -0
- package/dist/cjs/node/Node.js.map +1 -1
- package/dist/cjs/node/client/ClientNodeInteraction.d.ts +25 -6
- package/dist/cjs/node/client/ClientNodeInteraction.d.ts.map +1 -1
- package/dist/cjs/node/client/ClientNodeInteraction.js +45 -9
- package/dist/cjs/node/client/ClientNodeInteraction.js.map +1 -1
- package/dist/cjs/node/client/ClientStructure.d.ts +1 -1
- package/dist/cjs/node/client/ClientStructure.d.ts.map +1 -1
- package/dist/cjs/node/client/ClientStructure.js +4 -3
- package/dist/cjs/node/client/ClientStructure.js.map +1 -1
- package/dist/cjs/node/client/Peers.d.ts +6 -3
- package/dist/cjs/node/client/Peers.d.ts.map +1 -1
- package/dist/cjs/node/client/Peers.js +40 -15
- package/dist/cjs/node/client/Peers.js.map +2 -2
- package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts +1 -1
- package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
- package/dist/esm/behavior/system/commissioning/CommissioningClient.js +32 -14
- package/dist/esm/behavior/system/commissioning/CommissioningClient.js.map +2 -2
- package/dist/esm/behavior/system/network/ClientNetworkRuntime.d.ts.map +1 -1
- package/dist/esm/behavior/system/network/ClientNetworkRuntime.js +21 -2
- package/dist/esm/behavior/system/network/ClientNetworkRuntime.js.map +1 -1
- package/dist/esm/behavior/system/network/NetworkClient.d.ts +8 -4
- package/dist/esm/behavior/system/network/NetworkClient.d.ts.map +1 -1
- package/dist/esm/behavior/system/network/NetworkClient.js +33 -5
- package/dist/esm/behavior/system/network/NetworkClient.js.map +1 -1
- package/dist/esm/endpoint/properties/Behaviors.d.ts.map +1 -1
- package/dist/esm/endpoint/properties/Behaviors.js +31 -1
- package/dist/esm/endpoint/properties/Behaviors.js.map +1 -1
- package/dist/esm/node/ClientNode.d.ts +3 -3
- package/dist/esm/node/ClientNode.d.ts.map +1 -1
- package/dist/esm/node/ClientNode.js +5 -4
- package/dist/esm/node/ClientNode.js.map +1 -1
- package/dist/esm/node/Node.d.ts.map +1 -1
- package/dist/esm/node/Node.js +16 -1
- package/dist/esm/node/Node.js.map +1 -1
- package/dist/esm/node/client/ClientNodeInteraction.d.ts +25 -6
- package/dist/esm/node/client/ClientNodeInteraction.d.ts.map +1 -1
- package/dist/esm/node/client/ClientNodeInteraction.js +47 -10
- package/dist/esm/node/client/ClientNodeInteraction.js.map +1 -1
- package/dist/esm/node/client/ClientStructure.d.ts +1 -1
- package/dist/esm/node/client/ClientStructure.d.ts.map +1 -1
- package/dist/esm/node/client/ClientStructure.js +4 -3
- package/dist/esm/node/client/ClientStructure.js.map +1 -1
- package/dist/esm/node/client/Peers.d.ts +6 -3
- package/dist/esm/node/client/Peers.d.ts.map +1 -1
- package/dist/esm/node/client/Peers.js +49 -16
- package/dist/esm/node/client/Peers.js.map +2 -2
- package/package.json +7 -7
- package/src/behavior/system/commissioning/CommissioningClient.ts +32 -10
- package/src/behavior/system/network/ClientNetworkRuntime.ts +20 -2
- package/src/behavior/system/network/NetworkClient.ts +39 -8
- package/src/endpoint/properties/Behaviors.ts +39 -1
- package/src/endpoint/properties/Commands.ts +1 -1
- package/src/node/ClientNode.ts +10 -4
- package/src/node/Node.ts +17 -0
- package/src/node/client/ClientNodeInteraction.ts +65 -16
- package/src/node/client/ClientStructure.ts +13 -5
- package/src/node/client/Peers.ts +56 -19
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/node/client/Peers.ts"],
|
|
4
|
-
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AACjC,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AAEpC,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AACvC,SAAS,oCAAoC;AAE7C,SAAS,yBAAyB;AAElC;AAAA,EAEI;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,
|
|
5
|
-
"names": ["freshestExp"]
|
|
4
|
+
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AACjC,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AAEpC,S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,UAAU,SAAS,gBAAgB,QAAQ,SAAS,GAAG,KAAK,YAAY;AAAA,EACnF;AACA,SAAO;AACX;",
|
|
5
|
+
"names": ["id", "freshestExp"]
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matter/node",
|
|
3
|
-
"version": "0.16.0-alpha.0-
|
|
3
|
+
"version": "0.16.0-alpha.0-20251216-71c21f901",
|
|
4
4
|
"description": "API for building Matter nodes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"iot",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"#*": "./src/*"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@matter/general": "0.16.0-alpha.0-
|
|
46
|
-
"@matter/model": "0.16.0-alpha.0-
|
|
47
|
-
"@matter/types": "0.16.0-alpha.0-
|
|
48
|
-
"@matter/protocol": "0.16.0-alpha.0-
|
|
45
|
+
"@matter/general": "0.16.0-alpha.0-20251216-71c21f901",
|
|
46
|
+
"@matter/model": "0.16.0-alpha.0-20251216-71c21f901",
|
|
47
|
+
"@matter/types": "0.16.0-alpha.0-20251216-71c21f901",
|
|
48
|
+
"@matter/protocol": "0.16.0-alpha.0-20251216-71c21f901"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@matter/tools": "0.16.0-alpha.0-
|
|
52
|
-
"@matter/testing": "0.16.0-alpha.0-
|
|
51
|
+
"@matter/tools": "0.16.0-alpha.0-20251216-71c21f901",
|
|
52
|
+
"@matter/testing": "0.16.0-alpha.0-20251216-71c21f901"
|
|
53
53
|
},
|
|
54
54
|
"files": [
|
|
55
55
|
"dist/**/*",
|
|
@@ -38,7 +38,6 @@ import {
|
|
|
38
38
|
vendorId,
|
|
39
39
|
} from "#model";
|
|
40
40
|
import type { ClientNode } from "#node/ClientNode.js";
|
|
41
|
-
import type { Node } from "#node/Node.js";
|
|
42
41
|
import { IdentityService } from "#node/server/IdentityService.js";
|
|
43
42
|
import {
|
|
44
43
|
CommissioningMode,
|
|
@@ -49,6 +48,7 @@ import {
|
|
|
49
48
|
FabricAuthority,
|
|
50
49
|
FabricManager,
|
|
51
50
|
LocatedNodeCommissioningOptions,
|
|
51
|
+
PeerAddress,
|
|
52
52
|
PeerSet,
|
|
53
53
|
PeerAddress as ProtocolPeerAddress,
|
|
54
54
|
SessionIntervals as ProtocolSessionIntervals,
|
|
@@ -93,11 +93,24 @@ export class CommissioningClient extends Behavior {
|
|
|
93
93
|
this.state.discoveredAt = Time.nowMs;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
if (this.state.peerAddress !== undefined) {
|
|
97
|
+
// If restored from the storage ensure we have the proper logging sugar, else it is "just" an object
|
|
98
|
+
this.state.peerAddress = PeerAddress(this.state.peerAddress);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const node = this.endpoint as ClientNode;
|
|
102
|
+
this.reactTo(node.lifecycle.partsReady, this.#initializeNode);
|
|
103
|
+
this.reactTo(node.lifecycle.online, this.#nodeOnline);
|
|
97
104
|
this.reactTo(this.events.peerAddress$Changed, this.#peerAddressChanged);
|
|
98
105
|
}
|
|
99
106
|
|
|
100
|
-
|
|
107
|
+
#nodeOnline() {
|
|
108
|
+
if (this.state.peerAddress !== undefined) {
|
|
109
|
+
this.#updateAddresses(this.state.peerAddress);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
commission(passcode: number | string): Promise<ClientNode>;
|
|
101
114
|
|
|
102
115
|
commission(options: CommissioningClient.CommissioningOptions): Promise<ClientNode>;
|
|
103
116
|
|
|
@@ -268,17 +281,26 @@ export class CommissioningClient extends Behavior {
|
|
|
268
281
|
endpoint.lifecycle.initialized.emit(this.state.peerAddress !== undefined);
|
|
269
282
|
}
|
|
270
283
|
|
|
284
|
+
#updateAddresses(addr: ProtocolPeerAddress) {
|
|
285
|
+
const node = this.endpoint as ClientNode;
|
|
286
|
+
if (!node.env.has(PeerSet)) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const peer = node.env.get(PeerSet).for(addr);
|
|
291
|
+
if (peer) {
|
|
292
|
+
if (peer.descriptor.operationalAddress) {
|
|
293
|
+
this.state.addresses = [peer.descriptor.operationalAddress];
|
|
294
|
+
}
|
|
295
|
+
this.descriptor = peer.descriptor.discoveryData;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
271
299
|
#peerAddressChanged(addr?: ProtocolPeerAddress) {
|
|
272
300
|
const node = this.endpoint as ClientNode;
|
|
273
301
|
|
|
274
302
|
if (addr) {
|
|
275
|
-
|
|
276
|
-
if (peer) {
|
|
277
|
-
if (peer.descriptor.operationalAddress) {
|
|
278
|
-
this.state.addresses = [peer.descriptor.operationalAddress];
|
|
279
|
-
}
|
|
280
|
-
this.descriptor = peer.descriptor.discoveryData;
|
|
281
|
-
}
|
|
303
|
+
this.#updateAddresses(addr);
|
|
282
304
|
|
|
283
305
|
node.lifecycle.commissioned.emit(this.context);
|
|
284
306
|
} else {
|
|
@@ -6,7 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
import { InternalError, Logger, MatterError, ObserverGroup } from "#general";
|
|
8
8
|
import type { ClientNode } from "#node/ClientNode.js";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
ClientInteraction,
|
|
11
|
+
ExchangeProvider,
|
|
12
|
+
InteractionQueue,
|
|
13
|
+
PeerAddress,
|
|
14
|
+
PeerSet,
|
|
15
|
+
QueuedClientInteraction,
|
|
16
|
+
SessionManager,
|
|
17
|
+
} from "#protocol";
|
|
10
18
|
import { CommissioningClient } from "../commissioning/CommissioningClient.js";
|
|
11
19
|
import { RemoteDescriptor } from "../commissioning/RemoteDescriptor.js";
|
|
12
20
|
import { NetworkRuntime } from "./NetworkRuntime.js";
|
|
@@ -21,6 +29,7 @@ const logger = Logger.get("ClientNetworkRuntime");
|
|
|
21
29
|
*/
|
|
22
30
|
export class ClientNetworkRuntime extends NetworkRuntime {
|
|
23
31
|
#client?: ClientInteraction;
|
|
32
|
+
#queuedClient?: QueuedClientInteraction;
|
|
24
33
|
#observers = new ObserverGroup();
|
|
25
34
|
|
|
26
35
|
constructor(owner: ClientNode) {
|
|
@@ -54,7 +63,9 @@ export class ClientNetworkRuntime extends NetworkRuntime {
|
|
|
54
63
|
const networkState = this.owner.state.network;
|
|
55
64
|
|
|
56
65
|
const exchangeProvider = await peers.exchangeProviderFor(address, {
|
|
57
|
-
discoveryOptions: {
|
|
66
|
+
discoveryOptions: {
|
|
67
|
+
discoveryData: RemoteDescriptor.fromLongForm(commissioningState),
|
|
68
|
+
},
|
|
58
69
|
caseAuthenticatedTags: networkState.caseAuthenticatedTags
|
|
59
70
|
? [...networkState.caseAuthenticatedTags] // needed because the tags are readonly
|
|
60
71
|
: undefined,
|
|
@@ -63,6 +74,12 @@ export class ClientNetworkRuntime extends NetworkRuntime {
|
|
|
63
74
|
|
|
64
75
|
this.#client = new ClientInteraction({ environment: env, abort: this.abortSignal });
|
|
65
76
|
env.set(ClientInteraction, this.#client);
|
|
77
|
+
this.#queuedClient = new QueuedClientInteraction({
|
|
78
|
+
environment: env,
|
|
79
|
+
abort: this.abortSignal,
|
|
80
|
+
queue: env.get(InteractionQueue), // created and owned by Peers
|
|
81
|
+
});
|
|
82
|
+
env.set(QueuedClientInteraction, this.#queuedClient);
|
|
66
83
|
|
|
67
84
|
// Monitor sessions to maintain online state. We consider the node "online" if there is an active session. If
|
|
68
85
|
// not, we consider the node offline. This is the only real way we have of determining whether the node is
|
|
@@ -108,6 +125,7 @@ export class ClientNetworkRuntime extends NetworkRuntime {
|
|
|
108
125
|
await this.construction;
|
|
109
126
|
|
|
110
127
|
this.owner.env.delete(ClientInteraction, this.#client);
|
|
128
|
+
this.owner.env.delete(QueuedClientInteraction, this.#queuedClient);
|
|
111
129
|
|
|
112
130
|
try {
|
|
113
131
|
await this.#client?.close();
|
|
@@ -8,9 +8,10 @@ import { RemoteDescriptor } from "#behavior/system/commissioning/RemoteDescripto
|
|
|
8
8
|
import { BasicInformationClient } from "#behaviors/basic-information";
|
|
9
9
|
import { Observable, ServerAddress, ServerAddressUdp } from "#general";
|
|
10
10
|
import { DatatypeModel, FieldElement } from "#model";
|
|
11
|
+
import { ClientNodeInteraction } from "#node/client/ClientNodeInteraction.js";
|
|
11
12
|
import type { ClientNode } from "#node/ClientNode.js";
|
|
12
13
|
import { Node } from "#node/Node.js";
|
|
13
|
-
import {
|
|
14
|
+
import { ClientSubscription, PeerSet, Subscribe, SustainedSubscription } from "#protocol";
|
|
14
15
|
import { CaseAuthenticatedTag, EventNumber } from "#types";
|
|
15
16
|
import { ClientNetworkRuntime } from "./ClientNetworkRuntime.js";
|
|
16
17
|
import { NetworkBehavior } from "./NetworkBehavior.js";
|
|
@@ -86,18 +87,45 @@ export class NetworkClient extends NetworkBehavior {
|
|
|
86
87
|
|
|
87
88
|
// First, read. This allows us to retrieve attributes that do not support subscription and gives us
|
|
88
89
|
// physical device information required to optimize subscription parameters
|
|
89
|
-
for await (const _chunk of this.#node.interaction.read(
|
|
90
|
+
for await (const _chunk of this.#node.interaction.read({
|
|
91
|
+
...subscribe,
|
|
92
|
+
eventFilters: undefined,
|
|
93
|
+
eventRequests: undefined,
|
|
94
|
+
}));
|
|
90
95
|
|
|
91
96
|
// Now subscribe for subsequent updates
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
97
|
+
this.internal.activeSubscription = await (this.#node.interaction as ClientNodeInteraction).subscribe({
|
|
98
|
+
sustain: true,
|
|
99
|
+
...subscribe,
|
|
100
|
+
eventFilters: [{ eventMin: this.state.maxEventNumber + 1n }],
|
|
101
|
+
updated: async update => {
|
|
102
|
+
// Read over all changes
|
|
103
|
+
for await (const _chunk of update);
|
|
104
|
+
this.events.subscriptionAlive.emit(); // Inform that subscription is alive
|
|
105
|
+
},
|
|
106
|
+
closed: () => {
|
|
107
|
+
if (!(this.internal.activeSubscription instanceof SustainedSubscription)) {
|
|
108
|
+
this.events.subscriptionStatusChanged.emit(false);
|
|
109
|
+
}
|
|
110
|
+
this.internal.activeSubscription = undefined;
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
if (this.internal.activeSubscription instanceof SustainedSubscription) {
|
|
114
|
+
this.internal.activeSubscription.active.on(() => this.events.subscriptionStatusChanged.emit(true));
|
|
115
|
+
this.internal.activeSubscription.inactive.on(() => this.events.subscriptionStatusChanged.emit(false));
|
|
116
|
+
}
|
|
95
117
|
} else {
|
|
96
118
|
this.internal.activeSubscription?.close();
|
|
97
119
|
this.internal.activeSubscription = undefined;
|
|
98
120
|
}
|
|
99
121
|
}
|
|
100
122
|
|
|
123
|
+
override async [Symbol.asyncDispose]() {
|
|
124
|
+
// Clean up any active subscription
|
|
125
|
+
this.internal.activeSubscription?.close();
|
|
126
|
+
this.internal.activeSubscription = undefined;
|
|
127
|
+
}
|
|
128
|
+
|
|
101
129
|
get #node() {
|
|
102
130
|
return this.env.get(Node) as ClientNode;
|
|
103
131
|
}
|
|
@@ -162,20 +190,21 @@ export namespace NetworkClient {
|
|
|
162
190
|
/**
|
|
163
191
|
* The active default subscription.
|
|
164
192
|
*/
|
|
165
|
-
activeSubscription?:
|
|
193
|
+
activeSubscription?: ClientSubscription;
|
|
166
194
|
}
|
|
167
195
|
|
|
168
196
|
export class State extends NetworkBehavior.State {
|
|
169
197
|
/**
|
|
170
198
|
* This subscription defines the default set of attributes and events to which the node will automatically
|
|
171
|
-
* subscribe when started, if autoSubscribe is true.
|
|
199
|
+
* subscribe when started, if autoSubscribe is true. Alternatively, also just Subscribe.Options can be provided
|
|
200
|
+
* to adjust chosen default subscription parameters (see below).
|
|
172
201
|
*
|
|
173
202
|
* The default subscription is a wildcard for all attributes of the node. You can set to undefined or filter
|
|
174
203
|
* the fields and values but only values selected by this subscription will update automatically.
|
|
175
204
|
*
|
|
176
205
|
* The default subscription updates automatically if you change this property.
|
|
177
206
|
*/
|
|
178
|
-
defaultSubscription?: Subscribe;
|
|
207
|
+
defaultSubscription?: Subscribe | Subscribe.Options;
|
|
179
208
|
|
|
180
209
|
/**
|
|
181
210
|
* Represents the current operational network state of the node. When true the node is enabled and operational.
|
|
@@ -213,5 +242,7 @@ export namespace NetworkClient {
|
|
|
213
242
|
export class Events extends NetworkBehavior.Events {
|
|
214
243
|
autoSubscribe$Changed = new Observable<[value: boolean, oldValue: boolean]>();
|
|
215
244
|
defaultSubscription$Changed = new Observable<[value: Subscribe | undefined, oldValue: Subscribe | undefined]>();
|
|
245
|
+
subscriptionStatusChanged = new Observable<[isActive: boolean]>();
|
|
246
|
+
subscriptionAlive = new Observable<[]>();
|
|
216
247
|
}
|
|
217
248
|
}
|
|
@@ -13,9 +13,11 @@ import { Events } from "#behavior/Events.js";
|
|
|
13
13
|
import { BehaviorBacking } from "#behavior/internal/BehaviorBacking.js";
|
|
14
14
|
import { Datasource } from "#behavior/state/managed/Datasource.js";
|
|
15
15
|
import {
|
|
16
|
+
BasicObservable,
|
|
16
17
|
camelize,
|
|
17
18
|
Construction,
|
|
18
19
|
describeList,
|
|
20
|
+
DetachedObservers,
|
|
19
21
|
Diagnostic,
|
|
20
22
|
EventEmitter,
|
|
21
23
|
Immutable,
|
|
@@ -56,6 +58,7 @@ export class Behaviors {
|
|
|
56
58
|
#events: Record<string, EventEmitter> = {};
|
|
57
59
|
#options: Record<string, object | undefined>;
|
|
58
60
|
#protocol?: ProtocolService;
|
|
61
|
+
#detachedObservers?: Record<string, DetachedObservers>;
|
|
59
62
|
|
|
60
63
|
/**
|
|
61
64
|
* The {@link SupportedBehaviors} of the {@link Endpoint}.
|
|
@@ -508,10 +511,31 @@ export class Behaviors {
|
|
|
508
511
|
if (backing) {
|
|
509
512
|
logger.warn(`Removing ${backing} from active endpoint`);
|
|
510
513
|
promise = backing.close();
|
|
514
|
+
delete this.#backings[id];
|
|
511
515
|
}
|
|
512
516
|
|
|
513
517
|
this.#endpoint.lifecycle.change(EndpointLifecycle.Change.ServersChanged);
|
|
514
518
|
|
|
519
|
+
// Detach observers for reuse if present
|
|
520
|
+
const events = this.#events[id];
|
|
521
|
+
if (events) {
|
|
522
|
+
let detachedObservers: undefined | Record<string, DetachedObservers>;
|
|
523
|
+
|
|
524
|
+
for (const key in events) {
|
|
525
|
+
const observable = (events as unknown as Record<string, BasicObservable | undefined>)[key];
|
|
526
|
+
if (observable && "detachObservers" in observable) {
|
|
527
|
+
const detached = observable.detachObservers();
|
|
528
|
+
if (detached) {
|
|
529
|
+
(detachedObservers ??= {})[key] = detached;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
if (detachedObservers) {
|
|
535
|
+
(this.#detachedObservers ??= {})[id] = detachedObservers;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
515
539
|
return promise;
|
|
516
540
|
}
|
|
517
541
|
|
|
@@ -664,7 +688,7 @@ export class Behaviors {
|
|
|
664
688
|
const backing = this.#backingFor(type);
|
|
665
689
|
return backing.construction.ready;
|
|
666
690
|
},
|
|
667
|
-
{
|
|
691
|
+
{ lifetime: this.#endpoint.construction },
|
|
668
692
|
);
|
|
669
693
|
|
|
670
694
|
if (MaybePromise.is(result)) {
|
|
@@ -766,6 +790,20 @@ export class Behaviors {
|
|
|
766
790
|
Object.defineProperty(this.#endpoint.state, type.schema.id, { get, configurable: true });
|
|
767
791
|
}
|
|
768
792
|
|
|
793
|
+
// When replacing a behavior, transplant listeners from previous incarnation if present
|
|
794
|
+
const detachedObservers = this.#detachedObservers?.[type.id];
|
|
795
|
+
if (detachedObservers) {
|
|
796
|
+
delete this.#detachedObservers![type.id];
|
|
797
|
+
const newEvents = new Events();
|
|
798
|
+
for (const key in detachedObservers) {
|
|
799
|
+
const newEvent = (newEvents as unknown as Record<string, BasicObservable | undefined>)[key];
|
|
800
|
+
if (newEvent && "attachObservers" in newEvent) {
|
|
801
|
+
newEvent.attachObservers(detachedObservers);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
this.#events[id] = newEvents;
|
|
805
|
+
}
|
|
806
|
+
|
|
769
807
|
Object.defineProperty(this.#endpoint.events, id, {
|
|
770
808
|
get: () => {
|
|
771
809
|
let events = this.#events[id];
|
|
@@ -65,7 +65,7 @@ function Implementation(endpoint: Endpoint, type: Behavior.Type, name: string):
|
|
|
65
65
|
return Promise.resolve(context2.reject(e));
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
// Create function to perform invocation
|
|
68
|
+
// Create a function to perform invocation
|
|
69
69
|
function invokerFor(context: ActionContext) {
|
|
70
70
|
const agent = endpoint.agentFor(context);
|
|
71
71
|
const behavior = agent.get(type);
|
package/src/node/ClientNode.ts
CHANGED
|
@@ -79,8 +79,9 @@ export class ClientNode extends Node<ClientNode.RootEndpoint> {
|
|
|
79
79
|
return this.env.get(ServerNodeStore).clientStores.storeForNode(this);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
override initialize() {
|
|
82
|
+
override async initialize() {
|
|
83
83
|
const store = this.store;
|
|
84
|
+
await store.construction;
|
|
84
85
|
|
|
85
86
|
this.env.set(ClientNodeStore, store);
|
|
86
87
|
|
|
@@ -91,7 +92,7 @@ export class ClientNode extends Node<ClientNode.RootEndpoint> {
|
|
|
91
92
|
|
|
92
93
|
initializer.structure.loadCache();
|
|
93
94
|
|
|
94
|
-
|
|
95
|
+
await super.initialize();
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
override get owner(): ServerNode | undefined {
|
|
@@ -113,7 +114,7 @@ export class ClientNode extends Node<ClientNode.RootEndpoint> {
|
|
|
113
114
|
* Remove this node from the fabric (if commissioned) and locally.
|
|
114
115
|
* This method tries to communicate with the device to decommission it properly and will fail if the device is
|
|
115
116
|
* unreachable.
|
|
116
|
-
* If you
|
|
117
|
+
* If you cannot reach the device, use {@link delete} instead.
|
|
117
118
|
*/
|
|
118
119
|
async decommission() {
|
|
119
120
|
this.lifecycle.change(EndpointLifecycle.Change.Destroying);
|
|
@@ -129,11 +130,16 @@ export class ClientNode extends Node<ClientNode.RootEndpoint> {
|
|
|
129
130
|
/**
|
|
130
131
|
* Force-remove the node without first decommissioning.
|
|
131
132
|
*
|
|
132
|
-
* If the node is still available you should use {@link decommission} to remove it properly from the fabric and only use
|
|
133
|
+
* If the node is still available, you should use {@link decommission} to remove it properly from the fabric and only use
|
|
133
134
|
* this method as fallback. You should also tell the user that he needs to manually factory-reset the device.
|
|
134
135
|
*/
|
|
135
136
|
override async delete() {
|
|
137
|
+
// TODO If we know a peer address, get the Peer for it to delete it as well
|
|
138
|
+
//const peerAddress = this.behaviors.maybeStateOf("commissioning")?.peerAddress as PeerAddress | undefined;
|
|
139
|
+
//const peer = peerAddress !== undefined ? this.owner?.env.get(PeerSet).for(peerAddress) : undefined;
|
|
140
|
+
|
|
136
141
|
await super.delete();
|
|
142
|
+
//await peer?.delete();
|
|
137
143
|
}
|
|
138
144
|
|
|
139
145
|
override async erase() {
|
package/src/node/Node.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
Identity,
|
|
24
24
|
ImplementationError,
|
|
25
25
|
Logger,
|
|
26
|
+
MatterError,
|
|
26
27
|
} from "#general";
|
|
27
28
|
import { Interactable } from "#protocol";
|
|
28
29
|
import type { EndpointNumber } from "#types";
|
|
@@ -107,6 +108,9 @@ export abstract class Node<T extends Node.CommonRootEndpoint = Node.CommonRootEn
|
|
|
107
108
|
this.lifecycle.targetState = "online";
|
|
108
109
|
|
|
109
110
|
await this.lifecycle.mutex.produce(this.startWithMutex.bind(this));
|
|
111
|
+
} catch (error) {
|
|
112
|
+
this.lifecycle.targetState = "offline";
|
|
113
|
+
throw error;
|
|
110
114
|
} finally {
|
|
111
115
|
this.#startInProgress = false;
|
|
112
116
|
}
|
|
@@ -130,6 +134,19 @@ export abstract class Node<T extends Node.CommonRootEndpoint = Node.CommonRootEn
|
|
|
130
134
|
await this.#runtime.construction.ready;
|
|
131
135
|
await this.act("network startup", agent => agent.get(NetworkBehavior).startup());
|
|
132
136
|
} catch (e) {
|
|
137
|
+
// If a runtime instance got created, tear it down
|
|
138
|
+
if (this.#runtime) {
|
|
139
|
+
this.#environment.delete(NetworkRuntime, this.#runtime);
|
|
140
|
+
try {
|
|
141
|
+
await this.#runtime.close();
|
|
142
|
+
} catch (error) {
|
|
143
|
+
MatterError.accept(error);
|
|
144
|
+
// Ignore all errors that might, likely we cannot tear down because construction never completed
|
|
145
|
+
logger.info("Failed to tear down runtime", error.message);
|
|
146
|
+
}
|
|
147
|
+
this.#runtime = undefined;
|
|
148
|
+
this.behaviors.internalsOf(NetworkBehavior).runtime = undefined;
|
|
149
|
+
}
|
|
133
150
|
this.env.runtime.delete(this);
|
|
134
151
|
throw e;
|
|
135
152
|
}
|
|
@@ -11,16 +11,19 @@ import { NodePhysicalProperties } from "#node/NodePhysicalProperties.js";
|
|
|
11
11
|
import {
|
|
12
12
|
ClientInteraction,
|
|
13
13
|
ClientInvoke,
|
|
14
|
+
ClientRead,
|
|
14
15
|
ClientSubscribe,
|
|
16
|
+
ClientSubscription,
|
|
17
|
+
ClientWrite,
|
|
15
18
|
DecodedInvokeResult,
|
|
16
19
|
Interactable,
|
|
17
20
|
PhysicalDeviceProperties,
|
|
18
|
-
|
|
21
|
+
QueuedClientInteraction,
|
|
19
22
|
ReadResult,
|
|
20
|
-
|
|
21
|
-
Write,
|
|
23
|
+
Val,
|
|
22
24
|
WriteResult,
|
|
23
25
|
} from "#protocol";
|
|
26
|
+
import { EndpointNumber } from "#types";
|
|
24
27
|
import { ClientEndpointInitializer } from "./ClientEndpointInitializer.js";
|
|
25
28
|
|
|
26
29
|
/**
|
|
@@ -28,6 +31,7 @@ import { ClientEndpointInitializer } from "./ClientEndpointInitializer.js";
|
|
|
28
31
|
*/
|
|
29
32
|
export class ClientNodeInteraction implements Interactable<ActionContext> {
|
|
30
33
|
#node: ClientNode;
|
|
34
|
+
#physicalProps?: PhysicalDeviceProperties;
|
|
31
35
|
|
|
32
36
|
constructor(node: ClientNode) {
|
|
33
37
|
this.#node = node;
|
|
@@ -42,15 +46,27 @@ export class ClientNodeInteraction implements Interactable<ActionContext> {
|
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
|
|
49
|
+
get physicalProperties() {
|
|
50
|
+
if (this.#physicalProps === undefined) {
|
|
51
|
+
this.#physicalProps = NodePhysicalProperties(this.#node);
|
|
52
|
+
this.structure.changed.on(() => {
|
|
53
|
+
// When structure changes, physical properties may change, so clear cached value to recompute on the next access
|
|
54
|
+
this.#physicalProps = undefined;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return this.#physicalProps;
|
|
58
|
+
}
|
|
59
|
+
|
|
45
60
|
/**
|
|
46
61
|
* Read chosen attributes remotely from the node. Known data versions are automatically injected into the request to
|
|
47
62
|
* optimize the read.
|
|
48
63
|
* Therefore, the returned data only contains attributes that have changed since the last read or subscription.
|
|
49
|
-
* TODO: Allow control of data version injection and enrich response with attribute data missing in response due to data versioning
|
|
64
|
+
* TODO: Allow control of data version injection and enrich response with attribute data missing in response due to data versioning?
|
|
50
65
|
*/
|
|
51
|
-
async *read(request:
|
|
66
|
+
async *read(request: ClientRead, context?: ActionContext): ReadResult {
|
|
52
67
|
request = this.structure.injectVersionFilters(request);
|
|
53
68
|
const interaction = await this.#connect();
|
|
69
|
+
|
|
54
70
|
const response = interaction.read(request, context);
|
|
55
71
|
yield* this.structure.mutate(request, response);
|
|
56
72
|
}
|
|
@@ -60,21 +76,24 @@ export class ClientNodeInteraction implements Interactable<ActionContext> {
|
|
|
60
76
|
*
|
|
61
77
|
* matter.js updates local state
|
|
62
78
|
*
|
|
63
|
-
* By default matter.js subscribes to all attributes and events of the peer and updates {@link ClientNode} state
|
|
79
|
+
* By default, matter.js subscribes to all attributes and events of the peer and updates {@link ClientNode} state
|
|
64
80
|
* automatically. So you normally do not need to subscribe manually.
|
|
81
|
+
*
|
|
82
|
+
* When providing the "sustain" flag, a SustainedSubscription is returned immediately. You need to use the events to
|
|
83
|
+
* know when/if a subscription could be established. This class handles reconnections automatically.
|
|
84
|
+
* When not providing the "sustain" flag, a PeerSubscription is returned after a subscription have been successfully
|
|
85
|
+
* established; or an error is returned if this was not possible.
|
|
65
86
|
*/
|
|
66
|
-
async subscribe(request: ClientSubscribe, context?: ActionContext):
|
|
67
|
-
const physicalProps = NodePhysicalProperties(this.#node);
|
|
68
|
-
|
|
87
|
+
async subscribe(request: ClientSubscribe, context?: ActionContext): Promise<ClientSubscription> {
|
|
69
88
|
const intermediateRequest: ClientSubscribe = {
|
|
70
89
|
...this.structure.injectVersionFilters(request),
|
|
71
90
|
...PhysicalDeviceProperties.subscriptionIntervalBoundsFor({
|
|
72
91
|
description: this.#node.toString(),
|
|
73
|
-
properties:
|
|
92
|
+
properties: this.physicalProperties,
|
|
74
93
|
request,
|
|
75
94
|
}),
|
|
76
95
|
|
|
77
|
-
sustain: request.sustain
|
|
96
|
+
sustain: !!request.sustain,
|
|
78
97
|
|
|
79
98
|
updated: async data => {
|
|
80
99
|
const result = this.structure.mutate(request, data);
|
|
@@ -88,29 +107,59 @@ export class ClientNodeInteraction implements Interactable<ActionContext> {
|
|
|
88
107
|
closed: request.closed?.bind(request),
|
|
89
108
|
};
|
|
90
109
|
|
|
91
|
-
|
|
110
|
+
const client = await this.#connect();
|
|
111
|
+
|
|
112
|
+
return client.subscribe(intermediateRequest, context);
|
|
92
113
|
}
|
|
93
114
|
|
|
94
115
|
/**
|
|
95
116
|
* Write chosen attributes remotely to the node.
|
|
96
117
|
* The returned attribute write status information is returned.
|
|
97
118
|
*/
|
|
98
|
-
async write<T extends
|
|
99
|
-
|
|
119
|
+
async write<T extends ClientWrite>(request: T, context?: ActionContext): WriteResult<T> {
|
|
120
|
+
const client = await this.#connect();
|
|
121
|
+
|
|
122
|
+
return client.write(request, context);
|
|
100
123
|
}
|
|
101
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Invoke a command remotely on the node.
|
|
127
|
+
* The returned command response is returned as response chunks
|
|
128
|
+
*/
|
|
102
129
|
async *invoke(request: ClientInvoke, context?: ActionContext): DecodedInvokeResult {
|
|
103
|
-
|
|
130
|
+
const client = await this.#connect();
|
|
131
|
+
|
|
132
|
+
yield* client.invoke(request, context);
|
|
104
133
|
}
|
|
105
134
|
|
|
106
135
|
async #connect(): Promise<ClientInteraction> {
|
|
107
136
|
if (!this.#node.lifecycle.isOnline) {
|
|
108
137
|
await this.#node.start();
|
|
109
138
|
}
|
|
110
|
-
|
|
139
|
+
const props = this.physicalProperties;
|
|
140
|
+
// When we have a thread device, then we use the queue, or when we do not know anything
|
|
141
|
+
// (usually before the initial subscription)
|
|
142
|
+
return props.threadConnected || !props.rootEndpointServerList.length
|
|
143
|
+
? this.#node.env.get(QueuedClientInteraction)
|
|
144
|
+
: this.#node.env.get(ClientInteraction);
|
|
111
145
|
}
|
|
112
146
|
|
|
113
147
|
get structure() {
|
|
114
148
|
return (this.#node.env.get(EndpointInitializer) as ClientEndpointInitializer).structure;
|
|
115
149
|
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Temporary accessor of cached data, if any are stored. This will be implemented by the ClientNodeInteraction and
|
|
153
|
+
* point to the node state of the relevant endpoint and is needed to support the old API behavior for
|
|
154
|
+
* AttributeClient.
|
|
155
|
+
* TODO Remove when we remove the legacy controller API
|
|
156
|
+
* @deprecated
|
|
157
|
+
*/
|
|
158
|
+
localStateFor(endpointId: EndpointNumber): Record<string, Record<string, Val.Struct> | undefined> | undefined {
|
|
159
|
+
if (!this.#node.endpoints.has(endpointId)) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const endpoint = this.#node.endpoints.for(endpointId);
|
|
163
|
+
return endpoint.state as unknown as Record<string, Record<string, Val.Struct> | undefined>;
|
|
164
|
+
}
|
|
116
165
|
}
|