Skip to content

Commit 1386e80

Browse files
author
wabiwabo
committed
fix: use protobuf message & add onekeyfe/hd-transport-electron
1 parent 9a99b92 commit 1386e80

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

packages/connect-examples/electron-example/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"electron-log": "^5.1.5",
2727
"electron-updater": "^6.2.1",
2828
"fs-extra": "^11.2.0",
29-
"node-fetch": "^2.6.7"
29+
"node-fetch": "^2.6.7",
30+
"@onekeyfe/hd-transport-electron": "1.1.10-alpha.4"
3031
},
3132
"devDependencies": {
3233
"@types/webpack": "^5.28.5",

packages/hd-transport-electron/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
"electron-log": ">=4.0.0"
2626
},
2727
"dependencies": {
28+
"@onekeyfe/hd-core": "1.1.10-alpha.4",
29+
"@onekeyfe/hd-transport": "1.1.10-alpha.4",
2830
"@onekeyfe/hd-shared": "1.1.10-alpha.4",
2931
"@stoprocent/noble": "2.3.4"
3032
},

packages/hd-transport-electron/src/noble-ble-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const BLUETOOTH_INIT_TIMEOUT = 10000; // 10 seconds for Bluetooth initialization
9494
const DEVICE_SCAN_TIMEOUT = 5000; // 5 seconds for device scanning
9595
const FAST_SCAN_TIMEOUT = 1500; // 1.5 seconds for fast targeted scanning
9696
const DEVICE_CHECK_INTERVAL = 500; // 500ms interval for periodic device checks
97-
const CONNECTION_TIMEOUT = 15000; // 15 seconds for device connection
97+
const CONNECTION_TIMEOUT = 3000; // 3 seconds for device connection
9898
const CHUNK_WRITE_DELAY = 10; // 10ms delay between chunk writes
9999

100100
// BLE packet size constants

packages/hd-transport-electron/src/utils/blePairing.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*/
55

66
import type { Characteristic } from '@stoprocent/noble';
7+
import { DataManager } from '@onekeyfe/hd-core';
8+
import { parseConfigure, buildOne } from '@onekeyfe/hd-transport';
79
import type { Logger } from '../types/noble-extended';
810

911
export interface Step3Options {
@@ -12,8 +14,13 @@ export interface Step3Options {
1214
initDataHex?: string; // hex string to write; default OneKey init
1315
}
1416

15-
const DEFAULT_INIT_DATA =
16-
'3f232300000000000882f4030088f403010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';
17+
// Get protobuf definitions
18+
const messages = DataManager.getProtobufMessages();
19+
const messagesRoot = parseConfigure(messages as any);
20+
21+
// Dynamically build the Initialize message
22+
const initializeMessageBuffer = buildOne(messagesRoot, 'Initialize', {});
23+
const DEFAULT_INIT_DATA = initializeMessageBuffer.toString('hex');
1724

1825
export async function runPairingProbe(
1926
logger: Logger | null,

packages/hd-transport/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
export * from './serialization/send';
2+
export * from './serialization/protobuf';
3+
14
import * as protobuf from 'protobufjs/light';
25
import * as Long from 'long';
36
import {

0 commit comments

Comments
 (0)