Giter Site home page Giter Site logo

node-bluetooth-hci-socket's Introduction

node-bluetooth-hci-socket

Bluetooth HCI socket binding for Node.js

NOTE: Currently only supports Linux, FreeBSD and Windows.

Prerequisites

NOTE: node-gyp is only required if the npm cannot find binary for your OS version otherwise the binaries are prebuilt.

Linux

  • Bluetooth 4.0 Adapter

Note: the node-usb dependency might fail install, this is ok, because it is an optional optional dependency. Installing libudev-dev via your Linux distribution's package manager will resolve the problem.

Windows

This library needs raw USB access to a Bluetooth 4.0 USB adapter, as it needs to bypass the Windows Bluetooth stack.

A WinUSB driver is required, use Zadig tool to replace the driver for your adapter.

WARNING: This will make the adapter unavailable in Windows Bluetooth settings! To roll back to the original driver go to: Device Manager -> Open Device -> Update Driver

Compatible Bluetooth 4.0 USB Adapter's

Name USB VID USB PID
BCM920702 Bluetooth 4.0 0x0a5c 0x21e8
BCM20702A0 Bluetooth 4.0 0x19ff 0x0239
BCM20702A0 Bluetooth 4.0 0x0489 0xe07a
CSR8510 A10 0x0a12 0x0001
Asus BT-400 0x0b05 0x17cb
Intel Wireless Bluetooth 6235 0x8087 0x07da
Intel Wireless Bluetooth 7260 0x8087 0x07dc
Intel Wireless Bluetooth 7265 0x8087 0x0a2a
Intel Wireless Bluetooth 8265 0x8087 0x0a2b
Belkin BCM20702A0 0x050D 0x065A

Compatible Bluetooth 4.1 USB Adapter's

Name USB VID USB PID
BCM2045A0 Bluetooth 4.1 0x0a5c 0x6412

Install

npm install bluetooth-hci-socket

Usage

var BluetoothHciSocket = require('bluetooth-hci-socket');

Actions

Create

var bluetoothHciSocket = new BluetoothHciSocket();

Set Filter

var filter = new Buffer(14);

// ...

bluetoothHciSocket.setFilter(filter);

Note: setFilter is not required if bindRaw is used.

Bind

Raw Channel
bluetoothHciSocket.bindRaw([deviceId]); // optional deviceId (integer)
User Channel
bluetoothHciSocket.bindUser([deviceId]); // optional deviceId (integer)

Requires the device to be in the powered down state (sudo hciconfig hciX down).

Control Channel
bluetoothHciSocket.bindControl();

Is Device Up

Query the device state.

var isDevUp = bluetoothHciSocket.isDevUp(); // returns: true or false

Note: must be called after bindRaw.

Start/stop

Start or stop event handling:

bluetoothHciSocket.start();

// ...

bluetoothHciSocket.stop();

Note: must be called after bindRaw or bindControl.

Write

var data = new Buffer(/* ... */);

// ...


bluetoothHciSocket.write(data);

Note: must be called after bindRaw or bindControl.

Events

Data

bluetoothHciSocket.on('data', function(data) {
  // data is a Buffer

  // ...
});

Error

bluetoothHciSocket.on('error', function(error) {
  // error is a Error

  // ...
});

Examples

See examples folder for code examples.

Platform Notes

Linux

Force Raw USB mode

Unload btusb kernel module:

sudo rmmod btusb

Set BLUETOOTH_HCI_SOCKET_FORCE_USB environment variable:

sudo BLUETOOTH_HCI_SOCKET_FORCE_USB=1 node <file>.js

FreeBSD

Disable automatic loading of the default Bluetooth stack by putting no-ubt.conf into /usr/local/etc/devd/no-ubt.conf and restarting devd (sudo service devd restart).

Unload ng_ubt kernel module if already loaded:

sudo kldunload ng_ubt

OS X

Disable CSR USB Driver

sudo kextunload -b com.apple.iokit.CSRBluetoothHostControllerUSBTransport

Disable Broadcom USB Driver

sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport

Windows

Force adapter USB VID and PID

Set BLUETOOTH_HCI_SOCKET_USB_VID and BLUETOOTH_HCI_SOCKET_USB_PID environment variables.

Example for USB device id: 050d:065a:

set BLUETOOTH_HCI_SOCKET_USB_VID=0x050d
set BLUETOOTH_HCI_SOCKET_USB_PID=0x065a

node <file>.js

node-bluetooth-hci-socket's People

Contributors

biaydin avatar domir avatar geovie avatar gfwilliams avatar justmoon avatar leviathanbeak avatar loghorn avatar manixate avatar nicostuhlfauth avatar npohl avatar oroce avatar qingyuanz avatar robertchiras avatar sandeepmistry avatar shimmi avatar slashmili avatar steinerj avatar urish avatar valpackett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-bluetooth-hci-socket's Issues

Add support for Intel(R) Wireless Bluetooth(R) PID 07DA

@sandeepmistry we @OpenBCI have integrated your noble and were wondering what is the process for adding different devices to this repo?

The VID is the same as the other Intel chip supported 0x8087 however the PID is a bit different of 0x07DA (the supported one is 0x07DC)

I tried adding the PID and VID to the whitelist in usb.js but was not successful in getting it to work. Getting a LIBUSB_NOT_SUPPORTED error when trying to run the scan example

Also note that i did try overwriting and forcing the default values as recommended but that did not work either.

Installation failure in OpenWRT->ramips->mt7628, MIPS arch

I want to install bluetooth-hci-socket on my openwrt device which is mips and the chipset is mt7628 from MTK, but the log of installation is here, failed.

**root@OpenWrt:~/gateway# npm install bluetooth-hci-socket
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm WARN package.json [email protected] license should be a valid SPDX license expression
|

[email protected] install /root/gateway/node_modules/bluetooth-hci-socket/node_modules /usb
node-pre-gyp install --fallback-to-build

gyp ERR! configure error
gyp ERR! stack Error: Command failed: /usr/bin/python2 -c import platform; print (platform.python_version());
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:751:12)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at maybeClose (child_process.js:1015:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1087 :5)
gyp ERR! System Linux 3.18.27
gyp ERR! command "/usr/bin/node" "/root/gateway/node_modules/node-gyp/bin/node-g yp.js" "configure" "--fallback-to-build" "--module=/root/gateway/node_modules/bl uetooth-hci-socket/node_modules/usb/src/binding/usb_bindings.node" "--module_nam e=usb_bindings" "--module_path=/root/gateway/node_modules/bluetooth-hci-socket/n ode_modules/usb/src/binding"
gyp ERR! cwd /root/gateway/node_modules/bluetooth-hci-socket/node_modules/usb
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /root/gateway/no de_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/root /gateway/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding/usb_bind ings.node --module_name=usb_bindings --module_path=/root/gateway/node_modules/bl uetooth-hci-socket/node_modules/usb/src/binding' (1)
node-pre-gyp ERR! stack at ChildProcess. (/root/gateway/node_modu les/bluetooth-hci-socket/node_modules/usb/node_modules/node-pre-gyp/lib/util/com pile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:110:17)
node-pre-gyp ERR! stack at maybeClose (child_process.js:1015:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (child_proces s.js:1087:5)
node-pre-gyp ERR! System Linux 3.18.27
node-pre-gyp ERR! command "node" "/root/gateway/node_modules/bluetooth-hci-socke t/node_modules/usb/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-buil d"
node-pre-gyp ERR! cwd /root/gateway/node_modules/bluetooth-hci-socket/node_modul es/usb
node-pre-gyp ERR! node -v v0.12.7
node-pre-gyp ERR! node-pre-gyp -v v0.6.24
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /root/gateway/node_modules/node-gyp/bin/node-gy p.js configure --fallback-to-build --module=/root/gateway/node_modules/bluetooth -hci-socket/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bin dings --module_path=/root/gateway/node_modules/bluetooth-hci-socket/node_modules /usb/src/binding' (1)
npm WARN optional dep failed, continuing [email protected]

[email protected] install /root/gateway/node_modules/bluetooth-hci-so cket
node-gyp rebuild

gyp ERR! configure error
gyp ERR! stack Error: Command failed: /usr/bin/python2 -c import platform; print (platform.python_version());
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:751:12)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at maybeClose (child_process.js:1015:16)
gyp ERR! stack at Socket. (child_process.js:1183:11)
gyp ERR! stack at Socket.emit (events.js:107:17)
gyp ERR! stack at Pipe.close (net.js:485:12)
gyp ERR! System Linux 3.18.27
gyp ERR! command "node" "/root/gateway/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /root/gateway/node_modules/bluetooth-hci-socket
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm ERR! Linux 3.18.27
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "bluetooth-hci-socket"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebui ld'.
npm ERR! This is most likely a problem with the bluetooth-hci-socket package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls bluetooth-hci-socket
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /root/gateway/npm-debug.log**

