From cd2fddea6e388366c018dea727e648a4242d4647 Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Wed, 4 Jan 2023 21:24:06 -0500 Subject: [PATCH] handle incorrect passwords better --- plugins/pjlink/main.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/pjlink/main.js b/plugins/pjlink/main.js index 52b1a2a..ca6a6c1 100644 --- a/plugins/pjlink/main.js +++ b/plugins/pjlink/main.js @@ -144,12 +144,17 @@ exports.data = function data(_device, message) { exports.heartbeat = function heartbeat(device) { passwordMD5 = md5(`${passwordSeed}${device.fields.password}`); - if (device.fields.password.length > 0) { + if (device.fields.password.length > 0 && device.data.passwordOK) { device.send( `${passwordMD5}%1POWR ?\r%1INPT ?\r%1AVMT ?\r%1ERST ?\r%1LAMP ?\r%1NAME ?\r%1INF1 ?\r%1INF2 ?\r%2SNUM ?\r%2SVER ?\r` ); - } else { + } else if (device.fields.password.length > 0) { + device.send(`${passwordMD5}%1POWR ?\r`); + } else if (device.data.passwordOK) { device.send(`%1POWR ?\r%1INPT ?\r%1AVMT ?\r%1ERST ?\r%1LAMP ?\r%1NAME ?\r%1INF1 ?\r%1INF2 ?\r%2SNUM ?\r%2SVER ?\r`); + } else { + device.send(`%1POWR ?\r`); } + device.draw(); };