bluetooth-hci-socket
Advanced tools
Comparing version 0.3.0 to 0.3.1
var events = require('events'); | ||
var util = require('util'); | ||
var debug = require('debug')('bluetooth-hci-socket-usb'); | ||
var debug = require('debug')('hci-usb'); | ||
var usb = require('usb'); | ||
@@ -11,3 +11,8 @@ | ||
var OGF_HOST_CTL = 0x03; | ||
var OCF_RESET = 0x0003; | ||
function BluetoothHciSocket() { | ||
this._isUp = false; | ||
this._hciEventEndpointBuffer = new Buffer(0); | ||
@@ -27,2 +32,6 @@ } | ||
if (!this._usbDevice) { | ||
throw new Error('No compatible USB Bluetooth 4.0 device found!'); | ||
} | ||
this._usbDevice.open(); | ||
@@ -38,2 +47,4 @@ | ||
this._usbDeviceInterface.claim(); | ||
this.reset(); | ||
}; | ||
@@ -46,3 +57,3 @@ | ||
BluetoothHciSocket.prototype.isDevUp = function() { | ||
return true; | ||
return this._isUp; | ||
}; | ||
@@ -87,2 +98,7 @@ | ||
if (data.length === 6 && ('0e0401030c00' === data.toString('hex'))) { | ||
debug('reset complete'); | ||
this._isUp = true; | ||
} | ||
// add to buffer | ||
@@ -116,2 +132,16 @@ this._hciEventEndpointBuffer = Buffer.concat([ | ||
BluetoothHciSocket.prototype.reset = function() { | ||
var cmd = new Buffer(4); | ||
// header | ||
cmd.writeUInt8(HCI_COMMAND_PKT, 0); | ||
cmd.writeUInt16LE(OCF_RESET | OGF_HOST_CTL << 10, 1); | ||
// length | ||
cmd.writeUInt8(0x00, 3); | ||
debug('reset'); | ||
this.write(cmd); | ||
}; | ||
module.exports = BluetoothHciSocket; |
{ | ||
"name": "bluetooth-hci-socket", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Bluetooth HCI socket binding for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
37879
628