Bluetooth dongle not detected

I'm running Noble in an Electron app but sometimes the dongle we're using is not detected and so onStateChanged is not triggered.

After digging into the code we found that BluetoothHciSocket.prototype.isDevUp returns false even if the device is plugged in.
https://github.com/sandeepmistry/node-bluetooth-hci-socket/blob/master/lib/usb.js#L68

We're using a BCM20702A0 dongle with PID 21E8 and VID 0A5C which should be supported.

Is there any way to recover from this? or force detection of the dongle again?

Extending USB Driver Compatibilty

Wanted to know that what does this code snippet represent inside https://github.com/sandeepmistry/node-bluetooth-hci-socket/blob/master/lib/usb.js:
``
this._usbDevice.open();

this._usbDeviceInterface = this._usbDevice.interfaces[0];

this._aclDataOutEndpoint = this._usbDeviceInterface.endpoint(0x02);

this._hciEventEndpoint = this._usbDeviceInterface.endpoint(0x81);
this._aclDataInEndpoint = this._usbDeviceInterface.endpoint(0x82);

this._usbDeviceInterface.claim();
};
``
I want to make your library compatible with this Device
Marvell AVASTAR Wireless Composite Device driver
: USB VID 1286
PID :204C

Can we change some of the parameters in the above snippet, so that the binding is successful.

On windows 10 restart the serial bus driver needs re-install

