Skip to content

Commit

Permalink
optimize: reset connect (#352)
Browse files Browse the repository at this point in the history
* chore: optimize reset connect

chore: test refreshGatt

* chore: chage

* fix: ios error

* chore: error white list

* chore: release version 1.0.8
  • Loading branch information
ByteZhang1024 authored Aug 5, 2024
1 parent 05380d3 commit 7457c2a
Show file tree
Hide file tree
Showing 17 changed files with 66 additions and 40 deletions.
2 changes: 1 addition & 1 deletion packages/connect-examples/electron-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "hardware-example",
"productName": "HardwareExample",
"executableName": "onekey-hardware-example",
"version": "1.0.7",
"version": "1.0.8",
"author": "OneKey",
"description": "End-to-end encrypted workspaces for teams",
"main": "dist/index.js",
Expand Down
10 changes: 5 additions & 5 deletions packages/connect-examples/expo-example/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "expo-example",
"version": "1.0.7",
"version": "1.0.8",
"scripts": {
"start": "yarn expo start --dev-client",
"android": "yarn expo run:android",
Expand All @@ -15,10 +15,10 @@
"@noble/ed25519": "^2.1.0",
"@noble/hashes": "^1.3.3",
"@noble/secp256k1": "^1.7.1",
"@onekeyfe/hd-ble-sdk": "^1.0.7",
"@onekeyfe/hd-common-connect-sdk": "^1.0.7",
"@onekeyfe/hd-core": "^1.0.7",
"@onekeyfe/hd-web-sdk": "^1.0.7",
"@onekeyfe/hd-ble-sdk": "^1.0.8",
"@onekeyfe/hd-common-connect-sdk": "^1.0.8",
"@onekeyfe/hd-core": "^1.0.8",
"@onekeyfe/hd-web-sdk": "^1.0.8",
"@onekeyfe/react-native-ble-plx": "3.0.0",
"@react-native-async-storage/async-storage": "1.21.0",
"@react-native-picker/picker": "2.6.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const CONNECT_SRC = 'https://jssdk.onekey.so/1.0.6/';
export const CONNECT_SRC = 'https://jssdk.onekey.so/1.0.8/';
// export const CONNECT_SRC = 'https://localhost:8087/';
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-core",
"version": "1.0.7",
"version": "1.0.8",
"description": "> TODO: description",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
Expand All @@ -25,8 +25,8 @@
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
},
"dependencies": {
"@onekeyfe/hd-shared": "^1.0.7",
"@onekeyfe/hd-transport": "^1.0.7",
"@onekeyfe/hd-shared": "^1.0.8",
"@onekeyfe/hd-transport": "^1.0.8",
"axios": "^0.27.2",
"bignumber.js": "^9.0.2",
"bytebuffer": "^5.0.1",
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ const ensureConnected = async (method: BaseMethod, pollingId: number) => {
HardwareErrorCode.BleAlreadyConnected,
HardwareErrorCode.FirmwareUpdateLimitOneDevice,
HardwareErrorCode.DeviceDetectInBootloaderMode,
HardwareErrorCode.BleCharacteristicNotifyChangeFailure,
].includes(error.errorCode)
) {
reject(error);
Expand Down Expand Up @@ -732,6 +733,7 @@ export default class Core extends EventEmitter {
}

case UI_REQUEST.BLUETOOTH_PERMISSION:
case UI_REQUEST.BLUETOOTH_CHARACTERISTIC_NOTIFY_CHANGE_FAILURE:
case UI_REQUEST.LOCATION_PERMISSION:
case UI_REQUEST.LOCATION_SERVICE_PERMISSION: {
postMessage(message);
Expand Down
8 changes: 4 additions & 4 deletions packages/hd-ble-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-ble-sdk",
"version": "1.0.7",
"version": "1.0.8",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "ISC",
Expand All @@ -20,8 +20,8 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@onekeyfe/hd-core": "^1.0.7",
"@onekeyfe/hd-shared": "^1.0.7",
"@onekeyfe/hd-transport-react-native": "^1.0.7"
"@onekeyfe/hd-core": "^1.0.8",
"@onekeyfe/hd-shared": "^1.0.8",
"@onekeyfe/hd-transport-react-native": "^1.0.8"
}
}
12 changes: 6 additions & 6 deletions packages/hd-common-connect-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-common-connect-sdk",
"version": "1.0.7",
"version": "1.0.8",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "ISC",
Expand All @@ -20,10 +20,10 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@onekeyfe/hd-core": "^1.0.7",
"@onekeyfe/hd-shared": "^1.0.7",
"@onekeyfe/hd-transport-http": "^1.0.7",
"@onekeyfe/hd-transport-lowlevel": "^1.0.7",
"@onekeyfe/hd-transport-webusb": "^1.0.7"
"@onekeyfe/hd-core": "^1.0.8",
"@onekeyfe/hd-shared": "^1.0.8",
"@onekeyfe/hd-transport-http": "^1.0.8",
"@onekeyfe/hd-transport-lowlevel": "^1.0.8",
"@onekeyfe/hd-transport-webusb": "^1.0.8"
}
}
6 changes: 3 additions & 3 deletions packages/hd-transport-http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-transport-http",
"version": "1.0.7",
"version": "1.0.8",
"description": "hardware http transport",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
Expand All @@ -24,8 +24,8 @@
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
},
"dependencies": {
"@onekeyfe/hd-shared": "^1.0.7",
"@onekeyfe/hd-transport": "^1.0.7",
"@onekeyfe/hd-shared": "^1.0.8",
"@onekeyfe/hd-transport": "^1.0.8",
"axios": "^0.27.2"
}
}
6 changes: 3 additions & 3 deletions packages/hd-transport-lowlevel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-transport-lowlevel",
"version": "1.0.7",
"version": "1.0.8",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -19,7 +19,7 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@onekeyfe/hd-shared": "^1.0.7",
"@onekeyfe/hd-transport": "^1.0.7"
"@onekeyfe/hd-shared": "^1.0.8",
"@onekeyfe/hd-transport": "^1.0.8"
}
}
8 changes: 4 additions & 4 deletions packages/hd-transport-react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-transport-react-native",
"version": "1.0.7",
"version": "1.0.8",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -19,9 +19,9 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@onekeyfe/hd-shared": "^1.0.7",
"@onekeyfe/hd-transport": "^1.0.7",
"@onekeyfe/react-native-ble-plx": "3.0.0",
"@onekeyfe/hd-shared": "^1.0.8",
"@onekeyfe/hd-transport": "^1.0.8",
"@onekeyfe/react-native-ble-plx": "3.0.1",
"react-native-ble-manager": "^8.1.0"
}
}
17 changes: 17 additions & 0 deletions packages/hd-transport-react-native/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const transportCache: Record<string, any> = {};
let connectOptions: Record<string, unknown> = {
requestMTU: 256,
timeout: 3000,
refreshGatt: 'OnConnected',
};

