Comparing version 1.9.0 to 1.9.1
@@ -0,1 +1,8 @@ | ||
## Version 1.9.1 | ||
* Don't forget previously discovered services and characteristics ([@elafargue](https://github.com/elafargue)) | ||
* Fixed peripheral-explorer example with newer async versions | ||
* web socket binding: various fixes ([@hadrienk](https://github.com/hadrienk)) | ||
* Fix multiple init of bindings with multiple stateChange listeners added or noble.state is accessed | ||
## Version 1.9.0 | ||
@@ -2,0 +9,0 @@ |
@@ -98,3 +98,7 @@ var async = require('async'); | ||
function(descriptor, callback) { | ||
return callback(descriptor.uuid === '2901'); | ||
if (descriptor.uuid === '2901') { | ||
return callback(descriptor); | ||
} else { | ||
return callback(); | ||
} | ||
}, | ||
@@ -101,0 +105,0 @@ function(userDescriptionDescriptor){ |
@@ -413,3 +413,3 @@ var debug = require('debug')('att'); | ||
this._characteristics[serviceUuid] = {}; | ||
this._characteristics[serviceUuid] = this._characteristics[serviceUuid] || {}; | ||
this._descriptors[serviceUuid] = this._descriptors[serviceUuid] || {}; | ||
@@ -416,0 +416,0 @@ |
@@ -320,3 +320,3 @@ var events = require('events'); | ||
this._peripherals[deviceUuid].services = {}; | ||
this._peripherals[deviceUuid].services = this._peripherals[deviceUuid].services || {}; | ||
@@ -331,3 +331,5 @@ if (args.kCBMsgArgServices) { | ||
this._peripherals[deviceUuid].services[service.uuid] = this._peripherals[deviceUuid].services[service.startHandle] = service; | ||
if (!this._peripherals[deviceUuid].services[service.uuid] ) { | ||
this._peripherals[deviceUuid].services[service.uuid] = this._peripherals[deviceUuid].services[service.startHandle] = service; | ||
} | ||
@@ -382,3 +384,4 @@ serviceUuids.push(service.uuid); | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices = {}; | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices = | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices || {}; | ||
@@ -392,4 +395,6 @@ for(var i = 0; i < args.kCBMsgArgServices.length; i++) { | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.uuid] = | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.startHandle] = includedService; | ||
if (! this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.uuid]) { | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.uuid] = | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.startHandle] = includedService; | ||
} | ||
@@ -442,3 +447,4 @@ includedServiceUuids.push(includedService.uuid); | ||
this._peripherals[deviceUuid].services[serviceStartHandle].characteristics = {}; | ||
this._peripherals[deviceUuid].services[serviceStartHandle].characteristics = | ||
this._peripherals[deviceUuid].services[serviceStartHandle].characteristics || {}; | ||
@@ -445,0 +451,0 @@ for(var i = 0; i < args.kCBMsgArgCharacteristics.length; i++) { |
@@ -233,3 +233,3 @@ var events = require('events'); | ||
this._peripherals[deviceUuid].services = {}; | ||
this._peripherals[deviceUuid].services = this._peripherals[deviceUuid].services || {}; | ||
@@ -278,3 +278,4 @@ if (args.kCBMsgArgServices) { | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices = {}; | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices = | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices || {}; | ||
@@ -288,4 +289,6 @@ for(var i = 0; i < args.kCBMsgArgServices.length; i++) { | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.uuid] = | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.startHandle] = includedService; | ||
if (! this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.uuid]) { | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.uuid] = | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices[includedServices.startHandle] = includedService; | ||
} | ||
@@ -322,3 +325,4 @@ includedServiceUuids.push(includedService.uuid); | ||
this._peripherals[deviceUuid].services[serviceStartHandle].characteristics = {}; | ||
this._peripherals[deviceUuid].services[serviceStartHandle].characteristics = | ||
this._peripherals[deviceUuid].services[serviceStartHandle].characteristics || {}; | ||
@@ -325,0 +329,0 @@ for(var i = 0; i < args.kCBMsgArgCharacteristics.length; i++) { |
@@ -320,3 +320,3 @@ var events = require('events'); | ||
this._peripherals[deviceUuid].services = {}; | ||
this._peripherals[deviceUuid].services = this._peripherals[deviceUuid].services || {}; | ||
@@ -331,3 +331,5 @@ if (args.kCBMsgArgServices) { | ||
this._peripherals[deviceUuid].services[service.uuid] = this._peripherals[deviceUuid].services[service.startHandle] = service; | ||
if (typeof this._peripherals[deviceUuid].services[service.uuid] == 'undefined') { | ||
this._peripherals[deviceUuid].services[service.uuid] = this._peripherals[deviceUuid].services[service.startHandle] = service; | ||
} | ||
@@ -382,3 +384,4 @@ serviceUuids.push(service.uuid); | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices = {}; | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices = | ||
this._peripherals[deviceUuid].services[serviceStartHandle].includedServices || {}; | ||
@@ -441,3 +444,4 @@ for(var i = 0; i < args.kCBMsgArgServices.length; i++) { | ||
this._peripherals[deviceUuid].services[serviceStartHandle].characteristics = {}; | ||
this._peripherals[deviceUuid].services[serviceStartHandle].characteristics = | ||
this._peripherals[deviceUuid].services[serviceStartHandle].characteristics || {}; | ||
@@ -444,0 +448,0 @@ for(var i = 0; i < args.kCBMsgArgCharacteristics.length; i++) { |
@@ -54,5 +54,6 @@ var debug = require('debug')('noble'); | ||
if (event === 'stateChange' && !this.initialized) { | ||
this.initialized = true; | ||
process.nextTick(function() { | ||
this._bindings.init(); | ||
this.initialized = true; | ||
}.bind(this)); | ||
@@ -67,4 +68,5 @@ } | ||
if (!this.initialized) { | ||
this.initialized = true; | ||
this._bindings.init(); | ||
this.initialized = true; | ||
} | ||
@@ -120,4 +122,6 @@ return this._state; | ||
if (!this.initialized) { | ||
this.initialized = true; | ||
this._bindings.init(); | ||
this.initialized = true; | ||
this.once('stateChange', scan.bind(this)); | ||
@@ -138,3 +142,3 @@ }else{ | ||
} | ||
if(this._bindings && this.initialized){ | ||
if (this._bindings && this.initialized) { | ||
this._bindings.stopScanning(); | ||
@@ -141,0 +145,0 @@ } |
@@ -22,2 +22,3 @@ var events = require('events'); | ||
this._ws.on('close', this._onClose.bind(this)); | ||
this._ws.on('error', this._onClose.bind(this)); | ||
@@ -44,3 +45,2 @@ var _this = this; | ||
console.log('on -> close'); | ||
this.emit('stateChange', 'poweredOff'); | ||
@@ -124,6 +124,12 @@ }; | ||
NobleBindings.prototype._sendCommand = function(command) { | ||
NobleBindings.prototype._sendCommand = function(command, errorCallback) { | ||
var message = JSON.stringify(command); | ||
this._ws.send(message); | ||
this._ws.send(message, function(error) { | ||
if (error != null) { | ||
console.warn("could not send command", command, error); | ||
if (typeof errorCallback === "function") { | ||
errorCallback(error); | ||
} | ||
} | ||
}); | ||
}; | ||
@@ -130,0 +136,0 @@ |
@@ -10,3 +10,3 @@ { | ||
"description": "A Node.js BLE (Bluetooth Low Energy) central library.", | ||
"version": "1.9.0", | ||
"version": "1.9.1", | ||
"repository": { | ||
@@ -13,0 +13,0 @@ "type": "git", |
# ![noble](assets/noble-logo.png) | ||
[![Build Status](https://travis-ci.org/sandeepmistry/noble.svg?branch=master)](https://travis-ci.org/sandeepmistry/noble) | ||
[![Build Status](https://travis-ci.org/noble/noble.svg?branch=master)](https://travis-ci.org/noble/noble) | ||
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sandeepmistry/noble?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![OpenCollective](https://opencollective.com/noble/backers/badge.svg)](#backers) | ||
@@ -5,0 +5,0 @@ [![OpenCollective](https://opencollective.com/noble/sponsors/badge.svg)](#sponsors) |
@@ -28,7 +28,2 @@ /* jshint loopfunc: true */ | ||
sendEvent({ | ||
type: 'stateChange', | ||
state: noble.state | ||
}); | ||
ws.on('message', onMessage); | ||
@@ -38,5 +33,21 @@ | ||
console.log('ws -> close'); | ||
noble.stopScanning(); | ||
}); | ||
noble.on('stateChange', function(state) { | ||
sendEvent({ | ||
type: 'stateChange', | ||
state: state | ||
}); | ||
}); | ||
// Send poweredOn if already in this state. | ||
if (noble.state == "poweredOn") { | ||
sendEvent({ | ||
type: 'stateChange', | ||
state: "poweredOn" | ||
}); | ||
} | ||
}); | ||
@@ -43,0 +54,0 @@ } else { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
369148
8055