`Microsoft Windows [Version 10.0.10586]
(c) 2015 Microsoft Corporation. All rights reserved.

$C:\Users\Trezor.Owens>node-red

Welcome to Node-RED

20 Apr 12:13:46 - [info] Node-RED version: v0.15.1
20 Apr 12:13:46 - [info] Node.js version: v6.10.2
20 Apr 12:13:46 - [info] Windows_NT 10.0.10586 x64 LE
20 Apr 12:13:47 - [info] Loading palette nodes
20 Apr 12:13:49 - [warn] ------------------------------------------------------
20 Apr 12:13:49 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node
20 Apr 12:13:49 - [warn] [tail] Not currently supported on Windows.
20 Apr 12:13:49 - [warn] [serialport] Error: Module version mismatch. Expected 4
8, got 46.
20 Apr 12:13:49 - [warn] ------------------------------------------------------
20 Apr 12:13:49 - [info] Settings file : C:\Users\Trezor.Owens\AppData\Roaming
npm\node_modules\node-red\settings.js
20 Apr 12:13:49 - [info] User directory : \Users\Trezor.Owens.node-red
20 Apr 12:13:49 - [info] Flows file : \Users\Trezor.Owens.node-red\flows_00
1814-LAP.json
20 Apr 12:13:49 - [info] Server now running at http://127.0.0.1:1880/
20 Apr 12:13:49 - [info] Starting flows
20 Apr 12:13:49 - [info] Started flows
20 Apr 12:13:49 - [red] Uncaught Exception:
20 Apr 12:13:49 - RangeError: Index out of range
at checkOffset (buffer.js:834:11)
at Buffer.readUInt8 (buffer.js:872:5)
at Hci.processCmdCompleteEvent (C:\Users\Trezor.Owens.node-red\node_modules
\noble\lib\hci-socket\hci.js:566:25)
at Hci.onSocketData (C:\Users\Trezor.Owens.node-red\node_modules\noble\lib
hci-socket\hci.js:461:12)
at emitOne (events.js:96:13)
at BluetoothHciSocket.emit (events.js:188:7)
at BluetoothHciSocket.onHciEventEndpointData (C:\Users\Trezor.Owens.node-re
d\node_modules\noble\node_modules\bluetooth-hci-socket\lib\usb.js:156:10)
at emitOne (events.js:96:13)
at InEndpoint.emit (events.js:188:7)
at Transfer.transferDone (C:\Users\Trezor.Owens.node-red\node_modules\usb\u
sb.js:314:9)'

Here I update the usb serial bus device drive back to the default intel bluetooth driver, then re-install using zadig and it works as below. Any thoughts?

$C:\Users\Trezor.Owens>node-red

Welcome to Node-RED

20 Apr 12:14:41 - [info] Node-RED version: v0.15.1
20 Apr 12:14:41 - [info] Node.js version: v6.10.2
20 Apr 12:14:41 - [info] Windows_NT 10.0.10586 x64 LE
20 Apr 12:14:42 - [info] Loading palette nodes
20 Apr 12:14:43 - [warn] ------------------------------------------------------
20 Apr 12:14:43 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node
20 Apr 12:14:43 - [warn] [tail] Not currently supported on Windows.
20 Apr 12:14:43 - [warn] [serialport] Error: Module version mismatch. Expected 4
8, got 46.
20 Apr 12:14:43 - [warn] ------------------------------------------------------
20 Apr 12:14:43 - [info] Settings file : C:\Users\Trezor.Owens\AppData\Roaming
npm\node_modules\node-red\settings.js
20 Apr 12:14:43 - [info] User directory : \Users\Trezor.Owens.node-red
20 Apr 12:14:43 - [info] Flows file : \Users\Trezor.Owens.node-red\flows_00
1814-LAP.json
20 Apr 12:14:43 - [info] Server now running at http://127.0.0.1:1880/
20 Apr 12:14:43 - [info] Starting flows
20 Apr 12:14:43 - [info] Started flows

Write without response on multiple devices

Hi,
I am using noble to connect to multiple devices.
There are cases where I want to do writes without responses on multiple devices.
I get libusb errors when I transfer to more than 3 elements.
Which parameters do I need to tune if I am to support simultaneous writes for bulk transfers across multiple devices - say 4 in the minimum.
In the libusb documentation, I see there are different transport types - control, bulk, isochronous etc but the hci library uses only the control transfers. Do we need any tweaks to the HCI protocol if we were to do bulk data transfer on multiple devices or is it simply not possible with the available USB devices.

Node-red issue

command

Hi,
I've been trying to download and install this node for a while now.
When it comes to running node-red the package is ackowledged but never loads.
Any help would be greatly appreciated

Thanks

Following issue 233 from Noble : compatibility with Intel adapter

Following issue noble/noble#233

After having read some part of the linux BT drivers, it seems obvious that the Intel adapters work a bit differently from other one. To have them work they ;

  1. Put the adapter in "developer mode" to get the firmware
  2. Patch the firmware and reinject it
  3. Reset the adapter (it seems to be a special command to reset as well).

https://github.com/torvalds/linux/blob/master/drivers/bluetooth/btusb.c

I'm gonna try to reproduce the same thing adapting your work on this repo (and thx to the "usb" thing in node.js) but I'm afraid it's a bit beyond my field so help would be welcome :)

Anyway, I guess Intel adapters represent a decent chunk of the market and everyone will be happy to use them :) !

Keep you posted.

Compiling for MIPS architecture.

Good evening, I am attempting to use this library within a small embedded system. I am getting an error with the binding.node file found in the path "bluetooth-hci-socket/build/Release/binding.node", oddly enough however, on your repository here I do not see the build folder. This is part of a larger npm install of the node rolling spider library. The error I am getting is that it says the binding.node file stated in the above path "is not an ELF executable for MIPS". Sorry for putting this as an issue but I wasn't sure of another way to contact you. Any chance you know how I can compile this to work on a MIPS based architecture?

Thank you!

unable to run le-scan example after node-gyp rebuild

I wanted to try out bleno, but found this package causing issues.

I am on a raspberry pi zero w running node lts/baron v6.11.3

> sudo node examples/le-scan-test.js
module.js:434
return process.dlopen(module, path._makeLong(filename));
^

Error: Module version mismatch. Expected 46, got 48.
at Error (native)
at Object.Module._extensions..node (module.js:434:18)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/home/pi/git/guidos/sandbox/raspberrypi/blinky/node_modules/bluetooth-hci-socket/lib/native.js:3:15)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)

Any thoughts on how I can get this working of if there is something I am doing incorrectly?

Installation issue

Hello,

I'm not sure if I have installed correctly node-bluetooth-hci-socket as some warnings pop up. I've visualized the following when I installed it:

image

Could anyone help me out?

Thanks

Add support for BCM20702

Is it possible to add support for the BCM20702 chip as found in this dongle and the ASUS BT-400 ? It works with Noble on Linux and the Mac but on Windows it won't. Since it can support up to 14 simultaneous connections it would be very nice to have this adapter supported on Windows as wel..

Kind regards!

using userBind cause error on setFilter

Not sure if it's a bug or not having proper configuration, I tried to change le-scan-test.js to use bluetoothHciSocket.bindUser() and when run it I get [Error: File descriptor in bad state]. It's happens when code sets in bluetoothHciSocket.setFilter. BTW beside that error, looks like scanning works

this the change:

diff --git a/examples/le-scan-test.js b/examples/le-scan-test.js
index e573c53..8912a5d 100644
--- a/examples/le-scan-test.js
+++ b/examples/le-scan-test.js
@@ -120,7 +120,7 @@ function setScanEnable(enabled, duplicates) {
   bluetoothHciSocket.write(cmd);
 }

-bluetoothHciSocket.bindRaw();
+bluetoothHciSocket.bindUser();
 setFilter();
 bluetoothHciSocket.start();

and this is the output

sudo hciconfig hci0 down
sudo node le-scan-test.js
[Error: File descriptor in bad state]
data: 040e04010c200c
data: 040e04010b2000
LE Scan Parameters Set
data: 040e04010c2000
LE Scan Enable Set
data: 043e1702010000efe1d4c2153c0b02010607ff4c0010020b00c7
LE Advertising Report
	ADV_IND
	PUBLIC
	3c:15:c2:d4:e1:ef
	02010607ff4c0010020b00
	-57
data: 043e0c02010400efe1d4c2153c00c6
LE Advertising Report
	SCAN_RSP
	PUBLIC
	3c:15:c2:d4:e1:ef

	-58
data: 043e2b02010000ca09cc6ebb141f02011e1bff7500420401404f14bb6ecc09ca16bb6e5109c908000000000000ae

fails to build on iojs 3.2.0 (on Fedora 22)

I know the USB support is optional, but it probably shouldn't fail like this. Seems to be related to nan

$ iojs --version
v3.2.0
$ npm install bluetooth-hci-socket
-
> [email protected] install /home/johnny/.local/share/node_modules/bluetooth-hci-socket/node_modules/usb
> node-pre-gyp install --fallback-to-build

make: Entering directory '/home/johnny/.local/share/node_modules/bluetooth-hci-socket/node_modules/usb/build'
  CC(target) Release/obj.target/libusb/libusb/libusb/core.o
  CC(target) Release/obj.target/libusb/libusb/libusb/descriptor.o
  CC(target) Release/obj.target/libusb/libusb/libusb/hotplug.o
  CC(target) Release/obj.target/libusb/libusb/libusb/io.o
  CC(target) Release/obj.target/libusb/libusb/libusb/strerror.o
  CC(target) Release/obj.target/libusb/libusb/libusb/sync.o
  CC(target) Release/obj.target/libusb/libusb/libusb/os/poll_posix.o
  CC(target) Release/obj.target/libusb/libusb/libusb/os/threads_posix.o
../libusb/libusb/os/threads_posix.c:24:0: warning: "_GNU_SOURCE" redefined
 #  define _GNU_SOURCE
 ^
<command-line>:0:0: note: this is the location of the previous definition
  CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_usbfs.o
  CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_udev.o
  AR(target) Release/obj.target/usb.a
  COPY Release/usb.a
  CXX(target) Release/obj.target/usb_bindings/src/node_usb.o
In file included from ../src/helpers.h:3:0,
                 from ../src/node_usb.h:21,
                 from ../src/node_usb.cc:1:
../node_modules/nan/nan.h:324:27: error: redefinition of ‘template<class T> v8::Local<T> Nan::imp::NanEnsureHandleOrPersistent(const v8::Local<T>&)’
   NAN_INLINE v8::Local<T> NanEnsureHandleOrPersistent(const v8::Local<T> &val) {
                           ^
../node_modules/nan/nan.h:319:17: note: ‘template<class T> v8::Handle<T> Nan::imp::NanEnsureHandleOrPersistent(v8::Handle<T>&)’ previously declared here
   v8::Handle<T> NanEnsureHandleOrPersistent(const v8::Handle<T> &val) {
                 ^
../node_modules/nan/nan.h:344:27: error: redefinition of ‘template<class T> v8::Local<T> Nan::imp::NanEnsureLocal(v8::Handle<T>&)’
   NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Handle<T> &val) {
                           ^
../node_modules/nan/nan.h:334:27: note: ‘template<class T> v8::Local<T> Nan::imp::NanEnsureLocal(const v8::Local<T>&)’ previously declared here
   NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Local<T> &val) {
                           ^
../node_modules/nan/nan.h:757:13: error: ‘node::smalloc’ has not been declared
     , node::smalloc::FreeCallback callback
             ^
../node_modules/nan/nan.h:757:35: error: expected ‘,’ or ‘...’ before ‘callback’
     , node::smalloc::FreeCallback callback
                                   ^
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(char*, size_t, int)’:
../node_modules/nan/nan.h:761:50: error: ‘callback’ was not declared in this scope
         v8::Isolate::GetCurrent(), data, length, callback, hint);
                                                  ^
../node_modules/nan/nan.h:761:60: error: ‘hint’ was not declared in this scope
         v8::Isolate::GetCurrent(), data, length, callback, hint);
                                                            ^
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(const char*, uint32_t)’:
../node_modules/nan/nan.h:768:67: error: no matching function for call to ‘New(v8::Isolate*, const char*&, uint32_t&)’
     return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
                                                                   ^
In file included from ../src/node_usb.h:15:0,
                 from ../src/node_usb.cc:1:
/home/johnny/.node-gyp/3.2.0/include/node/node_buffer.h:31:40: note: candidate: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, v8::Handle<v8::String>, node::encoding) <near match>
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                        ^
/home/johnny/.node-gyp/3.2.0/include/node/node_buffer.h:31:40: note:   conversion of argument 3 would be ill-formed:
In file included from ../src/helpers.h:3:0,
                 from ../src/node_usb.h:21,
                 from ../src/node_usb.cc:1:
../node_modules/nan/nan.h:768:67: error: invalid conversion from ‘uint32_t {aka unsigned int}’ to ‘node::encoding’ [-fpermissive]
     return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
                                                                   ^
In file included from ../src/node_usb.h:15:0,
                 from ../src/node_usb.cc:1:
/home/johnny/.node-gyp/3.2.0/include/node/node_buffer.h:43:40: note: candidate: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, char*, size_t) <near match>
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                        ^
/home/johnny/.node-gyp/3.2.0/include/node/node_buffer.h:43:40: note:   conversion of argument 2 would be ill-formed:
In file included from ../src/helpers.h:3:0,
                 from ../src/node_usb.h:21,
                 from ../src/node_usb.cc:1:
../node_modules/nan/nan.h:768:67: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
     return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
                                                                   ^
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(uint32_t)’:
../node_modules/nan/nan.h:772:29: error: could not convert ‘node::Buffer::New(v8::Isolate::GetCurrent(), ((size_t)size))’ from ‘v8::MaybeLocal<v8::Object>’ to ‘v8::Local<v8::Object>return node::Buffer::New(v8::Isolate::GetCurrent(), size);
                             ^
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanBufferUse(char*, uint32_t)’:
../node_modules/nan/nan.h:779:12: error: ‘Use’ is not a member of ‘node::Buffer’
     return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
            ^
usb_bindings.target.mk:101: recipe for target 'Release/obj.target/usb_bindings/src/node_usb.o' failed
make: *** [Release/obj.target/usb_bindings/src/node_usb.o] Error 1
make: Leaving directory '/home/johnny/.local/share/node_modules/bluetooth-hci-socket/node_modules/usb/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.1.6-200.fc22.x86_64
gyp ERR! command "/usr/bin/iojs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/johnny/.local/share/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding/usb_bindings.node" "--module_name=usb_bindings" "--module_path=/home/johnny/.local/share/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding"
gyp ERR! cwd /home/johnny/.local/share/node_modules/bluetooth-hci-socket/node_modules/usb
gyp ERR! node -v v3.2.0
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/iojs /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/johnny/.local/share/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/home/johnny/.local/share/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/johnny/.local/share/node_modules/bluetooth-hci-socket/node_modules/usb/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:87:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:764:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Linux 4.1.6-200.fc22.x86_64
node-pre-gyp ERR! command "/usr/bin/iojs" "/home/johnny/.local/share/node_modules/bluetooth-hci-socket/node_modules/usb/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/johnny/.local/share/node_modules/bluetooth-hci-socket/node_modules/usb
node-pre-gyp ERR! node -v v3.2.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.4
node-pre-gyp ERR! not ok 
Failed to execute '/usr/bin/iojs /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/johnny/.local/share/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/home/johnny/.local/share/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding' (1)
npm WARN optional dep failed, continuing [email protected]

> [email protected] install /home/johnny/.local/share/node_modules/bluetooth-hci-socket
> node-gyp rebuild

make: Entering directory '/home/johnny/.local/share/node_modules/bluetooth-hci-socket/build'
  CXX(target) Release/obj.target/binding/src/BluetoothHciSocket.o
  SOLINK_MODULE(target) Release/obj.target/binding.node
  COPY Release/binding.node
make: Leaving directory '/home/johnny/.local/share/node_modules/bluetooth-hci-socket/build'
[email protected] node_modules/bluetooth-hci-socket
├── [email protected] ([email protected])
└── [email protected]

Unable to install on Raspberry Pi 3

Hi,
I am unable to install your package on Raspberry Pi 3. Here is the error:

ostuninstall [email protected]
2731 error [email protected] install: node-gyp rebuild
2731 error Exit status 1
2732 error Failed at the [email protected] install script.
2732 error This is most likely a problem with the bluetooth-hci-socket package,
2732 error not with npm itself.
2732 error Tell the author that this fails on your system:
2732 error node-gyp rebuild
2732 error You can get their info via:
2732 error npm owner ls bluetooth-hci-socket
2732 error There is likely additional logging output above.

Is this expected to work on OS X?

I noticed:

NOTE: Currently only supports Linux and Windows.

but also at the end of the page there are some notes about disabling the Bluetooth kexts on OS X.

So is this expected to work on OS X?

This returns -1 for me (after disabling all Bluetooth kexts):

socket(31, SOCK_RAW, 1);

I also tried 36 instead of 31, same deal.

Issue with macOS

I see OSX was mentioned in the read me, but it does not seem to be compatible on my machine (macOS Sierra). Is there any way I can get this to work with my machine?

npm-debug.txt

HRM disconection after 1 minute in Windows 8 machine

Hi @sandeepmistry

Thank you for your hard work, you have come a long way.

I started using noble and noble-device with Windows 8.1 just recently and discovered a problem when interacting with a hear rate monitor using the same example in the noble-devices repo. After 1 minute, or 60 measurements, the device gets disconnected by itself.

I already tried the same example on a Linux machine and the problem does not happen in Linux. I tried with two different ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode) dongles, but the result is the same.

Using the NODE=* tag, I managed to see that the last hci interaction before disconnecting is always the same in the windows machine (of course this is never experimented in the Linux Machine),

called hci   event type = 4 +0ms
  hci   sub event type = 5 +1ms
  hci           handle = 70 +0ms
  hci           reason = 59 +0ms

Some data received before looks like this:

update measument: 70
  hci-usb ACL Data In: 46200d00090004001b120016468a034403 +1s
  hci onSocketData: 0246200d00090004001b120016468a034403 +0ms
  hci   event type = 2 +0ms
  hci           cid = 4 +1ms
  hci           handle = 70 +0ms
  hci           data = 1b120016468a034403 +0ms
update measument: 70
  hci-usb ACL Data In: 46200b00070004001b120016468b03 +1s
  hci onSocketData: 0246200b00070004001b120016468b03 +0ms
  hci   event type = 2 +0ms
  hci           cid = 4 +1ms
  hci           handle = 70 +0ms
  hci           data = 1b120016468b03 +0ms
update measument: 70
  hci-usb ACL Data In: 46200b00070004001b120016469e03 +1s
  hci onSocketData: 0246200b00070004001b120016469e03 +1ms
  hci   event type = 2 +0ms
  hci           cid = 4 +1ms
  hci           handle = 70 +0ms
  hci           data = 1b120016469e03 +0ms
update measument: 70
  hci-usb HCI event: 05040046003b +494ms
  hci onSocketData: 0405040046003b +1ms
  hci   event type = 4 +0ms
  hci   sub event type = 5 +1ms
  hci           handle = 70 +0ms
  hci           reason = 59 +0ms
disconnected!
  hci set scan enabled - writing: 010c20020001 +1ms
  hci-usb write: 010c20020001 +0ms

Any help would be greatly appreciated :)

List hci devices

Hey, do you think we can expose the deviceList function?

I will look into creating a pull request, but only if you are interested 😅

Crypto error when connecting to WICED Sense

When connecting to the Broadcom WICED Sense tag from Linux (Ubuntu 14.04), I hit the following error. I do not have this problem with any other BLE hardware:

buffer.js:229
      length += list[i].length;
                       ^

TypeError: Cannot read property 'length' of undefined
    at Function.Buffer.concat (buffer.js:229:24)
    at Object.c1 (/home/ron/Development/cylonjs/cylon-example/node_modules/cylon-ble/node_modules/noble/lib/hci-socket/crypto.js:8:19)
    at Smp.handlePairingResponse (/home/ron/Development/cylonjs/cylon-example/node_modules/cylon-ble/node_modules/noble/lib/hci-socket/smp.js:86:12)
    at Smp.onAclStreamData (/home/ron/Development/cylonjs/cylon-example/node_modules/cylon-ble/node_modules/noble/lib/hci-socket/smp.js:57:10)
    at emitTwo (events.js:92:20)
    at emit (events.js:172:7)
    at AclStream.push (/home/ron/Development/cylonjs/cylon-example/node_modules/cylon-ble/node_modules/noble/lib/hci-socket/acl-stream.js:35:10)
    at NobleBindings.onAclDataPkt (/home/ron/Development/cylonjs/cylon-example/node_modules/cylon-ble/node_modules/noble/lib/hci-socket/bindings.js:252:15)
    at emitThree (events.js:97:13)
    at emit (events.js:175:7)

not able to install bluetooth-hci-socket

npm install bluetooth-hci-socket
npm WARN engine [email protected]: wanted: {"node":">=0.12.x"} (current: {"node":"0.10.29","npm":"1.4.21"})

[email protected] install /home/pi/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb
node-pre-gyp install --fallback-to-build

make: Entering directory '/home/pi/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/build'
CC(target) Release/obj.target/libusb/libusb/libusb/core.o
CC(target) Release/obj.target/libusb/libusb/libusb/descriptor.o
CC(target) Release/obj.target/libusb/libusb/libusb/hotplug.o
CC(target) Release/obj.target/libusb/libusb/libusb/io.o
CC(target) Release/obj.target/libusb/libusb/libusb/strerror.o
CC(target) Release/obj.target/libusb/libusb/libusb/sync.o
CC(target) Release/obj.target/libusb/libusb/libusb/os/poll_posix.o
CC(target) Release/obj.target/libusb/libusb/libusb/os/threads_posix.o
CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_usbfs.o
CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_udev.o
AR(target) Release/obj.target/usb.a
COPY Release/usb.a
CXX(target) Release/obj.target/usb_bindings/src/node_usb.o
In file included from ../src/helpers.h:3:0,
from ../src/node_usb.h:21,
from ../src/node_usb.cc:1:
../../nan/nan.h:324:47: error: ‘REPLACE_INVALID_UTF8’ is not a member of ‘v8::String’
static const unsigned kReplaceInvalidUtf8 = v8::String::REPLACE_INVALID_UTF8;
^
usb_bindings.target.mk:93: recipe for target 'Release/obj.target/usb_bindings/src/node_usb.o' failed
make: *** [Release/obj.target/usb_bindings/src/node_usb.o] Error 1
make: Leaving directory '/home/pi/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:809:12)
gyp ERR! System Linux 4.4.11-v7+
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "build" "--fallback-to-build" "--module=/home/pi/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding/usb_bindings.node" "--module_name=usb_bindings" "--module_path=/home/pi/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding"
gyp ERR! cwd /home/pi/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp build --fallback-to-build --module=/home/pi/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/home/pi/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding' (1)
node-pre-gyp ERR! stack at ChildProcess. (/home/pi/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:98:17)
node-pre-gyp ERR! stack at maybeClose (child_process.js:755:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:822:5)
node-pre-gyp ERR! System Linux 4.4.11-v7+
node-pre-gyp ERR! command "node" "/home/pi/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/pi/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb
node-pre-gyp ERR! node -v v0.10.29
node-pre-gyp ERR! node-pre-gyp -v v0.6.24
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp build --fallback-to-build --module=/home/pi/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/home/pi/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding' (1)
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm WARN optional dep failed, continuing [email protected]

[email protected] install /home/pi/node_modules/noble/node_modules/bluetooth-hci-socket
node-gyp rebuild

make: Entering directory '/home/pi/node_modules/noble/node_modules/bluetooth-hci-socket/build'
CXX(target) Release/obj.target/binding/src/BluetoothHciSocket.o
In file included from ../src/BluetoothHciSocket.cpp:8:0:
../node_modules/nan/nan.h:324:47: error: ‘REPLACE_INVALID_UTF8’ is not a member of ‘v8::String’
static const unsigned kReplaceInvalidUtf8 = v8::String::REPLACE_INVALID_UTF8;
^
binding.target.mk:82: recipe for target 'Release/obj.target/binding/src/BluetoothHciSocket.o' failed
make: *** [Release/obj.target/binding/src/BluetoothHciSocket.o] Error 1
make: Leaving directory '/home/pi/node_modules/noble/node_modules/bluetooth-hci-socket/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:809:12)
gyp ERR! System Linux 4.4.11-v7+
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/pi/node_modules/noble/node_modules/bluetooth-hci-socket
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm WARN optional dep failed, continuing [email protected]

I don't understand whats happening? I actually wanted to run noble on Pi 3. so noble was installed but when I ran the examples I got error for bluetooth-hci -socket so I tried to install it.

TypeError: Cannot read property 'on' of undefined

Hi this error in my computer with Windows 10

C:\node\controlBLE>node control.js
C:\node\controlBLE\node_modules\noble\node_modules\bluetooth-hci-socket\lib\usb.js:98
this._aclDataInEndpoint.on('data', this.onAclDataInEndpointData.bind(this));
^

TypeError: Cannot read property 'on' of undefined
at BluetoothHciSocket.start (C:\node\controlBLE\node_modules\noble\node_modules\bluetooth-hci-socket\lib\usb.js:98:28)
at Hci.init (C:\node\controlBLE\node_modules\noble\lib\hci-socket\hci.js: 100:18)
at NobleBindings.init (C:\node\controlBLE\node_modules\noble\lib\hci-socket\bindings.js:83:13)
at new Noble (C:\node\controlBLE\node_modules\noble\lib\noble.js:50:18) at Object. (C:\node\controlBLE\node_modules\noble\index.js:4:18)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)

The target device its Arduino 101: USB\VID_8087&PID_0AB6

install bluetooth-hci-socket on mips.

Hello,
I have a wrtnode2r which should be openwrt platform and mips ARCH, I want to install bluetooth-hci-socket on it, but below is error log, can you help me? Thanks.
root@OpenWrt:~/node_modules/noble# npm install bluetooth-hci-socket
npm WARN engine [email protected]: wanted: {"node":">=0.12.x"} (current: {"node":"0.10.36","npm":"1.4.28"})

[email protected] install /root/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb
node-pre-gyp install --fallback-to-build

gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at failNoPython (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:103:14)
gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:42:11
gyp ERR! stack at F (/usr/lib/node_modules/npm/node_modules/which/which.js:43:25)
gyp ERR! stack at E (/usr/lib/node_modules/npm/node_modules/which/which.js:46:29)
gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:57:16
gyp ERR! stack at Object.oncomplete (evalmachine.:108:15)
gyp ERR! System Linux 3.18.23
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/root/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding/usb_bindings.node" "--module_name=usb_bindings" "--module_path=/root/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding"
gyp ERR! cwd /root/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb
gyp ERR! node -v v0.10.36
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/nodejs /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/root/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/root/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding' (1)
node-pre-gyp ERR! stack at ChildProcess. (/root/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:98:17)
node-pre-gyp ERR! stack at maybeClose (child_process.js:766:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:833:5)
node-pre-gyp ERR! System Linux 3.18.23
node-pre-gyp ERR! command "node" "/root/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /root/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb
node-pre-gyp ERR! node -v v0.10.36
node-pre-gyp ERR! node-pre-gyp -v v0.6.4
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/nodejs /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/root/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/root/node_modules/noble/node_modules/bluetooth-hci-socket/node_modules/usb/src/binding' (1)
npm WARN optional dep failed, continuing [email protected]

[email protected] install /root/node_modules/noble/node_modules/bluetooth-hci-socket
node-gyp rebuild

gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at failNoPython (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:103:14)
gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:42:11
gyp ERR! stack at F (/usr/lib/node_modules/npm/node_modules/which/which.js:43:25)
gyp ERR! stack at E (/usr/lib/node_modules/npm/node_modules/which/which.js:46:29)
gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:57:16
gyp ERR! stack at Object.oncomplete (evalmachine.:108:15)
gyp ERR! System Linux 3.18.23
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/node_modules/noble/node_modules/bluetooth-hci-socket
gyp ERR! node -v v0.10.36
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok
npm WARN optional dep failed, continuing [email protected]

[Windows 8] StateChange incidentally not registered

Hi @sandeepmistry

I finally had time to dig a bit deeper into the issue I described here: noble/noble#353. Turnes out is was not just an Electron issue, because the error still appears on Window 8. Windows 10 does not seem to cause any problems at this moment. I will describe the problem below:

Problem

Incidentally after starting Noble the StateChange is either not registered or not called, because the program just waits and noble.state is unknown or poweredOff. Scanning therefore does not start and the program is not usable. No error is thrown so the bluetooth dongle I'm using is recognized, because starting the program without the dongle immediately throws the 'No compatible USB Bluetooth 4.0 device found'.

Analysis

The problem appears more often then not, meaning that when starting the test program is usually does not work, but something it will register the StateChange and start scanning.
If I start the program with DEBUG enabled:

set DEBUG=*
node test.js

the problem never appears! It seems like setting debug causes an extra reset somewhere that makes the adapter respond again. Unfortunately because setting DEBUG seems to fix the problem I cannot log debug output for the actual problem... However, I think that I see a different output when the adapter is reset. See the difference between these the logs:

Seems to work directly

noble_when_working

#### Seems to cause reset and then work
C:\Users\Studio Tast\Documents\Development\noble_test>set DEBUG=*

C:\Users\Studio Tast\Documents\Development\noble_test>node test.js
  hci-usb reset +0ms
  hci-usb write: 01030c00 +2ms
  noble stateChange poweredOff +4ms
Starting Noble Test
  hci-usb HCI event: 0e0401030c00 +6ms
  hci-usb reset complete +3ms
  hci onSocketData: 040e0401030c00 +3ms
  hci   event type = 4 +4ms
  hci   sub event type = 14 +11ms
  hci           cmd = 3075 +4ms
  hci           status = 0 +4ms
  hci           result =  +3ms
  hci-usb HCI event: 0e0401030c00 +5ms
  hci-usb reset complete +3ms
  hci onSocketData: 040e0401030c00 +3ms
  hci   event type = 4 +11ms
  hci   sub event type = 14 +4ms
  hci           cmd = 3075 +4ms
  hci           status = 0 +3ms
  hci           result =  +3ms
  hci setting filter to: 1600000020c10000000000400000 +929ms
  hci set event mask - writing: 01010c08fffffbff07f8bf3d +2ms
  hci-usb write: 01010c08fffffbff07f8bf3d +3ms
  hci set le event mask - writing: 010120081f00000000000000 +5ms
  hci-usb write: 010120081f00000000000000 +11ms
  hci read local version - writing: 01011000 +4ms
  hci-usb write: 01011000 +3ms
  hci write LE host supported - writing: 016d0c020100 +4ms
  hci-usb write: 016d0c020100 +3ms
  hci read LE host supported - writing: 016c0c00 +5ms
  hci-usb write: 016c0c00 +3ms
  hci read bd addr - writing: 01091000 +5ms
  hci-usb write: 01091000 +10ms
  hci-usb HCI event: 0e0401010c00 +6ms
  hci onSocketData: 040e0401010c00 +2ms
  hci   event type = 4 +3ms
  hci   sub event type = 14 +11ms
  hci           cmd = 3073 +7ms
  hci           status = 0 +3ms
  hci           result =  +4ms
  hci-usb HCI event: 0e0401012000 +5ms
  hci onSocketData: 040e0401012000 +12ms
  hci   event type = 4 +5ms
  hci   sub event type = 14 +3ms
  hci           cmd = 8193 +4ms
  hci           status = 0 +4ms
  hci           result =  +4ms
  hci-usb HCI event: 0e0c01011000060010060f000e22 +10ms
  hci onSocketData: 040e0c01011000060010060f000e22 +4ms
  hci   event type = 4 +3ms
  hci   sub event type = 14 +4ms
  hci           cmd = 4097 +3ms
  hci           status = 0 +3ms
  hci           result = 060010060f000e22 +4ms
  hci set scan enabled - writing: 010c20020001 +9ms
  hci-usb write: 010c20020001 +4ms
  hci set scan parameters - writing: 010b200701100010000000 +4ms
  hci-usb write: 010b200701100010000000 +3ms
  hci-usb HCI event: 0e04016d0c00 +3ms
  hci onSocketData: 040e04016d0c00 +3ms
  hci   event type = 4 +4ms
  hci   sub event type = 14 +9ms
  hci           cmd = 3181 +3ms
  hci           status = 0 +4ms
  hci           result =  +3ms
  hci-usb HCI event: 0e06016c0c000100 +4ms
  hci onSocketData: 040e06016c0c000100 +2ms
  hci   event type = 4 +4ms
  hci   sub event type = 14 +4ms
  hci           cmd = 3180 +7ms
  hci           status = 0 +5ms
  hci           result = 0100 +3ms
  hci                   le = 1 +3ms
  hci                   simul = 0 +2ms
  hci-usb HCI event: 0e0a0109100020606670f35c +3ms
  hci onSocketData: 040e0a0109100020606670f35c +3ms
  hci   event type = 4 +9ms
  hci   sub event type = 14 +4ms
  hci           cmd = 4105 +5ms
  hci           status = 0 +2ms
  hci           result = 20606670f35c +4ms
  hci address = 5c:f3:70:66:60:20 +3ms
  noble addressChange 5c:f3:70:66:60:20 +2ms
  hci-usb HCI event: 0e04010c200c +3ms
  hci onSocketData: 040e04010c200c +8ms
  hci   event type = 4 +3ms
  hci   sub event type = 14 +5ms
  hci           cmd = 8204 +2ms
  hci           status = 12 +3ms
  hci           result =  +2ms
  hci-usb HCI event: 0e04010b2000 +3ms
  hci onSocketData: 040e04010b2000 +4ms
  hci   event type = 4 +2ms
  hci   sub event type = 14 +9ms
  hci           cmd = 8203 +5ms
  hci           status = 0 +3ms
  hci           result =  +2ms
  noble stateChange poweredOn +3ms
We can start scanning
poweredOn  (current state)
poweredOn  (current state)
poweredOn  (current state)
  hci set scan enabled - writing: 010c20020001 +7s
  hci-usb write: 010c20020001 +2ms

C:\Users\Studio Tast\Documents\Development\noble_test>

The program outputs the following when not working and DEBUG is disabled:
noble_when_broken2
As you can see the state is 'poweredOff'

When working and debug is disabled (the desired output)
noble_when_working_without_debug

Related?

I have found a few related problems:
#13 (I am hoever not exiting the app in any strange way)

noble/noble#233 and #3 (closed due to lack of activity)
noble/noble#176 (My state is not unsupported and this was before Noble and node-bluetooth-hci-socket were separated)

System

I am running Window 8.1 Pro 64-bit. The dongle I'm using is the ASUS-BT400 (BCM20702) chipset. This is the test.js script that I'm running:

var noble = require('noble');
console.log("Starting Noble Test");
noble.on('stateChange', function(state) {
    if(state === 'poweredOn') {
        console.log('We can start scanning');
    } else {
        console.log('Stopped scanning');
});
setInterval(function(){ 
    console.log(noble.state, ' (current state)');
}, 2000);
console.log("Still alive"); //this was added later and does not appear in the first two logs

I recall that you don't have a Windows 8 machine available, if it's needed for further debugging I can provide a VM for you :) Thanks in advance for thanking a look and I'm sorry about the wall of text ;)

Interfacing two bluetooth modules with the rpi

I am trying to interface two bluetooth modules with the rpi. One would act as a peripheral and the other would be detected as an ibeacon. But it is just behaving as a peripheral and I not able to detect the second module

discoverAllServicesAndCharacteristics stopped working with raw USB mode at version 0.4.3

I cannot discover services and characteristics while using the raw USB mode anymore. It worked (and still works) with version 0.4.2 though. These are the adapters I've tested this with (separately):

Bus 001 Device 006: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 001 Device 008: ID 0a5c:21e8 Broadcom Corp. BCM20702A0 Bluetooth 4.0

Installing on Windows 10

Hi,

i have following issue when I try to install.

PS C:\nuimo-electron> npm install bluetooth-hci-socket
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
-
> [email protected] install C:\nuimo-electron\node_modules\bluetooth-hci-socket\node_modules\usb
> node-pre-gyp install --fallback-to-build

[usb] Success: "C:\nuimo-electron\node_modules\bluetooth-hci-socket\node_modules\usb\src\binding\usb_bindings.node" is installed via remote

> [email protected] install C:\nuimo-electron\node_modules\bluetooth-hci-socket
> node-gyp rebuild


C:\nuimo-electron\node_modules\bluetooth-hci-socket>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node ""
Die Projekte in dieser Projektmappe werden nacheinander erstellt. Um eine parallele Erstellung zu ermöglichen, müssen Sie den Schalter "/m" hinzufügen.
  win_delay_load_hook.c
C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\src\win_delay_load_hook.c(34): error C2373: "__pfnDliNotifyHook2": Neudefinition; unterschiedliche Modifizierer [C:\nuimo-electron\node_modules\bluetooth-hci-s
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\delayimp.h(134): note: Siehe Deklaration von "__pfnDliNotifyHook2"
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\nuimo-electron\node_modules\bluetooth-hci-socket
gyp ERR! node -v v4.4.4
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "bluetooth-hci-socket"
npm ERR! node v4.4.4
npm ERR! npm  v2.15.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the bluetooth-hci-socket package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs bluetooth-hci-socket
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls bluetooth-hci-socket
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\nuimo-electron\npm-debug.log

npm-debug.txt

nam install graceful-fs

common i use: npm install --save-dev graceful-fs
result:
npm WARN optional Skipping failed optional dependency /noble/bluetooth-hci-socket:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]

Turning on bluetooth after installing WinUSB

Hi,
I installed the WINUSB driver for my Intel Wireless Bluetooth 7260 bluetooth hardware. However, I'm not able to enable or disable bluetooth with the WINUSB driver. The default apps to enable bluetooth do not work anymore. Running a bluetooth code using this just hangs

set BLUETOOTH_HCI_SOCKET_USB_VID=0x050d
set BLUETOOTH_HCI_SOCKET_USB_PID=0x065a

node <file>.js

I'm running on Windows 8.1

Cant install on Beaglebone Black

I installed all prerequisites for noble package, and this package is its dependency. I can't install this package and the usb adapter is working fine with hcitool.

node-gyp rebuild

make: Entering directory /var/lib/cloud9/BluetoothWeb/node_modules/noble/node_modules/bluetooth-hci-socket/build' CXX(target) Release/obj.target/binding/src/BluetoothHciSocket.o In file included from ../src/BluetoothHciSocket.cpp:8:0: ../node_modules/nan/nan.h:330:47: error: ‘REPLACE_INVALID_UTF8’ is not a member of ‘v8::String’ make: *** [Release/obj.target/binding/src/BluetoothHciSocket.o] Error 1 make: Leaving directory/var/lib/cloud9/BluetoothWeb/node_modules/noble/node_modules/bluetooth-hci-socket/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:809:12)
gyp ERR! System Linux 3.8.13-bone70
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /var/lib/cloud9/BluetoothWeb/node_modules/noble/node_modules/bluetooth-hci-socket
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"

I tried everything but it's not working yet! Please help

Intel(R) Dual Band Wireless-AC 8260

I'm trying to make this work with my laptop which has a Intel(R) Dual Band Wireless-AC 8260 chipset. Should I just give up as I see this is not one of the compatible devices or is there something I could try?

It looks like you may have allowed for some bending of the "rules" with this:
Example for USB device id: 050d:065a:

set BLUETOOTH_HCI_SOCKET_USB_VID=0x050d
set BLUETOOTH_HCI_SOCKET_USB_PID=0x065a

node .js

If I were to replace the Example with:

set BLUETOOTH_HCI_SOCKET_USB_VID=0x8087
set BLUETOOTH_HCI_SOCKET_USB_PID=0x0a2a

node forceFit.js
perhaps it would work..

Support for multiple usb adapters in raw USB mode (with same VID and PID)?

Hi,

I'm using noble with multiple adapters to communicate with more than 5 BLE devices at the same time. For this I'm using the raw mode, since it is much more stable than with bluez. To differentiate the adapters, I'm using USB dongles with different VID/PIDs and BLUETOOTH_HCI_SOCKET_USB_VID and BLUETOOTH_HCI_SOCKET_USB_PID set to according values.

This works well, but it is limited to knowing the exact VID/PIDs. It would be much nicer to enumerate the adapters with a simple number (like in noble with the NOBLE_HCI_DEVICE_ID environment variable). This would also allow to use multiple adapters with same VID and PID. It would be helpful to enumerate valid values for this number, to enable a program to discover all available BLE adapters easily and use them.

Thanks,
Norman

error on [email protected] install

Hello,

I'm totally new to node & nodered.
I'm trying to install "node-red-contrib-sensortag" or "node-red-node-sensortag" to connect TI sensor tag to WatsonIoT, but encountered the below error.
I'm using raspbian Jessie on raspberry pi 3B, with below module versions:
node -v
v8.10.0
nodejs -v
v8.10.0
npm -v
3.10.10

What should I do?
Appreciate any clue and help. :)

Thank you!
Adi

`pi@raspberrypi:~/.node-red $ npm install node-red-contrib-sensortag

