blendmicro
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -0,1 +1,5 @@ | ||
=== 0.3.1 2015-12-8 | ||
* fixed re-connecting for BLENano #9 | ||
=== 0.3.0 2015-12-5 | ||
@@ -2,0 +6,0 @@ |
(function() { | ||
var attr, attrs, ble, debug, fn, i, len, noble; | ||
var BLE, EventEmitter2, debug, noble, | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
hasProp = {}.hasOwnProperty; | ||
@@ -8,5 +10,27 @@ noble = require('noble'); | ||
ble = { | ||
noble: noble, | ||
startScanning: function() { | ||
EventEmitter2 = require('eventemitter2').EventEmitter2; | ||
module.exports = BLE = (function(superClass) { | ||
extend(BLE, superClass); | ||
function BLE() { | ||
var attr, attrs, fn, i, len; | ||
debug('start ble class'); | ||
this.noble = noble; | ||
this.scanCount = 0; | ||
attrs = ['state']; | ||
fn = (function(_this) { | ||
return function(attr) { | ||
return _this.__defineGetter__(attr, function() { | ||
return noble[attr]; | ||
}); | ||
}; | ||
})(this); | ||
for (i = 0, len = attrs.length; i < len; i++) { | ||
attr = attrs[i]; | ||
fn(attr); | ||
} | ||
} | ||
BLE.prototype.startScanning = function() { | ||
this.scanCount += 1; | ||
@@ -16,6 +40,7 @@ debug("scan count: " + this.scanCount); | ||
debug("start scanning"); | ||
return noble.startScanning(); | ||
return noble.startScanning([], true); | ||
} | ||
}, | ||
stopScanning: function() { | ||
}; | ||
BLE.prototype.stopScanning = function() { | ||
this.scanCount -= 1; | ||
@@ -27,21 +52,8 @@ debug("scan count: " + this.scanCount); | ||
} | ||
} | ||
}; | ||
}; | ||
ble.scanCount = 0; | ||
return BLE; | ||
attrs = ['state']; | ||
})(EventEmitter2); | ||
fn = function(attr) { | ||
return ble.__defineGetter__(attr, function() { | ||
return noble[attr]; | ||
}); | ||
}; | ||
for (i = 0, len = attrs.length; i < len; i++) { | ||
attr = attrs[i]; | ||
fn(attr); | ||
} | ||
module.exports = ble; | ||
}).call(this); |
(function() { | ||
var BlendMicro, UUID_LIST, _, ble, debug, events, | ||
var BLE, BlendMicro, UUID_LIST, _, ble, debug, events, | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
@@ -8,4 +8,2 @@ hasProp = {}.hasOwnProperty; | ||
ble = require('./ble'); | ||
_ = require('lodash'); | ||
@@ -15,2 +13,8 @@ | ||
BLE = require('./ble'); | ||
ble = new BLE; | ||
ble.setMaxListeners(16); | ||
UUID_LIST = { | ||
@@ -66,2 +70,3 @@ blendmicro: { | ||
return function(peripheral) { | ||
debug("discover \"" + peripheral.advertisement.localName + "\""); | ||
if (_this.peripheral !== null) { | ||
@@ -179,3 +184,3 @@ return; | ||
if (!(this.peripheral && this.tx)) { | ||
return callback('disconnected'); | ||
return typeof callback === "function" ? callback('disconnected') : void 0; | ||
} | ||
@@ -182,0 +187,0 @@ if (!(data instanceof Buffer)) { |
{ | ||
"name": "blendmicro", | ||
"private": false, | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "BlendMicro/BLENano Node Lib", | ||
@@ -6,0 +6,0 @@ "main": "lib/blendmicro.js", |
Sorry, the diff of this file is not supported yet
15983
247