@matter-server/dashboard 1.3.2-alpha.0-20260727-ec21ba7 → 1.3.3
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/esm/client/models/descriptions.d.ts +12 -0
- package/dist/esm/client/models/descriptions.d.ts.map +1 -1
- package/dist/esm/client/models/descriptions.js +1480 -1
- package/dist/esm/client/models/descriptions.js.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/icd-management-commands.d.ts +1 -1
- package/dist/esm/pages/cluster-commands/clusters/icd-management-commands.d.ts.map +1 -1
- package/dist/esm/pages/cluster-commands/clusters/icd-management-commands.js +3 -3
- package/dist/esm/pages/cluster-commands/clusters/icd-management-commands.js.map +1 -1
- package/dist/esm/pages/matter-cluster-view.d.ts +3 -1
- package/dist/esm/pages/matter-cluster-view.d.ts.map +1 -1
- package/dist/esm/pages/matter-cluster-view.js +72 -25
- package/dist/esm/pages/matter-cluster-view.js.map +1 -1
- package/dist/esm/pages/network/network-types.d.ts +2 -0
- package/dist/esm/pages/network/network-types.d.ts.map +1 -1
- package/dist/esm/pages/network/network-utils.d.ts +6 -0
- package/dist/esm/pages/network/network-utils.d.ts.map +1 -1
- package/dist/esm/pages/network/network-utils.js +19 -0
- package/dist/esm/pages/network/network-utils.js.map +1 -1
- package/dist/esm/pages/network/thread-graph.d.ts.map +1 -1
- package/dist/esm/pages/network/thread-graph.js +29 -0
- package/dist/esm/pages/network/thread-graph.js.map +1 -1
- package/dist/esm/pages/network/update-connections-dialog.d.ts +14 -1
- package/dist/esm/pages/network/update-connections-dialog.d.ts.map +1 -1
- package/dist/esm/pages/network/update-connections-dialog.js +107 -15
- package/dist/esm/pages/network/update-connections-dialog.js.map +1 -1
- package/dist/esm/pages/network/wifi-graph.d.ts.map +1 -1
- package/dist/esm/pages/network/wifi-graph.js +8 -3
- package/dist/esm/pages/network/wifi-graph.js.map +1 -1
- package/dist/esm/util/icd.d.ts +2 -6
- package/dist/esm/util/icd.d.ts.map +1 -1
- package/dist/esm/util/icd.js +3 -9
- package/dist/esm/util/icd.js.map +1 -1
- package/dist/esm/util/semantic-tags.d.ts +31 -0
- package/dist/esm/util/semantic-tags.d.ts.map +1 -0
- package/dist/esm/util/semantic-tags.js +65 -0
- package/dist/esm/util/semantic-tags.js.map +6 -0
- package/dist/web/js/{attribute-write-dialog-DQ9quSZw.js → attribute-write-dialog-Dfm95ZtQ.js} +1 -1
- package/dist/web/js/{command-invoke-dialog-CztMjUn9.js → command-invoke-dialog-DrORSE5f.js} +1 -1
- package/dist/web/js/{commission-node-dialog-B4r-97Ng.js → commission-node-dialog-Wjb4chGv.js} +5 -5
- package/dist/web/js/{commission-node-existing-BhR5cegs.js → commission-node-existing-Ykm-eejQ.js} +1 -1
- package/dist/web/js/{commission-node-thread-dtQAPgAE.js → commission-node-thread-DacHGwnB.js} +1 -1
- package/dist/web/js/{commission-node-wifi-Dyxa8cfO.js → commission-node-wifi-CEKp93HM.js} +1 -1
- package/dist/web/js/{dialog-box-DkZh3xw5.js → dialog-box-DEKE_ZlH.js} +1 -1
- package/dist/web/js/{fabric-label-dialog-B38vLRHA.js → fabric-label-dialog-CcMZOA7F.js} +1 -1
- package/dist/web/js/main.js +1 -1
- package/dist/web/js/{matter-dashboard-app-D_fK75eF.js → matter-dashboard-app-CEG7MSLx.js} +2142 -373
- package/dist/web/js/{node-acl-add-dialog-CC_Cbnx3.js → node-acl-add-dialog-BDM3Rcou.js} +1 -1
- package/dist/web/js/{node-binding-dialog-COAoH_PY.js → node-binding-dialog-CYsbUPsh.js} +1 -1
- package/dist/web/js/{node-label-dialog-Cts_ibpe.js → node-label-dialog-DFIMPMuJ.js} +1 -1
- package/dist/web/js/{settings-dialog-CGgXCmWv.js → settings-dialog-CGXliJcr.js} +1 -1
- package/package.json +4 -4
- package/src/client/models/descriptions.ts +1490 -0
- package/src/pages/cluster-commands/AGENTS.md +6 -0
- package/src/pages/cluster-commands/clusters/icd-management-commands.ts +3 -6
- package/src/pages/matter-cluster-view.ts +83 -29
- package/src/pages/network/network-types.ts +2 -0
- package/src/pages/network/network-utils.ts +26 -0
- package/src/pages/network/thread-graph.ts +42 -0
- package/src/pages/network/update-connections-dialog.ts +142 -22
- package/src/pages/network/wifi-graph.ts +7 -2
- package/src/util/icd.ts +5 -13
- package/src/util/semantic-tags.ts +89 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# cluster-commands — non-obvious invariants
|
|
2
|
+
|
|
3
|
+
- **Panel DOM reuse:** `matter-cluster-view` reuses panel elements across hash navigations (tag keyed by cluster id only). Every async flow must capture `const node = this.node` / `const endpoint = this.endpoint` before its first `await`, target the captured values, and guard post-await state writes with `BaseClusterCommands.isSameContext(node, endpoint)`. Guards go BEFORE the write/dialog, never after.
|
|
4
|
+
- **Busy-flag resets:** ACL/Binding/BasicInformation reset `_busy`/`_saving` UNCONDITIONALLY in `finally` (avoids wedging a reused panel). The ICD panel instead resets only when `isSameContext` holds — safe solely because its `updated()` force-resets `_busy`/`_busyLabel` on node-id change AND IcdManagement is EP0-only. If ICD Management ever appears on a non-zero endpoint, that reset becomes reachable-stuck: make it unconditional then.
|
|
5
|
+
- **Loaded-flag keys:** Binding keys its `_loadedKey` by node+endpoint; ICD (`#loadedForNode`) and ACL (`_loadedKey`) are node-only — justified because both clusters are EP0-only (ACL reads hardcode `0/31/0`). Endpoint-scoped panels must include the endpoint in their key.
|
|
6
|
+
- **Incoming-event subscriptions** (e.g. chime's `addNodeEventListener`) correctly filter against LIVE `this.node`/`this.endpoint` — do not "fix" them to captured values; they are not request/response flows.
|
|
@@ -10,6 +10,7 @@ import "@material/web/progress/circular-progress";
|
|
|
10
10
|
import "@material/web/radio/radio";
|
|
11
11
|
import {
|
|
12
12
|
ICD_MULTI_ADMIN_ERROR_CODE,
|
|
13
|
+
isLongIdleTimeCapable,
|
|
13
14
|
ServerCommandError,
|
|
14
15
|
type IcdStateData,
|
|
15
16
|
type MatterNode,
|
|
@@ -24,7 +25,6 @@ import {
|
|
|
24
25
|
ICD_CLUSTER_ID,
|
|
25
26
|
icdInfo,
|
|
26
27
|
isRegisteredByUs,
|
|
27
|
-
litSpecVersionOk,
|
|
28
28
|
otherFabricClientCount,
|
|
29
29
|
parseMultiAdminDetails,
|
|
30
30
|
wakeInstruction,
|
|
@@ -142,12 +142,9 @@ export class IcdManagementClusterCommands extends BaseClusterCommands {
|
|
|
142
142
|
return isRegisteredByUs(this._info.registeredClients, this.client.serverInfo?.controller_node_id);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
/**
|
|
145
|
+
/** The server's own IcdClient verdict wins; the attribute check is the fallback before it arrives. */
|
|
146
146
|
private get _litSupported(): boolean {
|
|
147
|
-
return (
|
|
148
|
-
this._serverState?.lit_supported ??
|
|
149
|
-
(this._info.features.longIdleTimeSupport && litSpecVersionOk(this.node.attributes))
|
|
150
|
-
);
|
|
147
|
+
return this._serverState?.lit_supported ?? isLongIdleTimeCapable(this.node.attributes);
|
|
151
148
|
}
|
|
152
149
|
|
|
153
150
|
private get _actualMode(): IcdMode {
|
|
@@ -27,6 +27,12 @@ import "../pages/components/node-details";
|
|
|
27
27
|
import { computeActiveClusterFeatures } from "../util/cluster-features.js";
|
|
28
28
|
import { DevModeService } from "../util/dev-mode-service.js";
|
|
29
29
|
import { formatHex, formatNodeAddress, getEffectiveFabricIndex } from "../util/format_hex.js";
|
|
30
|
+
import {
|
|
31
|
+
decodeSemanticTagList,
|
|
32
|
+
describeSemanticTagListEntry,
|
|
33
|
+
DESCRIPTOR_CLUSTER_ID,
|
|
34
|
+
TAG_LIST_ATTR,
|
|
35
|
+
} from "../util/semantic-tags.js";
|
|
30
36
|
import { notFoundStyles } from "../util/shared-styles.js";
|
|
31
37
|
import { BaseClusterCommands, getClusterCommandsTag } from "./cluster-commands/index.js";
|
|
32
38
|
import { bindingContext } from "./components/context.js";
|
|
@@ -146,8 +152,7 @@ class MatterClusterView extends LitElement {
|
|
|
146
152
|
<node-details .node=${this.node}></node-details>
|
|
147
153
|
</div>
|
|
148
154
|
|
|
149
|
-
|
|
150
|
-
${this._renderFeaturesPanel()}
|
|
155
|
+
${this._renderClusterInfoPanel()}
|
|
151
156
|
|
|
152
157
|
<!-- Cluster commands section (if available for this cluster) -->
|
|
153
158
|
${this._renderClusterCommands()}
|
|
@@ -348,38 +353,74 @@ class MatterClusterView extends LitElement {
|
|
|
348
353
|
});
|
|
349
354
|
}
|
|
350
355
|
|
|
351
|
-
private
|
|
352
|
-
|
|
356
|
+
private _renderClusterInfoPanel(): TemplateResult | typeof nothing {
|
|
357
|
+
const sections = new Array<TemplateResult>();
|
|
358
|
+
for (const section of [this._renderFeaturesSection(), this._renderTagListSection()]) {
|
|
359
|
+
if (section !== undefined) sections.push(section);
|
|
360
|
+
}
|
|
361
|
+
if (sections.length === 0) return nothing;
|
|
362
|
+
|
|
363
|
+
return html`
|
|
364
|
+
<div class="container">
|
|
365
|
+
<div class="info-panel">${sections}</div>
|
|
366
|
+
</div>
|
|
367
|
+
`;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
private _renderFeaturesSection(): TemplateResult | undefined {
|
|
371
|
+
if (this.cluster === undefined || !this.node) return undefined;
|
|
353
372
|
|
|
354
373
|
const clusterMeta = clusters[this.cluster];
|
|
355
374
|
const knownFeatures = Object.values(clusterMeta?.features ?? {});
|
|
356
|
-
if (knownFeatures.length === 0) return
|
|
375
|
+
if (knownFeatures.length === 0) return undefined;
|
|
357
376
|
|
|
358
377
|
const featureMapValue = this.node.attributes[`${this.endpoint}/${this.cluster}/${FEATURE_MAP_ATTR}`];
|
|
359
|
-
if (featureMapValue === undefined) return
|
|
378
|
+
if (featureMapValue === undefined) return undefined;
|
|
360
379
|
|
|
361
380
|
const activeFeatures = computeActiveClusterFeatures(featureMapValue, knownFeatures);
|
|
362
381
|
|
|
363
382
|
return html`
|
|
364
|
-
<div class="
|
|
365
|
-
<div class="
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
${
|
|
373
|
-
feature
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
+
<div class="info-section">
|
|
384
|
+
<div class="info-section-header">Active Features</div>
|
|
385
|
+
${activeFeatures.length === 0
|
|
386
|
+
? html`<p class="empty">No active features</p>`
|
|
387
|
+
: html`
|
|
388
|
+
<ul class="chip-list">
|
|
389
|
+
${activeFeatures.map(
|
|
390
|
+
feature => html`
|
|
391
|
+
<li class="chip" title="Bit ${feature.bit} (${feature.code})">
|
|
392
|
+
${feature.label}
|
|
393
|
+
</li>
|
|
394
|
+
`,
|
|
395
|
+
)}
|
|
396
|
+
</ul>
|
|
397
|
+
`}
|
|
398
|
+
</div>
|
|
399
|
+
`;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
private _renderTagListSection(): TemplateResult | undefined {
|
|
403
|
+
if (this.cluster !== DESCRIPTOR_CLUSTER_ID || !this.node) return undefined;
|
|
404
|
+
|
|
405
|
+
const tagListValue = this.node.attributes[`${this.endpoint}/${this.cluster}/${TAG_LIST_ATTR}`];
|
|
406
|
+
const tagList = decodeSemanticTagList(tagListValue);
|
|
407
|
+
if (tagList === undefined) return undefined;
|
|
408
|
+
|
|
409
|
+
return html`
|
|
410
|
+
<div class="info-section">
|
|
411
|
+
<div class="info-section-header">Semantic Tags (TagList)</div>
|
|
412
|
+
${tagList.length === 0
|
|
413
|
+
? html`<p class="empty">No semantic tags</p>`
|
|
414
|
+
: html`
|
|
415
|
+
<ul class="chip-list">
|
|
416
|
+
${tagList.map(entry => {
|
|
417
|
+
const { text, title, erroneous } = describeSemanticTagListEntry(entry);
|
|
418
|
+
return html`<li class=${erroneous ? "chip chip-error" : "chip"} title=${title}>
|
|
419
|
+
${text}
|
|
420
|
+
</li>`;
|
|
421
|
+
})}
|
|
422
|
+
</ul>
|
|
423
|
+
`}
|
|
383
424
|
</div>
|
|
384
425
|
`;
|
|
385
426
|
}
|
|
@@ -670,20 +711,26 @@ class MatterClusterView extends LitElement {
|
|
|
670
711
|
border-radius: 3px;
|
|
671
712
|
}
|
|
672
713
|
|
|
673
|
-
.
|
|
714
|
+
.info-panel {
|
|
674
715
|
background-color: var(--md-sys-color-surface-container);
|
|
675
716
|
border: 1px solid var(--md-sys-color-outline-variant);
|
|
676
717
|
border-radius: 12px;
|
|
677
718
|
padding: 14px 16px;
|
|
678
719
|
}
|
|
679
720
|
|
|
680
|
-
.
|
|
721
|
+
.info-section + .info-section {
|
|
722
|
+
margin-top: 12px;
|
|
723
|
+
padding-top: 12px;
|
|
724
|
+
border-top: 1px solid var(--md-sys-color-outline-variant);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
.info-section-header {
|
|
681
728
|
font-weight: 500;
|
|
682
729
|
color: var(--md-sys-color-on-surface);
|
|
683
730
|
margin-bottom: 10px;
|
|
684
731
|
}
|
|
685
732
|
|
|
686
|
-
.
|
|
733
|
+
.chip-list {
|
|
687
734
|
list-style: none;
|
|
688
735
|
margin: 0;
|
|
689
736
|
padding: 0;
|
|
@@ -692,13 +739,20 @@ class MatterClusterView extends LitElement {
|
|
|
692
739
|
gap: 8px;
|
|
693
740
|
}
|
|
694
741
|
|
|
695
|
-
.
|
|
742
|
+
.chip {
|
|
696
743
|
font-size: 0.85rem;
|
|
697
744
|
color: var(--md-sys-color-on-secondary-container);
|
|
698
745
|
background: var(--md-sys-color-secondary-container);
|
|
699
746
|
padding: 4px 10px;
|
|
700
747
|
border-radius: 8px;
|
|
701
748
|
}
|
|
749
|
+
|
|
750
|
+
.chip.chip-error {
|
|
751
|
+
color: var(--md-sys-color-on-error-container);
|
|
752
|
+
background: var(--md-sys-color-error-container);
|
|
753
|
+
border: 1px solid var(--md-sys-color-error);
|
|
754
|
+
font-family: var(--monospace-font);
|
|
755
|
+
}
|
|
702
756
|
`,
|
|
703
757
|
];
|
|
704
758
|
}
|
|
@@ -64,6 +64,8 @@ export interface NetworkGraphEdge {
|
|
|
64
64
|
dashes?: boolean;
|
|
65
65
|
/** Whether the edge should be hidden */
|
|
66
66
|
hidden?: boolean;
|
|
67
|
+
/** vis.js per-edge spring length; overrides the global physics springLength */
|
|
68
|
+
length?: number;
|
|
67
69
|
/** vis.js arrow configuration: shorthand string ("to", "from", "") or
|
|
68
70
|
* object form for explicit head sizing on dashed edges. */
|
|
69
71
|
arrows?: string | { to?: { enabled: boolean; scaleFactor: number } };
|
|
@@ -81,6 +81,32 @@ export function signalLevelToColor(level: SignalLevel): string {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
/** Spring length per LQI stage, index = LQI 0..3 (OpenThread reports 0-3). */
|
|
85
|
+
const LQI_EDGE_LENGTHS = [340, 270, 190, 100];
|
|
86
|
+
|
|
87
|
+
/** Extra spring length for an edge on a node with a single link, pushing leaves outward. */
|
|
88
|
+
export const LEAF_EDGE_LENGTH_PENALTY = 70;
|
|
89
|
+
|
|
90
|
+
/** Map an averaged LQI to a physics spring length, interpolating between stages. */
|
|
91
|
+
export function lqiToEdgeLength(avgLqi: number): number {
|
|
92
|
+
const clamped = Math.min(LQI_EDGE_LENGTHS.length - 1, Math.max(0, avgLqi));
|
|
93
|
+
const lower = Math.floor(clamped);
|
|
94
|
+
const upper = Math.ceil(clamped);
|
|
95
|
+
if (lower === upper) return LQI_EDGE_LENGTHS[lower];
|
|
96
|
+
return LQI_EDGE_LENGTHS[lower] + (LQI_EDGE_LENGTHS[upper] - LQI_EDGE_LENGTHS[lower]) * (clamped - lower);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** RSSI (dBm) and spring-length bounds for the Wi-Fi star layout. */
|
|
100
|
+
const RSSI_EDGE_LENGTH_BOUNDS = { strongRssi: -50, weakRssi: -90, strongLength: 90, weakLength: 260 };
|
|
101
|
+
|
|
102
|
+
/** Map an RSSI to a physics spring length, so weakly-attached devices sit further from their AP. */
|
|
103
|
+
export function rssiToEdgeLength(rssi: number): number {
|
|
104
|
+
const { strongRssi, weakRssi, strongLength, weakLength } = RSSI_EDGE_LENGTH_BOUNDS;
|
|
105
|
+
const clamped = Math.min(strongRssi, Math.max(weakRssi, rssi));
|
|
106
|
+
const weakness = (strongRssi - clamped) / (strongRssi - weakRssi);
|
|
107
|
+
return strongLength + weakness * (weakLength - strongLength);
|
|
108
|
+
}
|
|
109
|
+
|
|
84
110
|
/**
|
|
85
111
|
* Get signal color from an LQI value (0-3 in practice on OpenThread).
|
|
86
112
|
* 0 = grey (no link), 1 = red, 2 = orange, 3 = green.
|
|
@@ -40,6 +40,8 @@ import {
|
|
|
40
40
|
getThreadExtendedAddressHex,
|
|
41
41
|
getThreadRole,
|
|
42
42
|
getThreadRoleDescription,
|
|
43
|
+
LEAF_EDGE_LENGTH_PENALTY,
|
|
44
|
+
lqiToEdgeLength,
|
|
43
45
|
mergeDiagnosticEdges,
|
|
44
46
|
signalLevelToColor,
|
|
45
47
|
stripMdnsHostname,
|
|
@@ -514,6 +516,16 @@ export class ThreadGraph extends BaseNetworkGraph {
|
|
|
514
516
|
|
|
515
517
|
const graphEdges: NetworkGraphEdge[] = [];
|
|
516
518
|
|
|
519
|
+
// Spring lengths are applied after the loop: the leaf penalty needs every node's
|
|
520
|
+
// final link count.
|
|
521
|
+
const pairSprings = new Array<{
|
|
522
|
+
edges: NetworkGraphEdge[];
|
|
523
|
+
nodeA: string;
|
|
524
|
+
nodeB: string;
|
|
525
|
+
baseLength: number;
|
|
526
|
+
}>();
|
|
527
|
+
const linkCounts = new Map<string, number>();
|
|
528
|
+
|
|
517
529
|
for (const pair of this._edgePairs.values()) {
|
|
518
530
|
// Collect both directional edges for this pair
|
|
519
531
|
const edgesInPair: { conn: ThreadConnection; visEdge: NetworkGraphEdge; filterHidden: boolean }[] = [];
|
|
@@ -632,6 +644,28 @@ export class ThreadGraph extends BaseNetworkGraph {
|
|
|
632
644
|
}
|
|
633
645
|
}
|
|
634
646
|
|
|
647
|
+
if (edgesInPair.some(e => e.visEdge.hidden !== true)) {
|
|
648
|
+
// Count every visible link, LQI or not: excluding LQI-less links would
|
|
649
|
+
// make their peers look like leaves.
|
|
650
|
+
linkCounts.set(pair.nodeA, (linkCounts.get(pair.nodeA) ?? 0) + 1);
|
|
651
|
+
linkCounts.set(pair.nodeB, (linkCounts.get(pair.nodeB) ?? 0) + 1);
|
|
652
|
+
|
|
653
|
+
const liveLqis = new Array<number>();
|
|
654
|
+
for (const e of edgesInPair) {
|
|
655
|
+
if (e.conn.signalLevel === "none" || e.conn.lqi === null) continue;
|
|
656
|
+
liveLqis.push(e.conn.lqi);
|
|
657
|
+
}
|
|
658
|
+
if (liveLqis.length > 0) {
|
|
659
|
+
const avgLqi = liveLqis.reduce((sum, lqi) => sum + lqi, 0) / liveLqis.length;
|
|
660
|
+
pairSprings.push({
|
|
661
|
+
edges: edgesInPair.map(e => e.visEdge),
|
|
662
|
+
nodeA: pair.nodeA,
|
|
663
|
+
nodeB: pair.nodeB,
|
|
664
|
+
baseLength: lqiToEdgeLength(avgLqi),
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
635
669
|
// Save base state and collect edges for the dataset
|
|
636
670
|
for (const e of edgesInPair) {
|
|
637
671
|
const isHidden = e.visEdge.hidden ?? false;
|
|
@@ -651,6 +685,14 @@ export class ThreadGraph extends BaseNetworkGraph {
|
|
|
651
685
|
}
|
|
652
686
|
}
|
|
653
687
|
|
|
688
|
+
for (const spring of pairSprings) {
|
|
689
|
+
const isLeafLink = linkCounts.get(spring.nodeA) === 1 || linkCounts.get(spring.nodeB) === 1;
|
|
690
|
+
const length = spring.baseLength + (isLeafLink ? LEAF_EDGE_LENGTH_PENALTY : 0);
|
|
691
|
+
for (const edge of spring.edges) {
|
|
692
|
+
edge.length = length;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
|
|
654
696
|
// --- Update vis.js datasets ---
|
|
655
697
|
|
|
656
698
|
const existingNodeIds = this._nodesDataSet.getIds();
|
|
@@ -9,7 +9,12 @@ import "@material/web/button/text-button";
|
|
|
9
9
|
import "@material/web/checkbox/checkbox";
|
|
10
10
|
import "@material/web/dialog/dialog";
|
|
11
11
|
import { consume } from "@lit/context";
|
|
12
|
-
import
|
|
12
|
+
import {
|
|
13
|
+
isLongIdleTimeDevice,
|
|
14
|
+
THREAD_TOPOLOGY_ATTRIBUTE_PATHS,
|
|
15
|
+
type MatterClient,
|
|
16
|
+
type MatterNode,
|
|
17
|
+
} from "@matter-server/ws-client";
|
|
13
18
|
import { mdiLoading } from "@mdi/js";
|
|
14
19
|
import { LitElement, css, html, nothing, svg } from "lit";
|
|
15
20
|
import { customElement, property, state } from "lit/decorators.js";
|
|
@@ -23,12 +28,14 @@ declare global {
|
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
|
|
26
|
-
/** Thread network attributes to read */
|
|
27
|
-
const THREAD_ATTRIBUTE_PATHS = ["0/53/7", "0/53/8", "0/51/0"]; // NeighborTable, RouteTable, NetworkInterfaces
|
|
28
|
-
|
|
29
31
|
/** WiFi network attributes to read */
|
|
30
32
|
const WIFI_ATTRIBUTE_PATHS = ["0/54/0", "0/54/3", "0/54/4"]; // BSSID, Channel, RSSI
|
|
31
33
|
|
|
34
|
+
// A LIT node answers when it next polls, which can be hours away. Give it a short grace period once
|
|
35
|
+
// the other nodes are done, capped so one sleepy device cannot hold the dialog open.
|
|
36
|
+
const LIT_GRACE_MS = 10_000;
|
|
37
|
+
const LIT_MAX_WAIT_MS = 20_000;
|
|
38
|
+
|
|
32
39
|
@customElement("update-connections-dialog")
|
|
33
40
|
export class UpdateConnectionsDialog extends LitElement {
|
|
34
41
|
@consume({ context: clientContext })
|
|
@@ -61,10 +68,20 @@ export class UpdateConnectionsDialog extends LitElement {
|
|
|
61
68
|
/** Timeout ID for auto-close */
|
|
62
69
|
private _timeoutId: ReturnType<typeof setTimeout> | null = null;
|
|
63
70
|
|
|
71
|
+
private _litTimeoutId: ReturnType<typeof setTimeout> | null = null;
|
|
72
|
+
|
|
73
|
+
private _litGraceResolve: (() => void) | null = null;
|
|
74
|
+
|
|
64
75
|
/** Track if we've already dispatched close event to prevent double-firing */
|
|
65
76
|
private _hasClosedEvent: boolean = false;
|
|
66
77
|
|
|
67
78
|
override firstUpdated(): void {
|
|
79
|
+
// A sleeping node cannot report its own link data in time, so its neighbours — which can — are
|
|
80
|
+
// the default target rather than an opt-in extra.
|
|
81
|
+
if (this._selectedIsLongIdleTime) {
|
|
82
|
+
this._includeNeighbors = true;
|
|
83
|
+
}
|
|
84
|
+
|
|
68
85
|
// Open dialog when component is first rendered
|
|
69
86
|
const dialog = this.shadowRoot?.querySelector("md-dialog") as HTMLElement & { show: () => void };
|
|
70
87
|
dialog?.show();
|
|
@@ -77,6 +94,7 @@ export class UpdateConnectionsDialog extends LitElement {
|
|
|
77
94
|
clearTimeout(this._timeoutId);
|
|
78
95
|
this._timeoutId = null;
|
|
79
96
|
}
|
|
97
|
+
this._endLongIdleTimeGrace();
|
|
80
98
|
}
|
|
81
99
|
|
|
82
100
|
/**
|
|
@@ -100,7 +118,7 @@ export class UpdateConnectionsDialog extends LitElement {
|
|
|
100
118
|
const networkType = getNetworkType(node);
|
|
101
119
|
|
|
102
120
|
if (networkType === "thread") {
|
|
103
|
-
return
|
|
121
|
+
return [...THREAD_TOPOLOGY_ATTRIBUTE_PATHS];
|
|
104
122
|
}
|
|
105
123
|
if (networkType === "wifi") {
|
|
106
124
|
return WIFI_ATTRIBUTE_PATHS;
|
|
@@ -124,6 +142,54 @@ export class UpdateConnectionsDialog extends LitElement {
|
|
|
124
142
|
return this.onlineNeighborIds;
|
|
125
143
|
}
|
|
126
144
|
|
|
145
|
+
private _longIdleTimeGrace(startedAt: number): Promise<void> {
|
|
146
|
+
const budget = Math.min(LIT_GRACE_MS, LIT_MAX_WAIT_MS - (Date.now() - startedAt));
|
|
147
|
+
if (budget <= 0) return Promise.resolve();
|
|
148
|
+
return new Promise<void>(resolve => {
|
|
149
|
+
this._litGraceResolve = resolve;
|
|
150
|
+
this._litTimeoutId = setTimeout(resolve, budget);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Ends the grace period. Resolving is what matters: dropping the timer alone would leave the raced
|
|
156
|
+
* promise pending on a LIT read that only settles on the client's command timeout, holding this
|
|
157
|
+
* element and its node map alive for as long as that takes.
|
|
158
|
+
*/
|
|
159
|
+
private _endLongIdleTimeGrace(): void {
|
|
160
|
+
if (this._litTimeoutId) {
|
|
161
|
+
clearTimeout(this._litTimeoutId);
|
|
162
|
+
this._litTimeoutId = null;
|
|
163
|
+
}
|
|
164
|
+
this._litGraceResolve?.();
|
|
165
|
+
this._litGraceResolve = null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
private get _selectedIsLongIdleTime(): boolean {
|
|
169
|
+
if (this.selectedNodeType !== "online" || this.selectedNodeId === null) return false;
|
|
170
|
+
const node = this.nodes[String(this.selectedNodeId)];
|
|
171
|
+
return node !== undefined && isLongIdleTimeDevice(node.attributes);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private get _longIdleTimeNodeIds(): string[] {
|
|
175
|
+
return this._getNodeIdsToUpdate().filter(nodeId => {
|
|
176
|
+
const node = this.nodes[nodeId];
|
|
177
|
+
return node !== undefined && isLongIdleTimeDevice(node.attributes);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
private _readNode(nodeIdStr: string): Promise<void> {
|
|
182
|
+
const node = this.nodes[nodeIdStr];
|
|
183
|
+
if (!node) return Promise.resolve();
|
|
184
|
+
|
|
185
|
+
const paths = this._getAttributePathsForNode(nodeIdStr);
|
|
186
|
+
if (paths.length === 0) return Promise.resolve();
|
|
187
|
+
|
|
188
|
+
// fabric_filtered must match the node subscription's filter (true), else matter.js
|
|
189
|
+
// discards the read and no attribute_updated fires, leaving the store stale.
|
|
190
|
+
return this.client.readAttribute(node.node_id, paths, undefined, true).then(() => undefined);
|
|
191
|
+
}
|
|
192
|
+
|
|
127
193
|
private async _executeUpdate(): Promise<void> {
|
|
128
194
|
if (this._isUpdating || this._updateCount === 0) return;
|
|
129
195
|
|
|
@@ -135,24 +201,40 @@ export class UpdateConnectionsDialog extends LitElement {
|
|
|
135
201
|
this._closeDialog();
|
|
136
202
|
}, 30000);
|
|
137
203
|
|
|
204
|
+
const startedAt = Date.now();
|
|
205
|
+
|
|
138
206
|
try {
|
|
207
|
+
const longIdleTime = new Set(this._longIdleTimeNodeIds);
|
|
139
208
|
const nodeIds = this._getNodeIdsToUpdate();
|
|
140
209
|
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
210
|
+
// A LIT node answers only when it next polls, so its read is started but never waited out:
|
|
211
|
+
// the value still lands in the store via attribute_updated whenever the node wakes up.
|
|
212
|
+
const litReads = new Array<Promise<void>>();
|
|
213
|
+
const reads = new Array<Promise<void>>();
|
|
214
|
+
let failures = 0;
|
|
215
|
+
for (const nodeId of nodeIds) {
|
|
216
|
+
const sleepy = longIdleTime.has(nodeId);
|
|
217
|
+
const read = this._readNode(nodeId).catch(error => {
|
|
218
|
+
// Only the awaited reads count: a LIT failure cannot say anything about the ones
|
|
219
|
+
// this update actually reported on.
|
|
220
|
+
if (!sleepy) failures++;
|
|
221
|
+
console.warn(`Failed to refresh network data of node ${nodeId}:`, error);
|
|
222
|
+
});
|
|
223
|
+
(sleepy ? litReads : reads).push(read);
|
|
224
|
+
}
|
|
145
225
|
|
|
146
|
-
|
|
147
|
-
|
|
226
|
+
// Return values are discarded; refreshed data arrives via attribute_updated events.
|
|
227
|
+
await Promise.all(reads);
|
|
148
228
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
});
|
|
229
|
+
if (reads.length > 0 && failures === reads.length) {
|
|
230
|
+
console.error(`Refreshing network data failed for all ${failures} nodes`);
|
|
231
|
+
}
|
|
153
232
|
|
|
154
|
-
//
|
|
155
|
-
|
|
233
|
+
// Only worth a grace period when other nodes were waited for anyway; a selection of LIT
|
|
234
|
+
// nodes alone would just spin for the full budget, which is what the dialog says it won't do.
|
|
235
|
+
if (litReads.length > 0 && reads.length > 0) {
|
|
236
|
+
await Promise.race([Promise.all(litReads), this._longIdleTimeGrace(startedAt)]);
|
|
237
|
+
}
|
|
156
238
|
|
|
157
239
|
// Close dialog on success
|
|
158
240
|
this._closeDialog();
|
|
@@ -166,6 +248,7 @@ export class UpdateConnectionsDialog extends LitElement {
|
|
|
166
248
|
clearTimeout(this._timeoutId);
|
|
167
249
|
this._timeoutId = null;
|
|
168
250
|
}
|
|
251
|
+
this._endLongIdleTimeGrace();
|
|
169
252
|
this._isUpdating = false;
|
|
170
253
|
}
|
|
171
254
|
}
|
|
@@ -192,9 +275,20 @@ export class UpdateConnectionsDialog extends LitElement {
|
|
|
192
275
|
}
|
|
193
276
|
|
|
194
277
|
private _renderOnlineContent(): unknown {
|
|
278
|
+
const sleepy = this._selectedIsLongIdleTime;
|
|
279
|
+
const neighborCount = this.onlineNeighborIds.length;
|
|
280
|
+
const plural = neighborCount !== 1 ? "s" : "";
|
|
281
|
+
|
|
195
282
|
return html`
|
|
196
|
-
|
|
197
|
-
|
|
283
|
+
${sleepy
|
|
284
|
+
? html`
|
|
285
|
+
<p>
|
|
286
|
+
"<strong>${this.selectedNodeName}</strong>" is a sleepy device (Matter LIT). It answers only
|
|
287
|
+
when it next wakes, so its own network data arrives later.
|
|
288
|
+
</p>
|
|
289
|
+
`
|
|
290
|
+
: html`<p>Refresh network information for "<strong>${this.selectedNodeName}</strong>".</p>`}
|
|
291
|
+
${neighborCount > 0
|
|
198
292
|
? html`
|
|
199
293
|
<label class="checkbox-row">
|
|
200
294
|
<md-checkbox
|
|
@@ -203,12 +297,14 @@ export class UpdateConnectionsDialog extends LitElement {
|
|
|
203
297
|
?disabled=${this._isUpdating}
|
|
204
298
|
></md-checkbox>
|
|
205
299
|
<span
|
|
206
|
-
|
|
207
|
-
neighbor${
|
|
300
|
+
>${sleepy ? "Refresh" : "Include"} ${neighborCount} connected online
|
|
301
|
+
neighbor${plural}${sleepy ? " for current link data" : ""}</span
|
|
208
302
|
>
|
|
209
303
|
</label>
|
|
210
304
|
`
|
|
211
|
-
:
|
|
305
|
+
: sleepy
|
|
306
|
+
? html`<p class="note">No online neighbor can report its current link data either.</p>`
|
|
307
|
+
: nothing}
|
|
212
308
|
`;
|
|
213
309
|
}
|
|
214
310
|
|
|
@@ -241,6 +337,23 @@ export class UpdateConnectionsDialog extends LitElement {
|
|
|
241
337
|
`;
|
|
242
338
|
}
|
|
243
339
|
|
|
340
|
+
private _renderLongIdleTimeNote(): unknown {
|
|
341
|
+
// The selected node's own sleep state is already spelled out by _renderOnlineContent.
|
|
342
|
+
const selectedId = String(this.selectedNodeId);
|
|
343
|
+
const count = this._longIdleTimeNodeIds.filter(
|
|
344
|
+
nodeId => !(this._selectedIsLongIdleTime && nodeId === selectedId),
|
|
345
|
+
).length;
|
|
346
|
+
if (count === 0) return nothing;
|
|
347
|
+
|
|
348
|
+
return html`
|
|
349
|
+
<p class="note">
|
|
350
|
+
${count === 1 ? "One of them is" : `${count} of them are`} a sleepy device (Matter LIT), so the update
|
|
351
|
+
does not wait for ${count === 1 ? "it" : "them"} — ${count === 1 ? "its" : "their"} data appears once
|
|
352
|
+
${count === 1 ? "it wakes" : "they wake"} up.
|
|
353
|
+
</p>
|
|
354
|
+
`;
|
|
355
|
+
}
|
|
356
|
+
|
|
244
357
|
override render() {
|
|
245
358
|
const buttonText =
|
|
246
359
|
this._updateCount === 0
|
|
@@ -256,6 +369,7 @@ export class UpdateConnectionsDialog extends LitElement {
|
|
|
256
369
|
: this.selectedNodeType === "offline"
|
|
257
370
|
? this._renderOfflineContent()
|
|
258
371
|
: this._renderUnknownContent()}
|
|
372
|
+
${this._renderLongIdleTimeNote()}
|
|
259
373
|
</div>
|
|
260
374
|
<div slot="actions">
|
|
261
375
|
<md-text-button @click=${this._closeDialog} ?disabled=${this._isUpdating}>Cancel</md-text-button>
|
|
@@ -296,6 +410,12 @@ export class UpdateConnectionsDialog extends LitElement {
|
|
|
296
410
|
margin-bottom: 0;
|
|
297
411
|
}
|
|
298
412
|
|
|
413
|
+
[slot="content"] p.note {
|
|
414
|
+
margin-top: 12px;
|
|
415
|
+
font-size: 0.8125rem;
|
|
416
|
+
color: var(--text-color, rgba(0, 0, 0, 0.6));
|
|
417
|
+
}
|
|
418
|
+
|
|
299
419
|
.checkbox-row {
|
|
300
420
|
display: flex;
|
|
301
421
|
align-items: center;
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
getNetworkType,
|
|
16
16
|
getSignalColorFromRssi,
|
|
17
17
|
getWiFiDiagnostics,
|
|
18
|
+
rssiToEdgeLength,
|
|
18
19
|
} from "./network-utils.js";
|
|
19
20
|
|
|
20
21
|
declare global {
|
|
@@ -146,7 +147,7 @@ export class WiFiGraph extends BaseNetworkGraph {
|
|
|
146
147
|
const apId = `ap_${wifiDiag.bssid.replace(/:/g, "")}`;
|
|
147
148
|
const signalColor = getSignalColorFromRssi(wifiDiag.rssi);
|
|
148
149
|
|
|
149
|
-
|
|
150
|
+
const edge: NetworkGraphEdge = {
|
|
150
151
|
id: `edge_${edgeIndex++}`,
|
|
151
152
|
from: nodeId,
|
|
152
153
|
to: apId,
|
|
@@ -157,7 +158,11 @@ export class WiFiGraph extends BaseNetworkGraph {
|
|
|
157
158
|
width: 2,
|
|
158
159
|
title: wifiDiag.rssi !== null ? `RSSI: ${wifiDiag.rssi} dBm` : "RSSI: Unknown",
|
|
159
160
|
dashes: isOffline, // Dashed lines for offline devices
|
|
160
|
-
}
|
|
161
|
+
};
|
|
162
|
+
if (wifiDiag.rssi !== null) {
|
|
163
|
+
edge.length = rssiToEdgeLength(wifiDiag.rssi);
|
|
164
|
+
}
|
|
165
|
+
graphEdges.push(edge);
|
|
161
166
|
}
|
|
162
167
|
}
|
|
163
168
|
|