From 41d6ce238c7d9d600048ae8c3d24b366819ba52f Mon Sep 17 00:00:00 2001 From: Dave Nicolson Date: Sat, 17 Jan 2026 22:13:35 +0100 Subject: [PATCH] =?UTF-8?q?fix=20(noble):=20=E2=80=9Cunknown=20peripheral?= =?UTF-8?q?=20null=20connected!=E2=80=9D=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/hci-socket/bindings.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/hci-socket/bindings.js b/lib/hci-socket/bindings.js index 6ffead84..88fc3974 100644 --- a/lib/hci-socket/bindings.js +++ b/lib/hci-socket/bindings.js @@ -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); } }; @@ -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; @@ -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);