openbci-archive / OpenBCI_NodeJS_Ganglion

The ganglion node js driver
24 stars 15 forks source link

openbci-ganglion depends on bluetooth-hci-socket, which is abandoned and doesn't build with node 10 #52

Open mhirsch opened 5 years ago

mhirsch commented 5 years ago

openbci-ganglion fails to install with node v10, due to a broken dependency, bluetooth-hci-socket.

$ node -v
v10.13.0
npm install @openbci/ganglion

...

../src/BluetoothHciSocket.cpp: In member function ‘void BluetoothHciSocket::emitErrnoError()’:
../src/BluetoothHciSocket.cpp:275:72: error: no matching function for call to ‘v8::Function::NewInstance(int, v8::Local<v8::Value> [1])’
   Local<Value> error = errorConstructor->NewInstance(1, constructorArgs);
                                                                        ^
In file included from /home/mhirsch/.node-gyp/10.13.0/include/node/node.h:63,
                 from /home/mhirsch/.node-gyp/10.13.0/include/node/node_buffer.h:25,
                 from ../src/BluetoothHciSocket.cpp:7:

...

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Linux 4.18.18-300.fc29.x86_64
gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/mhirsch/Projects/OpenBCI/node_modules/bluetooth-hci-socket
gyp ERR! node -v v10.13.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
npm WARN enoent ENOENT: no such file or directory, open '/home/mhirsch/Projects/OpenBCI/package.json'
npm WARN OpenBCI No description
npm WARN OpenBCI No repository field.
npm WARN OpenBCI No README data
npm WARN OpenBCI No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: xpc-connection@0.1.4 (node_modules/xpc-connection):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for xpc-connection@0.1.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bluetooth-hci-socket@0.5.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the bluetooth-hci-socket@0.5.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

See the issue with bluetooth-hci-socket here

https://github.com/noble/node-bluetooth-hci-socket/issues/84

The project should migrate away from this abandoned dependency.

mhirsch commented 5 years ago

It depends on bluetooth-hci-scocket by way of noble. Since noble is an optional dependency you can get around this by running npm install --no-optional @openbci/ganglion

One thing I didn't understand is that the BLED112 dongle is not a normal BLE dongle. It has the ability to bypass the normal system bluetooth stack and interact as a serial port. The way this code is written, at least on Windows and Linux, it relies on this very specific behavior of the BLED112 dongle. But then on macos, it seems the project does rely on the native bluetooth stack, which is why noble is a dependency. When used on linux, noble perhaps once upon a time worked by pulling in bluetooth-hci-scocket, but that's all crufty and broken.

Why in the world it was written this way is a confounding and frustrating mystery. But then again, every layer of OpenBCI code, from this driver, to the Hub, to the GUI, is a hot mess of barely functional, brittle spaghetti code. I'm so dissapointed by this project. I am sad that I gave them money for the ganglion board. The debt of human misery they have created by subjecting the world to their insane concept of software engineering could never be sufficiently repaid in brain research.

daniellasry commented 5 years ago

@mhirsch I'm with you. Painfully aware of how brittle, messy, and hard to maintain the code is. It has been neglected for a while.

The good news is that we're working on making it better. Way better. It won't happen overnight, but it's happening.

Why is noble is a dependency? Probably because we still support built-in bluetooth on mac. I'll see if I can get the install working on Node 10. If not, maybe it's time to consider dropping built-in bluetooth for now.