[email protected] install /home/pi/.node-red/node_modules/usb
node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://github.com/tessel/node-usb/releases/download/1.3.1/usb_bindings-v1.3.1-node-v57-linux-arm.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v57 ABI, glibc) (falling back to source compile with node-gyp)
make: Entering directory '/home/pi/.node-red/node_modules/usb/build'
CC(target) Release/obj.target/libusb/libusb/libusb/core.o
CC(target) Release/obj.target/libusb/libusb/libusb/descriptor.o
CC(target) Release/obj.target/libusb/libusb/libusb/hotplug.o
CC(target) Release/obj.target/libusb/libusb/libusb/io.o
CC(target) Release/obj.target/libusb/libusb/libusb/strerror.o
CC(target) Release/obj.target/libusb/libusb/libusb/sync.o
CC(target) Release/obj.target/libusb/libusb/libusb/os/poll_posix.o
CC(target) Release/obj.target/libusb/libusb/libusb/os/threads_posix.o
CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_usbfs.o
CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_udev.o
AR(target) Release/obj.target/usb.a
COPY Release/usb.a
CXX(target) Release/obj.target/usb_bindings/src/node_usb.o
CXX(target) Release/obj.target/usb_bindings/src/device.o
CXX(target) Release/obj.target/usb_bindings/src/transfer.o
SOLINK_MODULE(target) Release/obj.target/usb_bindings.node
COPY Release/usb_bindings.node
COPY /home/pi/.node-red/node_modules/usb/src/binding/usb_bindings.node
TOUCH Release/obj.target/action_after_build.stamp
make: Leaving directory '/home/pi/.node-red/node_modules/usb/build'

