Skip to content

Commit

Permalink
fix(hci): closing connections on exit in hci driver
Browse files Browse the repository at this point in the history
  • Loading branch information
stoprocent committed Dec 30, 2024
1 parent 0387a52 commit ecb4333
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
17 changes: 1 addition & 16 deletions lib/hci-socket/bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ NobleBindings.prototype.init = function () {
this._hci.on('disconnComplete', this.onDisconnComplete.bind(this));
this._hci.on('encryptChange', this.onEncryptChange.bind(this));
this._hci.on('aclDataPkt', this.onAclDataPkt.bind(this));

this._hci.init();

/* Add exit handlers after `init()` has completed. If no adaptor
Expand All @@ -134,21 +134,6 @@ NobleBindings.prototype.onSigInt = function () {
const sigIntListeners = process.listeners('SIGINT');

if (sigIntListeners[sigIntListeners.length - 1] === this.onSigIntBinded) {
// Stop scanning if active
if (this._isScanning) {
this.stopScanning();
}

// Disconnect all active connections
for (const handle in this._handles) {
if (Object.hasOwn(this._handles, handle)) {
this.disconnect(this._handles[handle]);
}
}

// Clear connection queue
this._connectionQueue = [];

// we are the last listener, so exit
// this will trigger onExit, and clean up
process.exit(1);
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"node-gyp-build": "^4.8.1"
},
"optionalDependencies": {
"@stoprocent/bluetooth-hci-socket": "^1.4.3"
"@stoprocent/bluetooth-hci-socket": "^1.4.4"
},
"devDependencies": {
"@commitlint/cli": "^19.3.0",
Expand Down

0 comments on commit ecb4333

Please sign in to comment.