question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trapping "No compatible USB Bluetooth 4.0 device" error?

See original GitHub issue

Hi!

I have a project that uses Noble as one of a few different connection options (BLE, USB Serial, TCP/IP) - however I’m finding that on Windows 10 I get No compatible USB Bluetooth 4.0 device errors on some devices which closes my application.

That’s fine - I know some devices won’t have BLE dongles that work with Noble. However I’d like to be able to trap the error gracefully and carry on without Noble regardless.

On Linux, I get stateChange -> poweredOff without any devices, so that’s easy.

I have tried:

  var noble = undefined;
  try {
    noble = require('noble');
  } catch (e) {
   ...
  }

But that doesn’t seem to be able to trap the error that occurs on Windows 10 as it appears it’s coming from a callback that’s been scheduled at some later point.

Error: No compatible USB Bluetooth 4.0 device found!
at BluetoothHciSocket.bindUser (C:\Users\name\AppData\Roaming\npm\node_modules\espruino\node_modules\bluetooth-hci-socket\lib\usb.js:70:11)
at BluetoothHciSocket.bindRaw (C:\Users\name\AppData\Roaming\npm\node_modules\espruino\node_modules\bluetooth-hci-socket\lib\usb.js:28:8)
at Hci.init (C:\Users\name\AppData\Roaming\npm\node_modules\espruino\node_modules\noble\lib\hci-socket\hci.js:101:35)
at NobleBindings.init (C:\Users\name\AppData\Roaming\npm\node_modules\espruino\node_modules\noble\lib\hci-socket\bindings.js:82:13)
at Noble.<anonymous> (C:\Users\name\AppData\Roaming\npm\node_modules\espruino\node_modules\noble\lib\noble.js:57:24)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
at Function.Module.runMain (module.js:695:11)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3

Is there any way I can trap it nicely? About the only thing I can think right now is uncaughtException but that seems like overkill.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gfwilliamscommented, Jul 25, 2022

All I currently do to work around it is this: https://github.com/espruino/EspruinoTools/blob/974b572217b724d4c29c9ca9e3c86385e9fcd765/core/serial_noble.js#L50-L71

So I just install an uncaughtException handler. Also I’m now using https://github.com/abandonware/noble as it’s a bit better maintained.

Closing this as there’s a workaround

0reactions
paramsiddharthcommented, Jul 22, 2022

@gfwilliams Do we have any updates? I think this might be related to #133.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Possible upstream issues with noble causing No compatible ...
Error : No compatible USB Bluetooth 4.0 device found! at BluetoothHciSocket. ... EspruinoWebIDE still giving same error: dive into nw.js ?
Read more >
"No compatible USB Bluetooth 4.0 device found!" error with ...
Hi Espruino Savants, I am trying to use the Espruino Command Line module on a Windows 10 PC. I type "espruino -p COM18"...
Read more >
@ycanince/bluetooth-hci-socket - npm
This library needs raw USB access to a Bluetooth 4.0 USB adapter, as it needs to bypass the Windows Bluetooth stack.
Read more >
@abandonware/noble NPM | npm.io
You will not get any errors if running without sudo, but nothing will happen. ... Compatible Bluetooth 4.0 USB adapter; WinUSB driver setup...
Read more >
How to Fix Bluetooth Pairing Problems - Techlicious
Bluetooth Smart devices are not backward compatible and won't ... Bluetooth 4.0 devices will be officially labeled Bluetooth Smart Ready.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found