smithtek-mako-rf 2.9.7 → 2.9.8
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/package.json +1 -1
- package/smithtek-mako-rf.js +35 -3
- package/smithtek-mako-rf-2.9.7.tgz +0 -0
package/package.json
CHANGED
package/smithtek-mako-rf.js
CHANGED
|
@@ -117,7 +117,9 @@ module.exports = function (RED) {
|
|
|
117
117
|
try { port.removeListener("data", onData); } catch (_e2) {}
|
|
118
118
|
}
|
|
119
119
|
try { if (typeof port.flush === "function") port.flush(() => {}); } catch (_e) {}
|
|
120
|
+
if (state._rssiCleanup === cleanup) delete state._rssiCleanup;
|
|
120
121
|
}
|
|
122
|
+
state._rssiCleanup = cleanup;
|
|
121
123
|
|
|
122
124
|
function onData(chunk) {
|
|
123
125
|
rx = Buffer.concat([rx, Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)]);
|
|
@@ -498,6 +500,7 @@ module.exports = function (RED) {
|
|
|
498
500
|
state.busy = true;
|
|
499
501
|
|
|
500
502
|
(async () => {
|
|
503
|
+
await sleep(20);
|
|
501
504
|
while (state.queue.length > 0) {
|
|
502
505
|
const item = state.queue.shift();
|
|
503
506
|
const { node, msg, send, done, req, items } = item;
|
|
@@ -548,8 +551,9 @@ module.exports = function (RED) {
|
|
|
548
551
|
// Force reconnect next attempt
|
|
549
552
|
state.connected = false;
|
|
550
553
|
try {
|
|
551
|
-
|
|
552
|
-
|
|
554
|
+
await new Promise((resolve) => state.client.close(() => resolve()));
|
|
555
|
+
} catch (_e) {}
|
|
556
|
+
|
|
553
557
|
|
|
554
558
|
if (attempt < totalTries && gap_s > 0) {
|
|
555
559
|
await sleep(Math.floor(gap_s * 1000));
|
|
@@ -598,8 +602,12 @@ module.exports = function (RED) {
|
|
|
598
602
|
|
|
599
603
|
|
|
600
604
|
const rssiDbm = await queryRssiOnSamePort(state, guardMs, timeoutMs);
|
|
605
|
+
await sleep(30);
|
|
601
606
|
state.connected = false;
|
|
602
|
-
|
|
607
|
+
try {
|
|
608
|
+
await new Promise((resolve) => state.client.close(() => resolve()));
|
|
609
|
+
} catch (_e) {}
|
|
610
|
+
|
|
603
611
|
|
|
604
612
|
|
|
605
613
|
const nodeKeyBase = sanitizeKey(node.name || busName || "mako_rf");
|
|
@@ -652,6 +660,7 @@ module.exports = function (RED) {
|
|
|
652
660
|
this.gap_s = toNum(n.gap_s, 0);
|
|
653
661
|
this.maxQueue = toNum(n.maxQueue, 50);
|
|
654
662
|
|
|
663
|
+
BUS.delete(this.id);
|
|
655
664
|
ensureBusState(this);
|
|
656
665
|
|
|
657
666
|
this.on("close", (removed, done) => {
|
|
@@ -769,9 +778,32 @@ module.exports = function (RED) {
|
|
|
769
778
|
});
|
|
770
779
|
|
|
771
780
|
node.on("close", function (_removed, done) {
|
|
781
|
+
try {
|
|
782
|
+
const busCfg = RED.nodes.getNode(config.bus);
|
|
783
|
+
if (busCfg) {
|
|
784
|
+
const s = BUS.get(busCfg.id);
|
|
785
|
+
if (s) {
|
|
786
|
+
// NEW: stop any in-flight queue processor from the old deploy
|
|
787
|
+
s.queue = [];
|
|
788
|
+
s.busy = false;
|
|
789
|
+
|
|
790
|
+
if (typeof s._rssiCleanup === "function") {
|
|
791
|
+
try { s._rssiCleanup(); } catch (_e) {}
|
|
792
|
+
}
|
|
793
|
+
if (s.client) {
|
|
794
|
+
try { s.client.close(() => {}); } catch (_e) {}
|
|
795
|
+
s.connected = false;
|
|
796
|
+
s.client = new (require("modbus-serial"))();
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
} catch (_e) {}
|
|
801
|
+
|
|
772
802
|
node.status({});
|
|
773
803
|
done();
|
|
774
804
|
});
|
|
805
|
+
|
|
806
|
+
|
|
775
807
|
}
|
|
776
808
|
|
|
777
809
|
RED.nodes.registerType("smithtek-mako-rf", SmithtekMakoRfNode);
|
|
Binary file
|