From e84fa48a82a593da1dfe6c2de66c77bcd6b08ba9 Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Mon, 12 Dec 2022 14:35:56 -0600 Subject: [PATCH] pretty pjlink plugin --- plugins/pjlink/info.html | 4 +-- plugins/pjlink/main.js | 51 +++++++++++++++++++-------------------- plugins/pjlink/styles.css | 2 +- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/plugins/pjlink/info.html b/plugins/pjlink/info.html index edbdc3c..4b60e01 100644 --- a/plugins/pjlink/info.html +++ b/plugins/pjlink/info.html @@ -1,4 +1,4 @@

Connection Requirements

\ No newline at end of file +
  • Requires no password on the projector
  • + diff --git a/plugins/pjlink/main.js b/plugins/pjlink/main.js index c6a7f01..2776916 100644 --- a/plugins/pjlink/main.js +++ b/plugins/pjlink/main.js @@ -2,7 +2,7 @@ const md5 = require('md5'); exports.config = { defaultName: 'PJLink Projector', - connectionType: "TCPsocket", + connectionType: 'TCPsocket', heartbeatInterval: 5000, heartbeatTimeout: 15000, defaultPort: 4352, @@ -12,28 +12,29 @@ exports.config = { searchBuffer: Buffer.from([0x25, 0x32, 0x53, 0x52, 0x43, 0x48, 0x0d]), devicePort: 4352, listenPort: 4352, - validateResponse (msg, info) { + validateResponse(msg, info) { console.log(msg.toString()); return msg.toString().indexOf('%2ACKN=') >= 0; - } + }, }, - fields: [{ - key: "password", - label: "Pass", - type: "textinput", - value: "", - action: function(device){ - device.plugin.heartbeat(device); - } - }] -} + fields: [ + { + key: 'password', + label: 'Pass', + type: 'textinput', + value: '', + action: function (device) { + device.plugin.heartbeat(device); + }, + }, + ], +}; exports.ready = function ready(device) { // Power status query // device.send("%1POWR ?\r"); }; - const PJLinkCmds = [ '%1POWR=', '%1INPT=', @@ -44,8 +45,8 @@ const PJLinkCmds = [ '%1INF1=', '%1INF2=', '%2SNUM=', - '%2SVER=' -] + '%2SVER=', +]; let passwordMD5 = false; let passwordSeed = false; @@ -123,35 +124,33 @@ exports.data = function data(device, message) { if (msg.substring(0, 8) === 'PJLINK 1') { passwordSeed = msg.substring(9, 17); passwordMD5 = md5(`${passwordSeed}${device.fields.password}`); - device.data.authentication = "ON"; + device.data.authentication = 'ON'; device.send( `${passwordMD5}%1POWR ?\r%1INPT ?\r%1AVMT ?\r%1ERST ?\r%1LAMP ?\r%1NAME ?\r%1INF1 ?\r%1INF2 ?\r%2SNUM ?\r%2SVER ?\r` ); device.draw(); - - }else if(msg.substring(0, 8) === 'PJLINK 0') { - device.data.authentication = "OFF"; + } else if (msg.substring(0, 8) === 'PJLINK 0') { + device.data.authentication = 'OFF'; device.draw(); - - }else if(msg.startsWith('PJLINK ERRA')) { + } else if (msg.startsWith('PJLINK ERRA')) { device.data.passwordOK = false; device.draw(); } - if(PJLinkCmds.includes(msg.substring(0,7))){ - processPJLink(device,msg,this); + if (PJLinkCmds.includes(msg.substring(0, 7))) { + processPJLink(device, msg, this); device.data.passwordOK = true; } }; exports.heartbeat = function heartbeat(device) { passwordMD5 = md5(`${passwordSeed}${device.fields.password}`); - if (device.fields.password.length>0) { + if (device.fields.password.length > 0) { 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 { device.send( `%1POWR ?\r%1INPT ?\r%1AVMT ?\r%1ERST ?\r%1LAMP ?\r%1NAME ?\r%1INF1 ?\r%1INF2 ?\r%2SNUM ?\r%2SVER ?\r` ); diff --git a/plugins/pjlink/styles.css b/plugins/pjlink/styles.css index 0ed35ba..970f403 100644 --- a/plugins/pjlink/styles.css +++ b/plugins/pjlink/styles.css @@ -7,7 +7,7 @@ .ok { color: #79b757; } -table{ +table { margin-bottom: 30px; width: 350px; }