From a6826b587e4f11561ce072041582aab3dcf37203 Mon Sep 17 00:00:00 2001 From: Bruno Gelatti Date: Tue, 7 Jan 2025 09:07:56 -0300 Subject: [PATCH 1/3] Fixed setdeviceparams for helium network --- plugins/mysql/src/Database/index.ts | 4 ++++ plugins/network-helium/src/Services/uplink.ts | 5 +++-- plugins/postgres/src/Database/index.ts | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/mysql/src/Database/index.ts b/plugins/mysql/src/Database/index.ts index 053ec6e2..fbfa54c8 100644 --- a/plugins/mysql/src/Database/index.ts +++ b/plugins/mysql/src/Database/index.ts @@ -54,6 +54,10 @@ export async function setupKnex(this: DatabaseModule, config: Config) { try { this.showMessage("info", "Testing connection"); + if (!config.main_read_host && !config.main_read_port) { + return; + } + setupConnections(config); await testDatabaseConnection(); diff --git a/plugins/network-helium/src/Services/uplink.ts b/plugins/network-helium/src/Services/uplink.ts index 8326ed9d..2866366b 100644 --- a/plugins/network-helium/src/Services/uplink.ts +++ b/plugins/network-helium/src/Services/uplink.ts @@ -90,6 +90,7 @@ async function uplinkService( const downlinkString = deviceParams.find( (param) => param.key === "downlink_string", ); + if (!downlinkString) { deviceParams.push({ key: "downlink_string", @@ -100,8 +101,8 @@ async function uplinkService( }); core.setDeviceParams(device.id, deviceParams); - } else if (downlinkString.value !== data.downlink_string) { - downlinkString.value = data.downlink_string as string; + } else if (downlinkString.value !== data.downlink_string || downlinkString.value !== data.downlink_url) { + downlinkString.value = (data.downlink_string as string) || (data.downlink_url as string); core.setDeviceParams(device.id, deviceParams); } } diff --git a/plugins/postgres/src/Database/index.ts b/plugins/postgres/src/Database/index.ts index 6e262a0d..5f86aedb 100644 --- a/plugins/postgres/src/Database/index.ts +++ b/plugins/postgres/src/Database/index.ts @@ -76,6 +76,10 @@ async function setupKnex(this: DatabaseModule, config: Config) { try { this.showMessage("info", "Testing connection"); + if (!config.main_read_host && !config.main_read_port) { + return; + } + setupConnections(config); await testDatabaseConnection(); From 585844e022149050faf9a422564e53b0869202a0 Mon Sep 17 00:00:00 2001 From: Bruno Gelatti Date: Tue, 7 Jan 2025 09:28:40 -0300 Subject: [PATCH 2/3] fix linter --- plugins/network-helium/src/Services/uplink.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/network-helium/src/Services/uplink.ts b/plugins/network-helium/src/Services/uplink.ts index 2866366b..85bfe6b0 100644 --- a/plugins/network-helium/src/Services/uplink.ts +++ b/plugins/network-helium/src/Services/uplink.ts @@ -101,8 +101,12 @@ async function uplinkService( }); core.setDeviceParams(device.id, deviceParams); - } else if (downlinkString.value !== data.downlink_string || downlinkString.value !== data.downlink_url) { - downlinkString.value = (data.downlink_string as string) || (data.downlink_url as string); + } else if ( + downlinkString.value !== data.downlink_string || + downlinkString.value !== data.downlink_url + ) { + downlinkString.value = + (data.downlink_string as string) || (data.downlink_url as string); core.setDeviceParams(device.id, deviceParams); } } From 794eeb4c1cbcd4c6712a288ae204175afd69c3c8 Mon Sep 17 00:00:00 2001 From: Bruno Gelatti Date: Tue, 7 Jan 2025 17:28:09 -0300 Subject: [PATCH 3/3] Fixed rabbitmq plugin --- plugins/nodered/README.md | 2 +- plugins/rabbitmq/src/consume-data.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/nodered/README.md b/plugins/nodered/README.md index 01d10252..f6959ce3 100644 --- a/plugins/nodered/README.md +++ b/plugins/nodered/README.md @@ -45,7 +45,7 @@ To install Node-RED on your machine, follow this tutorial that Node-RED provided ## Install Node TagoIO out on Node-RED: -To install TagoIO out node on Node-RED, click in `more options`, `manage pallet`, abd search for `TagoIO out` on the `Install”` tab and click in install. When installing is finished, the TagoIO out node will appear on the “Nodes” tab. +To install TagoIO out node on Node-RED, click in `more options`, `manage pallet`, and search for `node-red-tagocore` on the `Install”` tab and click in install. When installing is finished, the TagoIO out node will appear on the “Nodes” tab. You can check the full process in the [Node-RED documentation](https://Node-RED.org/docs/user-guide/runtime/adding-nodes). diff --git a/plugins/rabbitmq/src/consume-data.ts b/plugins/rabbitmq/src/consume-data.ts index 75b24b3d..eb73d6a8 100644 --- a/plugins/rabbitmq/src/consume-data.ts +++ b/plugins/rabbitmq/src/consume-data.ts @@ -8,8 +8,17 @@ function consumeData(msg: ConsumeMessage | null): void { return; } - const data = JSON.parse(msg.content.toString()); - const deviceID = msg.properties.messageId; + let deviceID: string; + let data: any; + + try { + data = JSON.parse(msg.content.toString()); + deviceID = msg.properties.messageId; + } catch (e) { + console.error(`ERROR: ${e.message}`); + consumer.reject(msg, false); + return; + } core .addDeviceData(deviceID, data, { forceDBInsert: true })