diff --git a/data/web/index.html b/data/web/index.html index 667b099..5e478e5 100644 --- a/data/web/index.html +++ b/data/web/index.html @@ -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 = ` ${node.id || 'N/A'} ${node.name || 'N/A'} diff --git a/main/main.cpp b/main/main.cpp index d1b5598..b30d384 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -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) {