@onekeyfe/hd-transport-react-native
Advanced tools
Comparing version 0.1.22 to 0.1.23
@@ -20,2 +20,3 @@ export declare const initializeBleManager: () => void; | ||
}[]>; | ||
export declare const refreshCache: (peripheralId: string) => Promise<void>; | ||
//# sourceMappingURL=BleManager.d.ts.map |
@@ -170,3 +170,3 @@ 'use strict'; | ||
let connectOptions = { | ||
requestMTU: 512, | ||
requestMTU: 256, | ||
timeout: 3000, | ||
@@ -307,2 +307,3 @@ }; | ||
device = yield blePlxManager.connectToDevice(uuid); | ||
this.Log.debug('first try to reconnect without params'); | ||
} | ||
@@ -323,3 +324,3 @@ else { | ||
catch (e) { | ||
this.Log.debug('try to connect to device has error: ', e); | ||
this.Log.debug('not connected, try to connect to device has error: ', e); | ||
if (e.errorCode === reactNativeBlePlx.BleErrorCode.DeviceMTUChangeFailed || | ||
@@ -329,2 +330,3 @@ e.errorCode === reactNativeBlePlx.BleErrorCode.OperationCancelled) { | ||
yield device.connect(); | ||
this.Log.debug('second try to reconnect without params'); | ||
} | ||
@@ -507,7 +509,10 @@ else { | ||
catch (e) { | ||
this.Log.debug('writeCharacteristic write error: ', e); | ||
this.runPromise = null; | ||
if (e.errorCode === reactNativeBlePlx.BleErrorCode.DeviceDisconnected) { | ||
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleDeviceNotBonded); | ||
} | ||
this.runPromise = null; | ||
this.Log.debug('writeCharacteristic write error: ', e); | ||
if (e.errorCode === reactNativeBlePlx.BleErrorCode.OperationStartFailed) { | ||
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleWriteCharacteristicError, e.reason); | ||
} | ||
return; | ||
@@ -514,0 +519,0 @@ } |
{ | ||
"name": "@onekeyfe/hd-transport-react-native", | ||
"version": "0.1.22", | ||
"version": "0.1.23", | ||
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", | ||
@@ -23,8 +23,8 @@ "license": "MIT", | ||
"dependencies": { | ||
"@onekeyfe/hd-shared": "^0.1.22", | ||
"@onekeyfe/hd-transport": "^0.1.22", | ||
"@onekeyfe/hd-shared": "^0.1.23", | ||
"@onekeyfe/hd-transport": "^0.1.23", | ||
"react-native-ble-manager": "^8.1.0", | ||
"react-native-ble-plx": "^2.0.3" | ||
}, | ||
"gitHead": "ebc730c7be2b0d11fc8ec5f3ee08b1440d345c7a" | ||
"gitHead": "1d460705e90267f20fff95c9cd118c8ba818c7bc" | ||
} |
@@ -27,1 +27,12 @@ import BleManager from 'react-native-ble-manager'; | ||
}; | ||
export const refreshCache = async (peripheralId: string) => { | ||
try { | ||
await BleManager.connect(peripheralId); | ||
await BleManager.refreshCache(peripheralId); | ||
await BleManager.disconnect(peripheralId, true); | ||
console.log('refreshCache success'); | ||
} catch (error) { | ||
console.log('refreshCache error: ', error); | ||
} | ||
}; |
@@ -32,3 +32,3 @@ import { Platform } from 'react-native'; | ||
let connectOptions: Record<string, unknown> = { | ||
requestMTU: 512, | ||
requestMTU: 256, | ||
timeout: 3000, | ||
@@ -210,2 +210,3 @@ }; | ||
device = await blePlxManager.connectToDevice(uuid); | ||
this.Log.debug('first try to reconnect without params'); | ||
} else { | ||
@@ -227,3 +228,3 @@ throw ERRORS.TypedError(HardwareErrorCode.BleConnectedError, e.reason ?? e); | ||
} catch (e) { | ||
this.Log.debug('try to connect to device has error: ', e); | ||
this.Log.debug('not connected, try to connect to device has error: ', e); | ||
if ( | ||
@@ -235,2 +236,3 @@ e.errorCode === BleErrorCode.DeviceMTUChangeFailed || | ||
await device.connect(); | ||
this.Log.debug('second try to reconnect without params'); | ||
} else { | ||
@@ -447,7 +449,10 @@ throw ERRORS.TypedError(HardwareErrorCode.BleConnectedError, e.reason ?? e); | ||
} catch (e) { | ||
this.Log.debug('writeCharacteristic write error: ', e); | ||
this.runPromise = null; | ||
if (e.errorCode === BleErrorCode.DeviceDisconnected) { | ||
throw ERRORS.TypedError(HardwareErrorCode.BleDeviceNotBonded); | ||
} | ||
this.runPromise = null; | ||
this.Log.debug('writeCharacteristic write error: ', e); | ||
if (e.errorCode === BleErrorCode.OperationStartFailed) { | ||
throw ERRORS.TypedError(HardwareErrorCode.BleWriteCharacteristicError, e.reason); | ||
} | ||
return; | ||
@@ -454,0 +459,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52562
1211