const tryToGetConfiguration = (device: Device) => {
Expand Down Expand Up @@ -405,6 +406,22 @@ export default class ReactNativeBleTransport {
if (error.reason?.includes('Encryption is insufficient')) {
ERROR = HardwareErrorCode.BleDeviceBondError;
}
if (
error.reason?.includes('Cannot write client characteristic config descriptor') ||
error.reason?.includes('Cannot find client characteristic config descriptor') ||
error.reason?.includes('The handle is invalid')
) {
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));
this.Log.debug(': monitor notify error, and has unreleased Promise');
}
Expand Down
6 changes: 3 additions & 3 deletions packages/hd-transport-webusb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-transport-webusb",
"version": "1.0.7",
"version": "1.0.8",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "MIT",
Expand All @@ -20,8 +20,8 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@onekeyfe/hd-shared": "^1.0.7",
"@onekeyfe/hd-transport": "^1.0.7"
"@onekeyfe/hd-shared": "^1.0.8",
"@onekeyfe/hd-transport": "^1.0.8"
},
"devDependencies": {
"@types/w3c-web-usb": "^1.0.6"
Expand Down
2 changes: 1 addition & 1 deletion packages/hd-transport/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-transport",
"version": "1.0.7",
"version": "1.0.8",
"description": "> TODO: description",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
Expand Down
10 changes: 5 additions & 5 deletions packages/hd-web-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-web-sdk",
"version": "1.0.7",
"version": "1.0.8",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "ISC",
Expand All @@ -21,10 +21,10 @@
},
"dependencies": {
"@onekeyfe/cross-inpage-provider-core": "^0.0.17",
"@onekeyfe/hd-core": "^1.0.7",
"@onekeyfe/hd-shared": "^1.0.7",
"@onekeyfe/hd-transport-http": "^1.0.7",
"@onekeyfe/hd-transport-webusb": "^1.0.7"
"@onekeyfe/hd-core": "^1.0.8",
"@onekeyfe/hd-shared": "^1.0.8",
"@onekeyfe/hd-transport-http": "^1.0.8",
"@onekeyfe/hd-transport-webusb": "^1.0.8"
},
"devDependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.17.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-shared",
"version": "1.0.7",
"version": "1.0.8",
"description": "Hardware SDK's shared tool library",
"keywords": [
"Hardware-SDK",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/HardwareError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ export const HardwareErrorCode = {
BleTimeoutError: 713,
BleForceCleanRunPromise: 714,
BleDeviceBondError: 715,
BleCharacteristicNotifyChangeFailure: 716,

/**
* Hardware runtiome errors
Expand Down Expand Up @@ -446,6 +447,7 @@ export const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping = {
[HardwareErrorCode.BleTimeoutError]: 'The connection has timed out unexpectedly.',
[HardwareErrorCode.BleForceCleanRunPromise]: 'Force clean Bluetooth run promise',
[HardwareErrorCode.BleDeviceBondError]: 'Bluetooth pairing failed',
[HardwareErrorCode.BleCharacteristicNotifyChangeFailure]: 'Characteristic Notify Change Failure',

/**
* Runtime Error
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3410,6 +3410,11 @@
resolved "https://registry.yarnpkg.com/@onekeyfe/react-native-ble-plx/-/react-native-ble-plx-3.0.0.tgz#508f40eb8d0b0ee3b81f3a2ec5ff7f23a9d6f24b"
integrity sha512-YckXy6XiOcd6a/J7HMcXi+GFDhtBTpN+12FfukJNINwJQxYxWpo1RHgzaa5Rxpx6LQ/f8yC/YEQC48HqZq4b7A==

"@onekeyfe/react-native-ble-plx@3.0.1":
version "3.0.1"
resolved "https://registry.yarnpkg.com/@onekeyfe/react-native-ble-plx/-/react-native-ble-plx-3.0.1.tgz#81d01414abf9e6ed242619f38dd69b04feafc6d9"
integrity sha512-kMNKh9iyuTVCnd9rYBUSq/urrzS/1gcwEhxOtor3hKl9TaFAre8qMq0mGv/VedgtePYNSY4H32hOFSQmWM6fSw==

"@pkgjs/parseargs@^0.11.0":
version "0.11.0"
resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"
Expand Down

0 comments on commit 7457c2a

Please sign in to comment.