This commit is contained in:
HTotoo
2025-09-11 13:49:23 +02:00
parent 16503479e2
commit ccc0bcf2d6
2 changed files with 12 additions and 5 deletions
+3 -3
View File
@@ -444,7 +444,7 @@
if (data.nodes && Array.isArray(data.nodes)) {
data.nodes.forEach(node => {
if (node.id) {
node.js_last_seen = Date.now();
node.js_last_seen = node.ls;
allNodes.set(node.id, node);
}
});
@@ -477,8 +477,8 @@
if (nodesArray.length > 0) {
nodesArray.forEach(node => {
const row = document.createElement('tr');
const lat = node.pos ? node.pos.lat.toFixed(4) : 'N/A';
const lon = node.pos ? node.pos.lon.toFixed(4) : 'N/A';
const lat = node.pos ? (node.pos.lat / 1e7).toFixed(4) : 'N/A';
const lon = node.pos ? (node.pos.lon / 1e7).toFixed(4) : 'N/A';
row.innerHTML = `
<td>${node.id || 'N/A'}</td>
<td>${node.name || 'N/A'}</td>
+9 -2
View File
@@ -82,8 +82,15 @@ void app_main(void) {
meshtasticCompact.setSendEnabled(true); // we want to send packets
meshtasticCompact.setOnNodeInfoMessage([](MC_Header& header, MC_NodeInfo& nodeinfo, bool needReply) {
MC_Position pos;
meshtasticCompact.nodeinfo_db.getPosition(nodeinfo.node_id, pos);
std::string json = "{ \"type\": \"node_update\", \"nodes\": [ { \"id\": \"" + std::string(nodeinfo.id) + "\", \"name\": \"" + nodeinfo.short_name + "\", \"pos\": { \"lat\": " + std::to_string(pos.latitude_i) + ", \"lon\": " + std::to_string(pos.longitude_i) + " } } ]}";
if (!meshtasticCompact.nodeinfo_db.getPosition(nodeinfo.node_id, pos)) {
pos.latitude_i = 0;
pos.longitude_i = 0;
}
if (!pos.has_latitude_i || !pos.has_longitude_i) {
pos.latitude_i = 0;
pos.longitude_i = 0;
}
std::string json = "{ \"type\": \"node_update\", \"nodes\": [ { \"id\": \"" + std::string(nodeinfo.id) + "\", \"ls\": " + std::to_string(nodeinfo.last_updated) + " ,\"name\": \"" + nodeinfo.short_name + "\", \"pos\": { \"lat\": " + std::to_string(pos.latitude_i) + ", \"lon\": " + std::to_string(pos.longitude_i) + " } } ]}";
ws_sendall((uint8_t*)json.c_str(), json.length(), true);
});
meshtasticCompact.setOnPositionMessage([](MC_Header& header, MC_Position& pos, bool needReply) {