@onekeyfe/hd-transport-react-native 1.2.8-alpha.121 → 1.2.8-alpha.122

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.
package/dist/index.d.ts CHANGED
@@ -67,12 +67,24 @@ declare const BLE_WRITE_TIMEOUT_MANAGER_RESET_THRESHOLD = 2;
67
67
  type ProtocolV2BleTuning = {
68
68
  iosPacketLength?: number;
69
69
  androidPacketLength?: number;
70
+ /**
71
+ * Write each multi-packet high-throughput frame with one native call when the native
72
+ * BLE module supports it. Defaults to true; false keeps the per-packet JS write loop.
73
+ */
74
+ nativeFrameWrite?: boolean;
75
+ /**
76
+ * Android CONNECTION_PRIORITY_HIGH around Protocol V2 high-throughput calls. 'auto' (the
77
+ * default) requests it below Android 17 only; true or false forces it on every version.
78
+ */
79
+ androidHighConnectionPriority?: boolean | 'auto';
70
80
  };
71
81
  declare function configureProtocolV2BleTuning(tuning?: ProtocolV2BleTuning): void;
72
82
  declare function resetProtocolV2BleTuning(): void;
73
83
  declare function getProtocolV2BleTuning(): {
74
84
  iosPacketLength: number;
75
85
  androidPacketLength: number;
86
+ nativeFrameWrite: boolean;
87
+ androidHighConnectionPriority: boolean | "auto";
76
88
  };
77
89
  /**
78
90
  * With no cached GATT table the stack runs its own discovery (up to ~8s) before the MTU
@@ -158,6 +170,10 @@ declare class ReactNativeBleTransport {
158
170
  private protocolV2HighVolumeLogSignatures;
159
171
  private androidHighPriorityDevices;
160
172
  private androidPriorityResetTimers;
173
+ /** In-flight native frame write per device; Protocol V2 writes are serialized per device. */
174
+ private protocolV2FrameWrites;
175
+ private protocolV2FrameWriteCounter;
176
+ private protocolV2FileWritePerfs;
161
177
  private nextMonitorToken;
162
178
  /** Serializes transport lifecycle changes for the same physical device. */
163
179
  private lifecycleOperations;
