Skip to content

Commit

Permalink
feat(hwcontrol) add hardware error to pjlink debug
Browse files Browse the repository at this point in the history
feat(api) add pjlinkstate to status
  • Loading branch information
smarthomeagentur committed Oct 17, 2024
1 parent ed79732 commit 518d1a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 11 additions & 4 deletions app/hwcontrol.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var DEBUG = process.env.DEBUG != "true" ? false : true;
var BEAMER_IP = process.env.BEAMER_IP || "0.0.0.0";

var beamerArray = [];
var beamerPjLinkState;

const delay = (time) => new Promise((res) => setTimeout(res, time));

Expand Down Expand Up @@ -196,10 +197,10 @@ function pjlinkSet(ip, command) {
resolve(state);
});
});
const info = await new Promise((resolve, reject) => {
projector.getInfo(function (err, state) {
const error = await new Promise((resolve, reject) => {
projector.getErrors(function (err, state) {
if (err) {
console.log("[PJLINK] error getInfo", err);
console.log("[PJLINK] error getErrors", err);
clearTimeout(timeout);
resolve("err");
return;
Expand All @@ -208,7 +209,8 @@ function pjlinkSet(ip, command) {
});
});

var stateArray = { powerstate, input, name, manufacturer, model, info };
var stateArray = { powerstate, input, name, manufacturer, model, error };
beamerPjLinkState = stateArray; // add to global for later api calls

console.log("[PJLINK] return state");
clearTimeout(timeout);
Expand Down Expand Up @@ -287,6 +289,11 @@ module.exports = {
resolve(result);
});
},
getPjlinkState: async function () {
return new Promise(async (resolve, reject) => {
resolve(beamerPjLinkState);
});
},
getBalenaName: async function () {
return new Promise(async (resolve, reject) => {
let result = await getBalenaName();
Expand Down
4 changes: 2 additions & 2 deletions app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ module.exports = function (app) {
var appName = process.env.BALENA_APP_NAME;
var deviceType = process.env.BALENA_DEVICE_TYPE;
var deviceUUID = process.env.BALENA_DEVICE_UUID;

res.send({ success: true, error: null, data: { balenaData, appName, deviceName, deviceType, deviceUUID } });
var pjlinkState = await control.getPjlinkState();
res.send({ success: true, error: null, data: { balenaData, appName, deviceName, deviceType, deviceUUID, pjlinkState } });
});
app.post("/shutdown", async function (req, res) {
if (DEBUG) console.log("[API] post shutdown");
Expand Down

0 comments on commit 518d1a6

Please sign in to comment.