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", "author": "Skylar Grant",
"license": "MIT", "license": "MIT",
"dependencies": { "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 = { module.exports = {
// State class // State class
State: class State { State: class State {
@ -77,7 +79,6 @@ module.exports = {
console.log(`Message received on topic ${topic}: ${msgStr}`); console.log(`Message received on topic ${topic}: ${msgStr}`);
console.log(msgJson); console.log(msgJson);
state[msgJson.name].on = msgJson.on; state[msgJson.name].on = msgJson.on;
window.refreshState(window.document, state);
}); });
} }

View File

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

View File

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