[email protected] install /home/pi/.node-red/node_modules/bluetooth-hci-socket
node-gyp rebuild

make: Entering directory '/home/pi/.node-red/node_modules/bluetooth-hci-socket/build'
CXX(target) Release/obj.target/binding/src/BluetoothHciSocket.o
../src/BluetoothHciSocket.cpp: In member function ‘void BluetoothHciSocket::emitErrnoError()’:
../src/BluetoothHciSocket.cpp:275:72: warning: ‘v8::Localv8::Object v8::Function::NewInstance(int, v8::Localv8::Value*) const’ is deprecated (declared at /home/pi/.node-gyp/8.10.0/include/node/v8.h:3846): Use maybe version [-Wdeprecated-declarations]
Local error = errorConstructor->NewInstance(1, constructorArgs);

^
SOLINK_MODULE(target) Release/obj.target/binding.node
COPY Release/binding.node
make: Leaving directory '/home/pi/.node-red/node_modules/bluetooth-hci-socket/build'
[email protected] /home/pi/.node-red

`

Raspberry Pi 3 UART BT LE Reconnects not working...

Any idea why there would be a problem with the built in BT chip on the Raspberry Pi 3? I am able to do an initial BT LE Pairing and have an encrypted connection setup correctly. However, after I break the connection and reconnect, the connection will not stay up. Judging by the HCIDump, the encryption is reestablished fine and some initial data packets are able to go back and forth correctly, however after about 2 seconds of being idle the connection drops.

I have it working fine on the same raspberry Pi using a BroadComm USB Dongle. The RPI 3 bluetooth is also a BroadComm chip connected over UART. The only obvious difference I can see is that the internal Bluetooth is v4.1 and the USB Dongle is v4.0.

From HCIDump it looks like it is the Pi initiating the disconnect:

2016-04-10 11:08:47.039373 > ACL data: handle 64 flags 0x02 dlen 11
    ATT: Read By Type req (0x08)
      start 0x0001, end 0x0005
      type-uuid 0x2a00
2016-04-10 11:08:47.042228 < ACL data: handle 64 flags 0x00 dlen 16
    ATT: Read By Type resp (0x09)
      length: 10
        handle 0x0003, value 0x62 0x6c 0x65 0x2d 0x61 0x6e 0x63 0x73 
2016-04-10 11:08:47.285530 > HCI Event: Number of Completed Packets (0x13) plen 5
    handle 64 packets 1
2016-04-10 11:08:48.953332 < HCI Command: Disconnect (0x01|0x0006) plen 3
    handle 64 reason 0x13
    Reason: Remote User Terminated Connection
2016-04-10 11:08:48.953737 > HCI Event: Command Status (0x0f) plen 4
    Disconnect (0x01|0x0006) status 0x00 ncmd 1
2016-04-10 11:08:49.020318 > HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 64 reason 0x16
    Reason: Connection Terminated by Local Host

libudev-dev dependency

I was just attempting to install on a fresh Ubuntu system and discovered that it would fail until I installed libudev-dev.

Windows installation fails

Having trouble "npm installing" node-bbc-microbit on Windows 10 x64, node 6.x, VS2015.

> [email protected] install C:\gh\node-bbc-microbit\node_modules\bluetooth-hci-socket
> node-gyp rebuild


C:\gh\node-bbc-microbit\node_modules\bluetooth-hci-socket>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  win_delay_load_hook.c
C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\src\win_delay_load_hook.c(34): error
C2373: '__pfnDliNotifyHook2': redefinition; different type modifiers [C:\gh\node-bbc-microbit\node_m
odules\bluetooth-hci-socket\build\binding.vcxproj]
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\delayimp.h(134): note: see declarat
  ion of '__pfnDliNotifyHook2'
gyp ERR! build error
gyp ERR! stack Error: `msbuild` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\gh\node-bbc-microbit\node_modules\bluetooth-hci-socket
gyp ERR! node -v v6.5.0
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm WARN install:[email protected] [email protected] install: `node-gyp rebuild`
npm WARN install:[email protected] Exit status 1
npm WARN optional Skipping failed optional dependency /noble/xpc-connection:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]

Bluetooth 4.2 support?

With the new Raspberry PI Model B+ which now using an adapter version of 4.2. I been having issues with the bluetooth 4.2 version.

Cannot read property 'call' of undefined

Hi,

the following exception is thrown if a bluetooth dongle is taken off during write.
The problem is that when calling the function usb.Device.controlTransfer in BluetoothHciSocket.write no callback is given.

The simplest fix for this issue would be to add an empty function as callback:

this._usbDevice.controlTransfer(usb.LIBUSB_REQUEST_TYPE_CLASS | usb.LIBUSB_RECIPIENT_INTERFACE, 0, 0, 0, data.slice(1), function() {});

Current NPM release is missing some device IDs

As mentioned in this issue: noble/noble#670

Looks like some new device IDs have been added since v0.5.1, but they haven't been released to NPM and so aren't available to the noble package.

Is it possible to release a new version so these devices don't cause an error?

Unable to install hci-socket on Chromebook

Hello,
I am running Linux Chromebook 4.4.0-59 #80-Ubuntu. I have node 7.7.2 installed. When I run sudo npm install bluetooth-hci-socket, I get this error:

[email protected] install /home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/usb
node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download: https://github.com/tessel/node-usb/releases/download/1.2.0/usb_bindings-v1.2.0-node-v51-linux-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v51 ABI) (falling back to source compile with node-gyp) make: Entering directory '/home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/usb/build'
CC(target) Release/obj.target/libusb/libusb/libusb/core.o
CC(target) Release/obj.target/libusb/libusb/libusb/descriptor.o
CC(target) Release/obj.target/libusb/libusb/libusb/hotplug.o
CC(target) Release/obj.target/libusb/libusb/libusb/io.o
CC(target) Release/obj.target/libusb/libusb/libusb/strerror.o
CC(target) Release/obj.target/libusb/libusb/libusb/sync.o
CC(target) Release/obj.target/libusb/libusb/libusb/os/poll_posix.o
CC(target) Release/obj.target/libusb/libusb/libusb/os/threads_posix.o
CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_usbfs.o
CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_udev.o
AR(target) Release/obj.target/usb.a
COPY Release/usb.a
CXX(target) Release/obj.target/usb_bindings/src/node_usb.o
make: g++: Command not found
usb_bindings.target.mk:105: recipe for target 'Release/obj.target/usb_bindings/src/node_usb.o' failed
make: *** [Release/obj.target/usb_bindings/src/node_usb.o] Error 127
make: Leaving directory '/home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/usb/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:194:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-59-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/usb/src/binding/usb_bindings.node" "--module_name=usb_bindings" "--module_path=/home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/usb/src/binding"
gyp ERR! cwd /home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/usb
gyp ERR! node -v v7.7.2
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/nodejs /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/usb/src/binding' (1)
node-pre-gyp ERR! stack at ChildProcess. (/home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/usb/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:194:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:899:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
node-pre-gyp ERR! System Linux 4.4.0-59-generic
node-pre-gyp ERR! command "/usr/bin/nodejs" "/home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/usb/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/usb
node-pre-gyp ERR! node -v v7.7.2
node-pre-gyp ERR! node-pre-gyp -v v0.6.30
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/nodejs /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/usb/src/binding' (1)

[email protected] install /home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/bluetooth-hci-socket
node-gyp rebuild
make: Entering directory '/home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/bluetooth-hci-socket/build'
CXX(target) Release/obj.target/binding/src/BluetoothHciSocket.o
make: g++: Command not found
binding.target.mk:94: recipe for target 'Release/obj.target/binding/src/BluetoothHciSocket.o' failed
make: *** [Release/obj.target/binding/src/BluetoothHciSocket.o] Error 127
make: Leaving directory '/home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/bluetooth-hci-socket/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:194:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-59-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/eazyigz/workspace/crestron/locus_bridge_emu_node/node_modules/bluetooth-hci-socket
gyp ERR! node -v v7.7.2
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/usb):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: node-pre-gyp install --fallback-to-build
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bluetooth-hci-socket package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs bluetooth-hci-socket
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls bluetooth-hci-socket
npm ERR! There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/eazyigz/.npm/_logs/2017-03-14T18_49_23_334Z-debug.log

On Linux use D-Bus GATT APIs

Lets please not alienate the Linux upstream, we do have a very complete set of APIs for BLE including GATT, which is build with a LGPL C library and D-Bus APIs so you don't need to rewrite everything from scratch. It is actually in use in Chrome OS as well so I wonder how much code can be shared.

Support for mac

Are you planning to support Mac as well in the future? OS X el capital currently doesn't support more than 6 connected devices maybe using this lib can resolve that issue?

bluetooth-hci-socket can't find my bluetooth device

i wrote some program using ble, but it only not working in my new laptop.

i wonder that this library can't connect to BLE 4.1 device?

enviromnet

  • Dell XPS13 9350
    • ble driver : Dell Wireless 1820A Bluetooth 4.1 LE

error log

\node_modules\bluetooth-hci-socket\lib\usb.js:50
throw new Error('No compatible USB Bluetooth 4.0 device found!');
^

Error: No compatible USB Bluetooth 4.0 device found!
at BluetoothHciSocket.bindUser (C:\Users\Nacer\Documents\1.nBand\BandLogger-master\BandLogger-master\node_modules\bluetooth-hci-socket\lib\usb.js:50:11)
at BluetoothHciSocket.bindRaw (C:\Users\Nacer\Documents\1.nBand\BandLogger-master\BandLogger-master\node_modules\bluetooth-hci-socket\lib\usb.js:28:8)
at Hci.init (C:\Users\Nacer\Documents\1.nBand\BandLogger-master\BandLogger-master\node_modules\noble\lib\hci-socket\hci.js:89:16)
at NobleBindings.init (C:\Users\Nacer\Documents\1.nBand\BandLogger-master\BandLogger-master\node_modules\noble\lib\hci-socket\bindings.js:83:13)
at new Noble (C:\Users\Nacer\Documents\1.nBand\BandLogger-master\BandLogger-master\node_modules\noble\lib\noble.js:67:18)
at Object. (C:\Users\Nacer\Documents\1.nBand\BandLogger-master\BandLogger-master\node_modules\noble\index.js:3:18)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)

Install fails on Win 7: " error C2373: '__pfnDliNotifyHook2'"

Error log below. Any advice on how I can fix / get around this? Thank you! I'm super excited to use this library!

C:\NearbyWeb\node_modules\bluetooth-hci-socket>if not defined npm_config_node_gyp (node "C:\node\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
win_delay_load_hook.c
C:\node\node_modules\npm\node_modules\node-gyp\src\win_delay_load_hook.c(34): error C2373: '__pfnDliNotifyHook2': redefinition; different type modifiers [C:\NearbyWeb\node_modules\bluetooth-hci-socket\build\binding.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\delayimp.h(134): note: see declaration of '__pfnDliNotifyHook2'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.