noble
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -0,1 +1,8 @@ | ||
## Version 1.6.0 | ||
* hci-socket binding: use latest bluetooth-hci-socket dependency (~0.4.4) | ||
* Added characteristic.subscribe and characteristic.unsubscribe API's (characteristic.notify is now deprecated) | ||
* hci-socket binding: use OCF_LE_SET_EVENT_MASK for LE_SET_EVENT_MASK_CMD | ||
* hci-socket binding: check READ_LE_HOST_SUPPORTED_CMD status before parsing result | ||
## Version 1.5.0 | ||
@@ -2,0 +9,0 @@ |
@@ -139,3 +139,3 @@ | ||
}); | ||
pizzaBakeCharacteristic.notify(true, function(err) { | ||
pizzaBakeCharacteristic.subscribe(function(err) { | ||
// | ||
@@ -142,0 +142,0 @@ // Bake at 450 degrees! |
@@ -88,2 +88,3 @@ var debug = require('debug')('characteristic'); | ||
// deprecated in favour of subscribe/unsubscribe | ||
Characteristic.prototype.notify = function(notify, callback) { | ||
@@ -104,2 +105,10 @@ if (callback) { | ||
Characteristic.prototype.subscribe = function(callback) { | ||
this.notify(true, callback); | ||
}; | ||
Characteristic.prototype.unsubscribe = function(callback) { | ||
this.notify(false, callback); | ||
}; | ||
Characteristic.prototype.discoverDescriptors = function(callback) { | ||
@@ -106,0 +115,0 @@ if (callback) { |
@@ -59,3 +59,3 @@ var debug = require('debug')('hci'); | ||
var LE_SET_EVENT_MASK_CMD = OCF_SET_EVENT_MASK | OGF_LE_CTL << 10; | ||
var LE_SET_EVENT_MASK_CMD = OCF_LE_SET_EVENT_MASK | OGF_LE_CTL << 10; | ||
var LE_SET_SCAN_PARAMETERS_CMD = OCF_LE_SET_SCAN_PARAMETERS | OGF_LE_CTL << 10; | ||
@@ -504,7 +504,9 @@ var LE_SET_SCAN_ENABLE_CMD = OCF_LE_SET_SCAN_ENABLE | OGF_LE_CTL << 10; | ||
if (cmd === READ_LE_HOST_SUPPORTED_CMD) { | ||
var le = result.readUInt8(0); | ||
var simul = result.readUInt8(1); | ||
if (status === 0) { | ||
var le = result.readUInt8(0); | ||
var simul = result.readUInt8(1); | ||
debug('\t\t\tle = ' + le); | ||
debug('\t\t\tsimul = ' + simul); | ||
debug('\t\t\tle = ' + le); | ||
debug('\t\t\tsimul = ' + simul); | ||
} | ||
} else if (cmd === READ_LOCAL_VERSION_CMD) { | ||
@@ -511,0 +513,0 @@ var hciVer = result.readUInt8(0); |
@@ -6,3 +6,3 @@ { | ||
"description": "A Node.js BLE (Bluetooth Low Energy) central library.", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"repository": { | ||
@@ -35,3 +35,3 @@ "type": "git", | ||
"optionalDependencies": { | ||
"bluetooth-hci-socket": "~0.4.1", | ||
"bluetooth-hci-socket": "~0.4.4", | ||
"bplist-parser": "0.0.6", | ||
@@ -38,0 +38,0 @@ "xpc-connection": "~0.1.4" |
@@ -189,11 +189,20 @@ # noble | ||
##### Notify | ||
##### Subscribe | ||
```javascript | ||
characteristic.notify(notify[, callback(error)]); // notify is true|false | ||
characteristic.subscribe([callback(error)]); | ||
``` | ||
* allows notification to trigger `'data'` event | ||
* subscribe to a characteristic, triggers `'data'` events when peripheral sends an notification or indication | ||
* use for characteristics with notify or indicate properties | ||
##### Unsubscribe | ||
```javascript | ||
characteristic.unsubscribe([callback(error)]); | ||
``` | ||
* unsubscribe to a characteristic | ||
* use for characteristics with notify or indicate properties | ||
##### Discover descriptors | ||
@@ -200,0 +209,0 @@ |
@@ -172,2 +172,40 @@ var should = require('should'); | ||
describe('subscribe', function() { | ||
it('should delegate to noble notify, true', function() { | ||
characteristic.subscribe(); | ||
mockNoble.notify.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, true).should.equal(true); | ||
}); | ||
it('should callback', function() { | ||
var calledback = false; | ||
characteristic.subscribe(function() { | ||
calledback = true; | ||
}); | ||
characteristic.emit('notify'); | ||
calledback.should.equal(true); | ||
}); | ||
}); | ||
describe('unsubscribe', function() { | ||
it('should delegate to noble notify, false', function() { | ||
characteristic.unsubscribe(); | ||
mockNoble.notify.calledWithExactly(mockPeripheralId, mockServiceUuid, mockUuid, false).should.equal(true); | ||
}); | ||
it('should callback', function() { | ||
var calledback = false; | ||
characteristic.unsubscribe(function() { | ||
calledback = true; | ||
}); | ||
characteristic.emit('notify'); | ||
calledback.should.equal(true); | ||
}); | ||
}); | ||
describe('discoverDescriptors', function() { | ||
@@ -203,2 +241,2 @@ it('should delegate to noble', function() { | ||
}); | ||
}); | ||
}); |
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
286669
6731
478