Skip to content

Commit

Permalink
fix(server) wait for init done
Browse files Browse the repository at this point in the history
  • Loading branch information
smarthomeagentur committed Nov 26, 2024
1 parent 518d1a6 commit d2a127f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions app/hwcontrol.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,23 @@ function pjlinkSet(ip, command) {

module.exports = {
init: async function () {
beamerArray = BEAMER_IP.split(",");
if (beamerArray.length >= 1) {
console.log("[INIT] projector defined: " + beamerArray);
console.log("[INIT] PJLINK data:");
for (let index = 0; index < beamerArray.length; index++) {
const element = beamerArray[index];
//await sendSerialProjector("7E3030303020310D", element); //power on optoma
var status = await pjlinkSet(element, "status");
console.log(status);
return new Promise(async (resolve, reject) => {
beamerArray = BEAMER_IP.split(",");
if (beamerArray.length >= 1) {
console.log("[INIT] projector defined: " + beamerArray);
console.log("[INIT] PJLINK data:");
for (let index = 0; index < beamerArray.length; index++) {
const element = beamerArray[index];
//await sendSerialProjector("7E3030303020310D", element); //power on optoma
var status = await pjlinkSet(element, "status");
console.log(status);
}
resolve(true);
} else {
console.log("[INIT] NO projector defined");
resolve(false);
}
} else {
console.log("[INIT] NO projector defined");
}
});
},

setScreenPower: async function (powerState, screenNumber = 0, ddc = false) {
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ httpServer2.listen(PORT2, () => {
init();

async function init() {
control.init();
await control.init();
let displayCount = (await control.getDisplayCount()).data;
if (displayCount < 1) {
if (AUTOREBOOT) {
Expand Down

0 comments on commit d2a127f

Please sign in to comment.