Comms working!!

This commit is contained in:
Skylar Grant 2024-08-21 21:43:56 -04:00
parent ccc84173cb
commit 5fa3d5bb9c
4 changed files with 13 additions and 5 deletions

View File

@ -13,6 +13,7 @@
"author": "Skylar Grant",
"license": "MIT",
"dependencies": {
"dotenv": "^16.4.5"
"dotenv": "^16.4.5",
"mqtt": "^5.10.0"
}
}

View File

@ -1,3 +1,5 @@
const mqtt = require('mqtt');
module.exports = {
// State class
State: class State {
@ -77,7 +79,6 @@ module.exports = {
console.log(`Message received on topic ${topic}: ${msgStr}`);
console.log(msgJson);
state[msgJson.name].on = msgJson.on;
window.refreshState(window.document, state);
});
}

View File

@ -9,6 +9,13 @@
"auger": "hestia/status/auger"
}
},
"states": {
"elements": [
"igniter",
"exhaust",
"auger"
]
},
"pins": [
{
"key": "igniter",

View File

@ -15,10 +15,9 @@ fn.gpio.debugInit();
setInterval(() => {
for (const pin of config.pins) {
if (pin.mode === 'IN') {
gpio.readPin(pin.board, (err, state) => {
if (err) throw err;
gpio.readPin(pin.board).then(state => {
fn.log(`${pin.key}: ${state}`);
});
}).catch(e => console.error(e));
}
}
}, 1000);