Skip to content

Commit

Permalink
Merge branch 'bugfix/handle-android-connecton-problems' of https://gi…
Browse files Browse the repository at this point in the history
…thub.com/dotintent/react-native-ble-plx into bugfix/handle-android-connecton-problems
  • Loading branch information
dimninik committed Oct 13, 2023
2 parents dacc477 + c262e3d commit bb0d429
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/BleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import type {
ConnectionOptions,
BleManagerOptions
} from './TypeDefinition'
import { Platform } from 'react-native'

const enableDisableDeprecatedMessage =
'react-native-ble-plx: The enable and disable feature is no longer supported. In Android SDK 31+ there were major changes in permissions, which may cause problems with these functions, and in SDK 33+ they were completely removed.'
Expand Down Expand Up @@ -457,6 +458,9 @@ export class BleManager {
* @returns {Promise<Device>} Connected {@link Device} object if successful.
*/
async connectToDevice(deviceIdentifier: DeviceId, options: ?ConnectionOptions): Promise<Device> {
if (Platform.OS === 'android' && (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 bb0d429

Please sign in to comment.