@onekeyfe/hd-transport-react-native 1.2.0-alpha.70 → 1.2.0-alpha.72

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.
@@ -3,7 +3,7 @@ export default class BleTransport {
3
3
  id: string;
4
4
  name: string;
5
5
  device: Device;
6
- mtuSize: number;
6
+ mtuSize: number | undefined;
7
7
  writeCharacteristic: Characteristic;
8
8
  notifyCharacteristic: Characteristic;
9
9
  notifySubscription?: Subscription;
@@ -1 +1 @@
1
- {"version":3,"file":"BleTransport.d.ts","sourceRoot":"","sources":["../src/BleTransport.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEjF,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,EAAE,EAAE,MAAM,CAAC;IAEX,IAAI,SAA6B;IAEjC,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,SAAM;IAEb,mBAAmB,EAAE,cAAc,CAAC;IAEpC,oBAAoB,EAAE,cAAc,CAAC;IAErC,kBAAkB,CAAC,EAAE,YAAY,CAAC;IAElC,sBAAsB,CAAC,EAAE,YAAY,CAAC;IAEtC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,YAAY,CAAC,EAAE,MAAM,CAAC;gBAGpB,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,cAAc,EACnC,oBAAoB,EAAE,cAAc;IAQhC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAOlD"}
1
+ {"version":3,"file":"BleTransport.d.ts","sourceRoot":"","sources":["../src/BleTransport.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEjF,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,EAAE,EAAE,MAAM,CAAC;IAEX,IAAI,SAA6B;IAEjC,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B,mBAAmB,EAAE,cAAc,CAAC;IAEpC,oBAAoB,EAAE,cAAc,CAAC;IAErC,kBAAkB,CAAC,EAAE,YAAY,CAAC;IAElC,sBAAsB,CAAC,EAAE,YAAY,CAAC;IAEtC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,YAAY,CAAC,EAAE,MAAM,CAAC;gBAGpB,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,cAAc,EACnC,oBAAoB,EAAE,cAAc;IAQhC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAOlD"}
@@ -10,4 +10,11 @@ export declare function resolveProtocolV2PacketCapacity({ platform, iosPacketLen
10
10
  androidPacketLength?: number;
11
11
  mtu?: number | null;
12
12
  }): number;
13
+ export declare function shouldRefreshNegotiatedMtu(mtu?: number | null): boolean;
14
+ export declare function shouldWriteProtocolV2WithResponse({ platform, highThroughput, requestedWithResponse, characteristic, }: {
15
+ platform: BlePlatform;
16
+ highThroughput: boolean;
17
+ requestedWithResponse?: boolean;
18
+ characteristic: BleWriteCapability;
19
+ }): boolean;
13
20
  //# sourceMappingURL=bleStrategy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bleStrategy.d.ts","sourceRoot":"","sources":["../src/bleStrategy.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,CAAC;AAErD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,sBAAsB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACxC,yBAAyB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC5C,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,kBAAkB,WAEvE;AAED,wBAAgB,+BAA+B,CAAC,EAC9C,QAAQ,EACR,eAAmC,EACnC,mBAA2C,EAC3C,GAAG,GACJ,EAAE;IACD,QAAQ,EAAE,WAAW,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,UAWA"}
1
+ {"version":3,"file":"bleStrategy.d.ts","sourceRoot":"","sources":["../src/bleStrategy.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,CAAC;AAErD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,sBAAsB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACxC,yBAAyB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC5C,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,kBAAkB,WAEvE;AAED,wBAAgB,+BAA+B,CAAC,EAC9C,QAAQ,EACR,eAA+C,EAC/C,mBAAuD,EACvD,GAAG,GACJ,EAAE;IACD,QAAQ,EAAE,WAAW,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,UAMA;AAED,wBAAgB,0BAA0B,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,WAE7D;AAED,wBAAgB,iCAAiC,CAAC,EAChD,QAAQ,EACR,cAAc,EACd,qBAAqB,EACrB,cAAc,GACf,EAAE;IACD,QAAQ,EAAE,WAAW,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,cAAc,EAAE,kBAAkB,CAAC;CACpC,WAIA"}
@@ -1,6 +1,7 @@
1
1
  export declare const IOS_PACKET_LENGTH = 128;
2
2
  export declare const ANDROID_PACKET_LENGTH = 192;
3
- export declare const ANDROID_DEFAULT_MTU = 23;
3
+ export declare const IOS_PROTOCOL_V2_PACKET_LENGTH = 244;
4
+ export declare const ANDROID_PROTOCOL_V2_PACKET_LENGTH = 244;
4
5
  export declare const getBluetoothServiceUuids: () => string[];
5
6
  export declare const getInfosForServiceUuid: (serviceUuid: string, deviceType: 'classic') => {
6
7
  serviceUuid: string;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,mBAAmB,KAAK,CAAC;AA8BtC,eAAO,MAAM,wBAAwB,gBAA0B,CAAC;AAChE,eAAO,MAAM,sBAAsB,gBAAiB,MAAM,cAAc,SAAS;iBA1BhE,MAAM;;;QA2CtB,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAAW,MAAM,GAAG,IAAI,WACP,CAAC;AAE/C,eAAO,MAAM,aAAa,UAAW,MAAM,GAAG,IAAI,UAAU,MAAM,GAAG,IAAI,YAGxE,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,6BAA6B,MAAM,CAAC;AACjD,eAAO,MAAM,iCAAiC,MAAM,CAAC;AA8BrD,eAAO,MAAM,wBAAwB,gBAA0B,CAAC;AAChE,eAAO,MAAM,sBAAsB,gBAAiB,MAAM,cAAc,SAAS;iBA1BhE,MAAM;;;QA2CtB,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAAW,MAAM,GAAG,IAAI,WACP,CAAC;AAE/C,eAAO,MAAM,aAAa,UAAW,MAAM,GAAG,IAAI,UAAU,MAAM,GAAG,IAAI,YAGxE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ declare class BleTransport {
8
8
  id: string;
9
9
  name: string;
10
10
  device: Device;
11
- mtuSize: number;
11
+ mtuSize: number | undefined;
12
12
  writeCharacteristic: Characteristic;
13
13
  notifyCharacteristic: Characteristic;
14
14
  notifySubscription?: Subscription;
@@ -119,6 +119,9 @@ declare class ReactNativeBleTransport {
119
119
  private protocolV2Links;
120
120
  private monitorTokens;
121
121
  private disconnectEventTokens;
122
+ private protocolV2HighVolumeLogSignatures;
123
+ private androidHighPriorityDevices;
124
+ private androidPriorityResetTimers;
122
125
  private nextMonitorToken;
123
126
  constructor(options: TransportOptions);
124
127
  init(logger: any, emitter: EventEmitter): void;
@@ -194,6 +197,11 @@ declare class ReactNativeBleTransport {
194
197
  private writeProtocolV2Packet;
195
198
  private writeProtocolV2Frame;
196
199
  private callProtocolV2;
200
+ private ensureProtocolV2HighThroughputMtu;
201
+ private clearAndroidPriorityResetTimer;
202
+ private enableAndroidHighConnectionPriority;
203
+ private scheduleAndroidBalancedConnectionPriority;
204
+ private restoreAndroidConnectionPriority;
197
205
  private createProtocolV2Adapter;
198
206
  getProtocolType(path: string): ProtocolType | undefined;
199
207
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAIL,UAAU,IAAI,aAAa,EAE5B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAS,EAAE,EAEhB,KAAK,oBAAoB,EAIzB,KAAK,YAAY,EAKjB,KAAK,oBAAoB,EAG1B,MAAM,wBAAwB,CAAC;AAoBhC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAK1C,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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OAAO,CAAC,sBAAsB;YAShB,mBAAmB;YAiBnB,qBAAqB;YA2DrB,oBAAoB;YAgCpB,cAAc;YAqEd,iCAAiC;IAiB/C,OAAO,CAAC,8BAA8B;YAQxB,mCAAmC;IAsBjD,OAAO,CAAC,yCAAyC;YAanC,gCAAgC;IAoB9C,OAAO,CAAC,uBAAuB;IAkD/B,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;CAGxD"}
package/dist/index.js CHANGED
@@ -93,7 +93,8 @@ const onDeviceBondState = (bleMacAddress) => new Promise((resolve, reject) => {
93
93
 
94
94
  const IOS_PACKET_LENGTH = 128;
95
95
  const ANDROID_PACKET_LENGTH = 192;
96
- const ANDROID_DEFAULT_MTU = 23;
96
+ const IOS_PROTOCOL_V2_PACKET_LENGTH = 244;
97
+ const ANDROID_PROTOCOL_V2_PACKET_LENGTH = 244;
97
98
  const ClassicServiceUUID = '00000001-0000-1000-8000-00805f9b34fb';
98
99
  const OneKeyServices = {
99
100
  classic: {
@@ -134,15 +135,21 @@ const isSameBleUuid = (left, right) => {
134
135
  function hasWritableCapability(characteristic) {
135
136
  return !!(characteristic.isWritableWithResponse || characteristic.isWritableWithoutResponse);
136
137
  }
137
- function resolveProtocolV2PacketCapacity({ platform, iosPacketLength = IOS_PACKET_LENGTH, androidPacketLength = ANDROID_PACKET_LENGTH, mtu, }) {
138
- if (platform === 'ios') {
139
- return iosPacketLength;
140
- }
141
- if (platform === 'android') {
142
- const payloadLength = Math.max((mtu !== null && mtu !== void 0 ? mtu : ANDROID_DEFAULT_MTU) - 3, 1);
143
- return Math.min(androidPacketLength, payloadLength);
144
- }
145
- return androidPacketLength;
138
+ function resolveProtocolV2PacketCapacity({ platform, iosPacketLength = IOS_PROTOCOL_V2_PACKET_LENGTH, androidPacketLength = ANDROID_PROTOCOL_V2_PACKET_LENGTH, mtu, }) {
139
+ const negotiatedMtu = typeof mtu === 'number' && Number.isFinite(mtu) && mtu > 3 ? Math.floor(mtu) : 23;
140
+ const payloadLength = negotiatedMtu - 3;
141
+ const configuredPacketLength = platform === 'ios' ? iosPacketLength : androidPacketLength;
142
+ return Math.min(configuredPacketLength, payloadLength);
143
+ }
144
+ function shouldRefreshNegotiatedMtu(mtu) {
145
+ return typeof mtu !== 'number' || !Number.isFinite(mtu) || mtu <= 23;
146
+ }
147
+ function shouldWriteProtocolV2WithResponse({ platform, highThroughput, requestedWithResponse, characteristic, }) {
148
+ if (!characteristic.isWritableWithResponse)
149
+ return false;
150
+ if (!characteristic.isWritableWithoutResponse)
151
+ return true;
152
+ return requestedWithResponse === true || (platform === 'ios' && !highThroughput);
146
153
  }
147
154
 
148
155
  const timer = process.env.NODE_ENV === 'development'
@@ -202,7 +209,6 @@ const isHeaderChunk = (chunk) => {
202
209
  class BleTransport {
203
210
  constructor(device, writeCharacteristic, notifyCharacteristic) {
204
211
  this.name = 'ReactNativeBleTransport';
205
- this.mtuSize = 23;
206
212
  this.id = device.id;
207
213
  this.device = device;
208
214
  this.writeCharacteristic = writeCharacteristic;
@@ -226,7 +232,6 @@ const FIRMWARE_UPLOAD_WRITE_BURST_SIZE = reactNative.Platform.OS === 'ios' ? 4 :
226
232
  const FIRMWARE_UPLOAD_WRITE_PAUSE_MS = reactNative.Platform.OS === 'ios' ? 8 : 10;
227
233
  const FIRMWARE_UPLOAD_WRITE_FLUSH_DELAY_MS = reactNative.Platform.OS === 'ios' ? 24 : 30;
228
234
  const FIRMWARE_UPLOAD_WRITE_MAX_RETRIES = 8;
229
- const IOS_PROTOCOL_V2_CONTROL_WRITE_DELAY_MS = 5;
230
235
  const ANDROID_FIRMWARE_UPLOAD_PACKET_LENGTH = 192;
231
236
  const FIRMWARE_UPLOAD_WRITE_PACKET_CAPACITY = reactNative.Platform.OS === 'ios' ? IOS_PACKET_LENGTH : ANDROID_FIRMWARE_UPLOAD_PACKET_LENGTH;
232
237
  const ANDROID_GATT_CONGESTED_STATUS = 143;
@@ -285,8 +290,8 @@ const DEVICE_SCAN_TIMEOUT_MS = 3000;
285
290
  const IOS_NOTIFY_READY_DELAY_MS = 150;
286
291
  const ANDROID_NOTIFY_READY_DELAY_MS = 300;
287
292
  const DEFAULT_PROTOCOL_V2_BLE_TUNING = {
288
- iosPacketLength: IOS_PACKET_LENGTH,
289
- androidPacketLength: ANDROID_PACKET_LENGTH,
293
+ iosPacketLength: IOS_PROTOCOL_V2_PACKET_LENGTH,
294
+ androidPacketLength: ANDROID_PROTOCOL_V2_PACKET_LENGTH,
290
295
  };
291
296
  let protocolV2BleTuning = Object.assign({}, DEFAULT_PROTOCOL_V2_BLE_TUNING);
292
297
  const normalizePositiveInteger = (value, fallback) => {
@@ -315,10 +320,14 @@ function inferProtocolHintFromDeviceName(name) {
315
320
  function getDeviceDisplayName(device) {
316
321
  return (device === null || device === void 0 ? void 0 : device.name) || (device === null || device === void 0 ? void 0 : device.localName) || null;
317
322
  }
318
- const ANDROID_REQUEST_MTU = 256;
323
+ const IOS_REQUEST_MTU = 247;
324
+ const ANDROID_REQUEST_MTU = 517;
325
+ const BLE_MTU_REFRESH_RETRY_DELAY_MS = 200;
326
+ const ANDROID_HIGH_PRIORITY_IDLE_MS = 1000;
327
+ const getRequestedBleMtu = () => reactNative.Platform.OS === 'android' ? ANDROID_REQUEST_MTU : IOS_REQUEST_MTU;
319
328
  const BLE_NATIVE_CONNECT_TIMEOUT_MS = 3000;
320
329
  const connectOptions = {
321
- requestMTU: ANDROID_REQUEST_MTU,
330
+ requestMTU: getRequestedBleMtu(),
322
331
  timeout: BLE_NATIVE_CONNECT_TIMEOUT_MS,
323
332
  refreshGatt: 'OnConnected',
324
333
  };
@@ -345,23 +354,25 @@ const tryToGetConfiguration = (device) => {
345
354
  return null;
346
355
  return infos;
347
356
  };
348
- const requestAndroidMtu = (device) => __awaiter(void 0, void 0, void 0, function* () {
349
- if (reactNative.Platform.OS !== 'android')
357
+ const requestNegotiatedMtu = (device, stage, attempt) => __awaiter(void 0, void 0, void 0, function* () {
358
+ if (reactNative.Platform.OS !== 'ios' && reactNative.Platform.OS !== 'android')
350
359
  return device;
351
360
  try {
352
- const mtuDevice = yield device.requestMTU(ANDROID_REQUEST_MTU);
353
- Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] MTU configured', {
354
- deviceId: device.id,
355
- requested: ANDROID_REQUEST_MTU,
356
- actual: mtuDevice.mtu,
357
- });
361
+ const mtuDevice = yield device.requestMTU(getRequestedBleMtu());
358
362
  return mtuDevice;
359
363
  }
360
364
  catch (error) {
361
- Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Android MTU request failed:', error);
365
+ Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] MTU refresh failed, continuing with current value', {
366
+ platform: reactNative.Platform.OS,
367
+ stage,
368
+ attempt,
369
+ actual: device.mtu,
370
+ error: error instanceof Error ? error.message : String(error),
371
+ });
362
372
  return device;
363
373
  }
364
374
  });
375
+ const resolveNegotiatedMtu = (device) => requestNegotiatedMtu(device, 'connected', 0);
365
376
  function remapError(error) {
366
377
  var _a;
367
378
  if (error instanceof reactNativeBlePlx.BleError) {
@@ -423,6 +434,9 @@ class ReactNativeBleTransport {
423
434
  });
424
435
  this.monitorTokens = new Map();
425
436
  this.disconnectEventTokens = new Map();
437
+ this.protocolV2HighVolumeLogSignatures = new Map();
438
+ this.androidHighPriorityDevices = new Set();
439
+ this.androidPriorityResetTimers = new Map();
426
440
  this.nextMonitorToken = 1;
427
441
  this.scanTimeout = (_a = options.scanTimeout) !== null && _a !== void 0 ? _a : DEVICE_SCAN_TIMEOUT_MS;
428
442
  }
@@ -739,9 +753,7 @@ class ReactNativeBleTransport {
739
753
  return __awaiter(this, void 0, void 0, function* () {
740
754
  const { writeCharacteristic, notifyCharacteristic } = characteristics !== null && characteristics !== void 0 ? characteristics : (yield this.resolveCharacteristicsWithTimeout(uuid, device));
741
755
  const transport$1 = new BleTransport(device, writeCharacteristic, notifyCharacteristic);
742
- if (reactNative.Platform.OS === 'android') {
743
- transport$1.mtuSize = typeof device.mtu === 'number' ? device.mtu : transport$1.mtuSize;
744
- }
756
+ transport$1.mtuSize = typeof device.mtu === 'number' ? device.mtu : undefined;
745
757
  const monitorToken = this.nextMonitorToken;
746
758
  this.nextMonitorToken += 1;
747
759
  const notifyTransactionId = `${uuid}:notify:${monitorToken}`;
@@ -750,6 +762,7 @@ class ReactNativeBleTransport {
750
762
  this.monitorTokens.set(uuid, monitorToken);
751
763
  transport$1.notifySubscription = this._monitorCharacteristic(transport$1.notifyCharacteristic, uuid, monitorToken, notifyTransactionId);
752
764
  transportCache[uuid] = transport$1;
765
+ this.protocolV2HighVolumeLogSignatures.set(uuid, new Set());
753
766
  this.protocolV2Assemblers.set(uuid, new transport.ProtocolV2FrameAssembler(transport.PROTOCOL_V2_BLE_FRAME_MAX_BYTES));
754
767
  if (reactNative.Platform.OS === 'ios') {
755
768
  yield new Promise(resolve => {
@@ -759,6 +772,31 @@ class ReactNativeBleTransport {
759
772
  else if (reactNative.Platform.OS === 'android') {
760
773
  yield delay(ANDROID_NOTIFY_READY_DELAY_MS);
761
774
  }
775
+ const initialMtu = transport$1.mtuSize;
776
+ let refreshAttempts = 0;
777
+ if ((reactNative.Platform.OS === 'ios' || reactNative.Platform.OS === 'android') &&
778
+ shouldRefreshNegotiatedMtu(transport$1.mtuSize)) {
779
+ refreshAttempts += 1;
780
+ let refreshedDevice = yield requestNegotiatedMtu(transport$1.device, 'servicesAndNotifyReady', 1);
781
+ transport$1.device = refreshedDevice;
782
+ transport$1.mtuSize =
783
+ typeof refreshedDevice.mtu === 'number' ? refreshedDevice.mtu : transport$1.mtuSize;
784
+ if (shouldRefreshNegotiatedMtu(transport$1.mtuSize)) {
785
+ yield delay(BLE_MTU_REFRESH_RETRY_DELAY_MS);
786
+ refreshAttempts += 1;
787
+ refreshedDevice = yield requestNegotiatedMtu(transport$1.device, 'servicesAndNotifyReady', 2);
788
+ transport$1.device = refreshedDevice;
789
+ transport$1.mtuSize =
790
+ typeof refreshedDevice.mtu === 'number' ? refreshedDevice.mtu : transport$1.mtuSize;
791
+ }
792
+ }
793
+ Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] BLE MTU ready', {
794
+ platform: reactNative.Platform.OS,
795
+ requested: getRequestedBleMtu(),
796
+ initial: initialMtu,
797
+ actual: transport$1.mtuSize,
798
+ refreshAttempts,
799
+ });
762
800
  return transport$1;
763
801
  });
764
802
  }
@@ -875,7 +913,7 @@ class ReactNativeBleTransport {
875
913
  }
876
914
  }
877
915
  }
878
- device = yield requestAndroidMtu(device);
916
+ device = yield resolveNegotiatedMtu(device);
879
917
  const acquiredDevice = device;
880
918
  const { writeCharacteristic, notifyCharacteristic } = yield this.resolveCharacteristicsWithTimeout(uuid, acquiredDevice);
881
919
  const protocolHint = expectedProtocol
@@ -897,7 +935,7 @@ class ReactNativeBleTransport {
897
935
  if (!currentTransport) {
898
936
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportNotFound);
899
937
  }
900
- this.attachDisconnectSubscription(currentTransport, acquiredDevice, uuid);
938
+ this.attachDisconnectSubscription(currentTransport, currentTransport.device, uuid);
901
939
  return { uuid, protocolType };
902
940
  }
903
941
  catch (error) {
@@ -1036,6 +1074,7 @@ class ReactNativeBleTransport {
1036
1074
  this.resetProtocolV2Frames(uuid);
1037
1075
  return Promise.resolve(true);
1038
1076
  }
1077
+ yield this.restoreAndroidConnectionPriority(uuid, transport);
1039
1078
  if (transport) {
1040
1079
  if (this.monitorTokens.get(uuid) === transport.monitorToken) {
1041
1080
  this.monitorTokens.delete(uuid);
@@ -1056,6 +1095,7 @@ class ReactNativeBleTransport {
1056
1095
  }
1057
1096
  delete transportCache[uuid];
1058
1097
  }
1098
+ this.protocolV2HighVolumeLogSignatures.delete(uuid);
1059
1099
  this.deviceProtocol.delete(uuid);
1060
1100
  this.probingProtocols.delete(uuid);
1061
1101
  (_f = this.protocolV2Assemblers.get(uuid)) === null || _f === void 0 ? void 0 : _f.reset();
@@ -1800,8 +1840,12 @@ class ReactNativeBleTransport {
1800
1840
  }
1801
1841
  writeProtocolV2Packet(uuid, transport, base64, context, assertCurrentGeneration) {
1802
1842
  return __awaiter(this, void 0, void 0, function* () {
1803
- const shouldUseWriteWithResponse = transport.writeCharacteristic.isWritableWithResponse &&
1804
- (context.writeWithResponse === true || (reactNative.Platform.OS === 'ios' && !context.highVolume));
1843
+ const shouldUseWriteWithResponse = shouldWriteProtocolV2WithResponse({
1844
+ platform: reactNative.Platform.OS,
1845
+ highThroughput: context.highThroughput,
1846
+ requestedWithResponse: context.writeWithResponse,
1847
+ characteristic: transport.writeCharacteristic,
1848
+ });
1805
1849
  let attempt = 0;
1806
1850
  for (;;) {
1807
1851
  assertCurrentGeneration();
@@ -1847,40 +1891,59 @@ class ReactNativeBleTransport {
1847
1891
  platform: reactNative.Platform.OS,
1848
1892
  iosPacketLength: tuning.iosPacketLength,
1849
1893
  androidPacketLength: tuning.androidPacketLength,
1850
- mtu: reactNative.Platform.OS === 'android' ? transport$1.mtuSize : undefined,
1894
+ mtu: transport$1.mtuSize,
1851
1895
  });
1852
- const initialDelayMs = reactNative.Platform.OS === 'ios' && !context.highVolume && frame.length <= packetCapacity
1853
- ? IOS_PROTOCOL_V2_CONTROL_WRITE_DELAY_MS
1854
- : 0;
1855
1896
  yield transport.writeProtocolV2BleFrame({
1856
1897
  frame,
1857
1898
  packetCapacity,
1858
1899
  assertActive: assertCurrentGeneration,
1859
1900
  signal: context.signal,
1860
1901
  abortMessage: `Protocol V2 BLE write aborted for ${context.messageName}`,
1861
- initialDelayMs,
1862
- burstSize: FIRMWARE_UPLOAD_WRITE_BURST_SIZE,
1863
- burstPauseMs: FIRMWARE_UPLOAD_WRITE_PAUSE_MS,
1864
- flushDelayMs: FIRMWARE_UPLOAD_WRITE_FLUSH_DELAY_MS,
1865
1902
  wait: delay,
1866
1903
  writePacket: packet => this.writeProtocolV2Packet(uuid, transport$1, buffer.Buffer.from(packet).toString('base64'), context, assertCurrentGeneration),
1867
1904
  });
1868
1905
  });
1869
1906
  }
1870
1907
  callProtocolV2(uuid, name, data, options) {
1908
+ var _a;
1871
1909
  return __awaiter(this, void 0, void 0, function* () {
1872
1910
  if (!this._messages || !this._messagesV2) {
1873
1911
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportNotConfigured);
1874
1912
  }
1875
1913
  const callOptions = options;
1876
- const highVolumeWrite = transport.LogBlockCommand.has(name);
1877
- if (highVolumeWrite) {
1914
+ const highThroughputWrite = transport.isProtocolV2HighThroughputCall(name);
1915
+ if (highThroughputWrite) {
1916
+ yield this.ensureProtocolV2HighThroughputMtu(uuid);
1878
1917
  const tuning = getProtocolV2BleTuning();
1879
- Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Protocol V2 high-volume write configured', {
1880
- name,
1881
- writeMode: (options === null || options === void 0 ? void 0 : options.writeWithResponse) ? 'withResponse' : 'withoutResponse',
1882
- packetCapacity: reactNative.Platform.OS === 'ios' ? tuning.iosPacketLength : tuning.androidPacketLength,
1918
+ const currentTransport = this.getCachedTransport(uuid);
1919
+ const writeWithResponse = shouldWriteProtocolV2WithResponse({
1920
+ platform: reactNative.Platform.OS,
1921
+ highThroughput: true,
1922
+ requestedWithResponse: options === null || options === void 0 ? void 0 : options.writeWithResponse,
1923
+ characteristic: currentTransport.writeCharacteristic,
1883
1924
  });
1925
+ const packetCapacity = resolveProtocolV2PacketCapacity({
1926
+ platform: reactNative.Platform.OS,
1927
+ iosPacketLength: tuning.iosPacketLength,
1928
+ androidPacketLength: tuning.androidPacketLength,
1929
+ mtu: currentTransport.mtuSize,
1930
+ });
1931
+ const writeMode = writeWithResponse ? 'withResponse' : 'withoutResponse';
1932
+ const logSignature = `${name}:${writeMode}:${String(currentTransport.mtuSize)}:${packetCapacity}`;
1933
+ const loggedSignatures = (_a = this.protocolV2HighVolumeLogSignatures.get(uuid)) !== null && _a !== void 0 ? _a : new Set();
1934
+ if (!loggedSignatures.has(logSignature)) {
1935
+ loggedSignatures.add(logSignature);
1936
+ this.protocolV2HighVolumeLogSignatures.set(uuid, loggedSignatures);
1937
+ Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Protocol V2 high-volume write configured', {
1938
+ name,
1939
+ writeMode,
1940
+ reportedMtu: currentTransport.mtuSize,
1941
+ packetCapacity,
1942
+ });
1943
+ }
1944
+ }
1945
+ if (highThroughputWrite) {
1946
+ yield this.enableAndroidHighConnectionPriority(uuid);
1884
1947
  }
1885
1948
  try {
1886
1949
  return yield this.protocolV2Links.call(uuid, () => this.createProtocolV2Adapter(uuid), name, data, callOptions);
@@ -1889,6 +1952,85 @@ class ReactNativeBleTransport {
1889
1952
  Log === null || Log === void 0 ? void 0 : Log.error('[ReactNativeBleTransport] Protocol V2 call error:', e);
1890
1953
  throw e;
1891
1954
  }
1955
+ finally {
1956
+ if (highThroughputWrite) {
1957
+ this.scheduleAndroidBalancedConnectionPriority(uuid);
1958
+ }
1959
+ }
1960
+ });
1961
+ }
1962
+ ensureProtocolV2HighThroughputMtu(uuid) {
1963
+ return __awaiter(this, void 0, void 0, function* () {
1964
+ const transport = this.getCachedTransport(uuid);
1965
+ if (!shouldRefreshNegotiatedMtu(transport.mtuSize))
1966
+ return;
1967
+ const refreshedDevice = yield requestNegotiatedMtu(transport.device, 'highThroughput', 1);
1968
+ transport.device = refreshedDevice;
1969
+ transport.mtuSize =
1970
+ typeof refreshedDevice.mtu === 'number' ? refreshedDevice.mtu : transport.mtuSize;
1971
+ if (shouldRefreshNegotiatedMtu(transport.mtuSize)) {
1972
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleConnectedError, `Protocol V2 high-throughput BLE MTU unavailable: ${String(transport.mtuSize)}`);
1973
+ }
1974
+ });
1975
+ }
1976
+ clearAndroidPriorityResetTimer(uuid) {
1977
+ const timerId = this.androidPriorityResetTimers.get(uuid);
1978
+ if (timerId !== undefined) {
1979
+ clearTimeout(timerId);
1980
+ this.androidPriorityResetTimers.delete(uuid);
1981
+ }
1982
+ }
1983
+ enableAndroidHighConnectionPriority(uuid) {
1984
+ return __awaiter(this, void 0, void 0, function* () {
1985
+ if (reactNative.Platform.OS !== 'android')
1986
+ return;
1987
+ this.clearAndroidPriorityResetTimer(uuid);
1988
+ if (this.androidHighPriorityDevices.has(uuid))
1989
+ return;
1990
+ const transport = transportCache[uuid];
1991
+ if (!transport)
1992
+ return;
1993
+ try {
1994
+ transport.device = yield transport.device.requestConnectionPriority(reactNativeBlePlx.ConnectionPriority.High);
1995
+ this.androidHighPriorityDevices.add(uuid);
1996
+ Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Android BLE connection priority changed', {
1997
+ priority: 'high',
1998
+ });
1999
+ }
2000
+ catch (error) {
2001
+ Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Android BLE high priority request failed', {
2002
+ error: error instanceof Error ? error.message : String(error),
2003
+ });
2004
+ }
2005
+ });
2006
+ }
2007
+ scheduleAndroidBalancedConnectionPriority(uuid) {
2008
+ if (reactNative.Platform.OS !== 'android' || !this.androidHighPriorityDevices.has(uuid))
2009
+ return;
2010
+ this.clearAndroidPriorityResetTimer(uuid);
2011
+ const timerId = setTimeout(() => {
2012
+ this.androidPriorityResetTimers.delete(uuid);
2013
+ this.restoreAndroidConnectionPriority(uuid, transportCache[uuid]).catch(error => Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Android BLE priority restore failed', error));
2014
+ }, ANDROID_HIGH_PRIORITY_IDLE_MS);
2015
+ this.androidPriorityResetTimers.set(uuid, timerId);
2016
+ }
2017
+ restoreAndroidConnectionPriority(uuid, transport) {
2018
+ return __awaiter(this, void 0, void 0, function* () {
2019
+ this.clearAndroidPriorityResetTimer(uuid);
2020
+ if (reactNative.Platform.OS !== 'android' || !this.androidHighPriorityDevices.delete(uuid) || !transport) {
2021
+ return;
2022
+ }
2023
+ try {
2024
+ transport.device = yield transport.device.requestConnectionPriority(reactNativeBlePlx.ConnectionPriority.Balanced);
2025
+ Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Android BLE connection priority changed', {
2026
+ priority: 'balanced',
2027
+ });
2028
+ }
2029
+ catch (error) {
2030
+ Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Android BLE balanced priority request failed', {
2031
+ error: error instanceof Error ? error.message : String(error),
2032
+ });
2033
+ }
1892
2034
  });
1893
2035
  }
1894
2036
  createProtocolV2Adapter(uuid) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-react-native",
3
- "version": "1.2.0-alpha.70",
3
+ "version": "1.2.0-alpha.72",
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.0-alpha.70",
24
- "@onekeyfe/hd-shared": "1.2.0-alpha.70",
25
- "@onekeyfe/hd-transport": "1.2.0-alpha.70",
23
+ "@onekeyfe/hd-core": "1.2.0-alpha.72",
24
+ "@onekeyfe/hd-shared": "1.2.0-alpha.72",
25
+ "@onekeyfe/hd-transport": "1.2.0-alpha.72",
26
26
  "@onekeyfe/react-native-ble-utils": "^0.1.6",
27
27
  "react-native-ble-plx": "3.5.1"
28
28
  },
29
- "gitHead": "d86b033cf970f97e060c49fe4cf618f38b9ce666"
29
+ "gitHead": "76311ccd3753eca8e492b5324f93542bd38525ba"
30
30
  }
@@ -9,7 +9,7 @@ export default class BleTransport {
9
9
 
10
10
  device: Device;
11
11
 
12
- mtuSize = 23;
12
+ mtuSize: number | undefined;
13
13
 
14
14
  writeCharacteristic: Characteristic;
15
15
 
@@ -1,4 +1,9 @@
1
- import { hasWritableCapability, resolveProtocolV2PacketCapacity } from '../bleStrategy';
1
+ import {
2
+ hasWritableCapability,
3
+ resolveProtocolV2PacketCapacity,
4
+ shouldRefreshNegotiatedMtu,
5
+ shouldWriteProtocolV2WithResponse,
6
+ } from '../bleStrategy';
2
7
 
3
8
  describe('React Native BLE strategy', () => {
4
9
  test('accepts writeWithoutResponse-only characteristics', () => {
@@ -10,27 +15,52 @@ describe('React Native BLE strategy', () => {
10
15
  expect(hasWritableCapability(characteristic)).toBe(true);
11
16
  });
12
17
 
13
- test('falls back to Android default ATT payload when MTU is unavailable', () => {
18
+ test('uses the conservative ATT payload when MTU is unavailable', () => {
14
19
  expect(
15
20
  resolveProtocolV2PacketCapacity({
16
21
  platform: 'android',
17
- androidPacketLength: 192,
18
22
  mtu: null,
19
23
  })
20
24
  ).toBe(20);
21
25
  });
22
26
 
27
+ test('only refreshes an unavailable or default MTU snapshot', () => {
28
+ expect(shouldRefreshNegotiatedMtu(undefined)).toBe(true);
29
+ expect(shouldRefreshNegotiatedMtu(23)).toBe(true);
30
+ expect(shouldRefreshNegotiatedMtu(185)).toBe(false);
31
+ expect(shouldRefreshNegotiatedMtu(247)).toBe(false);
32
+ });
33
+
23
34
  test('caps Android packet length by negotiated MTU payload', () => {
24
35
  expect(
25
36
  resolveProtocolV2PacketCapacity({
26
37
  platform: 'android',
27
- androidPacketLength: 192,
38
+ androidPacketLength: 244,
28
39
  mtu: 100,
29
40
  })
30
41
  ).toBe(97);
31
42
  });
32
43
 
33
- test('keeps iOS packet length controlled by tuning profile', () => {
44
+ test('keeps the default Android packet length within the validated ceiling', () => {
45
+ expect(
46
+ resolveProtocolV2PacketCapacity({
47
+ platform: 'android',
48
+ mtu: 517,
49
+ })
50
+ ).toBe(244);
51
+ });
52
+
53
+ test('allows an explicit Android packet length override for validated experiments', () => {
54
+ expect(
55
+ resolveProtocolV2PacketCapacity({
56
+ platform: 'android',
57
+ androidPacketLength: 514,
58
+ mtu: 517,
59
+ })
60
+ ).toBe(514);
61
+ });
62
+
63
+ test('caps iOS packet length by the system-negotiated write payload', () => {
34
64
  expect(
35
65
  resolveProtocolV2PacketCapacity({
36
66
  platform: 'ios',
@@ -39,4 +69,62 @@ describe('React Native BLE strategy', () => {
39
69
  })
40
70
  ).toBe(244);
41
71
  });
72
+
73
+ test('uses the reported iOS MTU without a compatibility fallback', () => {
74
+ expect(
75
+ resolveProtocolV2PacketCapacity({
76
+ platform: 'ios',
77
+ iosPacketLength: 128,
78
+ mtu: 23,
79
+ })
80
+ ).toBe(20);
81
+ });
82
+
83
+ test('uses a smaller system-negotiated iOS write payload', () => {
84
+ expect(
85
+ resolveProtocolV2PacketCapacity({
86
+ platform: 'ios',
87
+ iosPacketLength: 244,
88
+ mtu: 185,
89
+ })
90
+ ).toBe(182);
91
+ });
92
+
93
+ test('uses withoutResponse for a high-volume write unless explicitly overridden', () => {
94
+ const characteristic = {
95
+ isWritableWithResponse: true,
96
+ isWritableWithoutResponse: true,
97
+ };
98
+
99
+ expect(
100
+ shouldWriteProtocolV2WithResponse({
101
+ platform: 'ios',
102
+ highThroughput: true,
103
+ requestedWithResponse: false,
104
+ characteristic,
105
+ })
106
+ ).toBe(false);
107
+ expect(
108
+ shouldWriteProtocolV2WithResponse({
109
+ platform: 'ios',
110
+ highThroughput: true,
111
+ requestedWithResponse: true,
112
+ characteristic,
113
+ })
114
+ ).toBe(true);
115
+ });
116
+
117
+ test('falls back to withResponse when withoutResponse is unavailable', () => {
118
+ expect(
119
+ shouldWriteProtocolV2WithResponse({
120
+ platform: 'ios',
121
+ highThroughput: true,
122
+ requestedWithResponse: false,
123
+ characteristic: {
124
+ isWritableWithResponse: true,
125
+ isWritableWithoutResponse: false,
126
+ },
127
+ })
128
+ ).toBe(true);
129
+ });
42
130
  });