Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: catch error on this._bindings.init() #310

Merged
merged 1 commit into from
Jul 28, 2023
Merged

fix: catch error on this._bindings.init() #310

merged 1 commit into from
Jul 28, 2023

Conversation

bwp91
Copy link

@bwp91 bwp91 commented Jul 28, 2023

Current Situation

Using noble with developing Homebridge plugins. In situations where, for example, a user is running from a raspberry pi with no bluetooth, this leads to an error which cannot be caught and results in the node process crashing. I managed to recreate this by disabling the bluetooth on my pi by adding dtoverlay=disable-bt to my /boot/config.txt file.

Homebridge logs on plugin init:

/home/pi/govee/node_modules/@abandonware/noble/lib/hci-socket/hci.js:160
      this._socket.bindRaw(this._deviceId);
                   ^
Error: ENODEV, No such device
    at Hci.init (/home/pi/govee/node_modules/@abandonware/noble/lib/hci-socket/hci.js:160:20)
    at NobleBindings.init (/home/pi/govee/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:100:13)
    at /home/pi/govee/node_modules/@abandonware/noble/lib/noble.js:61:24
    at processTicksAndRejections (node:internal/process/task_queues:77:11)
[27/07/2023, 08:07:33] [Govee] Child bridge process ended
[27/07/2023, 08:07:33] [Govee] Process Ended. Code: 1, Signal: null
[27/07/2023, 08:07:40] [Govee] Restarting Process...

With this PR fix, these logs become

[27/07/2023, 08:13:05] [Govee] ***** No devices found to initialise. *****
[27/07/2023, 08:13:05] [Govee] [BLE] Initialisation of USB device failed: ENODEV, No such device.

Fixes #132

Copy link

@Apollon77 Apollon77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see a better way for now

@rzr LGTM

@rzr rzr merged commit 8be1e4e into abandonware:master Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: ENODEV, No such device
3 participants