-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwriteJS.js
More file actions
62 lines (58 loc) · 2.2 KB
/
writeJS.js
File metadata and controls
62 lines (58 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const fs = require("fs");
module.exports = {
write(update, filename) {
const jsontable = update.nodes.map(node => {
const d = node;
const link_info = {};
for (k in d.link_info) {
const l = d.link_info[k];
link_info[k] = {
hostname: l.hostname,
linkType: l.linkType,
signal: l.signal,
noise: l.noise,
};
}
return {
data: {
node: d.node,
lat: parseFloat(d.lat),
lon: parseFloat(d.lon),
mlat: d.mlat,
mlon: d.mlon,
grid_square: d.grid_square,
api_version: d.api_version,
lastseen: d.lastseen,
node_details: {
description: d.node_details.description,
hardware: d.node_details.hardware,
firmware_version: d.node_details.firmware_version,
mesh_supernode: d.node_details.mesh_supernode
},
meshrf: {
status: d.meshrf.status,
ssid: d.meshrf.ssid,
channel: d.meshrf.channel,
freq: d.meshrf.freq,
mode: d.meshrf.mode,
chanbw: d.meshrf.chanbw,
height: d.meshrf.height,
azimuth: d.meshrf.azimuth,
elevation: d.meshrf.elevation,
polarization: d.meshrf.polarization,
antenna: d.meshrf.antenna ? { description : d.meshrf.antenna.description } : undefined
},
interfaces: [
{ mac: d.interfaces[0] && d.interfaces[0].mac }
],
link_info: link_info
}
}
});
fs.writeFileSync(filename, "const out = " + JSON.stringify({
version: "1",
date: Date.now(),
nodeInfo: jsontable
}));
}
}