@lifefinder/vsm-mqtt-client-open-source 0.0.59 → 0.0.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/integrations/chirpstack4.js +11 -1
- package/package.json +1 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (C) 2026, Lifefinder Systems International AB, all rights reserved.
|
|
2
|
+
// ChirpStack v4 MQTT integration. Supports plain-password auth via CS4_* env vars.
|
|
1
3
|
const mqtt = require('mqtt')
|
|
2
4
|
const { isDate } = require('util/types');
|
|
3
5
|
|
|
@@ -50,7 +52,15 @@ module.exports.api = {
|
|
|
50
52
|
connectAndSubscribe: async (args, devices, onUplinkDevicePortBufferDateLatLng) => {
|
|
51
53
|
args.v && console.log("Trying to connect to " + args.s + " with application " + args.a);
|
|
52
54
|
try {
|
|
53
|
-
|
|
55
|
+
// Build connect options — auth required for mosquitto plain-password auth (CS4).
|
|
56
|
+
// Credentials read from env so the integration file stays config-free.
|
|
57
|
+
const mqttOpts = {};
|
|
58
|
+
if (process.env.CS4_USERNAME) {
|
|
59
|
+
mqttOpts.clientId = process.env.CS4_CLIENTID || 'vsm-mqtt-client-v4';
|
|
60
|
+
mqttOpts.username = process.env.CS4_USERNAME;
|
|
61
|
+
mqttOpts.password = process.env.CS4_PASSWORD;
|
|
62
|
+
}
|
|
63
|
+
const client = mqtt.connect(args.s, mqttOpts);
|
|
54
64
|
|
|
55
65
|
client.on('connect', () => {
|
|
56
66
|
args.v && console.log("Connected to chirpstack server");
|