diff --git a/src/models/door.js b/src/models/door.js index 618dcea..1120e75 100644 --- a/src/models/door.js +++ b/src/models/door.js @@ -1,6 +1,19 @@ +const { Board } = require('easy-usb-relay') + +const DELAY = 6000 + module.exports = class Door { static open() { - console.log('OPEN DOOR!!!!!!!!!!!!!!') + return new Promise(success => { + console.log('OPEN DOOR!') + const board = new Board(2) + board.allOn() + setTimeout(() => { + console.log('CLOSING DOOR!') + board.allOff() + success() + }, DELAY) + }) } // static close() { diff --git a/src/routes/checkin.js b/src/routes/checkin.js index 050f6eb..14f20a9 100644 --- a/src/routes/checkin.js +++ b/src/routes/checkin.js @@ -10,10 +10,10 @@ module.exports = (req, res) => { console.log('CARD:', card) if (!card) return res.redirect('/failure') - Door.open() res.redirect('/success?name=' + card.name) Logs.log({ timestamp: new Date().getTime(), card }).then(() => console.log('Logged!') ) + Door.open() }) }