mirror of
https://github.com/zyphlar/doorlock.git
synced 2024-04-03 21:36:03 +00:00
Add door opening code
This commit is contained in:
parent
6af3ffc380
commit
c2733a83b3
|
@ -1,6 +1,19 @@
|
||||||
|
const { Board } = require('easy-usb-relay')
|
||||||
|
|
||||||
|
const DELAY = 6000
|
||||||
|
|
||||||
module.exports = class Door {
|
module.exports = class Door {
|
||||||
static open() {
|
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() {
|
// static close() {
|
||||||
|
|
|
@ -10,10 +10,10 @@ module.exports = (req, res) => {
|
||||||
console.log('CARD:', card)
|
console.log('CARD:', card)
|
||||||
if (!card) return res.redirect('/failure')
|
if (!card) return res.redirect('/failure')
|
||||||
|
|
||||||
Door.open()
|
|
||||||
res.redirect('/success?name=' + card.name)
|
res.redirect('/success?name=' + card.name)
|
||||||
Logs.log({ timestamp: new Date().getTime(), card }).then(() =>
|
Logs.log({ timestamp: new Date().getTime(), card }).then(() =>
|
||||||
console.log('Logged!')
|
console.log('Logged!')
|
||||||
)
|
)
|
||||||
|
Door.open()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user