@stoprocent/noble
Advanced tools
@@ -23,2 +23,3 @@ const { EventEmitter } = require('events'); | ||
| this._pendingConnectionUuid = null; | ||
| this._pendingConnectionAddress = null; | ||
| this._connectionQueue = []; | ||
@@ -152,2 +153,3 @@ | ||
| this._pendingConnectionUuid = nextConn.id; | ||
| this._pendingConnectionAddress = this.addressToId(nextConn.address); | ||
| this._hci.createLeConn(nextConn.address, nextConn.addressType, nextConn.params, Object.keys(this._handles).length === 0); | ||
@@ -168,2 +170,3 @@ }; | ||
| this._pendingConnectionUuid = null; | ||
| this._pendingConnectionAddress = null; | ||
| } | ||
@@ -205,2 +208,3 @@ | ||
| this._pendingConnectionUuid = null; | ||
| this._pendingConnectionAddress = null; | ||
| } | ||
@@ -316,3 +320,4 @@ | ||
| supervisionTimeout, | ||
| masterClockAccuracy | ||
| masterClockAccuracy, | ||
| peerResolvablePrivateAddress | ||
| ) { | ||
@@ -326,2 +331,12 @@ if (role !== 0 && role !== undefined) { | ||
| let error = null; | ||
| const currentConn = this._connectionQueue[0]; | ||
| const completionAddresses = [address, peerResolvablePrivateAddress] | ||
| .filter((candidate) => typeof candidate === 'string') | ||
| .map((candidate) => this.addressToId(candidate)); | ||
| const matchesPendingConnection = Boolean( | ||
| currentConn && | ||
| this._pendingConnectionUuid === currentConn.id && | ||
| this._pendingConnectionAddress && | ||
| completionAddresses.includes(this._pendingConnectionAddress) | ||
| ); | ||
@@ -364,3 +379,3 @@ if (status === 0) { | ||
| ); | ||
| const connectionParams = this._connectionQueue.length > 0 ? this._connectionQueue[0].params : {}; | ||
| const connectionParams = matchesPendingConnection ? currentConn.params : {}; | ||
| const gatt = new Gatt(address, aclStream, connectionParams && connectionParams.mtu); | ||
@@ -418,4 +433,2 @@ const signaling = new Signaling(handle, aclStream); | ||
| } else { | ||
| const currentConn = this._connectionQueue[0]; | ||
| uuid = currentConn ? currentConn.id : null; | ||
| let statusMessage = Hci.STATUS_MAPPER[status] || 'HCI Error: Unknown'; | ||
@@ -427,10 +440,14 @@ const errorCode = ` (0x${status.toString(16)})`; | ||
| // Remove the completed/failed connection attempt from queue | ||
| this._connectionQueue.shift(); | ||
| this._pendingConnectionUuid = null; | ||
| this.emit('connect', uuid, error); | ||
| // Process next connection in queue if any | ||
| this.processConnectionQueue(); | ||
| if (matchesPendingConnection) { | ||
| uuid = currentConn.id; | ||
| this._connectionQueue.shift(); | ||
| this._pendingConnectionUuid = null; | ||
| this._pendingConnectionAddress = null; | ||
| this.emit('connect', uuid, error); | ||
| this.processConnectionQueue(); | ||
| } else if (status === 0) { | ||
| // Preserve the existing behavior of adopting unsolicited successful links, | ||
| // without letting them consume or inherit parameters from a pending attempt. | ||
| this.emit('connect', uuid, null); | ||
| } | ||
| }; | ||
@@ -437,0 +454,0 @@ |
@@ -1245,3 +1245,4 @@ const debug = require('debug')('hci'); | ||
| supervisionTimeout, | ||
| masterClockAccuracy | ||
| masterClockAccuracy, | ||
| peerResolvablePrivateAddress | ||
| ); | ||
@@ -1248,0 +1249,0 @@ }; |
+1
-1
@@ -9,3 +9,3 @@ { | ||
| "description": "A Node.js BLE (Bluetooth Low Energy) central library.", | ||
| "version": "2.6.1", | ||
| "version": "2.6.2", | ||
| "repository": { | ||
@@ -12,0 +12,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
2538888
0.19%18083
0.53%