Skip to content

Commit

Permalink
feat(hwcontrol) add pjlink timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
smarthomeagentur committed Oct 11, 2024
1 parent 5b8404a commit 3283cbc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ POST http://XXX.XXX.XXX.XXX:3009/shutdown
}
```



### Debug

#### Check PJLINK Connection

To check if pjlink reacts on the projector you can use a simple netcat command: `echo '%1POWR ?' | nc 192.168.XXX.XXX 4352`. There should be a response like `POWR=0`.

### Screenshot 📸

Enable `public device url`. Make sure you also have [xserver](https://github.com/wirewirewirewire/xserver) running. This will allow you to get a screenshot of the application currently running on the public device url.
Expand Down
13 changes: 12 additions & 1 deletion app/hwcontrol.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,26 +108,37 @@ function getBalenaName() {
function pjlinkSet(ip, command) {
return new Promise(async (resolve, reject) => {
const projector = new PJLink(ip, 4352);
var timeout = setTimeout(() => {
console.log("[PJLINK] ERROR timeout sendig command: " + command + " to: " + ip);
resolve(false);
return;
}, 10000);
if (command == "on") {
projector.powerOn(function (err) {
if (err) {
console.log("[PJLINK] error turning on", err);
clearTimeout(timeout);
resolve(false);
return;
}
console.log("[PJLINK] turned on: " + ip);
clearTimeout(timeout);
resolve(true);
return;
});
}
if (command == "off") {
projector.powerOff(function (err) {
if (err) {
console.log("[PJLINK] error turning on", err);
clearTimeout(timeout);
resolve(false);
return;
}
console.log("[PJLINK] turned on: " + ip);
console.log("[PJLINK] turned off: " + ip);
clearTimeout(timeout);
resolve(true);
return;
});
}
});
Expand Down

0 comments on commit 3283cbc

Please sign in to comment.