Skip to content

Commit

Permalink
Handled disconnect reason to higher level
Browse files Browse the repository at this point in the history
  • Loading branch information
majo-icutech authored and rzr committed Nov 15, 2021
1 parent 67ccb54 commit 6165027
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/hci-socket/bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ NobleBindings.prototype.onDisconnComplete = function (handle, reason) {
delete this._handles[uuid];
delete this._handles[handle];

this.emit('disconnect', uuid); // TODO: handle reason?
this.emit('disconnect', uuid, reason);
} else {
console.warn(`noble warning: unknown handle ${handle} disconnected!`);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/noble.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,12 @@ Noble.prototype.disconnect = function (peripheralUuid) {
this._bindings.disconnect(peripheralUuid);
};

Noble.prototype.onDisconnect = function (peripheralUuid) {
Noble.prototype.onDisconnect = function (peripheralUuid, reason) {
const peripheral = this._peripherals[peripheralUuid];

if (peripheral) {
peripheral.state = 'disconnected';
peripheral.emit('disconnect');
peripheral.emit('disconnect', reason);
} else {
this.emit('warning', `unknown peripheral ${peripheralUuid} disconnected!`);
}
Expand Down

0 comments on commit 6165027

Please sign in to comment.