Comms working!!
This commit is contained in:
parent
ccc84173cb
commit
5fa3d5bb9c
@ -13,6 +13,7 @@
|
||||
"author": "Skylar Grant",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dotenv": "^16.4.5"
|
||||
"dotenv": "^16.4.5",
|
||||
"mqtt": "^5.10.0"
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,13 @@
|
||||
"auger": "hestia/status/auger"
|
||||
}
|
||||
},
|
||||
"states": {
|
||||
"elements": [
|
||||
"igniter",
|
||||
"exhaust",
|
||||
"auger"
|
||||
]
|
||||
},
|
||||
"pins": [
|
||||
{
|
||||
"key": "igniter",
|
||||
|
@ -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);
|
Loading…
Reference in New Issue
Block a user