espruino / EspruinoTools

JavaScript library of tools for Espruino - used for the Web IDE, CLI, etc.
Apache License 2.0
150 stars 89 forks source link

espruino --list returns "Error: No compatible USB Bluetooth 4.0 device found!" #151

Open TheLogan opened 2 years ago

TheLogan commented 2 years ago

Hi, so I am trying to see my Bangle.js 2 on my pc, I'd rather use VS Code for development than the app, so I am playing around with commandline. In the web ide I can connect to my bangle with the button in the top left, no issues. But in commandline I get the following error:

undefined:55
    } else throw err;
           ^

Error: No compatible USB Bluetooth 4.0 device found!
    at BluetoothHciSocket.bindUser (C:\Users\tlo\AppData\Roaming\nvm\v16.15.0\node_modules\espruino\node_modules\@abandonware\bluetooth-hci-socket\lib\usb.js:91:11)
    at BluetoothHciSocket.bindRaw (C:\Users\tlo\AppData\Roaming\nvm\v16.15.0\node_modules\espruino\node_modules\@abandonware\bluetooth-hci-socket\lib\usb.js:47:8)
    at Hci.init (C:\Users\tlo\AppData\Roaming\nvm\v16.15.0\node_modules\espruino\node_modules\@abandonware\noble\lib\hci-socket\hci.js:121:20)
    at NobleBindings.init (C:\Users\tlo\AppData\Roaming\nvm\v16.15.0\node_modules\espruino\node_modules\@abandonware\noble\lib\hci-socket\bindings.js:93:13)
    at C:\Users\tlo\AppData\Roaming\nvm\v16.15.0\node_modules\espruino\node_modules\@abandonware\noble\lib\noble.js:61:24
    at processTicksAndRejections (node:internal/process/task_queues:78:11)

I suspect that the culprit is bluetooth-hci-socket is in a folder called @abandonware and when I went to their page I could see that the last release was 6 years old and the last code edit was 4 years old. So it's likely woefully outdated at this point :(

I did find this https://github.com/noble/node-bluetooth-hci-socket/issues/118 but it doesn't really seem like a viable solution, and I can't get it working for my self either.

It seems that the @abandonware project is an attempt to save orphaned projects, but it hasn't really helped this one xD Not sure what the solution is though :/

mariusGundersen commented 2 years ago

I had the same problem, and I solved it using the issue you linked to. So edit the file in node_modules adding the values used there, and it should work.

Obviously that's not a very good solution, so maybe a PR to @abandonware could help?

TheLogan commented 2 years ago

I had the same problem, and I solved it using the issue you linked to. So edit the file in node_modules adding the values used there, and it should work.

image Like this, right? I first tried with the values suggested in the link, and when that didn't work I downloaded zadig got the values relevant to my pc and tried again, but still didn't work.

Obviously that's not a very good solution, so maybe a PR to @abandonware could help?

If it had worked, then certainly, but ... well I at least can't get it to work xD

gfwilliams commented 2 years ago

Moving this to the EspruinoTools repo...

I think there's a list of supported devices, and you just put your device's USB IDs here: https://github.com/abandonware/node-bluetooth-hci-socket/blob/master/lib/usb.js#L15-L30

A PR to abandonware would be great. Basically the original 'noble' was just totally abandoned so that project sprung up to try and fix the issues with it.

Either way, it's not really a great solution since it goes straight to the USB adaptor. Since Windows 10 you can just access BLE devices via API, and you'd hope there would be a node module to handle that. I'm not sure if there is though.

I did winnus but then Node.js changed their API so it doesn't build for more modern Node.js versions (and even so since then Windows released a better API that should be used instead)