diff --git a/lib/index.js b/lib/index.js index aee15b6..2c2ad51 100644 --- a/lib/index.js +++ b/lib/index.js @@ -28,7 +28,10 @@ bluetest = module.exports = function(options) { core.processLuxData = function(data) { var m, e, lux; - var _data = data.toString(); + var p = data.lastIndexOf(10); + var l = data.length - (p + 1); + + var _data = data.toString('ascii',p + 1, l); logger.debug(data); logger.debug(_data); var wH = _data.slice(-5).split(' '); @@ -119,8 +122,7 @@ bluetest = module.exports = function(options) { if (typeof options.mac !== 'undefined') { core.mac = options.mac; - } - else { + } else { console.log('You need to pass a mac address.'); process.exit(1); } @@ -139,8 +141,7 @@ bluetest = module.exports = function(options) { 'hciconfig: failed to bring up device ' + hcidev + '. Try running with sudo.'); return; - } - else { + } else { core.connectGatt();