File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
packages/hd-transport-react-native/src Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,12 @@ import {
1919 isOnekeyDevice ,
2020} from '@onekeyfe/hd-shared' ;
2121import type EventEmitter from 'events' ;
22- import { getConnectedDeviceIds , onDeviceBondState , pairDevice } from './BleManager' ;
22+ import {
23+ getConnectedDeviceIds ,
24+ onDeviceBondState ,
25+ pairDevice ,
26+ getBondedDevices ,
27+ } from './BleManager' ;
2328import { subscribeBleOn } from './subscribeBleOn' ;
2429import {
2530 getBluetoothServiceUuids ,
@@ -260,9 +265,16 @@ export default class ReactNativeBleTransport {
260265
261266 // check device is bonded
262267 if ( Platform . OS === 'android' ) {
263- const bondState = await pairDevice ( uuid ) ;
264- if ( bondState . bonding ) {
265- await onDeviceBondState ( uuid ) ;
268+ const bondedDevices = await getBondedDevices ( ) ;
269+ const existsBondedList = bondedDevices . find (
270+ device => device . id . toLowerCase ( ) === uuid . toLowerCase ( )
271+ ) ;
272+
273+ if ( ! existsBondedList ) {
274+ const bondState = await pairDevice ( uuid ) ;
275+ if ( bondState . bonding ) {
276+ await onDeviceBondState ( uuid ) ;
277+ }
266278 }
267279 }
268280
You can’t perform that action at this time.
0 commit comments