add pwr,conn,agct,cict to getDeviceDetails #6650
Signed-off-by: si458 <simonsmith5521@gmail.com>
si458 committed
Jan 2, 2025 at 23:49 UTC
fe02d3158dfa056c9e22f0db8065c515e99c64d6
1 file changed
+23
-1
meshuser.js
+23
-1
@@ -5089,7 +5089,29 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5089
5090
// Merge any last connection information
5091
const lc = lastConnects['lc' + results[i].node._id];
5092
- if (lc != null) { delete lc._id; delete lc.type;; delete lc.meshid; delete lc.domain; results[i].lastConnect = lc; }
5092
+ if (lc != null) { delete lc._id; delete lc.type; delete lc.meshid; delete lc.domain; results[i].lastConnect = lc; }
5093
+
5094
+ // Remove any connectivity and power state information, that should not be in the database anyway.
5095
+ // TODO: Find why these are sometimes saved in the db.
5096
+ if (results[i].node.conn != null) { delete results[i].node.conn; }
5097
+ if (results[i].node.pwr != null) { delete results[i].node.pwr; }
5098
+ if (results[i].node.agct != null) { delete results[i].node.agct; }
5099
+ if (results[i].node.cict != null) { delete results[i].node.cict; }
5100
+
5101
+ // Add the connection state
5102
+ var state = parent.parent.GetConnectivityState(results[i].node._id);
5103
+ if (state) {
5104
+ results[i].node.conn = state.connectivity;
5105
+ results[i].node.pwr = state.powerState;
5106
+ if ((state.connectivity & 1) != 0) { var agent = parent.wsagents[results[i].node._id]; if (agent != null) { results[i].node.agct = agent.connectTime; } }
5107
+
5108
+ // Use the connection time of the CIRA/Relay connection
5109
+ if ((state.connectivity & 2) != 0) {
5110
+ var ciraConnection = parent.parent.mpsserver.GetConnectionToNode(results[i].node._id, null, true);
5111
+ if ((ciraConnection != null) && (ciraConnection.tag != null)) { results[i].node.cict = ciraConnection.tag.connectTime; }
5112
+ }
5113
+ }
5114
+
5115
}
5116
5117
var output = null;