From 2a28b622f0d4baf4b08949b107523c65a0d1e634 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Wed, 13 Dec 2017 16:22:22 -0500 Subject: [PATCH] Set delay from ble --- index.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 7a4f8f1..b85c468 100644 --- a/index.js +++ b/index.js @@ -48,6 +48,7 @@ function createBLE () { ble.on('frame', bFrame) ble.on('dir', bDir) ble.on('exposure', bExposure) + ble.on('delay', bDelay) } //Restify functions @@ -312,7 +313,7 @@ function bFrame (obj, cb) { /*intval.frame(dir, exposure, (len) => { return cb() })*/ - setTimeout(cb, 630) + setTimeout(cb, exposure === 0 ? 630 : exposure) } function bDir (obj, cb) { @@ -344,6 +345,22 @@ function bExposure (obj, cb) { return cb() } +function bDelay (obj, cb) { + let delay = 0 + let set = false + if (typeof obj.delay !== 'undefined') { + if (typeof obj.delay === 'string') { + delay = parseInt(obj.delay) + } else { + delay = obj.delay + } + set = true + } + intval.setDelay(delay) + log.info('delay', { method: 'ble', delay : delay }) + return cb() +} + function index (req, res, next) { fs.readFile(INDEXPATH, 'utf8', (err, data) => { if (err) {