@onekeyfe/hd-transport-lowlevel 1.2.0-alpha.19 → 1.2.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -358,6 +358,28 @@ describe('LowlevelTransport protocol framing', () => {
358
358
  expect(plugin.disconnect).toHaveBeenCalledWith('timeout-v2-id');
359
359
  });
360
360
 
361
+ test('preserves an undefined business timeout outside explicit probes', async () => {
362
+ const plugin = createPlugin({
363
+ devices: [{ id: 'v2-id', name: 'OneKey Pro 2', commType: 'ble' }],
364
+ responses: [],
365
+ });
366
+ const lowlevel = configureTransport(plugin);
367
+ lowlevel.deviceProtocol.set('v2-id', 'V2');
368
+ const linkCall = jest
369
+ .spyOn(lowlevel.protocolV2Links, 'call')
370
+ .mockResolvedValue({ type: 'Success', message: {} });
371
+
372
+ await lowlevel.call('v2-id', 'Ping', { message: 'no-business-timeout' });
373
+
374
+ expect(linkCall).toHaveBeenCalledWith(
375
+ 'v2-id',
376
+ expect.any(Function),
377
+ 'Ping',
378
+ { message: 'no-business-timeout' },
379
+ undefined
380
+ );
381
+ });
382
+
361
383
  test('verifies expected Protocol V1 instead of trusting the requested protocol', async () => {
362
384
  const plugin = createPlugin({
363
385
  devices: [{ id: 'v2-id', name: 'Unknown BLE Device', commType: 'ble' }],
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,SAWN,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC7B,YAAY,EACZ,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAWpD,wBAAgB,+BAA+B,CAAC,EAC9C,OAAO,EACP,iBAAiB,EACjB,GAAG,EACH,YAAY,GACb,EAAE;IACD,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AE9D,OAAO,CAAC,mBAAmB,CAAwC;IAEnE,OAAO,CAAC,oBAAoB,CAAoD;IAEhF,OAAO,CAAC,qBAAqB,CAAkC;IAE/D,OAAO,CAAC,gBAAgB,CAA0B;IAElD,OAAO,CAAC,eAAe,CA6BpB;IAEH,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIvD,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,6BAA6B;IAO9E,SAAS,CAAC,UAAU,EAAE,GAAG;IAMzB,mBAAmB,CAAC,UAAU,EAAE,GAAG;IAOnC,MAAM;IAIA,SAAS;IAWT,OAAO,CAAC,KAAK,EAAE,oBAAoB;;;;IA6BnC,OAAO,CAAC,IAAI,EAAE,MAAM;IAgBpB,IAAI,CACR,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,oBAAoB;YAsBlB,cAAc;IAmE5B,OAAO,CAAC,0BAA0B;IAOlC,OAAO,CAAC,2BAA2B;IAOnC,OAAO,CAAC,4BAA4B;IAOpC,OAAO,CAAC,kBAAkB;YAMZ,cAAc;YAsDd,yBAAyB;YAiCzB,eAAe;YAgBf,eAAe;YA6Bf,UAAU;YAUV,qBAAqB;YAmBrB,mBAAmB;YAqBnB,oBAAoB;YAOpB,cAAc;IAwB5B,OAAO,CAAC,uBAAuB;IAkC/B,OAAO,CAAC,2BAA2B;IAMnC,MAAM;CAGP"}
package/dist/index.js CHANGED
@@ -42,7 +42,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
42
42
  const { check, ProtocolV1, parseConfigure } = transport__default["default"];
43
43
  const PROTOCOL_PROBE_TIMEOUT_MS = 1000;
44
44
  const PROTOCOL_V2_PROBE_TIMEOUT_MS = 5000;
45
- const LOWLEVEL_PROTOCOL_TIMEOUT_MS = 30000;
46
45
  const LOWLEVEL_PROTOCOL_V2_PACKET_LENGTH = 64;
47
46
  const FIRMWARE_UPLOAD_LOG_PERCENT_STEP = 5;
48
47
  const FIRMWARE_UPLOAD_LOG_INTERVAL_MS = 10000;
@@ -437,14 +436,12 @@ class LowlevelTransport {
437
436
  });
438
437
  }
439
438
  callProtocolV2(uuid, name, data, options) {
440
- var _a;
441
439
  return __awaiter(this, void 0, void 0, function* () {
442
440
  if (!this._messages || !this._messagesV2) {
443
441
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportNotConfigured);
444
442
  }
445
- const timeoutMs = (_a = options === null || options === void 0 ? void 0 : options.timeoutMs) !== null && _a !== void 0 ? _a : LOWLEVEL_PROTOCOL_TIMEOUT_MS;
446
443
  try {
447
- return yield this.protocolV2Links.call(uuid, () => this.createProtocolV2Adapter(uuid), name, data, Object.assign(Object.assign({}, options), { timeoutMs }));
444
+ return yield this.protocolV2Links.call(uuid, () => this.createProtocolV2Adapter(uuid), name, data, options);
448
445
  }
449
446
  catch (e) {
450
447
  this.Log.error('lowlevel Protocol V2 call error: ', e);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-lowlevel",
3
- "version": "1.2.0-alpha.19",
3
+ "version": "1.2.0-alpha.20",
4
4
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -20,8 +20,8 @@
20
20
  "lint:fix": "eslint . --fix"
21
21
  },
22
22
  "dependencies": {
23
- "@onekeyfe/hd-shared": "1.2.0-alpha.19",
24
- "@onekeyfe/hd-transport": "1.2.0-alpha.19"
23
+ "@onekeyfe/hd-shared": "1.2.0-alpha.20",
24
+ "@onekeyfe/hd-transport": "1.2.0-alpha.20"
25
25
  },
26
- "gitHead": "4e79f6a400463f342285b9a761b6b84523f1d6b9"
26
+ "gitHead": "5fbc1ada90fd3cfda7e5ef08be368cb452018733"
27
27
  }
package/src/index.ts CHANGED
@@ -25,7 +25,6 @@ const { check, ProtocolV1, parseConfigure } = transport;
25
25
 
26
26
  const PROTOCOL_PROBE_TIMEOUT_MS = 1000;
27
27
  const PROTOCOL_V2_PROBE_TIMEOUT_MS = 5000;
28
- const LOWLEVEL_PROTOCOL_TIMEOUT_MS = 30_000;
29
28
  const LOWLEVEL_PROTOCOL_V2_PACKET_LENGTH = 64;
30
29
  const FIRMWARE_UPLOAD_LOG_PERCENT_STEP = 5;
31
30
  const FIRMWARE_UPLOAD_LOG_INTERVAL_MS = 10_000;
@@ -192,8 +191,8 @@ export default class LowlevelTransport {
192
191
  await this.plugin.disconnect(uuid);
193
192
  this.connectedDevices.delete(uuid);
194
193
  this.deviceProtocol.delete(uuid);
195
- // 设备名称推断出的协议提示不依赖当前连接,保留它可以让快速重连
196
- // 直接执行 Protocol V2 探测,避免先发送一次无意义的 V1 Initialize
194
+ // A name-derived protocol hint survives disconnect and lets fast reconnect probe
195
+ // Protocol V2 first without sending a redundant V1 Initialize.
197
196
  this.protocolV2Assemblers.delete(uuid);
198
197
  return true;
199
198
  } catch (error) {
@@ -328,9 +327,9 @@ export default class LowlevelTransport {
328
327
  protocolHint?: ProtocolType
329
328
  ): Promise<ProtocolType> {
330
329
  if (expectedProtocol === 'V2') {
331
- // 固件升级重启后的 bootloader 不保证响应 Ping。上层显式传入 V2
332
- // 表示协议已经在重启前确认,这里与 RN/Electron BLE 保持一致,
333
- // 直接建立 V2 Link,首个业务命令负责验证链路是否可用。
330
+ // Bootloader may not answer Ping after an update reboot. An explicit V2 hint means
331
+ // the protocol was already confirmed, so establish the link and let the first
332
+ // business command validate it, matching RN and Electron BLE.
334
333
  this.deviceProtocol.set(uuid, 'V2');
335
334
  this.Log?.debug(`[LowlevelTransport] detectProtocol: uuid=${uuid} -> V2 (expected)`);
336
335
  return 'V2';
@@ -521,18 +520,13 @@ export default class LowlevelTransport {
521
520
  throw ERRORS.TypedError(HardwareErrorCode.TransportNotConfigured);
522
521
  }
523
522
 
524
- const timeoutMs = options?.timeoutMs ?? LOWLEVEL_PROTOCOL_TIMEOUT_MS;
525
-
526
523
  try {
527
524
  return await this.protocolV2Links.call(
528
525
  uuid,
529
526
  () => this.createProtocolV2Adapter(uuid),
530
527
  name,
531
528
  data,
532
- {
533
- ...options,
534
- timeoutMs,
535
- }
529
+ options
536
530
  );
537
531
  } catch (e) {
538
532
  this.Log.error('lowlevel Protocol V2 call error: ', e);