@onekeyfe/hd-transport-react-native
Advanced tools
Comparing version 1.0.7-alpha.3 to 1.0.7-alpha.4
@@ -30,7 +30,6 @@ import * as transport from '@onekeyfe/hd-transport'; | ||
enumerate(): Promise<Device[]>; | ||
refreshCache(deviceId: string): Promise<void>; | ||
acquire(input: BleAcquireInput): Promise<{ | ||
uuid: string; | ||
}>; | ||
_monitorCharacteristic(characteristic: Characteristic, deviceId: string): () => void; | ||
_monitorCharacteristic(characteristic: Characteristic): () => void; | ||
release(uuid: string): Promise<boolean>; | ||
@@ -37,0 +36,0 @@ call(uuid: string, name: string, data: Record<string, unknown>): Promise<transport.MessageFromOneKey | undefined>; |
@@ -177,2 +177,3 @@ 'use strict'; | ||
timeout: 3000, | ||
refreshGatt: 'OnConnected', | ||
}; | ||
@@ -291,14 +292,2 @@ const tryToGetConfiguration = (device) => { | ||
} | ||
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) { | ||
@@ -391,3 +380,2 @@ var _a, _b, _c; | ||
} | ||
this.refreshCache(uuid); | ||
if (reactNative.Platform.OS === 'android') { | ||
@@ -455,3 +443,3 @@ const bondedDevices = yield getBondedDevices(); | ||
const transport = new BleTransport(device, writeCharacteristic, notifyCharacteristic); | ||
transport.nofitySubscription = this._monitorCharacteristic(transport.notifyCharacteristic, device.id); | ||
transport.nofitySubscription = this._monitorCharacteristic(transport.notifyCharacteristic); | ||
transportCache[uuid] = transport; | ||
@@ -477,7 +465,7 @@ (_c = this.emitter) === null || _c === void 0 ? void 0 : _c.emit('device-connect', { | ||
} | ||
_monitorCharacteristic(characteristic, deviceId) { | ||
_monitorCharacteristic(characteristic) { | ||
let bufferLength = 0; | ||
let buffer$1 = []; | ||
const subscription = characteristic.monitor((error, c) => { | ||
var _a, _b, _c, _d, _e; | ||
var _a, _b, _c, _d, _e, _f, _g, _h; | ||
if (error) { | ||
@@ -493,4 +481,9 @@ this.Log.debug(`error monitor ${characteristic.uuid}, deviceId: ${characteristic.deviceID}: ${error}`); | ||
} | ||
this.refreshCache(deviceId); | ||
this.runPromise.reject(hdShared.ERRORS.TypedError(ERROR, (_c = error.reason) !== null && _c !== void 0 ? _c : error.message)); | ||
if (((_c = error.reason) === null || _c === void 0 ? void 0 : _c.includes('Cannot write client characteristic config descriptor')) || | ||
((_d = error.reason) === null || _d === void 0 ? void 0 : _d.includes('Cannot find client characteristic config descriptor'))) { | ||
this.runPromise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleCharacteristicNotifyChangeFailure, (_e = error.message) !== null && _e !== void 0 ? _e : error.reason)); | ||
this.Log.debug(`${hdShared.HardwareErrorCode.BleCharacteristicNotifyChangeFailure} ${error.message} ${error.reason}`); | ||
return; | ||
} | ||
this.runPromise.reject(hdShared.ERRORS.TypedError(ERROR, (_f = error.reason) !== null && _f !== void 0 ? _f : error.message)); | ||
this.Log.debug(': monitor notify error, and has unreleased Promise'); | ||
@@ -516,3 +509,3 @@ } | ||
buffer$1 = []; | ||
(_d = this.runPromise) === null || _d === void 0 ? void 0 : _d.resolve(value.toString('hex')); | ||
(_g = this.runPromise) === null || _g === void 0 ? void 0 : _g.resolve(value.toString('hex')); | ||
} | ||
@@ -522,3 +515,3 @@ } | ||
this.Log.debug('monitor data error: ', error); | ||
(_e = this.runPromise) === null || _e === void 0 ? void 0 : _e.reject(error); | ||
(_h = this.runPromise) === null || _h === void 0 ? void 0 : _h.reject(error); | ||
} | ||
@@ -525,0 +518,0 @@ }); |
{ | ||
"name": "@onekeyfe/hd-transport-react-native", | ||
"version": "1.0.7-alpha.3", | ||
"version": "1.0.7-alpha.4", | ||
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme", | ||
@@ -22,8 +22,8 @@ "license": "MIT", | ||
"dependencies": { | ||
"@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", | ||
"@onekeyfe/hd-shared": "^1.0.7-alpha.4", | ||
"@onekeyfe/hd-transport": "^1.0.7-alpha.4", | ||
"@onekeyfe/react-native-ble-plx": "3.0.1", | ||
"react-native-ble-manager": "^8.1.0" | ||
}, | ||
"gitHead": "2450f88fb75e9aeb6c5ebfc6a4ffb488bf5a60eb" | ||
"gitHead": "003e08dbef65862a4f747eaf4572d48a03c53c41" | ||
} |
@@ -35,2 +35,3 @@ import { Platform, PermissionsAndroid } from 'react-native'; | ||
timeout: 3000, | ||
refreshGatt: 'OnConnected', | ||
}; | ||
@@ -187,14 +188,2 @@ | ||
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) { | ||
@@ -303,4 +292,2 @@ const { uuid, forceCleanRunPromise } = input; | ||
this.refreshCache(uuid); | ||
// check device is bonded | ||
@@ -380,6 +367,3 @@ if (Platform.OS === 'android') { | ||
const transport = new BleTransport(device, writeCharacteristic, notifyCharacteristic); | ||
transport.nofitySubscription = this._monitorCharacteristic( | ||
transport.notifyCharacteristic, | ||
device.id | ||
); | ||
transport.nofitySubscription = this._monitorCharacteristic(transport.notifyCharacteristic); | ||
transportCache[uuid] = transport; | ||
@@ -407,3 +391,3 @@ | ||
_monitorCharacteristic(characteristic: Characteristic, deviceId: string) { | ||
_monitorCharacteristic(characteristic: Characteristic) { | ||
let bufferLength = 0; | ||
@@ -430,3 +414,17 @@ let buffer: any[] = []; | ||
} | ||
this.refreshCache(deviceId); | ||
if ( | ||
error.reason?.includes('Cannot write client characteristic config descriptor') || | ||
error.reason?.includes('Cannot find client characteristic config descriptor') | ||
) { | ||
this.runPromise.reject( | ||
ERRORS.TypedError( | ||
HardwareErrorCode.BleCharacteristicNotifyChangeFailure, | ||
error.message ?? error.reason | ||
) | ||
); | ||
this.Log.debug( | ||
`${HardwareErrorCode.BleCharacteristicNotifyChangeFailure} ${error.message} ${error.reason}` | ||
); | ||
return; | ||
} | ||
this.runPromise.reject(ERRORS.TypedError(ERROR, error.reason ?? error.message)); | ||
@@ -433,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
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
64073
0
0
1394
+ Added@onekeyfe/react-native-ble-plx@3.0.1(transitive)