From 7fc84a3f14a3b3a1758b3212644a29086e378c5f Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Wed, 13 Dec 2017 16:04:24 -0500 Subject: [PATCH] Set exposure with bluetooth app --- index.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 51443a0..7a4f8f1 100644 --- a/index.js +++ b/index.js @@ -47,6 +47,7 @@ function createBLE () { }) ble.on('frame', bFrame) ble.on('dir', bDir) + ble.on('exposure', bExposure) } //Restify functions @@ -300,8 +301,12 @@ function bFrame (obj, cb) { dir = obj.dir } } - if (typeof obj.dir !== 'undefined') { - exposure + if (typeof obj.exposure !== 'undefined') { + if (typeof obj.exposure === 'string') { + exposure = parseInt(obj.exposure) + } else { + exposure = obj.exposure + } } log.info('frame', { method : 'ble', dir : dir, exposure : exposure }) /*intval.frame(dir, exposure, (len) => { @@ -325,6 +330,20 @@ function bDir (obj, cb) { cb() } +function bExposure (obj, cb) { + let exposure = 0 + if (typeof obj.exposure !== 'undefined') { + if (typeof obj.exposure === 'string') { + exposure = parseInt(obj.exposure) + } else { + exposure = req.body.exposure + } + } + intval.setExposure(exposure) + log.info('exposure', { method: 'ble', exposure : exposure }) + return cb() +} + function index (req, res, next) { fs.readFile(INDEXPATH, 'utf8', (err, data) => { if (err) {