store neighbour info directly in the nodes table
This commit is contained in:
@ -0,0 +1,3 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE `nodes` ADD COLUMN `neighbour_broadcast_interval_secs` INTEGER NULL,
|
||||||
|
ADD COLUMN `neighbours` JSON NULL;
|
@ -31,6 +31,9 @@ model Node {
|
|||||||
channel_utilization Decimal?
|
channel_utilization Decimal?
|
||||||
air_util_tx Decimal?
|
air_util_tx Decimal?
|
||||||
|
|
||||||
|
neighbour_broadcast_interval_secs Int?
|
||||||
|
neighbours Json?
|
||||||
|
|
||||||
created_at DateTime @default(now())
|
created_at DateTime @default(now())
|
||||||
updated_at DateTime @default(now()) @updatedAt
|
updated_at DateTime @default(now()) @updatedAt
|
||||||
|
|
||||||
|
21
src/mqtt.js
21
src/mqtt.js
@ -273,6 +273,7 @@ client.on("message", async (topic, message) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create neighbour info
|
||||||
try {
|
try {
|
||||||
await prisma.neighbourInfo.create({
|
await prisma.neighbourInfo.create({
|
||||||
data: {
|
data: {
|
||||||
@ -290,6 +291,26 @@ client.on("message", async (topic, message) => {
|
|||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update node neighbour info in db
|
||||||
|
try {
|
||||||
|
await prisma.node.updateMany({
|
||||||
|
where: {
|
||||||
|
node_id: envelope.packet.from,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
neighbour_broadcast_interval_secs: neighbourInfo.nodeBroadcastIntervalSecs,
|
||||||
|
neighbours: neighbourInfo.neighbors.map((neighbour) => {
|
||||||
|
return {
|
||||||
|
node_id: neighbour.nodeId,
|
||||||
|
snr: neighbour.snr,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(portnum === 67) {
|
else if(portnum === 67) {
|
||||||
|
Reference in New Issue
Block a user