@matter-server/dashboard 0.6.2 → 0.6.3-alpha.0-20260429-7b8104b
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/pages/matter-network-view.d.ts +11 -0
- package/dist/esm/pages/matter-network-view.d.ts.map +1 -1
- package/dist/esm/pages/matter-network-view.js +143 -1
- package/dist/esm/pages/matter-network-view.js.map +1 -1
- package/dist/esm/pages/network/base-network-graph.d.ts +4 -0
- package/dist/esm/pages/network/base-network-graph.d.ts.map +1 -1
- package/dist/esm/pages/network/base-network-graph.js +9 -0
- package/dist/esm/pages/network/base-network-graph.js.map +1 -1
- package/dist/esm/pages/network/network-details.d.ts +6 -6
- package/dist/esm/pages/network/network-details.d.ts.map +1 -1
- package/dist/esm/pages/network/network-details.js +74 -76
- package/dist/esm/pages/network/network-details.js.map +1 -1
- package/dist/esm/pages/network/network-types.d.ts +38 -0
- package/dist/esm/pages/network/network-types.d.ts.map +1 -1
- package/dist/esm/pages/network/network-types.js.map +1 -1
- package/dist/esm/pages/network/network-utils.d.ts +45 -16
- package/dist/esm/pages/network/network-utils.d.ts.map +1 -1
- package/dist/esm/pages/network/network-utils.js +115 -80
- package/dist/esm/pages/network/network-utils.js.map +1 -1
- package/dist/esm/pages/network/thread-graph.d.ts +62 -0
- package/dist/esm/pages/network/thread-graph.d.ts.map +1 -1
- package/dist/esm/pages/network/thread-graph.js +339 -31
- package/dist/esm/pages/network/thread-graph.js.map +2 -2
- package/dist/web/js/{attribute-write-dialog-g4B6BoRt.js → attribute-write-dialog-Bq4WRAPd.js} +1 -1
- package/dist/web/js/{command-invoke-dialog-D6G704VK.js → command-invoke-dialog-BIpV8LqS.js} +1 -1
- package/dist/web/js/{commission-node-dialog-Bg3oo5ub.js → commission-node-dialog-Dge7vt1X.js} +4 -4
- package/dist/web/js/{commission-node-existing-DO3g1aQJ.js → commission-node-existing-BbQVV2ag.js} +2 -2
- package/dist/web/js/{commission-node-thread-DM432aH1.js → commission-node-thread-DvHzxYrT.js} +2 -2
- package/dist/web/js/{commission-node-wifi-Bx40FXij.js → commission-node-wifi-sZt9CzyL.js} +2 -2
- package/dist/web/js/{dialog-box-DjyfULWB.js → dialog-box-CQXluAt6.js} +1 -1
- package/dist/web/js/{fire_event-BstgNPuh.js → fire_event-CjgNg3ka.js} +1 -1
- package/dist/web/js/main.js +1 -1
- package/dist/web/js/{matter-dashboard-app-Cj88TtbZ.js → matter-dashboard-app-DH_5WkVB.js} +777 -232
- package/dist/web/js/{node-binding-dialog-9yy2LE3_.js → node-binding-dialog-Dzz35dyd.js} +1 -1
- package/dist/web/js/{settings-dialog-Cs2xMsXb.js → settings-dialog-B-CQ09b1.js} +1 -1
- package/package.json +4 -4
- package/src/pages/matter-network-view.ts +150 -1
- package/src/pages/network/base-network-graph.ts +10 -0
- package/src/pages/network/network-details.ts +78 -93
- package/src/pages/network/network-types.ts +35 -0
- package/src/pages/network/network-utils.ts +207 -144
- package/src/pages/network/thread-graph.ts +470 -42
|
@@ -9,7 +9,9 @@ import { getCssVar } from "../../util/shared-styles.js";
|
|
|
9
9
|
import type {
|
|
10
10
|
CategorizedDevices,
|
|
11
11
|
NetworkType,
|
|
12
|
+
SignalLevel,
|
|
12
13
|
ThreadConnection,
|
|
14
|
+
ThreadEdgePair,
|
|
13
15
|
ThreadNeighbor,
|
|
14
16
|
ThreadRoute,
|
|
15
17
|
UnknownThreadDevice,
|
|
@@ -451,8 +453,6 @@ export function findUnknownDevices(
|
|
|
451
453
|
return Array.from(unknownMap.values());
|
|
452
454
|
}
|
|
453
455
|
|
|
454
|
-
export type SignalLevel = "strong" | "medium" | "weak";
|
|
455
|
-
|
|
456
456
|
/** Determine signal level from a Thread neighbor's RSSI/LQI. */
|
|
457
457
|
export function getSignalLevel(neighbor: ThreadNeighbor): SignalLevel {
|
|
458
458
|
const rssi = neighbor.avgRssi ?? neighbor.lastRssi;
|
|
@@ -461,8 +461,13 @@ export function getSignalLevel(neighbor: ThreadNeighbor): SignalLevel {
|
|
|
461
461
|
if (rssi > SIGNAL_MEDIUM_THRESHOLD) return "medium";
|
|
462
462
|
return "weak";
|
|
463
463
|
}
|
|
464
|
-
|
|
465
|
-
|
|
464
|
+
return getSignalLevelFromLqi(neighbor.lqi);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/** Determine signal level from an LQI value alone (e.g. route table entries without RSSI). */
|
|
468
|
+
export function getSignalLevelFromLqi(lqi: number): SignalLevel {
|
|
469
|
+
if (lqi > LQI_STRONG_THRESHOLD) return "strong";
|
|
470
|
+
if (lqi > LQI_MEDIUM_THRESHOLD) return "medium";
|
|
466
471
|
return "weak";
|
|
467
472
|
}
|
|
468
473
|
|
|
@@ -669,20 +674,73 @@ export function getWiFiVersionName(version: number | null): string {
|
|
|
669
674
|
}
|
|
670
675
|
|
|
671
676
|
/**
|
|
672
|
-
*
|
|
673
|
-
*
|
|
674
|
-
* Includes connections to unknown devices (prefixed with 'unknown_').
|
|
677
|
+
* Represents a connection from the perspective of a specific node.
|
|
678
|
+
* Includes both neighbors this node reports AND nodes that report this node as their neighbor.
|
|
675
679
|
*/
|
|
676
|
-
export
|
|
680
|
+
export interface NodeConnection {
|
|
681
|
+
/** The connected node ID (number for known nodes, string for unknown devices) */
|
|
682
|
+
connectedNodeId: number | string;
|
|
683
|
+
/** The connected MatterNode if it's a known device */
|
|
684
|
+
connectedNode?: MatterNode;
|
|
685
|
+
/** Extended address hex string for display */
|
|
686
|
+
extAddressHex: string;
|
|
687
|
+
/** Signal strength info (if available) */
|
|
688
|
+
signalColor: string;
|
|
689
|
+
/** Undefined when link strength is unknown. */
|
|
690
|
+
signalLevel?: SignalLevel;
|
|
691
|
+
lqi: number | null;
|
|
692
|
+
rssi: number | null;
|
|
693
|
+
/** Whether this connection is from THIS node's neighbor table (true) or from the OTHER node's table (false) */
|
|
694
|
+
isOutgoing: boolean;
|
|
695
|
+
/** True when only the peer reports this edge — this node has no matching neighbor-table entry. Surfaces true asymmetric visibility, distinct from a reverse view caused by filtering. */
|
|
696
|
+
isReverseOnly: boolean;
|
|
697
|
+
/** Whether this is an unknown/external device */
|
|
698
|
+
isUnknown: boolean;
|
|
699
|
+
/** Path cost from route table (1 = direct, higher = multi-hop). Only available for routers. */
|
|
700
|
+
pathCost?: number;
|
|
701
|
+
/** Bidirectional LQI from route table (average of lqiIn and lqiOut) */
|
|
702
|
+
bidirectionalLqi?: number;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Creates a canonical pair key from two node IDs.
|
|
707
|
+
* The key is always ordered so that the same pair produces the same key regardless of direction.
|
|
708
|
+
*/
|
|
709
|
+
export function makePairKey(a: string, b: string): string {
|
|
710
|
+
return a < b ? `${a}|${b}` : `${b}|${a}`;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Computes a numeric signal score for edge comparison.
|
|
715
|
+
* Lower score = weaker signal (worst case).
|
|
716
|
+
*/
|
|
717
|
+
export function getEdgeSignalScore(conn: ThreadConnection): number {
|
|
718
|
+
const levelScore =
|
|
719
|
+
conn.signalLevel === "strong"
|
|
720
|
+
? 3000
|
|
721
|
+
: conn.signalLevel === "medium"
|
|
722
|
+
? 2000
|
|
723
|
+
: conn.signalLevel === "weak"
|
|
724
|
+
? 1000
|
|
725
|
+
: 0;
|
|
726
|
+
const detail = conn.rssi !== null ? conn.rssi + 200 : conn.lqi;
|
|
727
|
+
return levelScore + detail;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* Builds edge pairs for all Thread connections.
|
|
732
|
+
* Each pair represents two connected nodes with up to 2 directional edges
|
|
733
|
+
* (one from each node's neighbor/route table). No dedup is performed —
|
|
734
|
+
* callers are responsible for selecting which edge to display per pair.
|
|
735
|
+
*/
|
|
736
|
+
export function buildThreadEdgePairs(
|
|
677
737
|
nodes: Record<string, MatterNode>,
|
|
678
738
|
extAddrMap: Map<bigint, string>,
|
|
679
739
|
rloc16Map: Map<number, string>,
|
|
680
740
|
unknownDevices: UnknownThreadDevice[],
|
|
681
|
-
):
|
|
682
|
-
const
|
|
683
|
-
const seenConnections = new Set<string>();
|
|
741
|
+
): Map<string, ThreadEdgePair> {
|
|
742
|
+
const pairs = new Map<string, ThreadEdgePair>();
|
|
684
743
|
|
|
685
|
-
// Build map of unknown device extAddress -> id
|
|
686
744
|
const unknownExtAddrMap = new Map<bigint, string>();
|
|
687
745
|
for (const unknown of unknownDevices) {
|
|
688
746
|
unknownExtAddrMap.set(unknown.extAddress, unknown.id);
|
|
@@ -693,55 +751,50 @@ export function buildThreadConnections(
|
|
|
693
751
|
const neighbors = parseNeighborTable(node);
|
|
694
752
|
|
|
695
753
|
for (const neighbor of neighbors) {
|
|
696
|
-
// Try to find in known devices first (extAddress, then RLOC16 fallback)
|
|
697
754
|
let toNodeId: string | undefined = extAddrMap.get(neighbor.extAddress);
|
|
698
755
|
if (toNodeId === undefined && neighbor.rloc16 !== 0) {
|
|
699
756
|
toNodeId = rloc16Map.get(neighbor.rloc16);
|
|
700
757
|
}
|
|
701
|
-
|
|
702
|
-
// If not found, check unknown devices
|
|
703
758
|
if (toNodeId === undefined) {
|
|
704
759
|
toNodeId = unknownExtAddrMap.get(neighbor.extAddress);
|
|
705
760
|
}
|
|
761
|
+
if (toNodeId === undefined || fromNodeId === toNodeId) continue;
|
|
706
762
|
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
763
|
+
const pairKey = makePairKey(fromNodeId, toNodeId);
|
|
764
|
+
if (!pairs.has(pairKey)) {
|
|
765
|
+
const [nodeA, nodeB] = fromNodeId < toNodeId ? [fromNodeId, toNodeId] : [toNodeId, fromNodeId];
|
|
766
|
+
pairs.set(pairKey, { pairKey, nodeA, nodeB });
|
|
710
767
|
}
|
|
711
768
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
continue;
|
|
715
|
-
}
|
|
769
|
+
const pair = pairs.get(pairKey)!;
|
|
770
|
+
const isFromA = fromNodeId === pair.nodeA;
|
|
716
771
|
|
|
717
|
-
//
|
|
718
|
-
|
|
719
|
-
|
|
772
|
+
// Neighbor table entry takes precedence — skip if already present for this direction
|
|
773
|
+
if (isFromA && pair.edgeAB) continue;
|
|
774
|
+
if (!isFromA && pair.edgeBA) continue;
|
|
720
775
|
|
|
721
|
-
if (seenConnections.has(connectionKey) || seenConnections.has(reverseKey)) {
|
|
722
|
-
// Already have this connection
|
|
723
|
-
continue;
|
|
724
|
-
}
|
|
725
|
-
seenConnections.add(connectionKey);
|
|
726
|
-
|
|
727
|
-
// Look up route table entry for supplementary data (pathCost, bidirectional LQI)
|
|
728
776
|
const routeEntry = findRouteByExtAddress(node, neighbor.extAddress);
|
|
729
777
|
const bidirectionalLqi = routeEntry ? getRouteBidirectionalLqi(routeEntry) : undefined;
|
|
730
778
|
|
|
731
|
-
|
|
732
|
-
connections.push({
|
|
779
|
+
const edge: ThreadConnection = {
|
|
733
780
|
fromNodeId,
|
|
734
781
|
toNodeId,
|
|
735
782
|
signalColor: getSignalColor(neighbor),
|
|
783
|
+
signalLevel: getSignalLevel(neighbor),
|
|
736
784
|
lqi: neighbor.lqi,
|
|
737
785
|
rssi: neighbor.avgRssi ?? neighbor.lastRssi,
|
|
738
786
|
pathCost: routeEntry?.pathCost,
|
|
739
787
|
bidirectionalLqi,
|
|
740
|
-
}
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
if (isFromA) {
|
|
791
|
+
pair.edgeAB = edge;
|
|
792
|
+
} else {
|
|
793
|
+
pair.edgeBA = edge;
|
|
794
|
+
}
|
|
741
795
|
}
|
|
742
796
|
|
|
743
|
-
//
|
|
744
|
-
// This helps when neighbor table is stale or incomplete
|
|
797
|
+
// Supplementary: route table entries not already covered by neighbor table
|
|
745
798
|
const routes = parseRouteTable(node);
|
|
746
799
|
for (const route of routes) {
|
|
747
800
|
if (!route.linkEstablished || !route.allocated) continue;
|
|
@@ -755,156 +808,166 @@ export function buildThreadConnections(
|
|
|
755
808
|
}
|
|
756
809
|
if (toNodeId === undefined || toNodeId === fromNodeId) continue;
|
|
757
810
|
|
|
758
|
-
const
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
if (seenConnections.has(connectionKey) || seenConnections.has(reverseKey)) {
|
|
763
|
-
continue;
|
|
811
|
+
const pairKey = makePairKey(fromNodeId, toNodeId);
|
|
812
|
+
if (!pairs.has(pairKey)) {
|
|
813
|
+
const [nodeA, nodeB] = fromNodeId < toNodeId ? [fromNodeId, toNodeId] : [toNodeId, fromNodeId];
|
|
814
|
+
pairs.set(pairKey, { pairKey, nodeA, nodeB });
|
|
764
815
|
}
|
|
765
|
-
|
|
816
|
+
|
|
817
|
+
const pair = pairs.get(pairKey)!;
|
|
818
|
+
const isFromA = fromNodeId === pair.nodeA;
|
|
819
|
+
|
|
820
|
+
// Only add from route table if no neighbor table edge for this direction
|
|
821
|
+
if (isFromA && pair.edgeAB) continue;
|
|
822
|
+
if (!isFromA && pair.edgeBA) continue;
|
|
766
823
|
|
|
767
824
|
const bidirectionalLqi = getRouteBidirectionalLqi(route);
|
|
768
825
|
const signalColor =
|
|
769
826
|
bidirectionalLqi !== undefined
|
|
770
827
|
? getSignalColorFromLqi(bidirectionalLqi)
|
|
771
|
-
: "var(--md-sys-color-outline, grey)";
|
|
828
|
+
: "var(--md-sys-color-outline, grey)";
|
|
772
829
|
|
|
773
|
-
|
|
830
|
+
const edge: ThreadConnection = {
|
|
774
831
|
fromNodeId,
|
|
775
832
|
toNodeId,
|
|
776
833
|
signalColor,
|
|
834
|
+
signalLevel: bidirectionalLqi !== undefined ? getSignalLevelFromLqi(bidirectionalLqi) : undefined,
|
|
777
835
|
lqi: bidirectionalLqi ?? 0,
|
|
778
836
|
rssi: null,
|
|
779
837
|
pathCost: route.pathCost,
|
|
780
838
|
bidirectionalLqi,
|
|
781
839
|
fromRouteTable: true,
|
|
782
|
-
}
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
if (isFromA) {
|
|
843
|
+
pair.edgeAB = edge;
|
|
844
|
+
} else {
|
|
845
|
+
pair.edgeBA = edge;
|
|
846
|
+
}
|
|
783
847
|
}
|
|
784
848
|
}
|
|
785
849
|
|
|
786
|
-
return
|
|
850
|
+
return pairs;
|
|
787
851
|
}
|
|
788
852
|
|
|
789
853
|
/**
|
|
790
|
-
*
|
|
791
|
-
* Includes both neighbors this node reports AND nodes that report this node as their neighbor.
|
|
854
|
+
* Filter options for edge visibility, matching the graph's filter pipeline.
|
|
792
855
|
*/
|
|
793
|
-
export interface
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
/** Extended address hex string for display */
|
|
799
|
-
extAddressHex: string;
|
|
800
|
-
/** Signal strength info (if available) */
|
|
801
|
-
signalColor: string;
|
|
802
|
-
lqi: number | null;
|
|
803
|
-
rssi: number | null;
|
|
804
|
-
/** Whether this connection is from THIS node's neighbor table (true) or from the OTHER node's table (false) */
|
|
805
|
-
isOutgoing: boolean;
|
|
806
|
-
/** Whether this is an unknown/external device */
|
|
807
|
-
isUnknown: boolean;
|
|
808
|
-
/** Path cost from route table (1 = direct, higher = multi-hop). Only available for routers. */
|
|
809
|
-
pathCost?: number;
|
|
810
|
-
/** Bidirectional LQI from route table (average of lqiIn and lqiOut) */
|
|
811
|
-
bidirectionalLqi?: number;
|
|
856
|
+
export interface EdgeFilterOptions {
|
|
857
|
+
hideOfflineNodes?: boolean;
|
|
858
|
+
hideWeakSignalEdges?: boolean;
|
|
859
|
+
hideMediumSignalEdges?: boolean;
|
|
860
|
+
hideStrongSignalEdges?: boolean;
|
|
812
861
|
}
|
|
813
862
|
|
|
814
863
|
/**
|
|
815
|
-
*
|
|
816
|
-
*
|
|
817
|
-
*
|
|
818
|
-
*
|
|
864
|
+
* Derives NodeConnection[] from pre-computed edge pairs for a given node.
|
|
865
|
+
* Uses the same edge pairs as the graph, ensuring the side panel and the
|
|
866
|
+
* graph always agree on which connections exist.
|
|
867
|
+
*
|
|
868
|
+
* The function mirrors the graph's exact pipeline:
|
|
869
|
+
* 1. Filter each edge independently (offline cascade + signal level)
|
|
870
|
+
* 2. Among survivors per pair, prefer the outgoing edge (matches graph
|
|
871
|
+
* highlight swap); fall back to worst signal (matches graph dedup)
|
|
819
872
|
*
|
|
820
|
-
*
|
|
821
|
-
*
|
|
873
|
+
* When filters are omitted, no filtering is applied and the outgoing
|
|
874
|
+
* edge is preferred (useful for the "update connections" dialog).
|
|
822
875
|
*
|
|
823
|
-
*
|
|
876
|
+
* One entry per connected peer (no duplicates).
|
|
824
877
|
*/
|
|
825
|
-
export function
|
|
878
|
+
export function getNodeConnectionsFromPairs(
|
|
826
879
|
nodeId: string,
|
|
880
|
+
edgePairs: Map<string, ThreadEdgePair>,
|
|
827
881
|
nodes: Record<string, MatterNode>,
|
|
828
|
-
|
|
829
|
-
rloc16Map?: Map<number, string>,
|
|
882
|
+
filters?: EdgeFilterOptions,
|
|
830
883
|
): NodeConnection[] {
|
|
831
884
|
const connections: NodeConnection[] = [];
|
|
832
|
-
const seenConnectedIds = new Set<string>();
|
|
833
885
|
|
|
834
|
-
|
|
835
|
-
|
|
886
|
+
// Build set of hidden node IDs (offline cascade, same as graph)
|
|
887
|
+
const hiddenNodeIds = new Set<string>();
|
|
888
|
+
if (filters?.hideOfflineNodes) {
|
|
889
|
+
for (const node of Object.values(nodes)) {
|
|
890
|
+
if (node.available === false) {
|
|
891
|
+
hiddenNodeIds.add(String(node.node_id));
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
for (const pair of edgePairs.values()) {
|
|
897
|
+
const isA = pair.nodeA === nodeId;
|
|
898
|
+
const isB = pair.nodeB === nodeId;
|
|
899
|
+
if (!isA && !isB) continue;
|
|
900
|
+
|
|
901
|
+
const remoteId = isA ? pair.nodeB : pair.nodeA;
|
|
902
|
+
const outgoing = isA ? pair.edgeAB : pair.edgeBA;
|
|
903
|
+
const incoming = isA ? pair.edgeBA : pair.edgeAB;
|
|
904
|
+
|
|
905
|
+
// Apply filters to each edge independently (mirrors graph pipeline)
|
|
906
|
+
const survivors: { conn: ThreadConnection; isOutgoing: boolean }[] = [];
|
|
836
907
|
|
|
837
|
-
|
|
838
|
-
|
|
908
|
+
for (const [conn, isOut] of [
|
|
909
|
+
[outgoing, true],
|
|
910
|
+
[incoming, false],
|
|
911
|
+
] as const) {
|
|
912
|
+
if (!conn) continue;
|
|
839
913
|
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
914
|
+
if (filters) {
|
|
915
|
+
const fromId = String(conn.fromNodeId);
|
|
916
|
+
const toId = String(conn.toNodeId);
|
|
917
|
+
|
|
918
|
+
// Offline cascade: skip if either endpoint is hidden
|
|
919
|
+
if (hiddenNodeIds.has(fromId) || hiddenNodeIds.has(toId)) continue;
|
|
920
|
+
|
|
921
|
+
// Signal level filters
|
|
922
|
+
if (filters.hideWeakSignalEdges && conn.signalLevel === "weak") continue;
|
|
923
|
+
if (filters.hideMediumSignalEdges && conn.signalLevel === "medium") continue;
|
|
924
|
+
if (filters.hideStrongSignalEdges && conn.signalLevel === "strong") continue;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
survivors.push({ conn, isOutgoing: isOut });
|
|
846
928
|
}
|
|
847
|
-
const connectedNode = connectedNodeId ? nodes[connectedNodeId] : undefined;
|
|
848
|
-
const isUnknown = connectedNodeId === undefined;
|
|
849
|
-
const displayId: string =
|
|
850
|
-
connectedNodeId ?? `unknown_${neighbor.extAddress.toString(16).toUpperCase().padStart(16, "0")}`;
|
|
851
929
|
|
|
852
|
-
|
|
930
|
+
if (survivors.length === 0) continue;
|
|
931
|
+
|
|
932
|
+
// Among survivors: prefer outgoing (matches graph highlight swap),
|
|
933
|
+
// fall back to worst signal (matches graph dedup)
|
|
934
|
+
let winner: { conn: ThreadConnection; isOutgoing: boolean };
|
|
935
|
+
const outgoingSurvivor = survivors.find(s => s.isOutgoing);
|
|
936
|
+
if (outgoingSurvivor) {
|
|
937
|
+
winner = outgoingSurvivor;
|
|
938
|
+
} else {
|
|
939
|
+
survivors.sort((a, b) => getEdgeSignalScore(a.conn) - getEdgeSignalScore(b.conn));
|
|
940
|
+
winner = survivors[0];
|
|
941
|
+
}
|
|
853
942
|
|
|
854
|
-
|
|
855
|
-
const
|
|
856
|
-
|
|
943
|
+
const remoteNode = nodes[remoteId];
|
|
944
|
+
const isUnknown = remoteId.startsWith("unknown_");
|
|
945
|
+
|
|
946
|
+
// Derive extended address hex for display
|
|
947
|
+
let extAddressHex: string;
|
|
948
|
+
if (isUnknown) {
|
|
949
|
+
extAddressHex = remoteId.slice("unknown_".length);
|
|
950
|
+
} else if (remoteNode) {
|
|
951
|
+
extAddressHex = getThreadExtendedAddressHex(remoteNode) ?? "Unknown";
|
|
952
|
+
} else {
|
|
953
|
+
extAddressHex = "Unknown";
|
|
954
|
+
}
|
|
857
955
|
|
|
858
956
|
connections.push({
|
|
859
|
-
connectedNodeId:
|
|
860
|
-
connectedNode,
|
|
861
|
-
extAddressHex
|
|
862
|
-
signalColor:
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
957
|
+
connectedNodeId: remoteId,
|
|
958
|
+
connectedNode: remoteNode,
|
|
959
|
+
extAddressHex,
|
|
960
|
+
signalColor: winner.conn.signalColor,
|
|
961
|
+
signalLevel: winner.conn.signalLevel,
|
|
962
|
+
lqi: winner.conn.lqi,
|
|
963
|
+
rssi: winner.conn.rssi,
|
|
964
|
+
isOutgoing: winner.isOutgoing,
|
|
965
|
+
isReverseOnly: !outgoing,
|
|
866
966
|
isUnknown,
|
|
867
|
-
pathCost:
|
|
868
|
-
bidirectionalLqi,
|
|
967
|
+
pathCost: winner.conn.pathCost,
|
|
968
|
+
bidirectionalLqi: winner.conn.bidirectionalLqi,
|
|
869
969
|
});
|
|
870
970
|
}
|
|
871
971
|
|
|
872
|
-
// 2. Find nodes that report THIS node as their neighbor (incoming connections)
|
|
873
|
-
if (thisExtAddr !== undefined) {
|
|
874
|
-
for (const otherNode of Object.values(nodes)) {
|
|
875
|
-
const otherNodeId = String(otherNode.node_id);
|
|
876
|
-
if (otherNodeId === nodeId) continue; // Skip self
|
|
877
|
-
|
|
878
|
-
// Check if already connected via outgoing
|
|
879
|
-
if (seenConnectedIds.has(otherNodeId)) continue;
|
|
880
|
-
|
|
881
|
-
// Check if other node reports this node as neighbor
|
|
882
|
-
const otherNeighbors = parseNeighborTable(otherNode);
|
|
883
|
-
const reverseEntry = otherNeighbors.find(n => n.extAddress === thisExtAddr);
|
|
884
|
-
|
|
885
|
-
if (reverseEntry) {
|
|
886
|
-
const otherExtAddr = getThreadExtendedAddress(otherNode);
|
|
887
|
-
const extAddrHex = otherExtAddr ? otherExtAddr.toString(16).toUpperCase().padStart(16, "0") : "Unknown";
|
|
888
|
-
|
|
889
|
-
// Look up route table entry from the other node's perspective
|
|
890
|
-
const routeEntry = findRouteByExtAddress(otherNode, thisExtAddr);
|
|
891
|
-
const bidirectionalLqi = routeEntry ? getRouteBidirectionalLqi(routeEntry) : undefined;
|
|
892
|
-
|
|
893
|
-
connections.push({
|
|
894
|
-
connectedNodeId: otherNodeId,
|
|
895
|
-
connectedNode: otherNode,
|
|
896
|
-
extAddressHex: extAddrHex,
|
|
897
|
-
signalColor: getSignalColor(reverseEntry),
|
|
898
|
-
lqi: reverseEntry.lqi,
|
|
899
|
-
rssi: reverseEntry.avgRssi ?? reverseEntry.lastRssi,
|
|
900
|
-
isOutgoing: false,
|
|
901
|
-
isUnknown: false,
|
|
902
|
-
pathCost: routeEntry?.pathCost,
|
|
903
|
-
bidirectionalLqi,
|
|
904
|
-
});
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
|
|
909
972
|
return connections;
|
|
910
973
|
}
|