Skip to content

Commit

Permalink
fix: fast reuse of connect to device leads to 'device not connected e…
Browse files Browse the repository at this point in the history
…rror'
  • Loading branch information
gmiszewski-intent committed Oct 11, 2023
1 parent 9b93a1c commit 4d67f28
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/BleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@ export class BleManager {
* @returns {Promise<Device>} Connected {@link Device} object if successful.
*/
async connectToDevice(deviceIdentifier: DeviceId, options: ?ConnectionOptions): Promise<Device> {
if (await this.isDeviceConnected(deviceIdentifier)) {
await this.cancelDeviceConnection(deviceIdentifier)
}
const nativeDevice = await this._callPromise(BleModule.connectToDevice(deviceIdentifier, options))
return new Device(nativeDevice, this)
}
Expand Down

0 comments on commit 4d67f28

Please sign in to comment.