From 52194e0b4146371f81de733a0757014aebf073bb Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Wed, 13 Dec 2017 17:27:42 -0500 Subject: [PATCH] Set counter via ble --- index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/index.js b/index.js index 07911d7..c2159cb 100644 --- a/index.js +++ b/index.js @@ -49,6 +49,7 @@ function createBLE () { ble.on('dir', bDir) ble.on('exposure', bExposure) ble.on('delay', bDelay) + ble.on('counter', bCounter) } //Restify functions @@ -364,6 +365,20 @@ function bDelay (obj, cb) { return cb() } +function bCounter (obj, cb) { + let counter = 0 + if (typeof obj.counter !== 'undefined') { + if (typeof obj.counter !== 'string') { + counter = parseInt(obj.counter) + } else { + counter = obj.counter + } + } + intval.setCounter(counter) + log.info('counter', { method : 'ble', counter : counter }) + return cb() +} + function index (req, res, next) { fs.readFile(INDEXPATH, 'utf8', (err, data) => { if (err) {