@matter/protocol 0.13.1-alpha.0-20250520-d699cd56d → 0.14.0-alpha.0-20250524-51a7e1721
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/action/Interactable.d.ts +1 -1
- package/dist/cjs/action/Interactable.d.ts.map +1 -1
- package/dist/cjs/action/client/ClientInteraction.d.ts +1 -1
- package/dist/cjs/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/cjs/action/client/ClientInteraction.js +50 -8
- package/dist/cjs/action/client/ClientInteraction.js.map +1 -1
- package/dist/cjs/action/protocols.d.ts +49 -15
- package/dist/cjs/action/protocols.d.ts.map +1 -1
- package/dist/cjs/action/request/Invoke.d.ts +10 -1
- package/dist/cjs/action/request/Invoke.d.ts.map +1 -1
- package/dist/cjs/action/request/Invoke.js +17 -5
- 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 +1 -1
- package/dist/cjs/action/request/Read.js.map +1 -1
- package/dist/cjs/action/request/Write.d.ts +2 -0
- package/dist/cjs/action/request/Write.d.ts.map +1 -1
- package/dist/cjs/action/request/Write.js.map +1 -1
- package/dist/cjs/action/response/InvokeResult.d.ts +22 -6
- package/dist/cjs/action/response/InvokeResult.d.ts.map +1 -1
- package/dist/cjs/action/server/AttributeReadResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/AttributeReadResponse.js +1 -2
- package/dist/cjs/action/server/AttributeReadResponse.js.map +2 -2
- package/dist/cjs/action/server/AttributeWriteResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/AttributeWriteResponse.js +1 -14
- package/dist/cjs/action/server/AttributeWriteResponse.js.map +1 -1
- package/dist/cjs/action/server/CommandInvokeResponse.d.ts +25 -0
- package/dist/cjs/action/server/CommandInvokeResponse.d.ts.map +1 -0
- package/dist/cjs/action/server/CommandInvokeResponse.js +331 -0
- package/dist/cjs/action/server/CommandInvokeResponse.js.map +6 -0
- package/dist/cjs/action/server/EventReadResponse.js +1 -1
- package/dist/cjs/action/server/ServerInteraction.d.ts +1 -3
- package/dist/cjs/action/server/ServerInteraction.d.ts.map +1 -1
- package/dist/cjs/action/server/ServerInteraction.js +4 -2
- package/dist/cjs/action/server/ServerInteraction.js.map +1 -1
- package/dist/cjs/action/server/index.d.ts +1 -0
- package/dist/cjs/action/server/index.d.ts.map +1 -1
- package/dist/cjs/action/server/index.js +1 -0
- package/dist/cjs/action/server/index.js.map +1 -1
- package/dist/cjs/cluster/client/AttributeClient.d.ts +2 -0
- package/dist/cjs/cluster/client/AttributeClient.d.ts.map +1 -1
- package/dist/cjs/cluster/client/AttributeClient.js +10 -0
- package/dist/cjs/cluster/client/AttributeClient.js.map +1 -1
- package/dist/cjs/cluster/client/ClusterClientTypes.d.ts +0 -4
- package/dist/cjs/cluster/client/ClusterClientTypes.d.ts.map +1 -1
- package/dist/cjs/cluster/index.d.ts +0 -1
- package/dist/cjs/cluster/index.d.ts.map +1 -1
- package/dist/cjs/cluster/index.js +0 -1
- package/dist/cjs/cluster/index.js.map +1 -1
- package/dist/cjs/events/OccurrenceManager.d.ts +10 -2
- package/dist/cjs/events/OccurrenceManager.d.ts.map +1 -1
- package/dist/cjs/events/OccurrenceManager.js +57 -11
- package/dist/cjs/events/OccurrenceManager.js.map +1 -1
- package/dist/cjs/fabric/Fabric.d.ts +2 -11
- package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
- package/dist/cjs/fabric/Fabric.js +1 -38
- package/dist/cjs/fabric/Fabric.js.map +1 -1
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interaction/AttributeDataEncoder.d.ts +1 -1
- package/dist/cjs/interaction/InteractionClient.d.ts +13 -0
- package/dist/cjs/interaction/InteractionClient.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionClient.js +14 -0
- package/dist/cjs/interaction/InteractionClient.js.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.d.ts +8 -8
- package/dist/cjs/interaction/index.d.ts +0 -1
- package/dist/cjs/interaction/index.d.ts.map +1 -1
- package/dist/cjs/interaction/index.js +0 -1
- package/dist/cjs/interaction/index.js.map +1 -1
- package/dist/cjs/mdns/MdnsScanner.d.ts +23 -1
- package/dist/cjs/mdns/MdnsScanner.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsScanner.js +124 -11
- package/dist/cjs/mdns/MdnsScanner.js.map +2 -2
- package/dist/esm/action/Interactable.d.ts +1 -1
- package/dist/esm/action/Interactable.d.ts.map +1 -1
- package/dist/esm/action/client/ClientInteraction.d.ts +1 -1
- package/dist/esm/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/esm/action/client/ClientInteraction.js +50 -8
- package/dist/esm/action/client/ClientInteraction.js.map +1 -1
- package/dist/esm/action/protocols.d.ts +49 -15
- package/dist/esm/action/protocols.d.ts.map +1 -1
- package/dist/esm/action/request/Invoke.d.ts +10 -1
- package/dist/esm/action/request/Invoke.d.ts.map +1 -1
- package/dist/esm/action/request/Invoke.js +17 -5
- 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 +1 -1
- package/dist/esm/action/request/Read.js.map +1 -1
- package/dist/esm/action/request/Write.d.ts +2 -0
- package/dist/esm/action/request/Write.d.ts.map +1 -1
- package/dist/esm/action/request/Write.js.map +1 -1
- package/dist/esm/action/response/InvokeResult.d.ts +22 -6
- package/dist/esm/action/response/InvokeResult.d.ts.map +1 -1
- package/dist/esm/action/server/AttributeReadResponse.d.ts.map +1 -1
- package/dist/esm/action/server/AttributeReadResponse.js +1 -1
- package/dist/esm/action/server/AttributeReadResponse.js.map +1 -1
- package/dist/esm/action/server/AttributeWriteResponse.d.ts.map +1 -1
- package/dist/esm/action/server/AttributeWriteResponse.js +2 -15
- package/dist/esm/action/server/AttributeWriteResponse.js.map +1 -1
- package/dist/esm/action/server/CommandInvokeResponse.d.ts +25 -0
- package/dist/esm/action/server/CommandInvokeResponse.d.ts.map +1 -0
- package/dist/esm/action/server/CommandInvokeResponse.js +317 -0
- package/dist/esm/action/server/CommandInvokeResponse.js.map +6 -0
- package/dist/esm/action/server/EventReadResponse.js +1 -1
- package/dist/esm/action/server/ServerInteraction.d.ts +1 -3
- package/dist/esm/action/server/ServerInteraction.d.ts.map +1 -1
- package/dist/esm/action/server/ServerInteraction.js +4 -2
- package/dist/esm/action/server/ServerInteraction.js.map +1 -1
- package/dist/esm/action/server/index.d.ts +1 -0
- package/dist/esm/action/server/index.d.ts.map +1 -1
- package/dist/esm/action/server/index.js +1 -0
- package/dist/esm/action/server/index.js.map +1 -1
- package/dist/esm/cluster/client/AttributeClient.d.ts +2 -0
- package/dist/esm/cluster/client/AttributeClient.d.ts.map +1 -1
- package/dist/esm/cluster/client/AttributeClient.js +10 -0
- package/dist/esm/cluster/client/AttributeClient.js.map +1 -1
- package/dist/esm/cluster/client/ClusterClientTypes.d.ts +0 -4
- package/dist/esm/cluster/client/ClusterClientTypes.d.ts.map +1 -1
- package/dist/esm/cluster/index.d.ts +0 -1
- package/dist/esm/cluster/index.d.ts.map +1 -1
- package/dist/esm/cluster/index.js +0 -1
- package/dist/esm/cluster/index.js.map +1 -1
- package/dist/esm/events/OccurrenceManager.d.ts +10 -2
- package/dist/esm/events/OccurrenceManager.d.ts.map +1 -1
- package/dist/esm/events/OccurrenceManager.js +62 -12
- package/dist/esm/events/OccurrenceManager.js.map +1 -1
- package/dist/esm/fabric/Fabric.d.ts +2 -11
- package/dist/esm/fabric/Fabric.d.ts.map +1 -1
- package/dist/esm/fabric/Fabric.js +1 -38
- package/dist/esm/fabric/Fabric.js.map +1 -1
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interaction/AttributeDataEncoder.d.ts +1 -1
- package/dist/esm/interaction/InteractionClient.d.ts +13 -0
- package/dist/esm/interaction/InteractionClient.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionClient.js +14 -0
- package/dist/esm/interaction/InteractionClient.js.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.d.ts +8 -8
- package/dist/esm/interaction/index.d.ts +0 -1
- package/dist/esm/interaction/index.d.ts.map +1 -1
- package/dist/esm/interaction/index.js +0 -1
- package/dist/esm/interaction/index.js.map +1 -1
- package/dist/esm/mdns/MdnsScanner.d.ts +23 -1
- package/dist/esm/mdns/MdnsScanner.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsScanner.js +127 -11
- package/dist/esm/mdns/MdnsScanner.js.map +2 -2
- package/package.json +6 -6
- package/src/action/Interactable.ts +1 -1
- package/src/action/client/ClientInteraction.ts +53 -16
- package/src/action/protocols.ts +70 -16
- package/src/action/request/Invoke.ts +32 -5
- package/src/action/request/Read.ts +1 -1
- package/src/action/request/Write.ts +4 -1
- package/src/action/response/InvokeResult.ts +26 -6
- package/src/action/response/ReadResult.ts +1 -1
- package/src/action/server/AttributeReadResponse.ts +1 -1
- package/src/action/server/AttributeWriteResponse.ts +2 -20
- package/src/action/server/CommandInvokeResponse.ts +427 -0
- package/src/action/server/EventReadResponse.ts +1 -1
- package/src/action/server/ServerInteraction.ts +6 -5
- package/src/action/server/index.ts +1 -0
- package/src/cluster/client/AttributeClient.ts +12 -0
- package/src/cluster/client/ClusterClientTypes.ts +0 -6
- package/src/cluster/index.ts +0 -1
- package/src/events/OccurrenceManager.ts +91 -11
- package/src/fabric/Fabric.ts +1 -49
- package/src/index.ts +0 -1
- package/src/interaction/InteractionClient.ts +24 -0
- package/src/interaction/index.ts +0 -1
- package/src/mdns/MdnsScanner.ts +187 -12
- package/dist/cjs/cluster/server/AttributeServer.d.ts +0 -307
- package/dist/cjs/cluster/server/AttributeServer.d.ts.map +0 -1
- package/dist/cjs/cluster/server/AttributeServer.js +0 -736
- package/dist/cjs/cluster/server/AttributeServer.js.map +0 -6
- package/dist/cjs/cluster/server/ClusterDatasource.d.ts +0 -16
- package/dist/cjs/cluster/server/ClusterDatasource.d.ts.map +0 -1
- package/dist/cjs/cluster/server/ClusterDatasource.js +0 -22
- package/dist/cjs/cluster/server/ClusterDatasource.js.map +0 -6
- package/dist/cjs/cluster/server/ClusterServer.d.ts +0 -40
- package/dist/cjs/cluster/server/ClusterServer.d.ts.map +0 -1
- package/dist/cjs/cluster/server/ClusterServer.js +0 -22
- package/dist/cjs/cluster/server/ClusterServer.js.map +0 -6
- package/dist/cjs/cluster/server/CommandServer.d.ts +0 -34
- package/dist/cjs/cluster/server/CommandServer.d.ts.map +0 -1
- package/dist/cjs/cluster/server/CommandServer.js +0 -76
- package/dist/cjs/cluster/server/CommandServer.js.map +0 -6
- package/dist/cjs/cluster/server/EventServer.d.ts +0 -42
- package/dist/cjs/cluster/server/EventServer.d.ts.map +0 -1
- package/dist/cjs/cluster/server/EventServer.js +0 -152
- package/dist/cjs/cluster/server/EventServer.js.map +0 -6
- package/dist/cjs/cluster/server/index.d.ts +0 -11
- package/dist/cjs/cluster/server/index.d.ts.map +0 -1
- package/dist/cjs/cluster/server/index.js +0 -28
- package/dist/cjs/cluster/server/index.js.map +0 -6
- package/dist/cjs/endpoint/EndpointInterface.d.ts +0 -37
- package/dist/cjs/endpoint/EndpointInterface.d.ts.map +0 -1
- package/dist/cjs/endpoint/EndpointInterface.js +0 -22
- package/dist/cjs/endpoint/EndpointInterface.js.map +0 -6
- package/dist/cjs/endpoint/EndpointStructureLogger.d.ts +0 -31
- package/dist/cjs/endpoint/EndpointStructureLogger.d.ts.map +0 -1
- package/dist/cjs/endpoint/EndpointStructureLogger.js +0 -230
- package/dist/cjs/endpoint/EndpointStructureLogger.js.map +0 -6
- package/dist/cjs/endpoint/index.d.ts +0 -8
- package/dist/cjs/endpoint/index.d.ts.map +0 -1
- package/dist/cjs/endpoint/index.js +0 -25
- package/dist/cjs/endpoint/index.js.map +0 -6
- package/dist/cjs/interaction/InteractionEndpointStructure.d.ts +0 -95
- package/dist/cjs/interaction/InteractionEndpointStructure.d.ts.map +0 -1
- package/dist/cjs/interaction/InteractionEndpointStructure.js +0 -359
- package/dist/cjs/interaction/InteractionEndpointStructure.js.map +0 -6
- package/dist/esm/cluster/server/AttributeServer.d.ts +0 -307
- package/dist/esm/cluster/server/AttributeServer.d.ts.map +0 -1
- package/dist/esm/cluster/server/AttributeServer.js +0 -729
- package/dist/esm/cluster/server/AttributeServer.js.map +0 -6
- package/dist/esm/cluster/server/ClusterDatasource.d.ts +0 -16
- package/dist/esm/cluster/server/ClusterDatasource.d.ts.map +0 -1
- package/dist/esm/cluster/server/ClusterDatasource.js +0 -6
- package/dist/esm/cluster/server/ClusterDatasource.js.map +0 -6
- package/dist/esm/cluster/server/ClusterServer.d.ts +0 -40
- package/dist/esm/cluster/server/ClusterServer.d.ts.map +0 -1
- package/dist/esm/cluster/server/ClusterServer.js +0 -6
- package/dist/esm/cluster/server/ClusterServer.js.map +0 -6
- package/dist/esm/cluster/server/CommandServer.d.ts +0 -34
- package/dist/esm/cluster/server/CommandServer.d.ts.map +0 -1
- package/dist/esm/cluster/server/CommandServer.js +0 -56
- package/dist/esm/cluster/server/CommandServer.js.map +0 -6
- package/dist/esm/cluster/server/EventServer.d.ts +0 -42
- package/dist/esm/cluster/server/EventServer.d.ts.map +0 -1
- package/dist/esm/cluster/server/EventServer.js +0 -141
- package/dist/esm/cluster/server/EventServer.js.map +0 -6
- package/dist/esm/cluster/server/index.d.ts +0 -11
- package/dist/esm/cluster/server/index.d.ts.map +0 -1
- package/dist/esm/cluster/server/index.js +0 -11
- package/dist/esm/cluster/server/index.js.map +0 -6
- package/dist/esm/endpoint/EndpointInterface.d.ts +0 -37
- package/dist/esm/endpoint/EndpointInterface.d.ts.map +0 -1
- package/dist/esm/endpoint/EndpointInterface.js +0 -6
- package/dist/esm/endpoint/EndpointInterface.js.map +0 -6
- package/dist/esm/endpoint/EndpointStructureLogger.d.ts +0 -31
- package/dist/esm/endpoint/EndpointStructureLogger.d.ts.map +0 -1
- package/dist/esm/endpoint/EndpointStructureLogger.js +0 -210
- package/dist/esm/endpoint/EndpointStructureLogger.js.map +0 -6
- package/dist/esm/endpoint/index.d.ts +0 -8
- package/dist/esm/endpoint/index.d.ts.map +0 -1
- package/dist/esm/endpoint/index.js +0 -8
- package/dist/esm/endpoint/index.js.map +0 -6
- package/dist/esm/interaction/InteractionEndpointStructure.d.ts +0 -95
- package/dist/esm/interaction/InteractionEndpointStructure.d.ts.map +0 -1
- package/dist/esm/interaction/InteractionEndpointStructure.js +0 -355
- package/dist/esm/interaction/InteractionEndpointStructure.js.map +0 -6
- package/src/cluster/server/AttributeServer.ts +0 -997
- package/src/cluster/server/ClusterDatasource.ts +0 -17
- package/src/cluster/server/ClusterServer.ts +0 -46
- package/src/cluster/server/CommandServer.ts +0 -89
- package/src/cluster/server/EventServer.ts +0 -202
- package/src/cluster/server/index.ts +0 -11
- package/src/endpoint/EndpointInterface.ts +0 -41
- package/src/endpoint/EndpointStructureLogger.ts +0 -270
- package/src/endpoint/index.ts +0 -8
- package/src/interaction/InteractionEndpointStructure.ts +0 -510
|
@@ -1,510 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { ImplementationError, InternalError, Observable } from "#general";
|
|
8
|
-
import {
|
|
9
|
-
AcceptedCommandList,
|
|
10
|
-
AttributeList,
|
|
11
|
-
AttributeModel,
|
|
12
|
-
ClusterModel,
|
|
13
|
-
GeneratedCommandList,
|
|
14
|
-
MatterModel,
|
|
15
|
-
} from "#model";
|
|
16
|
-
import {
|
|
17
|
-
AttributeId,
|
|
18
|
-
ClusterId,
|
|
19
|
-
CommandId,
|
|
20
|
-
EndpointNumber,
|
|
21
|
-
EventId,
|
|
22
|
-
Mei,
|
|
23
|
-
NodeId,
|
|
24
|
-
StatusCode,
|
|
25
|
-
StatusResponseError,
|
|
26
|
-
TlvAttributePath,
|
|
27
|
-
TlvCommandPath,
|
|
28
|
-
TlvEventPath,
|
|
29
|
-
TypeFromPartialBitSchema,
|
|
30
|
-
TypeFromSchema,
|
|
31
|
-
WildcardPathFlagsBitmap,
|
|
32
|
-
} from "#types";
|
|
33
|
-
import { TlvClusterPath } from "@matter/types";
|
|
34
|
-
import { AnyAttributeServer } from "../cluster/server/AttributeServer.js";
|
|
35
|
-
import { ClusterServer } from "../cluster/server/ClusterServer.js";
|
|
36
|
-
import { CommandServer } from "../cluster/server/CommandServer.js";
|
|
37
|
-
import { AnyEventServer } from "../cluster/server/EventServer.js";
|
|
38
|
-
import { EndpointInterface } from "../endpoint/EndpointInterface.js";
|
|
39
|
-
|
|
40
|
-
export interface CommandPath {
|
|
41
|
-
nodeId?: NodeId;
|
|
42
|
-
endpointId: EndpointNumber;
|
|
43
|
-
clusterId: ClusterId;
|
|
44
|
-
commandId: CommandId;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface AttributePath {
|
|
48
|
-
nodeId?: NodeId;
|
|
49
|
-
endpointId: EndpointNumber;
|
|
50
|
-
clusterId: ClusterId;
|
|
51
|
-
attributeId: AttributeId;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface EventPath {
|
|
55
|
-
nodeId?: NodeId;
|
|
56
|
-
endpointId: EndpointNumber;
|
|
57
|
-
clusterId: ClusterId;
|
|
58
|
-
eventId: EventId;
|
|
59
|
-
isUrgent?: boolean;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface AttributeWithPath {
|
|
63
|
-
path: AttributePath;
|
|
64
|
-
attribute: AnyAttributeServer<any>;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface EventWithPath {
|
|
68
|
-
path: EventPath;
|
|
69
|
-
event: AnyEventServer<any, any>;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface CommandWithPath {
|
|
73
|
-
path: CommandPath;
|
|
74
|
-
command: CommandServer<any, any>;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function genericElementPathToId(
|
|
78
|
-
endpointId: EndpointNumber | undefined,
|
|
79
|
-
clusterId: ClusterId | undefined,
|
|
80
|
-
elementId: number | undefined,
|
|
81
|
-
) {
|
|
82
|
-
return `${endpointId}/${clusterId}/${elementId}`;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function commandPathToId({ endpointId, clusterId, commandId }: CommandPath) {
|
|
86
|
-
return genericElementPathToId(endpointId, clusterId, commandId);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function attributePathToId({ endpointId, clusterId, attributeId }: TypeFromSchema<typeof TlvAttributePath>) {
|
|
90
|
-
return genericElementPathToId(endpointId, clusterId, attributeId);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function eventPathToId({ endpointId, clusterId, eventId }: TypeFromSchema<typeof TlvEventPath>) {
|
|
94
|
-
return genericElementPathToId(endpointId, clusterId, eventId);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function clusterPathToId({ nodeId, endpointId, clusterId }: TypeFromSchema<typeof TlvClusterPath>) {
|
|
98
|
-
return `${nodeId}/${endpointId}/${clusterId}`;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* List of global attributes to skip when the WildcardSkipGlobalAttributes bit is set in an Wildcard Path Flags
|
|
103
|
-
* @see {@link MatterSpecification.v13.Core} §8.2.1.7
|
|
104
|
-
*/
|
|
105
|
-
const GLOBAL_COMMANDLIST_IDS = [GeneratedCommandList.id, AcceptedCommandList.id];
|
|
106
|
-
const GLOBAL_ATTRIBUTES_LIST = [...GLOBAL_COMMANDLIST_IDS, AttributeList.id];
|
|
107
|
-
|
|
108
|
-
// Build a list of cluster IDs that are used for diagnostics to not always filter through model
|
|
109
|
-
// TODO Find a way to also incorporate custom clusters here
|
|
110
|
-
const DIAGNOSTICS_CLUSTER_IDS = MatterModel.standard.clusters
|
|
111
|
-
.filter(cluster => cluster.diagnostics && cluster.id !== undefined)
|
|
112
|
-
.map(cluster => cluster.id as ClusterId);
|
|
113
|
-
|
|
114
|
-
export class InteractionEndpointStructure {
|
|
115
|
-
endpoints = new Map<EndpointNumber, EndpointInterface>();
|
|
116
|
-
attributes = new Map<string, AnyAttributeServer<any>>();
|
|
117
|
-
attributePaths = new Array<AttributePath>();
|
|
118
|
-
events = new Map<string, AnyEventServer<any, any>>();
|
|
119
|
-
eventPaths = new Array<EventPath>();
|
|
120
|
-
commands = new Map<string, CommandServer<any, any>>();
|
|
121
|
-
commandPaths = new Array<CommandPath>();
|
|
122
|
-
change = Observable(); // TODO adjust to AsyncObservable when we remove legacy API
|
|
123
|
-
|
|
124
|
-
public clear() {
|
|
125
|
-
this.endpoints.clear();
|
|
126
|
-
this.attributes.clear();
|
|
127
|
-
this.attributePaths.length = 0;
|
|
128
|
-
this.events.clear();
|
|
129
|
-
this.eventPaths.length = 0;
|
|
130
|
-
this.commands.clear();
|
|
131
|
-
this.commandPaths.length = 0;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
public close() {
|
|
135
|
-
for (const endpoint of this.endpoints.values()) {
|
|
136
|
-
endpoint.close();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
public initializeFromEndpoint(endpoint: EndpointInterface) {
|
|
141
|
-
this.clear();
|
|
142
|
-
|
|
143
|
-
this.verifyAndInitializeStructureElementsFromEndpoint(endpoint); // Initialize Data from Root Endpoint
|
|
144
|
-
this.initializeStructureFromEndpoints(endpoint); // Initialize Data from Child Endpoints
|
|
145
|
-
|
|
146
|
-
this.change.emit();
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
private initializeStructureFromEndpoints(endpoint: EndpointInterface) {
|
|
150
|
-
const endpoints = endpoint.getChildEndpoints();
|
|
151
|
-
for (let endpointIndex = 0; endpointIndex < endpoints.length; endpointIndex++) {
|
|
152
|
-
this.verifyAndInitializeStructureElementsFromEndpoint(endpoints[endpointIndex]);
|
|
153
|
-
this.initializeStructureFromEndpoints(endpoints[endpointIndex]);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
private verifyAndInitializeStructureElementsFromEndpoint(endpoint: EndpointInterface) {
|
|
158
|
-
if (endpoint.number === undefined) {
|
|
159
|
-
throw new InternalError(`Endpoint ID is undefined. It needs to be initialized first!`);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
endpoint.verifyRequiredClusters();
|
|
163
|
-
|
|
164
|
-
const endpointId = endpoint.number;
|
|
165
|
-
if (this.endpoints.has(endpoint.number)) {
|
|
166
|
-
throw new ImplementationError(`Endpoint ID ${endpoint.number} exists twice`);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
for (const cluster of endpoint.getAllClusterServers()) {
|
|
170
|
-
const {
|
|
171
|
-
id: clusterId,
|
|
172
|
-
attributes: clusterAttributes,
|
|
173
|
-
events: clusterEvents,
|
|
174
|
-
commands: clusterCommands,
|
|
175
|
-
} = cluster;
|
|
176
|
-
|
|
177
|
-
// Add attributes
|
|
178
|
-
for (const name in clusterAttributes) {
|
|
179
|
-
const attribute = clusterAttributes[name];
|
|
180
|
-
const path = { endpointId, clusterId, attributeId: attribute.id };
|
|
181
|
-
this.attributes.set(attributePathToId(path), attribute);
|
|
182
|
-
this.attributePaths.push(path);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Add events
|
|
186
|
-
for (const name in clusterEvents) {
|
|
187
|
-
const event = clusterEvents[name];
|
|
188
|
-
const path = { endpointId, clusterId, eventId: event.id };
|
|
189
|
-
this.events.set(eventPathToId(path), event);
|
|
190
|
-
this.eventPaths.push(path);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// Add commands
|
|
194
|
-
for (const name in clusterCommands) {
|
|
195
|
-
const command = clusterCommands[name];
|
|
196
|
-
const path = { endpointId, clusterId, commandId: command.invokeId };
|
|
197
|
-
this.commands.set(commandPathToId(path), command);
|
|
198
|
-
this.commandPaths.push(path);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
this.endpoints.set(endpointId, endpoint);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
toHex(value: number | bigint | undefined) {
|
|
206
|
-
return value === undefined ? "*" : `0x${value.toString(16)}`;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
resolveGenericElementName(
|
|
210
|
-
nodeId: NodeId | undefined,
|
|
211
|
-
endpointId: EndpointNumber | undefined,
|
|
212
|
-
clusterId: ClusterId | undefined,
|
|
213
|
-
elementId: number | undefined,
|
|
214
|
-
elementMap: Map<string, any>,
|
|
215
|
-
) {
|
|
216
|
-
const nodeIdPrefix = nodeId === undefined ? "" : `${this.toHex(nodeId)}/`;
|
|
217
|
-
if (endpointId === undefined) {
|
|
218
|
-
return `${nodeIdPrefix}*/${this.toHex(clusterId)}/${this.toHex(elementId)}`;
|
|
219
|
-
}
|
|
220
|
-
const endpoint = this.endpoints.get(endpointId);
|
|
221
|
-
if (endpoint === undefined) {
|
|
222
|
-
return `${nodeIdPrefix}unknown(${this.toHex(endpointId)})/${this.toHex(clusterId)}/${this.toHex(
|
|
223
|
-
elementId,
|
|
224
|
-
)}`;
|
|
225
|
-
}
|
|
226
|
-
const endpointName = `${endpoint.name}(${this.toHex(endpointId)})`;
|
|
227
|
-
|
|
228
|
-
if (clusterId === undefined) {
|
|
229
|
-
return `${nodeIdPrefix}${endpointName}/*/${this.toHex(elementId)}`;
|
|
230
|
-
}
|
|
231
|
-
const cluster = endpoint.getClusterServerById(clusterId);
|
|
232
|
-
if (cluster === undefined) {
|
|
233
|
-
return `${nodeIdPrefix}${endpointName}/unknown(${this.toHex(clusterId)})/${this.toHex(elementId)}`;
|
|
234
|
-
}
|
|
235
|
-
const clusterName = `${cluster.name}(${this.toHex(clusterId)})`;
|
|
236
|
-
|
|
237
|
-
if (elementId === undefined) {
|
|
238
|
-
return `${nodeIdPrefix}${endpointName}/${clusterName}/*`;
|
|
239
|
-
}
|
|
240
|
-
const element = elementMap.get(genericElementPathToId(endpointId, clusterId, elementId));
|
|
241
|
-
const elementName = `${element?.name ?? "unknown"}(${this.toHex(elementId)})`;
|
|
242
|
-
return `${nodeIdPrefix}${endpointName}/${clusterName}/${elementName}`;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
resolveAttributeName({ nodeId, endpointId, clusterId, attributeId }: TypeFromSchema<typeof TlvAttributePath>) {
|
|
246
|
-
return this.resolveGenericElementName(nodeId, endpointId, clusterId, attributeId, this.attributes);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
resolveEventName({ nodeId, endpointId, clusterId, eventId, isUrgent }: TypeFromSchema<typeof TlvEventPath>) {
|
|
250
|
-
return `${isUrgent ? "!" : ""}${this.resolveGenericElementName(
|
|
251
|
-
nodeId,
|
|
252
|
-
endpointId,
|
|
253
|
-
clusterId,
|
|
254
|
-
eventId,
|
|
255
|
-
this.events,
|
|
256
|
-
)}`;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
resolveCommandName({ endpointId, clusterId, commandId }: TypeFromSchema<typeof TlvCommandPath>) {
|
|
260
|
-
return this.resolveGenericElementName(undefined, endpointId, clusterId, commandId, this.commands);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
getEndpoint(endpointId: EndpointNumber): EndpointInterface | undefined {
|
|
264
|
-
return this.endpoints.get(endpointId);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
hasEndpoint(endpointId: EndpointNumber): boolean {
|
|
268
|
-
return this.endpoints.has(endpointId);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
getClusterServer(endpointId: EndpointNumber, clusterId: ClusterId): ClusterServer | undefined {
|
|
272
|
-
return this.endpoints.get(endpointId)?.getClusterServerById(clusterId);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
hasClusterServer(endpointId: EndpointNumber, clusterId: ClusterId): boolean {
|
|
276
|
-
return !!this.getClusterServer(endpointId, clusterId);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
getAttribute(
|
|
280
|
-
endpointId: EndpointNumber,
|
|
281
|
-
clusterId: ClusterId,
|
|
282
|
-
attributeId: AttributeId,
|
|
283
|
-
): AnyAttributeServer<any> | undefined {
|
|
284
|
-
return this.attributes.get(attributePathToId({ endpointId, clusterId, attributeId }));
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
hasAttribute(endpointId: EndpointNumber, clusterId: ClusterId, attributeId: AttributeId): boolean {
|
|
288
|
-
return !!this.getAttribute(endpointId, clusterId, attributeId);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
validateConcreteAttributePath(endpointId: EndpointNumber, clusterId: ClusterId, attributeId: AttributeId) {
|
|
292
|
-
if (!this.hasEndpoint(endpointId)) {
|
|
293
|
-
throw new StatusResponseError(`Endpoint ${endpointId} does not exist.`, StatusCode.UnsupportedEndpoint);
|
|
294
|
-
}
|
|
295
|
-
if (!this.hasClusterServer(endpointId, clusterId)) {
|
|
296
|
-
throw new StatusResponseError(`Cluster ${clusterId} does not exist.`, StatusCode.UnsupportedCluster);
|
|
297
|
-
}
|
|
298
|
-
if (this.hasAttribute(endpointId, clusterId, attributeId)) return true;
|
|
299
|
-
throw new StatusResponseError(`Attribute ${attributeId} does not exist`, StatusCode.UnsupportedAttribute);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
getEvent(endpointId: EndpointNumber, clusterId: ClusterId, eventId: EventId): AnyEventServer<any, any> | undefined {
|
|
303
|
-
return this.events.get(eventPathToId({ endpointId, clusterId, eventId }));
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
hasEvent(endpointId: EndpointNumber, clusterId: ClusterId, eventId: EventId): boolean {
|
|
307
|
-
return !!this.getEvent(endpointId, clusterId, eventId);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
validateConcreteEventPath(endpointId: EndpointNumber, clusterId: ClusterId, eventId: EventId) {
|
|
311
|
-
if (!this.hasEndpoint(endpointId)) {
|
|
312
|
-
throw new StatusResponseError(`Endpoint ${endpointId} does not exist.`, StatusCode.UnsupportedEndpoint);
|
|
313
|
-
}
|
|
314
|
-
if (!this.hasClusterServer(endpointId, clusterId)) {
|
|
315
|
-
throw new StatusResponseError(`Cluster ${clusterId} does not exist.`, StatusCode.UnsupportedCluster);
|
|
316
|
-
}
|
|
317
|
-
if (this.hasEvent(endpointId, clusterId, eventId)) return true;
|
|
318
|
-
throw new StatusResponseError(`Event ${eventId} does not exist`, StatusCode.UnsupportedEvent);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
getCommand(
|
|
322
|
-
endpointId: EndpointNumber,
|
|
323
|
-
clusterId: ClusterId,
|
|
324
|
-
commandId: CommandId,
|
|
325
|
-
): CommandServer<any, any> | undefined {
|
|
326
|
-
return this.commands.get(commandPathToId({ endpointId, clusterId, commandId }));
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
hasCommand(endpointId: EndpointNumber, clusterId: ClusterId, commandId: CommandId): boolean {
|
|
330
|
-
return !!this.getCommand(endpointId, clusterId, commandId);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
validateConcreteCommandPath(endpointId: EndpointNumber, clusterId: ClusterId, commandId: CommandId) {
|
|
334
|
-
if (!this.hasEndpoint(endpointId)) {
|
|
335
|
-
throw new StatusResponseError(`Endpoint ${endpointId} does not exist.`, StatusCode.UnsupportedEndpoint);
|
|
336
|
-
}
|
|
337
|
-
if (!this.hasClusterServer(endpointId, clusterId)) {
|
|
338
|
-
throw new StatusResponseError(`Cluster ${clusterId} does not exist.`, StatusCode.UnsupportedCluster);
|
|
339
|
-
}
|
|
340
|
-
if (this.hasCommand(endpointId, clusterId, commandId)) return true;
|
|
341
|
-
throw new StatusResponseError(`Command ${commandId} does not exist`, StatusCode.UnsupportedCommand);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/** Checks if the given attribute matches the wildcard path flags */
|
|
345
|
-
attributePathMatchesWildcardPathFlags(
|
|
346
|
-
{ endpointId, clusterId, attributeId }: AttributePath,
|
|
347
|
-
wildcardPathFlags?: TypeFromPartialBitSchema<typeof WildcardPathFlagsBitmap>,
|
|
348
|
-
) {
|
|
349
|
-
if (wildcardPathFlags === undefined) return false;
|
|
350
|
-
if (wildcardPathFlags.skipRootNode && endpointId === 0) {
|
|
351
|
-
return true;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
// Only check if the attribute ID is a global attribute ID
|
|
355
|
-
if (attributeId >= 0xfff8 && attributeId <= 0xfffb) {
|
|
356
|
-
if (wildcardPathFlags.skipGlobalAttributes && GLOBAL_ATTRIBUTES_LIST.includes(attributeId)) {
|
|
357
|
-
return true;
|
|
358
|
-
}
|
|
359
|
-
if (wildcardPathFlags.skipAttributeList && attributeId === AttributeList.id) {
|
|
360
|
-
return true;
|
|
361
|
-
}
|
|
362
|
-
if (wildcardPathFlags.skipCommandLists && GLOBAL_COMMANDLIST_IDS.includes(attributeId)) {
|
|
363
|
-
return true;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
if (
|
|
368
|
-
wildcardPathFlags.skipCustomElements &&
|
|
369
|
-
(Mei.hasCustomMeiPrefix(clusterId) || Mei.hasCustomMeiPrefix(attributeId))
|
|
370
|
-
) {
|
|
371
|
-
return true;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
const cluster = MatterModel.standard.get(ClusterModel, clusterId);
|
|
375
|
-
if (cluster !== undefined) {
|
|
376
|
-
const attribute = cluster.get(AttributeModel, attributeId);
|
|
377
|
-
if (attribute !== undefined) {
|
|
378
|
-
if (wildcardPathFlags.skipFixedAttributes && attribute.fixed) {
|
|
379
|
-
return true;
|
|
380
|
-
}
|
|
381
|
-
if (wildcardPathFlags.skipChangesOmittedAttributes && attribute.changesOmitted) {
|
|
382
|
-
return true;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
if (wildcardPathFlags.skipDiagnosticsClusters && DIAGNOSTICS_CLUSTER_IDS.includes(clusterId)) {
|
|
386
|
-
return true;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
return false;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
getAttributes(filters: TypeFromSchema<typeof TlvAttributePath>[], onlyWritable = false): AttributeWithPath[] {
|
|
393
|
-
const result = new Array<AttributeWithPath>();
|
|
394
|
-
|
|
395
|
-
filters.forEach(({ endpointId, clusterId, attributeId, wildcardPathFlags }) => {
|
|
396
|
-
this.validateAnyPathDataTypes({ endpointId, clusterId, attributeId });
|
|
397
|
-
if (endpointId !== undefined && clusterId !== undefined && attributeId !== undefined) {
|
|
398
|
-
const path = { endpointId, clusterId, attributeId };
|
|
399
|
-
const attribute = this.attributes.get(attributePathToId(path));
|
|
400
|
-
if (attribute === undefined) return;
|
|
401
|
-
if (onlyWritable && !attribute.isWritable) return;
|
|
402
|
-
if (this.attributePathMatchesWildcardPathFlags(path)) return;
|
|
403
|
-
result.push({ path, attribute });
|
|
404
|
-
} else {
|
|
405
|
-
this.attributePaths
|
|
406
|
-
.filter(
|
|
407
|
-
path =>
|
|
408
|
-
(endpointId === undefined || endpointId === path.endpointId) &&
|
|
409
|
-
(clusterId === undefined || clusterId === path.clusterId) &&
|
|
410
|
-
(attributeId === undefined || attributeId === path.attributeId),
|
|
411
|
-
)
|
|
412
|
-
.forEach(path => {
|
|
413
|
-
const attribute = this.attributes.get(attributePathToId(path));
|
|
414
|
-
if (attribute === undefined) return;
|
|
415
|
-
if (onlyWritable && !attribute.isWritable) return;
|
|
416
|
-
if (this.attributePathMatchesWildcardPathFlags(path, wildcardPathFlags)) return;
|
|
417
|
-
result.push({ path, attribute });
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
return result;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
getEvents(filters: TypeFromSchema<typeof TlvEventPath>[]): EventWithPath[] {
|
|
426
|
-
const result = new Array<EventWithPath>();
|
|
427
|
-
|
|
428
|
-
filters.forEach(({ endpointId, clusterId, eventId, isUrgent }) => {
|
|
429
|
-
this.validateAnyPathDataTypes({ endpointId, clusterId, eventId });
|
|
430
|
-
if (endpointId !== undefined && clusterId !== undefined && eventId !== undefined) {
|
|
431
|
-
const path = { endpointId, clusterId, eventId, isUrgent };
|
|
432
|
-
const event = this.events.get(eventPathToId(path));
|
|
433
|
-
if (event === undefined) return;
|
|
434
|
-
result.push({ path, event });
|
|
435
|
-
} else {
|
|
436
|
-
this.eventPaths
|
|
437
|
-
.filter(
|
|
438
|
-
path =>
|
|
439
|
-
(endpointId === undefined || endpointId === path.endpointId) &&
|
|
440
|
-
(clusterId === undefined || clusterId === path.clusterId) &&
|
|
441
|
-
(eventId === undefined || eventId === path.eventId),
|
|
442
|
-
)
|
|
443
|
-
.forEach(({ endpointId, clusterId, eventId }) => {
|
|
444
|
-
const path = { endpointId, clusterId, eventId, isUrgent };
|
|
445
|
-
const event = this.events.get(eventPathToId(path));
|
|
446
|
-
if (event === undefined) return;
|
|
447
|
-
result.push({ path, event });
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
return result;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
getCommands(filters: TypeFromSchema<typeof TlvCommandPath>[]): CommandWithPath[] {
|
|
456
|
-
const result = new Array<CommandWithPath>();
|
|
457
|
-
|
|
458
|
-
filters.forEach(({ endpointId, clusterId, commandId }) => {
|
|
459
|
-
this.validateAnyPathDataTypes({ endpointId, clusterId, commandId });
|
|
460
|
-
if (endpointId !== undefined && clusterId !== undefined && commandId !== undefined) {
|
|
461
|
-
const path = { endpointId, clusterId, commandId };
|
|
462
|
-
const command = this.commands.get(commandPathToId(path));
|
|
463
|
-
if (command === undefined) return;
|
|
464
|
-
result.push({ path, command });
|
|
465
|
-
} else {
|
|
466
|
-
this.commandPaths
|
|
467
|
-
.filter(
|
|
468
|
-
path =>
|
|
469
|
-
(endpointId === undefined || endpointId === path.endpointId) &&
|
|
470
|
-
(clusterId === undefined || clusterId === path.clusterId) &&
|
|
471
|
-
(commandId === undefined || commandId === path.commandId),
|
|
472
|
-
)
|
|
473
|
-
.forEach(path => {
|
|
474
|
-
const command = this.commands.get(commandPathToId(path));
|
|
475
|
-
if (command === undefined) return;
|
|
476
|
-
result.push({ path, command });
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
});
|
|
480
|
-
|
|
481
|
-
return result;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
// ValidationError will return ConstraintError ... we need to see if this is correct always
|
|
485
|
-
validateAnyPathDataTypes(data: {
|
|
486
|
-
endpointId?: EndpointNumber;
|
|
487
|
-
clusterId?: ClusterId;
|
|
488
|
-
attributeId?: AttributeId;
|
|
489
|
-
eventId?: EventId;
|
|
490
|
-
commandId?: CommandId;
|
|
491
|
-
}) {
|
|
492
|
-
const { endpointId, clusterId, attributeId, eventId, commandId } = data;
|
|
493
|
-
|
|
494
|
-
if (endpointId !== undefined) {
|
|
495
|
-
EndpointNumber(endpointId);
|
|
496
|
-
}
|
|
497
|
-
if (clusterId !== undefined) {
|
|
498
|
-
ClusterId(clusterId);
|
|
499
|
-
}
|
|
500
|
-
if (attributeId !== undefined) {
|
|
501
|
-
AttributeId(attributeId);
|
|
502
|
-
}
|
|
503
|
-
if (eventId !== undefined) {
|
|
504
|
-
EventId(eventId);
|
|
505
|
-
}
|
|
506
|
-
if (commandId !== undefined) {
|
|
507
|
-
CommandId(commandId);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
}
|