Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/hci-socket/bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ NobleBindings.prototype.connect = function (peripheralUuid, parameters = {}) {
const processNextConnection = () => {
if (this._connectionQueue.length === 1) {
const nextConn = this._connectionQueue[0]; // Look at next connection but don't remove yet
this._pendingConnectionUuid = nextConn.id;
this._hci.createLeConn(nextConn.address, nextConn.addressType, nextConn.params, Object.keys(this._handles).length === 0);
}
};
Expand Down Expand Up @@ -389,7 +390,8 @@ NobleBindings.prototype.onLeConnComplete = function (
this._gatts[handle].exchangeMtu();
} else {
const currentConn = this._connectionQueue[0];
uuid = currentConn ? currentConn.id : null;
const addrUuid = address ? this.addressToId(address) : null;
uuid = addrUuid || (currentConn ? currentConn.id : (this._pendingConnectionUuid || null));
let statusMessage = Hci.STATUS_MAPPER[status] || 'HCI Error: Unknown';
const errorCode = ` (0x${status.toString(16)})`;
statusMessage = statusMessage + errorCode;
Expand All @@ -398,6 +400,7 @@ NobleBindings.prototype.onLeConnComplete = function (

// Remove the completed/failed connection attempt from queue
this._connectionQueue.shift();
this._pendingConnectionUuid = null;

this.emit('connect', uuid, error);

Expand Down
Loading