@matter/node 0.16.0-alpha.0-20251031-0f308af69 → 0.16.0-alpha.0-20251101-70c8d51d7
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/behavior/state/managed/Datasource.js +13 -13
- package/dist/cjs/behavior/state/managed/Datasource.js.map +2 -2
- package/dist/cjs/behavior/state/managed/values/ListManager.js +2 -2
- package/dist/cjs/behavior/state/managed/values/ListManager.js.map +1 -1
- package/dist/cjs/behavior/state/managed/values/ValuePatcher.js +10 -3
- package/dist/cjs/behavior/state/managed/values/ValuePatcher.js.map +1 -1
- package/dist/cjs/behavior/supervision/ValueSupervisor.d.ts +4 -0
- package/dist/cjs/behavior/supervision/ValueSupervisor.d.ts.map +1 -1
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.d.ts +3 -3
- package/dist/cjs/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
- package/dist/cjs/behavior/system/network/ClientNetworkRuntime.d.ts +0 -1
- package/dist/cjs/behavior/system/network/ClientNetworkRuntime.d.ts.map +1 -1
- package/dist/cjs/behavior/system/network/ClientNetworkRuntime.js +3 -4
- package/dist/cjs/behavior/system/network/ClientNetworkRuntime.js.map +1 -1
- package/dist/cjs/behavior/system/network/NetworkClient.d.ts +8 -13
- package/dist/cjs/behavior/system/network/NetworkClient.d.ts.map +1 -1
- package/dist/cjs/behavior/system/network/NetworkClient.js +20 -35
- package/dist/cjs/behavior/system/network/NetworkClient.js.map +1 -1
- package/dist/cjs/behavior/system/network/NetworkRuntime.d.ts +1 -1
- package/dist/cjs/behavior/system/network/NetworkRuntime.d.ts.map +1 -1
- package/dist/cjs/behavior/system/network/NetworkRuntime.js +5 -1
- package/dist/cjs/behavior/system/network/NetworkRuntime.js.map +1 -1
- package/dist/cjs/behavior/system/network/ServerNetworkRuntime.d.ts +0 -1
- package/dist/cjs/behavior/system/network/ServerNetworkRuntime.d.ts.map +1 -1
- package/dist/cjs/behavior/system/network/ServerNetworkRuntime.js +4 -4
- package/dist/cjs/behavior/system/network/ServerNetworkRuntime.js.map +1 -1
- package/dist/cjs/behavior/system/remote/RemoteInterface.d.ts.map +1 -1
- package/dist/cjs/behavior/system/remote/RemoteInterface.js +3 -3
- package/dist/cjs/behavior/system/remote/RemoteInterface.js.map +1 -1
- package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.js +1 -1
- package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.js.map +1 -1
- package/dist/cjs/behaviors/color-control/ColorConversionUtils.js +2 -2
- package/dist/cjs/behaviors/color-control/ColorConversionUtils.js.map +1 -1
- package/dist/cjs/behaviors/thermostat/AtomicWriteHandler.js +1 -1
- package/dist/cjs/behaviors/thermostat/AtomicWriteHandler.js.map +1 -1
- package/dist/cjs/behaviors/thermostat/ThermostatServer.js +1 -1
- package/dist/cjs/behaviors/thermostat/ThermostatServer.js.map +1 -1
- package/dist/cjs/node/client/ClientEventEmitter.d.ts.map +1 -1
- package/dist/cjs/node/client/ClientEventEmitter.js +11 -10
- package/dist/cjs/node/client/ClientEventEmitter.js.map +2 -2
- package/dist/cjs/node/client/ClientNodeInteraction.d.ts +8 -5
- package/dist/cjs/node/client/ClientNodeInteraction.d.ts.map +1 -1
- package/dist/cjs/node/client/ClientNodeInteraction.js +9 -13
- package/dist/cjs/node/client/ClientNodeInteraction.js.map +1 -1
- package/dist/cjs/node/integration/ChangeNotificationService.js +1 -1
- package/dist/cjs/node/integration/ChangeNotificationService.js.map +1 -1
- package/dist/cjs/node/server/InteractionServer.js +1 -1
- package/dist/cjs/node/server/OnlineServerInteraction.d.ts +0 -1
- package/dist/cjs/node/server/OnlineServerInteraction.d.ts.map +1 -1
- package/dist/cjs/node/server/OnlineServerInteraction.js +0 -3
- package/dist/cjs/node/server/OnlineServerInteraction.js.map +1 -1
- package/dist/esm/behavior/state/managed/Datasource.js +13 -13
- package/dist/esm/behavior/state/managed/Datasource.js.map +2 -2
- package/dist/esm/behavior/state/managed/values/ListManager.js +2 -2
- package/dist/esm/behavior/state/managed/values/ListManager.js.map +1 -1
- package/dist/esm/behavior/state/managed/values/ValuePatcher.js +10 -3
- package/dist/esm/behavior/state/managed/values/ValuePatcher.js.map +1 -1
- package/dist/esm/behavior/supervision/ValueSupervisor.d.ts +4 -0
- package/dist/esm/behavior/supervision/ValueSupervisor.d.ts.map +1 -1
- package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts +3 -3
- package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
- package/dist/esm/behavior/system/network/ClientNetworkRuntime.d.ts +0 -1
- package/dist/esm/behavior/system/network/ClientNetworkRuntime.d.ts.map +1 -1
- package/dist/esm/behavior/system/network/ClientNetworkRuntime.js +3 -4
- package/dist/esm/behavior/system/network/ClientNetworkRuntime.js.map +1 -1
- package/dist/esm/behavior/system/network/NetworkClient.d.ts +8 -13
- package/dist/esm/behavior/system/network/NetworkClient.d.ts.map +1 -1
- package/dist/esm/behavior/system/network/NetworkClient.js +21 -36
- package/dist/esm/behavior/system/network/NetworkClient.js.map +1 -1
- package/dist/esm/behavior/system/network/NetworkRuntime.d.ts +1 -1
- package/dist/esm/behavior/system/network/NetworkRuntime.d.ts.map +1 -1
- package/dist/esm/behavior/system/network/NetworkRuntime.js +6 -2
- package/dist/esm/behavior/system/network/NetworkRuntime.js.map +1 -1
- package/dist/esm/behavior/system/network/ServerNetworkRuntime.d.ts +0 -1
- package/dist/esm/behavior/system/network/ServerNetworkRuntime.d.ts.map +1 -1
- package/dist/esm/behavior/system/network/ServerNetworkRuntime.js +4 -4
- package/dist/esm/behavior/system/network/ServerNetworkRuntime.js.map +1 -1
- package/dist/esm/behavior/system/remote/RemoteInterface.d.ts.map +1 -1
- package/dist/esm/behavior/system/remote/RemoteInterface.js +4 -4
- package/dist/esm/behavior/system/remote/RemoteInterface.js.map +1 -1
- package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.js +1 -1
- package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.js.map +1 -1
- package/dist/esm/behaviors/color-control/ColorConversionUtils.js +2 -2
- package/dist/esm/behaviors/color-control/ColorConversionUtils.js.map +1 -1
- package/dist/esm/behaviors/thermostat/AtomicWriteHandler.js +1 -1
- package/dist/esm/behaviors/thermostat/AtomicWriteHandler.js.map +1 -1
- package/dist/esm/behaviors/thermostat/ThermostatServer.js +1 -1
- package/dist/esm/behaviors/thermostat/ThermostatServer.js.map +1 -1
- package/dist/esm/node/client/ClientEventEmitter.d.ts.map +1 -1
- package/dist/esm/node/client/ClientEventEmitter.js +12 -11
- package/dist/esm/node/client/ClientEventEmitter.js.map +2 -2
- package/dist/esm/node/client/ClientNodeInteraction.d.ts +8 -5
- package/dist/esm/node/client/ClientNodeInteraction.d.ts.map +1 -1
- package/dist/esm/node/client/ClientNodeInteraction.js +9 -13
- package/dist/esm/node/client/ClientNodeInteraction.js.map +1 -1
- package/dist/esm/node/integration/ChangeNotificationService.js +1 -1
- package/dist/esm/node/integration/ChangeNotificationService.js.map +1 -1
- package/dist/esm/node/server/InteractionServer.js +1 -1
- package/dist/esm/node/server/OnlineServerInteraction.d.ts +0 -1
- package/dist/esm/node/server/OnlineServerInteraction.d.ts.map +1 -1
- package/dist/esm/node/server/OnlineServerInteraction.js +0 -3
- package/dist/esm/node/server/OnlineServerInteraction.js.map +1 -1
- package/package.json +7 -7
- package/src/behavior/Transitions.ts +1 -1
- package/src/behavior/state/managed/Datasource.ts +17 -14
- package/src/behavior/state/managed/values/ListManager.ts +2 -2
- package/src/behavior/state/managed/values/ValuePatcher.ts +15 -6
- package/src/behavior/supervision/ValueSupervisor.ts +5 -0
- package/src/behavior/system/commissioning/CommissioningClient.ts +3 -3
- package/src/behavior/system/network/ClientNetworkRuntime.ts +5 -5
- package/src/behavior/system/network/NetworkClient.ts +25 -43
- package/src/behavior/system/network/NetworkRuntime.ts +7 -4
- package/src/behavior/system/network/ServerNetworkRuntime.ts +5 -6
- package/src/behavior/system/remote/RemoteInterface.ts +4 -4
- package/src/behavior/system/subscriptions/SubscriptionsServer.ts +1 -1
- package/src/behaviors/color-control/ColorConversionUtils.ts +2 -2
- package/src/behaviors/thermostat/AtomicWriteHandler.ts +1 -1
- package/src/behaviors/thermostat/ThermostatServer.ts +1 -1
- package/src/node/client/ClientEventEmitter.ts +12 -11
- package/src/node/client/ClientNodeInteraction.ts +13 -17
- package/src/node/integration/ChangeNotificationService.ts +1 -1
- package/src/node/server/InteractionServer.ts +1 -1
- package/src/node/server/OnlineServerInteraction.ts +0 -4
|
@@ -5,7 +5,6 @@ export declare class OnlineServerInteraction implements Interactable<RemoteActor
|
|
|
5
5
|
constructor(node: NodeProtocol);
|
|
6
6
|
read(request: Read, context: RemoteActorContext.Options): ReadResult;
|
|
7
7
|
subscribe(_request: Subscribe, _context: RemoteActorContext.Options): SubscribeResult;
|
|
8
|
-
cancelSubscription(_id: number): void;
|
|
9
8
|
write<T extends Write>(request: T, context: RemoteActorContext.Options): WriteResult<T>;
|
|
10
9
|
invoke(request: Invoke, context: RemoteActorContext.Options): AsyncGenerator<import("#protocol").InvokeResult.Chunk, undefined, unknown>;
|
|
11
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnlineServerInteraction.d.ts","sourceRoot":"","sources":["../../../../src/node/server/OnlineServerInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAEpF,OAAO,EACH,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,UAAU,EAEV,SAAS,EACT,eAAe,EACf,KAAK,EACL,WAAW,EACd,MAAM,WAAW,CAAC;AAEnB,qBAAa,uBAAwB,YAAW,YAAY,CAAC,kBAAkB,CAAC,OAAO,CAAC;;gBAGxE,IAAI,EAAE,YAAY;IAIvB,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,CAAC,OAAO,GAAG,UAAU;IAW3E,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,CAAC,OAAO,GAAG,eAAe;
|
|
1
|
+
{"version":3,"file":"OnlineServerInteraction.d.ts","sourceRoot":"","sources":["../../../../src/node/server/OnlineServerInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAEpF,OAAO,EACH,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,UAAU,EAEV,SAAS,EACT,eAAe,EACf,KAAK,EACL,WAAW,EACd,MAAM,WAAW,CAAC;AAEnB,qBAAa,uBAAwB,YAAW,YAAY,CAAC,kBAAkB,CAAC,OAAO,CAAC;;gBAGxE,IAAI,EAAE,YAAY;IAIvB,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,CAAC,OAAO,GAAG,UAAU;IAW3E,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,CAAC,OAAO,GAAG,eAAe;IAI/E,KAAK,CAAC,CAAC,SAAS,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,kBAAkB,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC;IAItF,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,CAAC,OAAO;CAWrE"}
|
|
@@ -21,9 +21,6 @@ class OnlineServerInteraction {
|
|
|
21
21
|
subscribe(_request, _context) {
|
|
22
22
|
throw new NotImplementedError("subscribe not implemented");
|
|
23
23
|
}
|
|
24
|
-
cancelSubscription(_id) {
|
|
25
|
-
throw new NotImplementedError("cancelSubscription not implemented");
|
|
26
|
-
}
|
|
27
24
|
async write(request, context) {
|
|
28
25
|
return RemoteActorContext(context).act((session) => this.#interaction.write(request, session));
|
|
29
26
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/node/server/OnlineServerInteraction.ts"],
|
|
4
|
-
"mappings": "AAAA,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AACpC;AAAA,EAMI;AAAA,OAKG;AAEA,MAAM,wBAA4E;AAAA,EAC5E;AAAA,EAET,YAAY,MAAoB;AAC5B,SAAK,eAAe,IAAI,kBAAkB,IAAI;AAAA,EAClD;AAAA,EAEA,OAAO,KAAK,SAAe,SAAiD;AACxE,UAAM,UAAU,mBAAmB,OAAO,EAAE,cAAc;AAC1D,QAAI;AACA,uBAAiB,UAAU,KAAK,aAAa,KAAK,SAAS,OAAO,GAAG;AACjE,cAAM;AAAA,MACV;AAAA,IACJ,UAAE;AACE,cAAQ,OAAO,OAAO,EAAE;AAAA,IAC5B;AAAA,EACJ;AAAA,EAEA,UAAU,UAAqB,UAAuD;AAClF,UAAM,IAAI,oBAAoB,2BAA2B;AAAA,EAC7D;AAAA,EAEA,
|
|
4
|
+
"mappings": "AAAA,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AACpC;AAAA,EAMI;AAAA,OAKG;AAEA,MAAM,wBAA4E;AAAA,EAC5E;AAAA,EAET,YAAY,MAAoB;AAC5B,SAAK,eAAe,IAAI,kBAAkB,IAAI;AAAA,EAClD;AAAA,EAEA,OAAO,KAAK,SAAe,SAAiD;AACxE,UAAM,UAAU,mBAAmB,OAAO,EAAE,cAAc;AAC1D,QAAI;AACA,uBAAiB,UAAU,KAAK,aAAa,KAAK,SAAS,OAAO,GAAG;AACjE,cAAM;AAAA,MACV;AAAA,IACJ,UAAE;AACE,cAAQ,OAAO,OAAO,EAAE;AAAA,IAC5B;AAAA,EACJ;AAAA,EAEA,UAAU,UAAqB,UAAuD;AAClF,UAAM,IAAI,oBAAoB,2BAA2B;AAAA,EAC7D;AAAA,EAEA,MAAM,MAAuB,SAAY,SAAqD;AAC1F,WAAO,mBAAmB,OAAO,EAAE,IAAI,aAAW,KAAK,aAAa,MAAM,SAAS,OAAO,CAAC;AAAA,EAC/F;AAAA,EAEA,OAAO,OAAO,SAAiB,SAAqC;AAChE,UAAM,UAAU,mBAAmB,EAAE,GAAG,SAAS,SAAS,KAAK,CAAC,EAAE,KAAK;AACvE,QAAI;AACA,uBAAiB,SAAS,KAAK,aAAa,OAAO,SAAS,OAAO,GAAG;AAClE,cAAM;AAAA,MACV;AAAA,IACJ,SAAS,OAAO;AACZ,YAAM,QAAQ,OAAO,KAAK;AAAA,IAC9B;AACA,WAAO,QAAQ,QAAQ,MAAS;AAAA,EACpC;AACJ;",
|
|
5
5
|
"names": []
|
|
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-20251101-70c8d51d7",
|
|
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-20251101-70c8d51d7",
|
|
46
|
+
"@matter/model": "0.16.0-alpha.0-20251101-70c8d51d7",
|
|
47
|
+
"@matter/types": "0.16.0-alpha.0-20251101-70c8d51d7",
|
|
48
|
+
"@matter/protocol": "0.16.0-alpha.0-20251101-70c8d51d7"
|
|
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-20251101-70c8d51d7",
|
|
52
|
+
"@matter/testing": "0.16.0-alpha.0-20251101-70c8d51d7"
|
|
53
53
|
},
|
|
54
54
|
"files": [
|
|
55
55
|
"dist/**/*",
|
|
@@ -220,7 +220,7 @@ export class Transitions<B extends Behavior> {
|
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
// Only report if it changes, with a delta larger than 10, caused by
|
|
223
|
+
// Only report if it changes, with a delta larger than 10, caused by an invoke of a command
|
|
224
224
|
if (fromCommand && Math.abs(this.#prevPublishedRemainingTime - newRemainingTime) <= 10) {
|
|
225
225
|
return;
|
|
226
226
|
}
|
|
@@ -285,7 +285,7 @@ interface CommitChanges {
|
|
|
285
285
|
* Initialize the internal version of the datasource.
|
|
286
286
|
*/
|
|
287
287
|
function configure(options: Datasource.Options): Internals {
|
|
288
|
-
|
|
288
|
+
let values = new options.type() as Val.Struct;
|
|
289
289
|
|
|
290
290
|
let storedValues = options.store?.initialValues;
|
|
291
291
|
|
|
@@ -328,11 +328,26 @@ function configure(options: Datasource.Options): Internals {
|
|
|
328
328
|
primaryKey: options.primaryKey === "id" ? "id" : "name",
|
|
329
329
|
events,
|
|
330
330
|
version: options.entropy.randomUint32,
|
|
331
|
-
values,
|
|
332
331
|
featuresKey,
|
|
333
332
|
manageVersion: true,
|
|
334
333
|
persistentFields,
|
|
335
334
|
|
|
335
|
+
get values() {
|
|
336
|
+
return values;
|
|
337
|
+
},
|
|
338
|
+
|
|
339
|
+
set values(newValues: Val.Struct) {
|
|
340
|
+
const oldValues = this.values;
|
|
341
|
+
|
|
342
|
+
values = newValues;
|
|
343
|
+
|
|
344
|
+
if (this.sessions) {
|
|
345
|
+
for (const context of this.sessions.values()) {
|
|
346
|
+
context.onChange(oldValues);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
|
|
336
351
|
interactionObserver(session?: ValueSupervisor.Session) {
|
|
337
352
|
function handleObserverError(error: any) {
|
|
338
353
|
logger.error(`Error in ${options.location.path} observer:`, error);
|
|
@@ -425,12 +440,6 @@ function configureExternalChanges(internals: Internals) {
|
|
|
425
440
|
...changes,
|
|
426
441
|
};
|
|
427
442
|
|
|
428
|
-
if (internals.sessions) {
|
|
429
|
-
for (const context of internals.sessions.values()) {
|
|
430
|
-
context.onChange(oldValues!);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
|
|
434
443
|
const changedProps = Object.keys(changes);
|
|
435
444
|
|
|
436
445
|
const onChangePromise = internals.onChange?.(Array.from(changedProps));
|
|
@@ -825,13 +834,7 @@ function createReference(resource: Transaction.Resource, internals: Internals, s
|
|
|
825
834
|
return;
|
|
826
835
|
}
|
|
827
836
|
|
|
828
|
-
const oldValues = internals.values;
|
|
829
837
|
internals.values = values;
|
|
830
|
-
if (internals.sessions) {
|
|
831
|
-
for (const context of internals.sessions.values()) {
|
|
832
|
-
context.onChange(oldValues);
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
838
|
}
|
|
836
839
|
|
|
837
840
|
/**
|
|
@@ -65,8 +65,8 @@ function createConfig(owner: RootSupervisor, schema: Schema): ListConfig {
|
|
|
65
65
|
|
|
66
66
|
return {
|
|
67
67
|
schema,
|
|
68
|
-
fabricScoped: schema.effectiveAccess.fabric
|
|
69
|
-
fabricSensitive: schema.effectiveAccess.fabric
|
|
68
|
+
fabricScoped: schema.effectiveAccess.fabric === Access.Fabric.Scoped,
|
|
69
|
+
fabricSensitive: schema.effectiveAccess.fabric === Access.Fabric.Sensitive,
|
|
70
70
|
manageEntries: entryManager.manage !== PrimitiveManager,
|
|
71
71
|
manageEntry: entryManager.manage,
|
|
72
72
|
validateEntry: entryManager.validate,
|
|
@@ -70,9 +70,12 @@ function StructPatcher(schema: ValueModel, supervisor: RootSupervisor): ValueSup
|
|
|
70
70
|
// An object mapping name to default value (if any) for sub-structs
|
|
71
71
|
const memberDefaults = {} as Record<string, Val.Struct>;
|
|
72
72
|
|
|
73
|
-
// An object mapping name to true
|
|
73
|
+
// An object mapping name to true if member is an array
|
|
74
74
|
const memberArrays = {} as Record<string, boolean>;
|
|
75
75
|
|
|
76
|
+
// An object mapping alt keys (numeric IDs) to member names, if numeric IDs are defined
|
|
77
|
+
const memberAltKeys = {} as Record<string, string>;
|
|
78
|
+
|
|
76
79
|
for (const member of supervisor.membersOf(schema)) {
|
|
77
80
|
const metatype = member.effectiveMetatype;
|
|
78
81
|
|
|
@@ -82,6 +85,9 @@ function StructPatcher(schema: ValueModel, supervisor: RootSupervisor): ValueSup
|
|
|
82
85
|
}
|
|
83
86
|
|
|
84
87
|
const key = camelize(member.name);
|
|
88
|
+
if (member.id !== undefined) {
|
|
89
|
+
memberAltKeys[member.id.toString()] = key;
|
|
90
|
+
}
|
|
85
91
|
|
|
86
92
|
memberPatchers[key] = handler;
|
|
87
93
|
|
|
@@ -105,14 +111,17 @@ function StructPatcher(schema: ValueModel, supervisor: RootSupervisor): ValueSup
|
|
|
105
111
|
throw new WriteError(path, `cannot patch ${target} because it is not an object`);
|
|
106
112
|
}
|
|
107
113
|
|
|
108
|
-
for (
|
|
114
|
+
for (let key in changes as Val.Struct) {
|
|
115
|
+
let newValue = (changes as Val.Struct)[key];
|
|
116
|
+
|
|
109
117
|
// Validate the key
|
|
110
118
|
if (!(key in memberPatchers)) {
|
|
111
|
-
|
|
119
|
+
if (!(key in memberAltKeys)) {
|
|
120
|
+
throw new WriteError(path, `${key} is not a property of ${schema.name}`);
|
|
121
|
+
}
|
|
122
|
+
key = memberAltKeys[key];
|
|
112
123
|
}
|
|
113
124
|
|
|
114
|
-
let newValue = (changes as Val.Struct)[key];
|
|
115
|
-
|
|
116
125
|
// If this is not a subcollection or the new value is not an object, just do direct set
|
|
117
126
|
const subpatch = memberPatchers[key];
|
|
118
127
|
if (!subpatch || newValue === null || typeof newValue !== "object") {
|
|
@@ -137,7 +146,7 @@ function StructPatcher(schema: ValueModel, supervisor: RootSupervisor): ValueSup
|
|
|
137
146
|
continue;
|
|
138
147
|
}
|
|
139
148
|
|
|
140
|
-
// Patch existing container. Casts to collection here may be incorrect but
|
|
149
|
+
// Patch existing container. Casts to collection here may be incorrect but the subpatcher will validate
|
|
141
150
|
// input and throw for non-collections
|
|
142
151
|
subpatch(newValue as Val.Collection, target[key] as Val.Collection, path.at(key));
|
|
143
152
|
}
|
|
@@ -74,6 +74,11 @@ export namespace ValueSupervisor {
|
|
|
74
74
|
*/
|
|
75
75
|
transaction: Transaction;
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Signal for terminating asynchronous processes.
|
|
79
|
+
*/
|
|
80
|
+
abort?: AbortSignal;
|
|
81
|
+
|
|
77
82
|
/**
|
|
78
83
|
* If this is true, data validation is disabled. This should only be used in contexts where data validation is
|
|
79
84
|
* deferred.
|
|
@@ -521,15 +521,15 @@ export namespace CommissioningClient {
|
|
|
521
521
|
* ```
|
|
522
522
|
*
|
|
523
523
|
* Note that certain clusters like Descriptor and Basic Information contain critical operational data. If your
|
|
524
|
-
* read omits them then the node will only be partially functional once initialized
|
|
525
|
-
* endpoints need to be enabled manually.
|
|
524
|
+
* read omits them then the node will only be partially functional once initialized.
|
|
526
525
|
*/
|
|
527
526
|
defaultSubscription?: Subscribe;
|
|
528
527
|
|
|
529
528
|
/**
|
|
530
529
|
* By default, nodes we commission are automatically subscribed to using the {@link defaultSubscription} (or a
|
|
531
530
|
* full wildcard subscription if that is undefined).
|
|
532
|
-
*
|
|
531
|
+
*
|
|
532
|
+
* Matter.js will not subscribe automatically if set to false.
|
|
533
533
|
*/
|
|
534
534
|
autoSubscribe?: boolean;
|
|
535
535
|
|
|
@@ -61,10 +61,12 @@ export class ClientNetworkRuntime extends NetworkRuntime {
|
|
|
61
61
|
});
|
|
62
62
|
env.set(ExchangeProvider, exchangeProvider);
|
|
63
63
|
|
|
64
|
+
this.#client = new ClientInteraction({ environment: env, abort: this.abortSignal });
|
|
65
|
+
env.set(ClientInteraction, this.#client);
|
|
66
|
+
|
|
64
67
|
// Monitor sessions to maintain online state. We consider the node "online" if there is an active session. If
|
|
65
68
|
// not, we consider the node offline. This is the only real way we have of determining whether the node is
|
|
66
69
|
// healthy without actively polling
|
|
67
|
-
this.#client = env.get(ClientInteraction);
|
|
68
70
|
const { sessions } = env.get(SessionManager);
|
|
69
71
|
|
|
70
72
|
if (sessions.find(session => session.peerIs(address))) {
|
|
@@ -105,6 +107,8 @@ export class ClientNetworkRuntime extends NetworkRuntime {
|
|
|
105
107
|
protected async stop() {
|
|
106
108
|
await this.construction;
|
|
107
109
|
|
|
110
|
+
this.owner.env.delete(ClientInteraction, this.#client);
|
|
111
|
+
|
|
108
112
|
try {
|
|
109
113
|
await this.#client?.close();
|
|
110
114
|
} catch (e) {
|
|
@@ -113,8 +117,4 @@ export class ClientNetworkRuntime extends NetworkRuntime {
|
|
|
113
117
|
|
|
114
118
|
this.#observers.close();
|
|
115
119
|
}
|
|
116
|
-
|
|
117
|
-
blockNewActivity() {
|
|
118
|
-
this.owner.env.delete(ClientInteraction, this.#client);
|
|
119
|
-
}
|
|
120
120
|
}
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { RemoteDescriptor } from "#behavior/system/commissioning/RemoteDescriptor.js";
|
|
8
|
-
import {
|
|
8
|
+
import { Observable, ServerAddress, ServerAddressUdp } from "#general";
|
|
9
9
|
import { DatatypeModel, FieldElement } from "#model";
|
|
10
10
|
import type { ClientNode } from "#node/ClientNode.js";
|
|
11
11
|
import { Node } from "#node/Node.js";
|
|
12
|
-
import {
|
|
12
|
+
import { ActiveSubscription, DEFAULT_MIN_INTERVAL_FLOOR, PeerSet, Subscribe } from "#protocol";
|
|
13
13
|
import { CaseAuthenticatedTag } from "#types";
|
|
14
14
|
import { ClientNetworkRuntime } from "./ClientNetworkRuntime.js";
|
|
15
15
|
import { NetworkBehavior } from "./NetworkBehavior.js";
|
|
@@ -25,8 +25,8 @@ export class NetworkClient extends NetworkBehavior {
|
|
|
25
25
|
this.state.autoSubscribe = false;
|
|
26
26
|
this.state.defaultSubscription = undefined;
|
|
27
27
|
} else {
|
|
28
|
-
this.reactTo(this.events.autoSubscribe$Changed, this.#
|
|
29
|
-
this.reactTo(this.events.defaultSubscription$Changed, this.#
|
|
28
|
+
this.reactTo(this.events.autoSubscribe$Changed, this.#handleAutoSubscribeChanged, { offline: true });
|
|
29
|
+
this.reactTo(this.events.defaultSubscription$Changed, this.#handleDefaultSubscriptionChange);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -48,36 +48,23 @@ export class NetworkClient extends NetworkBehavior {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
await this.#
|
|
51
|
+
await this.#handleAutoSubscribeChanged();
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
* If you want to disable subscription, set the isDisabled state to true or set autoSubscribe to false.
|
|
58
|
-
*/
|
|
59
|
-
subscribe() {
|
|
60
|
-
if (this.state.isDisabled) {
|
|
61
|
-
throw new ImplementationError("Cannot subscribe when node is disabled");
|
|
62
|
-
}
|
|
63
|
-
return this.#handleSubscription(true);
|
|
64
|
-
}
|
|
54
|
+
async #handleDefaultSubscriptionChange() {
|
|
55
|
+
// Terminate any existing subscription
|
|
56
|
+
await this.#handleAutoSubscribeChanged(false);
|
|
65
57
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return;
|
|
58
|
+
if (this.state.autoSubscribe && !this.state.isDisabled) {
|
|
59
|
+
await this.#handleAutoSubscribeChanged(true);
|
|
69
60
|
}
|
|
70
|
-
|
|
71
|
-
// Restart the subscription with the new parameters
|
|
72
|
-
await this.#handleSubscription(false);
|
|
73
|
-
await this.#handleSubscription(true);
|
|
74
61
|
}
|
|
75
62
|
|
|
76
|
-
async #
|
|
63
|
+
async #handleAutoSubscribeChanged(desiredState = this.state.autoSubscribe) {
|
|
77
64
|
const { isDisabled } = this.state;
|
|
78
65
|
const subscriptionDesired = desiredState && !isDisabled;
|
|
79
66
|
|
|
80
|
-
if (subscriptionDesired === this.internal.
|
|
67
|
+
if (subscriptionDesired === !!this.internal.activeSubscription) {
|
|
81
68
|
return;
|
|
82
69
|
}
|
|
83
70
|
|
|
@@ -93,22 +80,17 @@ export class NetworkClient extends NetworkBehavior {
|
|
|
93
80
|
...this.state.defaultSubscription,
|
|
94
81
|
});
|
|
95
82
|
|
|
96
|
-
// First, read. This allows us to retrieve attributes that do not support subscription
|
|
83
|
+
// First, read. This allows us to retrieve attributes that do not support subscription and gives us
|
|
84
|
+
// physical device information required to optimize subscription parameters
|
|
97
85
|
for await (const _chunk of this.#node.interaction.read(subscribe));
|
|
98
86
|
|
|
99
87
|
// Now subscribe for subsequent updates
|
|
100
|
-
const
|
|
88
|
+
const subscription = await this.#node.interaction.subscribe(subscribe);
|
|
101
89
|
|
|
102
|
-
this.internal.
|
|
103
|
-
this.internal.defaultSubscriptionId = subscriptionId;
|
|
90
|
+
this.internal.activeSubscription = subscription;
|
|
104
91
|
} else {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
.get(this.internal.defaultSubscriptionId)
|
|
108
|
-
?.close();
|
|
109
|
-
this.internal.defaultSubscriptionId = undefined;
|
|
110
|
-
}
|
|
111
|
-
this.internal.subscriptionActivated = false;
|
|
92
|
+
this.internal.activeSubscription?.close();
|
|
93
|
+
this.internal.activeSubscription = undefined;
|
|
112
94
|
}
|
|
113
95
|
}
|
|
114
96
|
|
|
@@ -167,13 +149,9 @@ export namespace NetworkClient {
|
|
|
167
149
|
declare runtime?: ClientNetworkRuntime;
|
|
168
150
|
|
|
169
151
|
/**
|
|
170
|
-
*
|
|
171
|
-
* established, or we wait for the node to be rediscovered.
|
|
152
|
+
* The active default subscription.
|
|
172
153
|
*/
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
/** The ID of the current active default subscription, if any */
|
|
176
|
-
defaultSubscriptionId?: number;
|
|
154
|
+
activeSubscription?: ActiveSubscription;
|
|
177
155
|
}
|
|
178
156
|
|
|
179
157
|
export class State extends NetworkBehavior.State {
|
|
@@ -184,7 +162,7 @@ export namespace NetworkClient {
|
|
|
184
162
|
* The default subscription is a wildcard for all attributes of the node. You can set to undefined or filter
|
|
185
163
|
* the fields and values but only values selected by this subscription will update automatically.
|
|
186
164
|
*
|
|
187
|
-
*
|
|
165
|
+
* The default subscription updates automatically if you change this property.
|
|
188
166
|
*/
|
|
189
167
|
defaultSubscription?: Subscribe;
|
|
190
168
|
|
|
@@ -199,6 +177,10 @@ export namespace NetworkClient {
|
|
|
199
177
|
/**
|
|
200
178
|
* If true, automatically subscribe to the provided default subscription (or all attributes and events) when
|
|
201
179
|
* the node is started. If false, do not automatically subscribe.
|
|
180
|
+
*
|
|
181
|
+
* The subscription will activate or deactivate automatically if you change this property.
|
|
182
|
+
*
|
|
183
|
+
* Newly commissioned nodes default to true.
|
|
202
184
|
*/
|
|
203
185
|
autoSubscribe = false;
|
|
204
186
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { Construction, ImplementationError } from "#general";
|
|
7
|
+
import { Abort, Construction, ImplementationError } from "#general";
|
|
8
8
|
import type { Node } from "#node/Node.js";
|
|
9
9
|
import { NodeActivity } from "../../context/NodeActivity.js";
|
|
10
10
|
import { NetworkBehavior } from "./NetworkBehavior.js";
|
|
@@ -15,6 +15,11 @@ import { NetworkBehavior } from "./NetworkBehavior.js";
|
|
|
15
15
|
export abstract class NetworkRuntime {
|
|
16
16
|
#construction: Construction<NetworkRuntime>;
|
|
17
17
|
#owner: Node;
|
|
18
|
+
#abort = new Abort();
|
|
19
|
+
|
|
20
|
+
get abortSignal() {
|
|
21
|
+
return this.#abort.signal;
|
|
22
|
+
}
|
|
18
23
|
|
|
19
24
|
get construction() {
|
|
20
25
|
return this.#construction;
|
|
@@ -37,7 +42,7 @@ export abstract class NetworkRuntime {
|
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
async [Construction.destruct]() {
|
|
40
|
-
this
|
|
45
|
+
this.#abort();
|
|
41
46
|
const activity = this.#owner.env.get(NodeActivity);
|
|
42
47
|
if (activity.isActive) {
|
|
43
48
|
await activity.inactive;
|
|
@@ -59,8 +64,6 @@ export abstract class NetworkRuntime {
|
|
|
59
64
|
|
|
60
65
|
protected abstract stop(): Promise<void>;
|
|
61
66
|
|
|
62
|
-
protected abstract blockNewActivity(): void;
|
|
63
|
-
|
|
64
67
|
protected get owner() {
|
|
65
68
|
return this.#owner;
|
|
66
69
|
}
|
|
@@ -294,12 +294,15 @@ export class ServerNetworkRuntime extends NetworkRuntime {
|
|
|
294
294
|
|
|
295
295
|
await env.load(PeerSet);
|
|
296
296
|
|
|
297
|
+
// Prevent new connections when aborted
|
|
298
|
+
this.abortSignal.addEventListener("abort", () =>
|
|
299
|
+
this.owner.env.maybeGet(InteractionServer)?.blockNewActivity(),
|
|
300
|
+
);
|
|
301
|
+
|
|
297
302
|
await this.owner.act(agent => this.owner.lifecycle.online.emit(agent.context));
|
|
298
303
|
}
|
|
299
304
|
|
|
300
305
|
protected override async stop() {
|
|
301
|
-
this.blockNewActivity();
|
|
302
|
-
|
|
303
306
|
this.#observers.close();
|
|
304
307
|
|
|
305
308
|
const { env } = this.owner;
|
|
@@ -327,10 +330,6 @@ export class ServerNetworkRuntime extends NetworkRuntime {
|
|
|
327
330
|
await env.close(PeerSet);
|
|
328
331
|
}
|
|
329
332
|
|
|
330
|
-
protected override blockNewActivity() {
|
|
331
|
-
this.owner.env.maybeGet(InteractionServer)?.blockNewActivity();
|
|
332
|
-
}
|
|
333
|
-
|
|
334
333
|
async #initializeGroupNetworking() {
|
|
335
334
|
if (this.#groupNetworking) {
|
|
336
335
|
logger.warn("Group networking already initialized, skipping.");
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { AppAddress, BasicMultiplex, ImplementationError, Logger } from "#general";
|
|
7
|
+
import { Abort, AppAddress, BasicMultiplex, ImplementationError, Logger } from "#general";
|
|
8
8
|
import type { ServerNode } from "#node/ServerNode.js";
|
|
9
9
|
import { ApiPath } from "./api/ApiPath.js";
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ const logger = Logger.get("RemoteAdapter");
|
|
|
16
16
|
export abstract class RemoteInterface {
|
|
17
17
|
#node: ServerNode;
|
|
18
18
|
#address: AppAddress;
|
|
19
|
-
#abort = new
|
|
19
|
+
#abort = new Abort();
|
|
20
20
|
#root: ApiPath;
|
|
21
21
|
#workers = new BasicMultiplex();
|
|
22
22
|
|
|
@@ -48,7 +48,7 @@ export abstract class RemoteInterface {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
get isAborted() {
|
|
51
|
-
return this.#abort.
|
|
51
|
+
return this.#abort.aborted;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
get abort() {
|
|
@@ -75,7 +75,7 @@ export abstract class RemoteInterface {
|
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
this.#abort
|
|
78
|
+
this.#abort();
|
|
79
79
|
|
|
80
80
|
try {
|
|
81
81
|
await this.stop();
|
|
@@ -206,7 +206,7 @@ export class SubscriptionsBehavior extends Behavior {
|
|
|
206
206
|
const { formerSubscriptions } = this.internal;
|
|
207
207
|
|
|
208
208
|
if (!formerSubscriptions.length) {
|
|
209
|
-
logger.
|
|
209
|
+
logger.debug("No former subscriptions to re-establish");
|
|
210
210
|
return;
|
|
211
211
|
} else {
|
|
212
212
|
this.internal.formerSubscriptions = [];
|
|
@@ -172,8 +172,8 @@ export function rgbToXy(r: number, g: number, b: number): [number, number] {
|
|
|
172
172
|
const Z = r * 0.000088 + g * 0.07231 + b * 0.986039;
|
|
173
173
|
const sum = X + Y + Z;
|
|
174
174
|
|
|
175
|
-
const retX = sum
|
|
176
|
-
const retY = sum
|
|
175
|
+
const retX = sum === 0 ? 0 : X / sum;
|
|
176
|
+
const retY = sum === 0 ? 0 : Y / sum;
|
|
177
177
|
|
|
178
178
|
return [retX, retY];
|
|
179
179
|
}
|
|
@@ -325,7 +325,7 @@ export class AtomicWriteHandler {
|
|
|
325
325
|
*/
|
|
326
326
|
#pendingWriteStateForAttribute(endpoint: Endpoint, cluster: Behavior.Type, attribute: AttributeId) {
|
|
327
327
|
const writeStates = this.#pendingWrites.filter(
|
|
328
|
-
s => s.endpoint.number
|
|
328
|
+
s => s.endpoint.number === endpoint.number && s.clusterId === (cluster as ClusterBehavior.Type).cluster.id,
|
|
329
329
|
);
|
|
330
330
|
if (writeStates.length === 0) {
|
|
331
331
|
return undefined;
|
|
@@ -999,7 +999,7 @@ export class ThermostatBaseServer extends ThermostatBehaviorLogicBase {
|
|
|
999
999
|
* true.
|
|
1000
1000
|
*/
|
|
1001
1001
|
#handleTemperatureChangeForMode(temperature: number | null) {
|
|
1002
|
-
if (temperature
|
|
1002
|
+
if (temperature === null) {
|
|
1003
1003
|
return;
|
|
1004
1004
|
}
|
|
1005
1005
|
const consideration = this.temperatureConsideration;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { ElementEvent, Events } from "#behavior/Events.js";
|
|
8
|
-
import { camelize, Logger } from "#general";
|
|
8
|
+
import { camelize, Diagnostic, Logger } from "#general";
|
|
9
9
|
import { ClusterModel, EventModel, MatterModel } from "#model";
|
|
10
10
|
import type { ClientNode } from "#node/ClientNode.js";
|
|
11
11
|
import type { ReadResult } from "#protocol";
|
|
@@ -46,7 +46,7 @@ export function ClientEventEmitter(node: ClientNode, structure: ClientStructure)
|
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
const event = getEvent(occurrence.path.endpointId, names.cluster, names.event);
|
|
49
|
+
const event = getEvent(node, occurrence.path.endpointId, names.cluster, names.event);
|
|
50
50
|
if (event) {
|
|
51
51
|
node.act(agent => {
|
|
52
52
|
// Current ActionContext is not writable, could skip act() but meh, see TODO above
|
|
@@ -56,26 +56,27 @@ export function ClientEventEmitter(node: ClientNode, structure: ClientStructure)
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
function getEvent(endpointId: EndpointNumber, clusterName: string, eventName: string) {
|
|
59
|
+
function getEvent(node: ClientNode, endpointId: EndpointNumber, clusterName: string, eventName: string) {
|
|
60
60
|
const endpoint = structure.endpointFor(endpointId);
|
|
61
61
|
if (endpoint === undefined) {
|
|
62
|
-
logger.
|
|
62
|
+
logger.warn(`Received event for unsupported endpoint #${endpointId} on ${node}`);
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const events = (endpoint.events as Events.Generic<ElementEvent>)[clusterName];
|
|
67
67
|
if (events === undefined) {
|
|
68
|
-
logger.
|
|
68
|
+
logger.warn(`Received event ${eventName} for unsupported cluster ${clusterName} on ${endpoint}`);
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
logger.info(
|
|
73
|
+
"Received event",
|
|
74
|
+
Diagnostic.strong(`${clusterName}.${eventName}`),
|
|
75
|
+
" on ",
|
|
76
|
+
Diagnostic.strong(endpoint.toString()),
|
|
77
|
+
);
|
|
77
78
|
|
|
78
|
-
return
|
|
79
|
+
return events[eventName];
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
|