mirror of
https://github.com/Roslund/meshtastic-map.git
synced 2026-03-28 17:43:03 +01:00
add ok_to_mqtt to text-messages
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE `text_messages` ADD COLUMN `ok_to_mqtt` BOOLEAN NULL;
|
||||
@@ -239,6 +239,7 @@ model TextMessage {
|
||||
rx_snr Decimal?
|
||||
rx_rssi Int?
|
||||
hop_limit Int?
|
||||
ok_to_mqtt Boolean?
|
||||
|
||||
created_at DateTime @default(now())
|
||||
updated_at DateTime @default(now()) @updatedAt
|
||||
|
||||
15
src/mqtt.js
15
src/mqtt.js
@@ -741,6 +741,13 @@ client.on("message", async (topic, message) => {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// check if bitfield is available, then set ok-to-mqtt
|
||||
// else leave undefined to let Prisma ignore it.
|
||||
let isOkToMqtt
|
||||
if(bitfield != null){
|
||||
isOkToMqtt = Boolean(bitfield & BITFIELD_OK_TO_MQTT_MASK);
|
||||
}
|
||||
|
||||
// create service envelope in db
|
||||
if(collectServiceEnvelopes){
|
||||
@@ -818,6 +825,7 @@ client.on("message", async (topic, message) => {
|
||||
rx_snr: envelope.packet.rxSnr,
|
||||
rx_rssi: envelope.packet.rxRssi,
|
||||
hop_limit: envelope.packet.hopLimit,
|
||||
ok_to_mqtt: isOkToMqtt,
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -926,13 +934,6 @@ client.on("message", async (topic, message) => {
|
||||
});
|
||||
}
|
||||
|
||||
// check if bitfield is available, then set ok-to-mqtt
|
||||
// else leave undefined to let Prisma ignore it.
|
||||
let isOkToMqtt
|
||||
if(bitfield != null){
|
||||
isOkToMqtt = Boolean(bitfield & BITFIELD_OK_TO_MQTT_MASK);
|
||||
}
|
||||
|
||||
// create or update node in db
|
||||
try {
|
||||
await prisma.node.upsert({
|
||||
|
||||
Reference in New Issue
Block a user