collect neighbour info
This commit is contained in:
30
src/mqtt.js
30
src/mqtt.js
@ -19,6 +19,7 @@ root.resolvePath = (origin, target) => path.join(__dirname, "protos", target);
|
||||
root.loadSync('meshtastic/mqtt.proto');
|
||||
const Data = root.lookupType("Data");
|
||||
const ServiceEnvelope = root.lookupType("ServiceEnvelope");
|
||||
const NeighborInfo = root.lookupType("NeighborInfo");
|
||||
const Position = root.lookupType("Position");
|
||||
const Telemetry = root.lookupType("Telemetry");
|
||||
const User = root.lookupType("User");
|
||||
@ -160,6 +161,35 @@ client.on("message", async (topic, message) => {
|
||||
|
||||
}
|
||||
|
||||
if(portnum === 71) {
|
||||
|
||||
const neighbourInfo = NeighborInfo.decode(envelope.packet.decoded.payload);
|
||||
|
||||
console.log("NEIGHBORINFO_APP", {
|
||||
from: envelope.packet.from.toString(16),
|
||||
// envelope: envelope,
|
||||
neighbour_info: neighbourInfo,
|
||||
});
|
||||
|
||||
try {
|
||||
await prisma.neighbourInfo.create({
|
||||
data: {
|
||||
node_id: envelope.packet.from,
|
||||
node_broadcast_interval_secs: neighbourInfo.nodeBroadcastIntervalSecs,
|
||||
neighbours: neighbourInfo.neighbors.map((neighbour) => {
|
||||
return {
|
||||
node_id: neighbour.nodeId,
|
||||
snr: neighbour.snr,
|
||||
};
|
||||
}),
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(portnum === 67) {
|
||||
|
||||
const telemetry = Telemetry.decode(envelope.packet.decoded.payload);
|
||||
|
Reference in New Issue
Block a user