@onekeyfe/hd-transport-react-native
Advanced tools
Comparing version 1.0.7-alpha.2 to 1.0.7-alpha.3
@@ -30,2 +30,3 @@ import * as transport from '@onekeyfe/hd-transport'; | ||
enumerate(): Promise<Device[]>; | ||
refreshCache(deviceId: string): Promise<void>; | ||
acquire(input: BleAcquireInput): Promise<{ | ||
@@ -32,0 +33,0 @@ uuid: string; |
@@ -64,13 +64,2 @@ 'use strict'; | ||
}); | ||
const refreshCache = (peripheralId) => __awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
yield BleManager__default["default"].connect(peripheralId); | ||
yield BleManager__default["default"].refreshCache(peripheralId); | ||
yield BleManager__default["default"].disconnect(peripheralId, true); | ||
console.log('refreshCache success'); | ||
} | ||
catch (error) { | ||
console.log('refreshCache error: ', error); | ||
} | ||
}); | ||
@@ -302,2 +291,14 @@ const timer = process.env.NODE_ENV === 'development' | ||
} | ||
refreshCache(deviceId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const blePlxManager = yield this.getPlxManager(); | ||
yield blePlxManager.refreshGatt(deviceId); | ||
yield new Promise(resolve => setTimeout(resolve, 500)); | ||
} | ||
catch (error) { | ||
console.log('refreshCache error: ', error); | ||
} | ||
}); | ||
} | ||
acquire(input) { | ||
@@ -390,2 +391,3 @@ var _a, _b, _c; | ||
} | ||
this.refreshCache(uuid); | ||
if (reactNative.Platform.OS === 'android') { | ||
@@ -489,3 +491,3 @@ const bondedDevices = yield getBondedDevices(); | ||
} | ||
refreshCache(deviceId); | ||
this.refreshCache(deviceId); | ||
this.runPromise.reject(hdShared.ERRORS.TypedError(ERROR, (_c = error.reason) !== null && _c !== void 0 ? _c : error.message)); | ||
@@ -492,0 +494,0 @@ this.Log.debug(': monitor notify error, and has unreleased Promise'); |
{ | ||
"name": "@onekeyfe/hd-transport-react-native", | ||
"version": "1.0.7-alpha.2", | ||
"version": "1.0.7-alpha.3", | ||
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", | ||
@@ -22,8 +22,8 @@ "license": "MIT", | ||
"dependencies": { | ||
"@onekeyfe/hd-shared": "^1.0.7-alpha.2", | ||
"@onekeyfe/hd-transport": "^1.0.7-alpha.2", | ||
"@onekeyfe/react-native-ble-plx": "3.0.0", | ||
"@onekeyfe/hd-shared": "^1.0.7-alpha.3", | ||
"@onekeyfe/hd-transport": "^1.0.7-alpha.3", | ||
"@onekeyfe/react-native-ble-plx": "https://github.com/OneKeyHQ/react-native-ble-plx.git#feat/refreshGatt", | ||
"react-native-ble-manager": "^8.1.0" | ||
}, | ||
"gitHead": "220798f8e3b49640651e919c92403aa6d2b9b813" | ||
"gitHead": "2450f88fb75e9aeb6c5ebfc6a4ffb488bf5a60eb" | ||
} |
@@ -14,8 +14,3 @@ import { Platform, PermissionsAndroid } from 'react-native'; | ||
import type EventEmitter from 'events'; | ||
import { | ||
initializeBleManager, | ||
getConnectedDeviceIds, | ||
getBondedDevices, | ||
refreshCache, | ||
} from './BleManager'; | ||
import { initializeBleManager, getConnectedDeviceIds, getBondedDevices } from './BleManager'; | ||
import { subscribeBleOn } from './subscribeBleOn'; | ||
@@ -192,2 +187,14 @@ import { | ||
async refreshCache(deviceId: string) { | ||
try { | ||
const blePlxManager = await this.getPlxManager(); | ||
// @ts-expect-error | ||
await blePlxManager.refreshGatt(deviceId); | ||
// eslint-disable-next-line no-promise-executor-return | ||
await new Promise(resolve => setTimeout(resolve, 500)); | ||
} catch (error) { | ||
console.log('refreshCache error: ', error); | ||
} | ||
} | ||
async acquire(input: BleAcquireInput) { | ||
@@ -296,2 +303,4 @@ const { uuid, forceCleanRunPromise } = input; | ||
this.refreshCache(uuid); | ||
// check device is bonded | ||
@@ -419,3 +428,3 @@ if (Platform.OS === 'android') { | ||
} | ||
refreshCache(deviceId); | ||
this.refreshCache(deviceId); | ||
this.runPromise.reject(ERRORS.TypedError(ERROR, error.reason ?? error.message)); | ||
@@ -422,0 +431,0 @@ this.Log.debug(': monitor notify error, and has unreleased Promise'); |
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
HTTP dependency
Supply chain riskContains a dependency which resolves to a remote HTTP URL which could be used to inject untrusted code and reduce overall package reliability.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
63902
1402
1
1