Skip to content

Commit

Permalink
chore: change react native ble plx
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteZhang1024 committed Sep 13, 2024
1 parent 5d8e461 commit 7e35d10
Show file tree
Hide file tree
Showing 10 changed files with 1,168 additions and 54 deletions.
16 changes: 8 additions & 8 deletions packages/connect-examples/expo-example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ function UpdateTip() {
// Main App
export default function App() {
return (
<TamaguiProviderWrapperMemo>
<SafeAreaProvider>
<SDKProvider>
<AppIntlProvider>
<AppIntlProvider>
<TamaguiProviderWrapperMemo>
<SafeAreaProvider>
<SDKProvider>
<UpdateTip />
<NavigationContentMemo />
</AppIntlProvider>
</SDKProvider>
</SafeAreaProvider>
</TamaguiProviderWrapperMemo>
</SDKProvider>
</SafeAreaProvider>
</TamaguiProviderWrapperMemo>
</AppIntlProvider>
);
}
1 change: 1 addition & 0 deletions packages/connect-examples/expo-example/locale/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"label__image_res_type": "Resource type",
"label__res_file_suffix": "File Suffix",
"label__res_type_wall_paper": "WallPaper",
"label__res_file_name": "File Name (wp|nft-{filename}-{random})",
"label__res_type_nft": "NFT",
"label__nft_data": "NFT Data",
"label__nft_url": "NFT URL",
Expand Down
3 changes: 2 additions & 1 deletion packages/connect-examples/expo-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@onekeyfe/hd-common-connect-sdk": "^1.0.10",
"@onekeyfe/hd-core": "^1.0.10",
"@onekeyfe/hd-web-sdk": "^1.0.10",
"@onekeyfe/react-native-ble-plx": "3.0.0",
"react-native-ble-plx": "3.2.1",
"@react-native-async-storage/async-storage": "1.21.0",
"@react-native-picker/picker": "2.6.1",
"@react-navigation/bottom-tabs": "^6.5.12",
Expand Down Expand Up @@ -49,6 +49,7 @@
"expo-localization": "~14.8.4",
"expo-splash-screen": "~0.26.5",
"expo-status-bar": "~1.11.1",
"metro": "0.80.12",
"jotai": "^2.6.4",
"levelup": "^5.1.1",
"lodash": "^4.17.21",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ export default function HandleSDKEvents() {
if (message.type === UI_REQUEST.REQUEST_PIN) {
if (supportInputPinOnSoftware(message.payload.device.features).support) {
setShowPinInput(true);
} else {
onInputPinOnDeviceCallback();
}
}
if (message.type === UI_REQUEST.REQUEST_PASSPHRASE) {
Expand Down Expand Up @@ -111,7 +109,7 @@ export default function HandleSDKEvents() {
SDK.off(UI_EVENT, uiEventCallback);
registerListener = false;
};
}, [HardwareLowLevelSDK, SDK, onInputPinOnDeviceCallback])
}, [HardwareLowLevelSDK, SDK])
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,11 @@ export const HardwareInputPinDialogProvider: React.FC<{ children: ReactNode }> =
});
}, [dialogState.sdk]);

const openDialog = useCallback(
(sdk: any, features: Features) => {
if (supportInputPinOnSoftware(features).support) {
setDialogState({ isOpen: true, sdk });
} else {
onInputPinOnDeviceCallback();
}
},
[onInputPinOnDeviceCallback]
);
const openDialog = useCallback((sdk: any, features: Features) => {
if (supportInputPinOnSoftware(features).support) {
setDialogState({ isOpen: true, sdk });
}
}, []);

const closeDialog = useCallback(() => {
setDialogState(prevState => ({ ...prevState, isOpen: false, sdk: undefined }));
Expand Down
2 changes: 1 addition & 1 deletion packages/hd-transport-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dependencies": {
"@onekeyfe/hd-shared": "^1.0.10",
"@onekeyfe/hd-transport": "^1.0.10",
"@onekeyfe/react-native-ble-plx": "3.0.1",
"react-native-ble-plx": "3.2.1",
"react-native-ble-manager": "^8.1.0"
}
}
2 changes: 1 addition & 1 deletion packages/hd-transport-react-native/src/BleTransport.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Device, Characteristic } from '@onekeyfe/react-native-ble-plx';
import { Device, Characteristic } from 'react-native-ble-plx';

export default class BleTransport {
id: string;
Expand Down
7 changes: 4 additions & 3 deletions packages/hd-transport-react-native/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
BleErrorCode,
Characteristic,
ScanMode,
} from '@onekeyfe/react-native-ble-plx';
} from 'react-native-ble-plx';
import ByteBuffer from 'bytebuffer';
import transport, { COMMON_HEADER_SIZE, LogBlockCommand } from '@onekeyfe/hd-transport';
import { createDeferred, Deferred, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
Expand All @@ -30,8 +30,9 @@ const { check, buildBuffers, receiveOne, parseConfigure } = transport;
const transportCache: Record<string, any> = {};

let connectOptions: Record<string, unknown> = {
autoConnect: false,
requestMTU: 256,
timeout: 3000,
// timeout: 60 * 1000,
refreshGatt: 'OnConnected',
};

Expand Down Expand Up @@ -541,7 +542,7 @@ export default class ReactNativeBleTransport {
for (const o of buffers) {
const outData = o.toString('base64');
// Upload resources on low-end phones may OOM
// this.Log.debug('send hex strting: ', o.toString('hex'));
this.Log.debug('send hex strting: ', o.toString('hex'));
try {
await transport.writeCharacteristic.writeWithoutResponse(outData);
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion packages/hd-transport-react-native/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type { BleManager as BlePlxManager } from '@onekeyfe/react-native-ble-plx';
export type { BleManager as BlePlxManager } from 'react-native-ble-plx';

export type TransportOptions = {
scanTimeout?: number;
Expand Down
Loading

0 comments on commit 7e35d10

Please sign in to comment.