@@ -259,6 +275,25 @@ declare class ReactNativeBleTransport {
259
275
  private readProtocolV2Frame;
260
276
  private writeProtocolV2Packet;
261
277
  private writeProtocolV2Frame;
278
+ /**
279
+ * The native frame write only replaces the per-packet loop where its JS<->native round trips
280
+ * dominate: multi-packet (checked by the caller) high-throughput frames written without response.
281
+ */
282
+ private resolveProtocolV2NativeFrameWriter;
283
+ /**
284
+ * Writes one frame with a single native call that sends its packets in order without response.
285
+ * Nothing here retries it: a resend could duplicate bytes the device already received. The
286
+ * native transaction is cancelled on abort, watchdog expiry and link teardown so the native
287
+ * side stops writing a frame nobody waits for any more; a generation change detected after
288
+ * the frame completes still fails the write.
289
+ */
290
+ private writeProtocolV2NativeFrame;
291
+ /** Stops the native frame write in flight on `uuid`, optionally only one of `generation`. */
292
+ private cancelProtocolV2FrameWrite;
293
+ private cancelNativeTransaction;
294
+ private getProtocolV2FileWritePerf;
295
+ /** Returns true the first time `signature` is seen for `uuid` on this link. */
296
+ private markProtocolV2LogSignature;
262
297
  private callProtocolV2;
263
298
  private ensureProtocolV2HighThroughputMtu;
264
299
  private clearAndroidPriorityResetTimer;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAGL,UAAU,IAAI,aAAa,EAG5B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAS,EAAE,EAChB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAI3B,KAAK,YAAY,EAKjB,KAAK,oBAAoB,EAI1B,MAAM,wBAAwB,CAAC;AA4BhC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAI1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEjE,KAAK,8BAA8B,GAAG,eAAe,GAAG;IAMtD,iBAAiB,CAAC,EAAE,OAA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AC,OAAO,EAAE,MAAM;YAIlB,kBAAkB;YAwFlB,iBAAiB;IAkC/B,OAAO,CAAC,4BAA4B;YAQtB,qBAAqB;IAoB7B,MAAM;YAoBE,mBAAmB;YA4DnB,eAAe;YA6Bf,kBAAkB;YAkDlB,iCAAiC;IA8D/C,OAAO,CAAC,wBAAwB;IAwChC,OAAO,CAAC,yBAAyB;IAMjC,OAAO,CAAC,kBAAkB;YAcZ,cAAc;IAyC5B,OAAO,CAAC,kBAAkB;IA8B1B,OAAO,CAAC,eAAe;IAkEvB,OAAO,CAAC,2BAA2B;IAQnC,OAAO,CAAC,4BAA4B;IAIpC,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,iBAAiB;YAIX,cAAc;YA+Gd,0BAA0B;YAsB1B,iCAAiC;YAoDjC,eAAe;YAsBf,eAAe;IA2B7B,OAAO,CAAC,4BAA4B;IA2BpC,OAAO,CAAC,uBAAuB;IAS/B,OAAO,CAAC,sBAAsB;IAU9B,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,sBAAsB;YAShB,mBAAmB;YAiBnB,qBAAqB;YA8DrB,oBAAoB;IA2DlC,OAAO,CAAC,kCAAkC;YA2B5B,0BAA0B;IA+FxC,OAAO,CAAC,0BAA0B;IAMlC,OAAO,CAAC,uBAAuB;IAY/B,OAAO,CAAC,0BAA0B;IAOlC,OAAO,CAAC,0BAA0B;YAQpB,cAAc;YAmHd,iCAAiC;IAsB/C,OAAO,CAAC,8BAA8B;YAQxB,mCAAmC;IA+BjD,OAAO,CAAC,yCAAyC;YAanC,gCAAgC;IAoB9C,OAAO,CAAC,uBAAuB;IAwD/B,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;CAGxD"}
package/dist/index.js CHANGED
@@ -383,6 +383,7 @@ const WEDGED_WRITE_MESSAGE = 'BLE write timeout after';
383
383
  const isWedgedWriteError = (error) => (error === null || error === void 0 ? void 0 : error.errorCode) === hdShared.HardwareErrorCode.BleWriteCharacteristicError &&
384
384
  typeof (error === null || error === void 0 ? void 0 : error.message) === 'string' &&
385
385
  error.message.startsWith(WEDGED_WRITE_MESSAGE);
386
+ const createWedgedWriteError = () => hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleWriteCharacteristicError, `${WEDGED_WRITE_MESSAGE} ${BLE_WRITE_PACKET_TIMEOUT_MS}ms`);
386
387
  const shouldRethrowProtocolProbeError = (error) => {
387
388
  const code = error === null || error === void 0 ? void 0 : error.errorCode;
388
389
  return (isNativeBleDisconnectError(error) ||
@@ -400,6 +401,8 @@ const ANDROID_NOTIFY_READY_DELAY_MS = 300;
400
401
  const DEFAULT_PROTOCOL_V2_BLE_TUNING = {
401
402
  iosPacketLength: IOS_PROTOCOL_V2_PACKET_LENGTH,
402
403
  androidPacketLength: ANDROID_PROTOCOL_V2_PACKET_LENGTH,
404
+ nativeFrameWrite: true,
405
+ androidHighConnectionPriority: 'auto',
403
406
  };
404
407
  let protocolV2BleTuning = Object.assign({}, DEFAULT_PROTOCOL_V2_BLE_TUNING);
405
408
  const normalizePositiveInteger = (value, fallback) => {
@@ -412,6 +415,13 @@ function configureProtocolV2BleTuning(tuning = {}) {
412
415
  protocolV2BleTuning = {
413
416
  iosPacketLength: normalizePositiveInteger(tuning.iosPacketLength, protocolV2BleTuning.iosPacketLength),
414
417
  androidPacketLength: normalizePositiveInteger(tuning.androidPacketLength, protocolV2BleTuning.androidPacketLength),
418
+ nativeFrameWrite: typeof tuning.nativeFrameWrite === 'boolean'
419
+ ? tuning.nativeFrameWrite
420
+ : protocolV2BleTuning.nativeFrameWrite,
421
+ androidHighConnectionPriority: typeof tuning.androidHighConnectionPriority === 'boolean' ||
422
+ tuning.androidHighConnectionPriority === 'auto'
423
+ ? tuning.androidHighConnectionPriority
424
+ : protocolV2BleTuning.androidHighConnectionPriority,
415
425
  };
416
426
  Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] BLE tuning configured', protocolV2BleTuning);
417
427
  }
@@ -422,6 +432,91 @@ function resetProtocolV2BleTuning() {
422
432
  function getProtocolV2BleTuning() {
423
433
  return Object.assign({}, protocolV2BleTuning);
424
434
  }
435
+ const getProtocolV2NativeFrameWriter = (manager) => {
436
+ var _a;
437
+ const candidate = manager;
438
+ if (!candidate || typeof candidate.writeCharacteristicWithoutResponseFrame !== 'function') {
439
+ return undefined;
440
+ }
441
+ try {
442
+ return ((_a = candidate.isWriteCharacteristicWithoutResponseFrameSupported) === null || _a === void 0 ? void 0 : _a.call(candidate)) === true
443
+ ? candidate
444
+ : undefined;
445
+ }
446
+ catch (_b) {
447
+ return undefined;
448
+ }
449
+ };
450
+ const getNativeBleErrorReason = (error) => {
451
+ const { reason, message } = (error !== null && error !== void 0 ? error : {});
452
+ if (typeof reason === 'string' && reason)
453
+ return reason;
454
+ return typeof message === 'string' && message ? message : undefined;
455
+ };
456
+ const nowMs = () => typeof performance !== 'undefined' && typeof performance.now === 'function'
457
+ ? performance.now()
458
+ : Date.now();
459
+ const roundMs = (ms) => Math.round(ms * 10) / 10;
460
+ const FILE_WRITE_PACKET_HISTOGRAM_BOUNDS_MS = [1, 2, 3, 5, 8];
461
+ const createDurationStats = () => {
462
+ let total = 0;
463
+ let count = 0;
464
+ let max = 0;
465
+ return {
466
+ add(ms) {
467
+ total += ms;
468
+ count += 1;
469
+ max = Math.max(max, ms);
470
+ },
471
+ summarize: () => ({
472
+ total: roundMs(total),
473
+ avg: count ? roundMs(total / count) : 0,
474
+ max: roundMs(max),
475
+ }),
476
+ };
477
+ };
478
+ const createProtocolV2FileWritePerf = () => {
479
+ const startedAt = nowMs();
480
+ let nativeFrames = 0;
481
+ let frames = 0;
482
+ let packets = 0;
483
+ let frameBytes = 0;
484
+ const write = createDurationStats();
485
+ const readWait = createDurationStats();
486
+ const packet = createDurationStats();
487
+ const packetHistogram = Array.from({ length: FILE_WRITE_PACKET_HISTOGRAM_BOUNDS_MS.length + 1 }, () => 0);
488
+ return {
489
+ startFrame(mode) {
490
+ if (mode === 'native-frame')
491
+ nativeFrames += 1;
492
+ },
493
+ recordFrame(bytes, framePackets, elapsedMs) {
494
+ frames += 1;
495
+ packets += framePackets;
496
+ frameBytes += bytes;
497
+ write.add(elapsedMs);
498
+ },
499
+ recordPacket(elapsedMs) {
500
+ packet.add(elapsedMs);
501
+ const bucket = FILE_WRITE_PACKET_HISTOGRAM_BOUNDS_MS.findIndex(bound => elapsedMs < bound);
502
+ packetHistogram[bucket < 0 ? packetHistogram.length - 1 : bucket] += 1;
503
+ },
504
+ recordReadWait(elapsedMs) {
505
+ readWait.add(elapsedMs);
506
+ },
507
+ summarize(ok) {
508
+ const mode = nativeFrames > 0 ? 'native-frame' : 'per-packet';
509
+ const packetStats = packet.summarize();
510
+ return Object.assign({ platform: reactNative.Platform.OS, mode,
511
+ ok,
512
+ frames,
513
+ packets,
514
+ frameBytes, elapsedMs: roundMs(nowMs() - startedAt), writeMs: write.summarize(), readWaitMs: readWait.summarize() }, (mode === 'per-packet'
515
+ ? { packetMs: { avg: packetStats.avg, max: packetStats.max, hist: [...packetHistogram] } }
516
+ : {}));
517
+ },
518
+ };
519
+ };
425
520
  function getDeviceDisplayName(device) {
426
521
  return (device === null || device === void 0 ? void 0 : device.name) || (device === null || device === void 0 ? void 0 : device.localName) || null;
427
522
  }
@@ -449,6 +544,16 @@ function withBleColorCode(device) {
449
544
  const IOS_REQUEST_MTU = 247;
450
545
  const ANDROID_REQUEST_MTU = 517;
451
546
  const ANDROID_HIGH_PRIORITY_IDLE_MS = 1000;
547
+ const ANDROID_HIGH_PRIORITY_PERIPHERAL_LATENCY_API_LEVEL = 37;
548
+ const shouldRequestAndroidHighConnectionPriority = () => {
549
+ if (reactNative.Platform.OS !== 'android')
550
+ return false;
551
+ const { androidHighConnectionPriority } = protocolV2BleTuning;
552
+ if (typeof androidHighConnectionPriority === 'boolean')
553
+ return androidHighConnectionPriority;
554
+ const apiLevel = Number(reactNative.Platform.Version);
555
+ return (!Number.isFinite(apiLevel) || apiLevel < ANDROID_HIGH_PRIORITY_PERIPHERAL_LATENCY_API_LEVEL);
556
+ };
452
557
  const getRequestedBleMtu = () => reactNative.Platform.OS === 'android' ? ANDROID_REQUEST_MTU : IOS_REQUEST_MTU;
453
558
  const BLE_NATIVE_CONNECT_TIMEOUT_MS = 3000;
454
559
  const BLE_MTU_REQUEST_TIMEOUT_MS = BLE_NATIVE_CONNECT_TIMEOUT_MS;
@@ -641,6 +746,9 @@ class ReactNativeBleTransport {
641
746
  this.protocolV2HighVolumeLogSignatures = new Map();
642
747
  this.androidHighPriorityDevices = new Set();
643
748
  this.androidPriorityResetTimers = new Map();
749
+ this.protocolV2FrameWrites = new Map();
750
+ this.protocolV2FrameWriteCounter = 0;
751
+ this.protocolV2FileWritePerfs = new Map();
644
752
  this.nextMonitorToken = 1;
645
753
  this.lifecycleOperations = new Map();
646
754
  this.scanCleanups = new Set();
@@ -1442,13 +1550,16 @@ class ReactNativeBleTransport {
1442
1550
  }
1443
1551
  releaseUnlocked(uuid, onclose = false) {
1444
1552
  return __awaiter(this, void 0, void 0, function* () {
1445
- yield this.protocolV2Links.invalidateLink(uuid, 'React Native BLE transport released');
1553
+ const reason = 'React Native BLE transport released';
1554
+ this.cancelProtocolV2FrameWrite(uuid, new Error(reason));
1555
+ yield this.protocolV2Links.invalidateLink(uuid, reason);
1446
1556
  return this.releaseNative(uuid, onclose);
1447
1557
  });
1448
1558
  }
1449
1559
  releaseNative(uuid, onclose = false) {
1450
1560
  var _a, _b, _c, _d, _e;
1451
1561
  return __awaiter(this, void 0, void 0, function* () {
1562
+ this.cancelProtocolV2FrameWrite(uuid, new Error('React Native BLE transport released'));
1452
1563
  const transport = transportCache[uuid];
1453
1564
  const manager = this.blePlxManager;
1454
1565
  if (this.runPromise && this.runPromiseDeviceId === uuid) {
@@ -1775,7 +1886,11 @@ class ReactNativeBleTransport {
1775
1886
  disconnectUnlocked(session) {
1776
1887
  var _a, _b, _c;
1777
1888
  return __awaiter(this, void 0, void 0, function* () {
1778
- yield this.protocolV2Links.invalidateLink(session, 'React Native BLE transport disconnected');
1889
+ this.clearAndroidPriorityResetTimer(session);
1890
+ this.androidHighPriorityDevices.delete(session);
1891
+ const reason = 'React Native BLE transport disconnected';
1892
+ this.cancelProtocolV2FrameWrite(session, new Error(reason));
1893
+ yield this.protocolV2Links.invalidateLink(session, reason);
1779
1894
  const transport = transportCache[session];
1780
1895
  const manager = this.blePlxManager;
1781
1896
  const monitorToken = (_a = transport === null || transport === void 0 ? void 0 : transport.monitorToken) !== null && _a !== void 0 ? _a : this.monitorTokens.get(session);
@@ -2114,7 +2229,7 @@ class ReactNativeBleTransport {
2114
2229
  new Promise((_, reject) => {
2115
2230
  timer = setTimeout(() => {
2116
2231
  timedOut = true;
2117
- reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleWriteCharacteristicError, `BLE write timeout after ${BLE_WRITE_PACKET_TIMEOUT_MS}ms`));
2232
+ reject(createWedgedWriteError());
2118
2233
  }, BLE_WRITE_PACKET_TIMEOUT_MS);
2119
2234
  }),
2120
2235
  ]);
@@ -2144,6 +2259,7 @@ class ReactNativeBleTransport {
2144
2259
  Log === null || Log === void 0 ? void 0 : Log.error('[ReactNativeBleTransport] BLE write timed out, tearing down link:', uuid, {
2145
2260
  consecutiveWriteTimeouts: timeouts,
2146
2261
  });
2262
+ this.cancelProtocolV2FrameWrite(uuid, createWedgedWriteError());
2147
2263
  const wedged = transportCache[uuid];
2148
2264
  this.disconnect(uuid).catch(error => {
2149
2265
  Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] wedged link teardown failed (ignored):', error);
@@ -2167,6 +2283,7 @@ class ReactNativeBleTransport {
2167
2283
  const manager = this.blePlxManager;
2168
2284
  this.blePlxManager = undefined;
2169
2285
  const reason = 'React Native BLE manager reset';
2286
+ this.protocolV2FrameWrites.forEach(active => active.cancel(new Error(reason)));
2170
2287
  Object.entries(transportCache).forEach(([uuid, cachedTransport]) => {
2171
2288
  var _a, _b, _c, _d;
2172
2289
  try {
@@ -2556,19 +2673,162 @@ class ReactNativeBleTransport {
2556
2673
  androidPacketLength: tuning.androidPacketLength,
2557
2674
  mtu: transport$1.mtuSize,
2558
2675
  });
2559
- yield transport.writeProtocolV2BleFrame({
2560
- frame,
2561
- packetCapacity,
2562
- assertActive: assertCurrentGeneration,
2563
- signal: context.signal,
2564
- abortMessage: `Protocol V2 BLE write aborted for ${context.messageName}`,
2565
- wait: delay,
2566
- writePacket: packet => this.writeProtocolV2Packet(uuid, transport$1, buffer.Buffer.from(packet).toString('base64'), context, assertCurrentGeneration),
2676
+ const perf = this.getProtocolV2FileWritePerf(uuid, context);
2677
+ const startedAt = perf ? nowMs() : 0;
2678
+ const nativeFrameWriter = frame.length > packetCapacity
2679
+ ? this.resolveProtocolV2NativeFrameWriter(transport$1, context, tuning.nativeFrameWrite)
2680
+ : undefined;
2681
+ perf === null || perf === void 0 ? void 0 : perf.startFrame(nativeFrameWriter ? 'native-frame' : 'per-packet');
2682
+ if (nativeFrameWriter) {
2683
+ yield this.writeProtocolV2NativeFrame(uuid, transport$1, nativeFrameWriter, frame, packetCapacity, context, assertCurrentGeneration);
2684
+ }
2685
+ else {
2686
+ yield transport.writeProtocolV2BleFrame({
2687
+ frame,
2688
+ packetCapacity,
2689
+ assertActive: assertCurrentGeneration,
2690
+ signal: context.signal,
2691
+ abortMessage: `Protocol V2 BLE write aborted for ${context.messageName}`,
2692
+ wait: delay,
2693
+ writePacket: (packet) => __awaiter(this, void 0, void 0, function* () {
2694
+ const packetStartedAt = perf ? nowMs() : 0;
2695
+ yield this.writeProtocolV2Packet(uuid, transport$1, buffer.Buffer.from(packet).toString('base64'), context, assertCurrentGeneration);
2696
+ perf === null || perf === void 0 ? void 0 : perf.recordPacket(nowMs() - packetStartedAt);
2697
+ }),
2698
+ });
2699
+ }
2700
+ perf === null || perf === void 0 ? void 0 : perf.recordFrame(frame.length, Math.ceil(frame.length / packetCapacity), nowMs() - startedAt);
2701
+ });
2702
+ }
2703
+ resolveProtocolV2NativeFrameWriter(transport, context, nativeFrameWrite) {
2704
+ if (!context.highThroughput || !nativeFrameWrite)
2705
+ return undefined;
2706
+ if (shouldWriteProtocolV2WithResponse({
2707
+ platform: reactNative.Platform.OS,
2708
+ highThroughput: context.highThroughput,
2709
+ requestedWithResponse: context.writeWithResponse,
2710
+ characteristic: transport.writeCharacteristic,
2711
+ })) {
2712
+ return undefined;
2713
+ }
2714
+ if (typeof transport.writeCharacteristic.id !== 'number')
2715
+ return undefined;
2716
+ return getProtocolV2NativeFrameWriter(this.blePlxManager);
2717
+ }
2718
+ writeProtocolV2NativeFrame(uuid, transport, manager, frame, packetCapacity, context, assertCurrentGeneration) {
2719
+ return __awaiter(this, void 0, void 0, function* () {
2720
+ const abortMessage = `Protocol V2 BLE write aborted for ${context.messageName}`;
2721
+ assertCurrentGeneration();
2722
+ if (context.signal.aborted) {
2723
+ throw new Error(abortMessage);
2724
+ }
2725
+ this.protocolV2FrameWriteCounter += 1;
2726
+ const transactionId = `${uuid}:v2frame:${context.generation}:${this.protocolV2FrameWriteCounter}`;
2727
+ let cancelError;
2728
+ let rejectCancelled = () => undefined;
2729
+ const cancelled = new Promise((_, reject) => {
2730
+ rejectCancelled = reject;
2567
2731
  });
2732
+ const active = {
2733
+ generation: context.generation,
2734
+ cancel: error => {
2735
+ if (cancelError)
2736
+ return;
2737
+ cancelError = error;
2738
+ if (this.protocolV2FrameWrites.get(uuid) === active) {
2739
+ this.protocolV2FrameWrites.delete(uuid);
2740
+ }
2741
+ rejectCancelled(error);
2742
+ this.cancelNativeTransaction(manager, transactionId);
2743
+ },
2744
+ };
2745
+ const isCurrentOwner = () => {
2746
+ try {
2747
+ assertCurrentGeneration();
2748
+ return !context.signal.aborted;
2749
+ }
2750
+ catch (_a) {
2751
+ return false;
2752
+ }
2753
+ };
2754
+ const onAbort = () => active.cancel(new Error(abortMessage));
2755
+ let timer;
2756
+ try {
2757
+ const nativeWrite = Promise.resolve(manager.writeCharacteristicWithoutResponseFrame(transport.writeCharacteristic.id, buffer.Buffer.from(frame).toString('base64'), packetCapacity, transactionId));
2758
+ nativeWrite.catch(() => undefined);
2759
+ this.protocolV2FrameWrites.set(uuid, active);
2760
+ context.signal.addEventListener('abort', onAbort);
2761
+ timer = setTimeout(() => {
2762
+ const owner = isCurrentOwner();
2763
+ active.cancel(createWedgedWriteError());
2764
+ if (owner) {
2765
+ this.tearDownWedgedLink(uuid);
2766
+ }
2767
+ else {
2768
+ Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] stale BLE frame write timed out, link kept');
2769
+ }
2770
+ }, BLE_WRITE_PACKET_TIMEOUT_MS);
2771
+ yield Promise.race([nativeWrite, cancelled]);
2772
+ }
2773
+ catch (error) {
2774
+ if (cancelError)
2775
+ throw cancelError;
2776
+ if (isNativeBleDisconnectError(error)) {
2777
+ throw toBleDisconnectHardwareError(error);
2778
+ }
2779
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleWriteCharacteristicError, getNativeBleErrorReason(error));
2780
+ }
2781
+ finally {
2782
+ if (timer)
2783
+ clearTimeout(timer);
2784
+ context.signal.removeEventListener('abort', onAbort);
2785
+ if (this.protocolV2FrameWrites.get(uuid) === active) {
2786
+ this.protocolV2FrameWrites.delete(uuid);
2787
+ }
2788
+ }
2789
+ this.writeTimeoutCounts.delete(uuid);
2790
+ try {
2791
+ assertCurrentGeneration();
2792
+ }
2793
+ catch (error) {
2794
+ active.cancel(error instanceof Error ? error : new Error(String(error)));
2795
+ }
2796
+ if (cancelError)
2797
+ throw cancelError;
2568
2798
  });
2569
2799
  }
2570
- callProtocolV2(uuid, name, data, options) {
2800
+ cancelProtocolV2FrameWrite(uuid, error, generation) {
2801
+ const active = this.protocolV2FrameWrites.get(uuid);
2802
+ if (!active || (generation !== undefined && active.generation !== generation))
2803
+ return;
2804
+ active.cancel(error);
2805
+ }
2806
+ cancelNativeTransaction(manager, transactionId) {
2807
+ const logFailure = (error) => Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Protocol V2 frame write cancellation failed', {
2808
+ error: error instanceof Error ? error.message : String(error),
2809
+ });
2810
+ try {
2811
+ Promise.resolve(manager.cancelTransaction(transactionId)).catch(logFailure);
2812
+ }
2813
+ catch (error) {
2814
+ logFailure(error);
2815
+ }
2816
+ }
2817
+ getProtocolV2FileWritePerf(uuid, context) {
2818
+ return context.messageName === 'FilesystemFileWrite'
2819
+ ? this.protocolV2FileWritePerfs.get(uuid)
2820
+ : undefined;
2821
+ }
2822
+ markProtocolV2LogSignature(uuid, signature) {
2571
2823
  var _a;
2824
+ const signatures = (_a = this.protocolV2HighVolumeLogSignatures.get(uuid)) !== null && _a !== void 0 ? _a : new Set();
2825
+ if (signatures.has(signature))
2826
+ return false;
2827
+ signatures.add(signature);
2828
+ this.protocolV2HighVolumeLogSignatures.set(uuid, signatures);
2829
+ return true;
2830
+ }
2831
+ callProtocolV2(uuid, name, data, options) {
2572
2832
  return __awaiter(this, void 0, void 0, function* () {
2573
2833
  if (!this._messages || !this._messagesV2) {
2574
2834
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportNotConfigured);
@@ -2594,10 +2854,7 @@ class ReactNativeBleTransport {
2594
2854
  });
2595
2855
  const writeMode = writeWithResponse ? 'withResponse' : 'withoutResponse';
2596
2856
  const logSignature = `${name}:${writeMode}:${String(currentTransport.mtuSize)}:${packetCapacity}`;
2597
- const loggedSignatures = (_a = this.protocolV2HighVolumeLogSignatures.get(uuid)) !== null && _a !== void 0 ? _a : new Set();
2598
- if (!loggedSignatures.has(logSignature)) {
2599
- loggedSignatures.add(logSignature);
2600
- this.protocolV2HighVolumeLogSignatures.set(uuid, loggedSignatures);
2857
+ if (this.markProtocolV2LogSignature(uuid, logSignature)) {
2601
2858
  Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Protocol V2 high-volume write configured', {
2602
2859
  name,
2603
2860
  writeMode,
@@ -2605,12 +2862,33 @@ class ReactNativeBleTransport {
2605
2862
  packetCapacity,
2606
2863
  });
2607
2864
  }
2865
+ const frameWriteMode = this.resolveProtocolV2NativeFrameWriter(currentTransport, { highThroughput: true, writeWithResponse: options === null || options === void 0 ? void 0 : options.writeWithResponse }, tuning.nativeFrameWrite)
2866
+ ? 'native-frame'
2867
+ : 'per-packet';
2868
+ if (this.markProtocolV2LogSignature(uuid, `frameWriteMode:${frameWriteMode}`)) {
2869
+ Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Protocol V2 frame write mode', {
2870
+ platform: reactNative.Platform.OS,
2871
+ mode: frameWriteMode,
2872
+ nativeFrameWrite: tuning.nativeFrameWrite,
2873
+ nativeFrameWriteSupported: !!getProtocolV2NativeFrameWriter(this.blePlxManager),
2874
+ packetCapacity,
2875
+ });
2876
+ }
2608
2877
  }
2609
2878
  if (highThroughputWrite) {
2610
2879
  yield this.enableAndroidHighConnectionPriority(uuid);
2611
2880
  }
2881
+ const fileWritePerf = name === 'FilesystemFileWrite' && (options === null || options === void 0 ? void 0 : options.fileWritePipeline)
2882
+ ? createProtocolV2FileWritePerf()
2883
+ : undefined;
2884
+ if (fileWritePerf) {
2885
+ this.protocolV2FileWritePerfs.set(uuid, fileWritePerf);
2886
+ }
2887
+ let fileWriteOk = false;
2612
2888
  try {
2613
- return yield this.protocolV2Links.call(uuid, () => this.createProtocolV2Adapter(uuid), name, data, callOptions);
2889
+ const response = yield this.protocolV2Links.call(uuid, () => this.createProtocolV2Adapter(uuid), name, data, callOptions);
2890
+ fileWriteOk = response.type !== 'Failure';
2891
+ return response;
2614
2892
  }
2615
2893
  catch (e) {
2616
2894
  Log === null || Log === void 0 ? void 0 : Log.error('[ReactNativeBleTransport] Protocol V2 call error:', e);
@@ -2628,6 +2906,12 @@ class ReactNativeBleTransport {
2628
2906
  if (highThroughputWrite) {
2629
2907
  this.scheduleAndroidBalancedConnectionPriority(uuid);
2630
2908
  }
2909
+ if (fileWritePerf) {
2910
+ if (this.protocolV2FileWritePerfs.get(uuid) === fileWritePerf) {
2911
+ this.protocolV2FileWritePerfs.delete(uuid);
2912
+ }
2913
+ Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] FileWrite perf', fileWritePerf.summarize(fileWriteOk));
2914
+ }
2631
2915
  }
2632
2916
  });
2633
2917
  }
@@ -2659,6 +2943,15 @@ class ReactNativeBleTransport {
2659
2943
  this.clearAndroidPriorityResetTimer(uuid);
2660
2944
  if (this.androidHighPriorityDevices.has(uuid))
2661
2945
  return;
2946
+ if (!shouldRequestAndroidHighConnectionPriority()) {
2947
+ if (this.markProtocolV2LogSignature(uuid, 'androidPriority:peripheral')) {
2948
+ Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Android BLE connection priority left to peripheral', {
2949
+ apiLevel: reactNative.Platform.Version,
2950
+ setting: protocolV2BleTuning.androidHighConnectionPriority,
2951
+ });
2952
+ }
2953
+ return;
2954
+ }
2662
2955
  const transport = transportCache[uuid];
2663
2956
  if (!transport)
2664
2957
  return;
@@ -2728,9 +3021,12 @@ class ReactNativeBleTransport {
2728
3021
  const currentTransport = this.getCachedTransport(uuid);
2729
3022
  yield this.writeProtocolV2Frame(uuid, currentTransport, frame, context, assertCurrentGeneration);
2730
3023
  }),
2731
- readFrame: () => __awaiter(this, void 0, void 0, function* () {
3024
+ readFrame: (context) => __awaiter(this, void 0, void 0, function* () {
2732
3025
  assertCurrentGeneration();
3026
+ const perf = this.getProtocolV2FileWritePerf(uuid, context);
3027
+ const startedAt = perf ? nowMs() : 0;
2733
3028
  const rxFrame = yield this.readProtocolV2Frame(uuid);
3029
+ perf === null || perf === void 0 ? void 0 : perf.recordReadWait(nowMs() - startedAt);
2734
3030
  if (!(rxFrame instanceof Uint8Array)) {
2735
3031
  throw new Error('Protocol V2 response is not Uint8Array');
2736
3032
  }
@@ -2738,6 +3034,7 @@ class ReactNativeBleTransport {
2738
3034
  }),
2739
3035
  reset: (reason) => {
2740
3036
  var _a;
3037
+ this.cancelProtocolV2FrameWrite(uuid, new Error(reason), generation);
2741
3038
  if (this.monitorTokens.get(uuid) !== generation)
2742
3039
  return;
2743
3040
  (_a = this.protocolV2Assemblers.get(uuid)) === null || _a === void 0 ? void 0 : _a.reset();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-react-native",
3
- "version": "1.2.8-alpha.121",
3
+ "version": "1.2.8-alpha.122",
4
4
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -20,11 +20,11 @@
20
20
  "lint:fix": "eslint . --fix"
21
21
  },
22
22
  "dependencies": {
23
- "@onekeyfe/hd-core": "1.2.8-alpha.121",
24
- "@onekeyfe/hd-shared": "1.2.8-alpha.121",
25
- "@onekeyfe/hd-transport": "1.2.8-alpha.121",
23
+ "@onekeyfe/hd-core": "1.2.8-alpha.122",
24
+ "@onekeyfe/hd-shared": "1.2.8-alpha.122",
25
+ "@onekeyfe/hd-transport": "1.2.8-alpha.122",
26
26
  "@onekeyfe/react-native-ble-utils": "0.1.9",
27
27
  "react-native-ble-plx": "3.5.1"
28
28
  },
29
- "gitHead": "ce1078610eca281844be4caa5444d8dd2023fed4"
29
+ "gitHead": "352233965cd0eba1da3b3c533e94ff7565218a30"
30
30
  }