Comparing version 1.2.1 to 1.3.0
@@ -0,1 +1,10 @@ | ||
## Version 1.3.0 | ||
* Check and report LE Create Conn command status | ||
* Correct parsing master clock accuracy value from LE Conn Complete event | ||
* Added logic to reject rather than ignore unknown requests/commands. ([@george-hawkins](https://github.com/george-hawkins)) | ||
* Don't reset scan state on read local version response if state is powered on | ||
* Expose local adapter address via ```noble.address```, available after ```poweredOn``` state change event | ||
* Fix ```serviceUuids``` var check in ```peripheral-explorer.js``` ([@jrobeson](https://github.com/jrobeson)) | ||
## Version 1.2.1 | ||
@@ -2,0 +11,0 @@ |
@@ -43,3 +43,3 @@ var async = require('async'); | ||
if (localName) { | ||
if (serviceUuids) { | ||
console.log(' Service UUIDs = ' + serviceUuids); | ||
@@ -46,0 +46,0 @@ } |
@@ -19,3 +19,3 @@ var debug = require('debug')('bindings'); | ||
this._pendingConnection = false; | ||
this._pendingConnectionUuid = null; | ||
this._connectionQueue = []; | ||
@@ -48,4 +48,4 @@ | ||
if (!this._pendingConnection) { | ||
this._pendingConnection = true; | ||
if (!this._pendingConnectionUuid) { | ||
this._pendingConnectionUuid = peripheralUuid; | ||
@@ -77,2 +77,3 @@ this._hci.createLeConn(address, addressType); | ||
this._hci.on('stateChange', this.onStateChange.bind(this)); | ||
this._hci.on('addressChange', this.onAddressChange.bind(this)); | ||
this._hci.on('leConnComplete', this.onLeConnComplete.bind(this)); | ||
@@ -126,2 +127,6 @@ this._hci.on('leConnUpdateComplete', this.onLeConnUpdateComplete.bind(this)); | ||
NobleBindings.prototype.onAddressChange = function(address) { | ||
this.emit('addressChange', address); | ||
}; | ||
NobleBindings.prototype.onScanStart = function() { | ||
@@ -164,3 +169,3 @@ this.emit('scanStart'); | ||
NobleBindings.prototype.onLeConnComplete = function(status, handle, role, addressType, address, interval, latency, supervisionTimeout, masterClockAccuracy) { | ||
var uuid = address.split(':').join('').toLowerCase(); | ||
var uuid = null; | ||
@@ -170,2 +175,4 @@ var error = null; | ||
if (status === 0) { | ||
uuid = address.split(':').join('').toLowerCase(); | ||
var aclStream = new AclStream(this._hci, handle, this._hci.addressType, this._hci.address, addressType, address); | ||
@@ -197,2 +204,4 @@ var gatt = new Gatt(address, aclStream); | ||
} else { | ||
uuid = this._pendingConnectionUuid; | ||
error = new Error(Hci.STATUS_MAPPER[status] || ('Unknown (' + status + ')')); | ||
@@ -209,5 +218,7 @@ } | ||
this._pendingConnectionUuid = peripheralUuid; | ||
this._hci.createLeConn(address, addressType); | ||
} else { | ||
this._pendingConnection = false; | ||
this._pendingConnectionUuid = null; | ||
} | ||
@@ -214,0 +225,0 @@ }; |
@@ -89,3 +89,5 @@ var debug = require('debug')('att'); | ||
} else if (data[0] % 2 === 0) { | ||
debug(this._address + ': ignoring request/command ...'); | ||
var requestType = data[0]; | ||
debug(this._address + ': replying with REQ_NOT_SUPP to 0x' + requestType.toString(16)); | ||
this.writeAtt(this.errorResponse(requestType, 0x0000, ATT_ECODE_REQ_NOT_SUPP)); | ||
} else if (data[0] === ATT_OP_HANDLE_NOTIFY || data[0] === ATT_OP_HANDLE_IND) { | ||
@@ -166,2 +168,13 @@ var valueHandle = data.readUInt16LE(1); | ||
Gatt.prototype.errorResponse = function(opcode, handle, status) { | ||
var buf = new Buffer(5); | ||
buf.writeUInt8(ATT_OP_ERROR, 0); | ||
buf.writeUInt8(opcode, 1); | ||
buf.writeUInt16LE(handle, 2); | ||
buf.writeUInt8(status, 4); | ||
return buf; | ||
}; | ||
Gatt.prototype._queueCommand = function(buffer, callback, writeCallback) { | ||
@@ -168,0 +181,0 @@ this._commandQueue.push({ |
@@ -72,4 +72,7 @@ var debug = require('debug')('hci'); | ||
this._isDevUp = null; | ||
this._state = null; | ||
this._handleBuffers = {}; | ||
this.on('stateChange', this.onStateChange.bind(this)); | ||
}; | ||
@@ -374,2 +377,4 @@ | ||
var handle; | ||
var cmd; | ||
var status; | ||
@@ -400,4 +405,4 @@ debug('\tevent type = ' + eventType); | ||
} else if (subEventType === EVT_CMD_COMPLETE) { | ||
var cmd = data.readUInt16LE(4); | ||
var status = data.readUInt8(6); | ||
cmd = data.readUInt16LE(4); | ||
status = data.readUInt8(6); | ||
var result = data.slice(7); | ||
@@ -410,2 +415,10 @@ | ||
this.processCmdCompleteEvent(cmd, status, result); | ||
} else if (subEventType === EVT_CMD_STATUS) { | ||
status = data.readUInt8(3); | ||
cmd = data.readUInt16LE(5); | ||
debug('\t\tstatus = ' + status); | ||
debug('\t\tcmd = ' + cmd); | ||
this.processCmdStatusEvent(cmd, status); | ||
} else if (subEventType === EVT_LE_META_EVENT) { | ||
@@ -491,3 +504,3 @@ var leMetaEventType = data.readUInt8(3); | ||
this.emit('stateChange', 'unsupported'); | ||
} else { | ||
} else if (this._state !== 'poweredOn') { | ||
this.setScanEnabled(false, true); | ||
@@ -540,3 +553,3 @@ this.setScanParameters(); | ||
var supervisionTimeout = data.readUInt16LE(14) * 10; | ||
var masterClockAccuracy = data.readUInt8(15); // TODO: multiplier? | ||
var masterClockAccuracy = data.readUInt8(16); // TODO: multiplier? | ||
@@ -585,2 +598,14 @@ debug('\t\t\thandle = ' + handle); | ||
Hci.prototype.processCmdStatusEvent = function(cmd, status) { | ||
if (cmd === LE_CREATE_CONN_CMD) { | ||
if (status !== 0) { | ||
this.emit('leConnComplete', status); | ||
} | ||
} | ||
}; | ||
Hci.prototype.onStateChange = function(state) { | ||
this._state = state; | ||
}; | ||
module.exports = Hci; |
@@ -10,2 +10,3 @@ var events = require('events'); | ||
var localAddress = require('./local-address'); | ||
var uuidToAddress = require('./uuid-to-address'); | ||
@@ -85,6 +86,12 @@ | ||
this.sendCBMsg(1, { | ||
kCBMsgArgAlert: 1, | ||
kCBMsgArgName: 'node-' + (new Date()).getTime() | ||
}); | ||
localAddress(function(address) { | ||
if (address) { | ||
this.emit('addressChange', address); | ||
} | ||
this.sendCBMsg(1, { | ||
kCBMsgArgAlert: 1, | ||
kCBMsgArgName: 'node-' + (new Date()).getTime() | ||
}); | ||
}.bind(this)); | ||
}; | ||
@@ -91,0 +98,0 @@ |
@@ -9,2 +9,3 @@ var events = require('events'); | ||
var localAddress = require('./local-address'); | ||
var uuidToAddress = require('./uuid-to-address'); | ||
@@ -58,9 +59,15 @@ | ||
this.sendCBMsg(1, { | ||
kCBMsgArgName: 'node-' + (new Date()).getTime(), | ||
kCBMsgArgOptions: { | ||
kCBInitOptionShowPowerAlert: 0 | ||
}, | ||
kCBMsgArgType: 0 | ||
}); | ||
localAddress(function(address) { | ||
if (address) { | ||
this.emit('addressChange', address); | ||
} | ||
this.sendCBMsg(1, { | ||
kCBMsgArgName: 'node-' + (new Date()).getTime(), | ||
kCBMsgArgOptions: { | ||
kCBInitOptionShowPowerAlert: 0 | ||
}, | ||
kCBMsgArgType: 0 | ||
}); | ||
}.bind(this)); | ||
}; | ||
@@ -67,0 +74,0 @@ |
@@ -9,2 +9,3 @@ var events = require('events'); | ||
var localAddress = require('./local-address'); | ||
var uuidToAddress = require('./uuid-to-address'); | ||
@@ -60,9 +61,15 @@ | ||
this.sendCBMsg(1, { | ||
kCBMsgArgName: 'node-' + (new Date()).getTime(), | ||
kCBMsgArgOptions: { | ||
kCBInitOptionShowPowerAlert: 0 | ||
}, | ||
kCBMsgArgType: 0 | ||
}); | ||
localAddress(function(address) { | ||
if (address) { | ||
this.emit('addressChange', address); | ||
} | ||
this.sendCBMsg(1, { | ||
kCBMsgArgName: 'node-' + (new Date()).getTime(), | ||
kCBMsgArgOptions: { | ||
kCBInitOptionShowPowerAlert: 0 | ||
}, | ||
kCBMsgArgType: 0 | ||
}); | ||
}.bind(this)); | ||
}; | ||
@@ -69,0 +76,0 @@ |
@@ -30,2 +30,3 @@ var debug = require('debug')('noble'); | ||
this.state = 'unknown'; | ||
this.address = 'unknown'; | ||
@@ -40,2 +41,3 @@ this._bindings = bindings; | ||
this._bindings.on('stateChange', this.onStateChange.bind(this)); | ||
this._bindings.on('addressChange', this.onAddressChange.bind(this)); | ||
this._bindings.on('scanStart', this.onScanStart.bind(this)); | ||
@@ -80,2 +82,8 @@ this._bindings.on('scanStop', this.onScanStop.bind(this)); | ||
Noble.prototype.onAddressChange = function(address) { | ||
debug('addressChange ' + address); | ||
this.address = address; | ||
}; | ||
Noble.prototype.startScanning = function(serviceUuids, allowDuplicates, callback) { | ||
@@ -82,0 +90,0 @@ if (this.state !== 'poweredOn') { |
@@ -6,3 +6,3 @@ { | ||
"description": "A Node.js BLE (Bluetooth Low Energy) central library.", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"repository": { | ||
@@ -9,0 +9,0 @@ "type": "git", |
@@ -25,3 +25,3 @@ # noble | ||
```sh | ||
sudo apt-get install bluetooth bluez-utils libbluetooth-dev libudev-dev | ||
sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev | ||
``` | ||
@@ -52,2 +52,4 @@ | ||
See [@don](https://github.com/don)'s set up guide on [Bluetooth LE with Node.js and Noble on Windows](https://www.youtube.com/watch?v=mL9B8wuEdms). | ||
## Notes | ||
@@ -54,0 +56,0 @@ |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
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
278992
42
6635
438
1