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) {