@onekeyfe/hd-transport-react-native 1.2.0-alpha.32 → 1.2.0-alpha.34

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.
@@ -10,9 +10,7 @@ export default class BleTransport {
10
10
  disconnectSubscription?: Subscription;
11
11
  notifyTransactionId?: string;
12
12
  monitorToken?: number;
13
- static MAX_RETRIES: number;
14
- static RETRY_DELAY: number;
15
13
  constructor(device: Device, writeCharacteristic: Characteristic, notifyCharacteristic: Characteristic);
16
- writeWithRetry(data: string, retryCount?: number): Promise<void>;
14
+ writeWithRetry(data: string): Promise<void>;
17
15
  }
18
16
  //# sourceMappingURL=BleTransport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BleTransport.d.ts","sourceRoot":"","sources":["../src/BleTransport.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIjF,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;IAEtB,MAAM,CAAC,WAAW,SAAK;IAEvB,MAAM,CAAC,WAAW,SAAQ;gBAGxB,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,cAAc,EACnC,oBAAoB,EAAE,cAAc;IAchC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,SAA2B,GAAG,OAAO,CAAC,IAAI,CAAC;CA2BzF"}
1
+ {"version":3,"file":"BleTransport.d.ts","sourceRoot":"","sources":["../src/BleTransport.ts"],"names":[],"mappings":"AAAA,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;CAGlD"}
@@ -8,6 +8,5 @@ export declare const getInfosForServiceUuid: (serviceUuid: string, deviceType: '
8
8
  notifyUuid?: string | undefined;
9
9
  } | null;
10
10
  export declare const normalizeBleUuid: (uuid?: string | null) => string;
11
- export declare const getBleUuidKey: (uuid?: string | null) => string;
12
11
  export declare const isSameBleUuid: (left?: string | null, right?: string | null) => boolean;
13
12
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAoCtC,eAAO,MAAM,wBAAwB,gBAA0B,CAAC;AAChE,eAAO,MAAM,sBAAsB,gBAAiB,MAAM,cAAc,SAAS;iBAhChE,MAAM;;;QAiDtB,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAAW,MAAM,GAAG,IAAI,WACP,CAAC;AAE/C,eAAO,MAAM,aAAa,UAAW,MAAM,GAAG,IAAI,WAGjD,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,MAAM,GAAG,IAAI,UAAU,MAAM,GAAG,IAAI,YAQxE,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,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"}
package/dist/index.d.ts CHANGED
@@ -15,16 +15,8 @@ declare class BleTransport {
15
15
  disconnectSubscription?: Subscription;
16
16
  notifyTransactionId?: string;
17
17
  monitorToken?: number;
18
- static MAX_RETRIES: number;
19
- static RETRY_DELAY: number;
20
18
  constructor(device: Device, writeCharacteristic: Characteristic, notifyCharacteristic: Characteristic);
21
- /**
22
- * @description only for pro / touch , while upgrade firmware
23
- * @param data
24
- * @param retryCount
25
- * @returns
26
- */
27
- writeWithRetry(data: string, retryCount?: number): Promise<void>;
19
+ writeWithRetry(data: string): Promise<void>;
28
20
  }
29
21
 
30
22
  type TransportOptions = {
@@ -34,12 +26,15 @@ type BleAcquireInput = {
34
26
  uuid: string;
35
27
  forceCleanRunPromise?: boolean;
36
28
  expectedProtocol?: ProtocolType;
29
+ protocolHint?: ProtocolType;
37
30
  };
38
31
 
32
+ type FirmwareUploadWriteRetryType = 'congested';
39
33
  type ResolvedBleCharacteristics = {
40
34
  writeCharacteristic: Characteristic;
41
35
  notifyCharacteristic: Characteristic;
42
36
  };
37
+ declare const getFirmwareUploadWriteRetryType: (error: unknown) => FirmwareUploadWriteRetryType | null;
43
38
  type ProtocolV2BleTuning = {
44
39
  iosPacketLength?: number;
45
40
  androidPacketLength?: number;
@@ -61,6 +56,7 @@ declare class ReactNativeBleTransport {
61
56
  stopped: boolean;
62
57
  scanTimeout: number;
63
58
  runPromise: Deferred<any> | null;
59
+ private runPromiseDeviceId;
64
60
  emitter?: EventEmitter;
65
61
  firmwareUploadWriteRecoveryIds: Set<string>;
66
62
  /** Per-device protocol type detected by active wire-level probe after connect. */
@@ -113,7 +109,6 @@ declare class ReactNativeBleTransport {
113
109
  private handleProtocolV2Notification;
114
110
  private getProtocolV2FrameQueue;
115
111
  private resolveProtocolV2Frame;
116
- private rejectAllProtocolV2Frames;
117
112
  private resetProtocolV2Frames;
118
113
  private rejectProtocolV2Frames;
119
114
  private readProtocolV2Frame;
@@ -124,4 +119,4 @@ declare class ReactNativeBleTransport {
124
119
  getProtocolType(path: string): ProtocolType | undefined;
125
120
  }
126
121
 
127
- export { IOneKeyDevice, ProtocolV2BleTuning, configureProtocolV2BleTuning, ReactNativeBleTransport as default, getProtocolV2BleTuning, resetProtocolV2BleTuning };
122
+ export { IOneKeyDevice, ProtocolV2BleTuning, configureProtocolV2BleTuning, ReactNativeBleTransport as default, getFirmwareUploadWriteRetryType, getProtocolV2BleTuning, resetProtocolV2BleTuning };
@@ -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;AAehC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAK1C,OAAO,K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B;IAS/B,OAAO,CAAC,sBAAsB;IAU9B,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,sBAAsB;YAShB,mBAAmB;YAiBnB,qBAAqB;YAmCrB,oBAAoB;YAiCpB,cAAc;IAoC5B,OAAO,CAAC,uBAAuB;IA4C/B,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;CAGxD"}
package/dist/index.js CHANGED
@@ -95,7 +95,6 @@ const IOS_PACKET_LENGTH = 128;
95
95
  const ANDROID_PACKET_LENGTH = 192;
96
96
  const ANDROID_DEFAULT_MTU = 23;
97
97
  const ClassicServiceUUID = '00000001-0000-1000-8000-00805f9b34fb';
98
- const Pro2ServiceUUID = 'fffd';
99
98
  const OneKeyServices = {
100
99
  classic: {
101
100
  [ClassicServiceUUID]: {
@@ -103,11 +102,6 @@ const OneKeyServices = {
103
102
  writeUuid: '00000002-0000-1000-8000-00805f9b34fb',
104
103
  notifyUuid: '00000003-0000-1000-8000-00805f9b34fb',
105
104
  },
106
- [Pro2ServiceUUID]: {
107
- serviceUuid: Pro2ServiceUUID,
108
- writeUuid: '00000002-0000-1000-8000-00805f9b34fb',
109
- notifyUuid: '00000003-0000-1000-8000-00805f9b34fb',
110
- },
111
105
  },
112
106
  };
113
107
  const bluetoothServices = [];
@@ -124,22 +118,17 @@ const getInfosForServiceUuid = (serviceUuid, deviceType) => {
124
118
  }
125
119
  const normalizedServiceUuid = normalizeBleUuid(serviceUuid);
126
120
  const service = (_a = services[serviceUuid]) !== null && _a !== void 0 ? _a : Object.values(services).find(item => normalizeBleUuid(item.serviceUuid) === normalizedServiceUuid ||
127
- getBleUuidKey(item.serviceUuid) === getBleUuidKey(serviceUuid));
121
+ hdShared.matchesKnownBleUuid(serviceUuid, hdShared.createKnownBleUuidAliases(item.serviceUuid)));
128
122
  if (!service) {
129
123
  return null;
130
124
  }
131
125
  return service;
132
126
  };
133
127
  const normalizeBleUuid = (uuid) => (uuid !== null && uuid !== void 0 ? uuid : '').replace(/-/g, '').toLowerCase();
134
- const getBleUuidKey = (uuid) => {
135
- const normalized = normalizeBleUuid(uuid);
136
- return normalized.length >= 8 ? normalized.substring(4, 8) : normalized;
137
- };
138
128
  const isSameBleUuid = (left, right) => {
139
- const normalizedLeft = normalizeBleUuid(left);
140
- const normalizedRight = normalizeBleUuid(right);
141
- return (normalizedLeft === normalizedRight ||
142
- (getBleUuidKey(left) !== '' && getBleUuidKey(left) === getBleUuidKey(right)));
129
+ if (!left || !right)
130
+ return false;
131
+ return hdShared.matchesKnownBleUuid(left, hdShared.createKnownBleUuidAliases(right));
143
132
  };
144
133
 
145
134
  function hasWritableCapability(characteristic) {
@@ -210,7 +199,6 @@ const isHeaderChunk = (chunk) => {
210
199
  return false;
211
200
  };
212
201
 
213
- const Log$1 = bleLogger;
214
202
  class BleTransport {
215
203
  constructor(device, writeCharacteristic, notifyCharacteristic) {
216
204
  this.name = 'ReactNativeBleTransport';
@@ -220,37 +208,12 @@ class BleTransport {
220
208
  this.writeCharacteristic = writeCharacteristic;
221
209
  this.notifyCharacteristic = notifyCharacteristic;
222
210
  }
223
- writeWithRetry(data, retryCount = BleTransport.MAX_RETRIES) {
211
+ writeWithRetry(data) {
224
212
  return __awaiter(this, void 0, void 0, function* () {
225
- try {
226
- yield this.writeCharacteristic.writeWithoutResponse(data);
227
- }
228
- catch (error) {
229
- Log$1 === null || Log$1 === void 0 ? void 0 : Log$1.debug(`Write retry attempt ${BleTransport.MAX_RETRIES - retryCount + 1}, error: ${error}`);
230
- if (retryCount > 0) {
231
- yield hdShared.wait(BleTransport.RETRY_DELAY);
232
- if (error.errorCode === reactNativeBlePlx.BleErrorCode.DeviceDisconnected ||
233
- error.errorCode === reactNativeBlePlx.BleErrorCode.CharacteristicNotFound) {
234
- try {
235
- yield this.device.connect();
236
- yield this.device.discoverAllServicesAndCharacteristics();
237
- }
238
- catch (e) {
239
- Log$1 === null || Log$1 === void 0 ? void 0 : Log$1.debug(`Connect or discoverAllServicesAndCharacteristics error: ${e}`);
240
- }
241
- }
242
- else {
243
- Log$1 === null || Log$1 === void 0 ? void 0 : Log$1.debug(`writeCharacteristic error: ${error}`);
244
- }
245
- return this.writeWithRetry(data, retryCount - 1);
246
- }
247
- throw error;
248
- }
213
+ yield this.writeCharacteristic.writeWithoutResponse(data);
249
214
  });
250
215
  }
251
216
  }
252
- BleTransport.MAX_RETRIES = 5;
253
- BleTransport.RETRY_DELAY = 2000;
254
217
 
255
218
  function createTransportCallLog(name, protocol, data) {
256
219
  if (name === 'ResourceUpdate' || name === 'ResourceAck') {
@@ -271,7 +234,6 @@ const FIRMWARE_UPLOAD_WRITE_BURST_SIZE = reactNative.Platform.OS === 'ios' ? 4 :
271
234
  const FIRMWARE_UPLOAD_WRITE_PAUSE_MS = reactNative.Platform.OS === 'ios' ? 8 : 10;
272
235
  const FIRMWARE_UPLOAD_WRITE_FLUSH_DELAY_MS = reactNative.Platform.OS === 'ios' ? 24 : 30;
273
236
  const FIRMWARE_UPLOAD_WRITE_MAX_RETRIES = 8;
274
- const FIRMWARE_UPLOAD_RECONNECT_RETRY_DELAY_MS = 2000;
275
237
  const ANDROID_FIRMWARE_UPLOAD_PACKET_LENGTH = 192;
276
238
  const FIRMWARE_UPLOAD_WRITE_PACKET_CAPACITY = reactNative.Platform.OS === 'ios' ? IOS_PACKET_LENGTH : ANDROID_FIRMWARE_UPLOAD_PACKET_LENGTH;
277
239
  const ANDROID_GATT_CONGESTED_STATUS = 143;
@@ -282,10 +244,6 @@ const getFirmwareUploadWriteRetryType = (error) => {
282
244
  if (!error || typeof error !== 'object')
283
245
  return null;
284
246
  const bleWriteError = error;
285
- if (bleWriteError.errorCode === reactNativeBlePlx.BleErrorCode.DeviceDisconnected ||
286
- bleWriteError.errorCode === reactNativeBlePlx.BleErrorCode.CharacteristicNotFound) {
287
- return 'reconnectable';
288
- }
289
247
  if (bleWriteError.androidErrorCode === ANDROID_GATT_CONGESTED_STATUS ||
290
248
  bleWriteError.status === ANDROID_GATT_CONGESTED_STATUS) {
291
249
  return 'congested';
@@ -332,13 +290,6 @@ function inferProtocolHintFromDeviceName(name) {
332
290
  function getDeviceDisplayName(device) {
333
291
  return (device === null || device === void 0 ? void 0 : device.name) || (device === null || device === void 0 ? void 0 : device.localName) || null;
334
292
  }
335
- function isGenericBleService(uuid) {
336
- return ['1800', '1801', '180a'].includes(getBleUuidKey(uuid));
337
- }
338
- function hasKnownOneKeyService(device) {
339
- var _a;
340
- return ((_a = device === null || device === void 0 ? void 0 : device.serviceUUIDs) !== null && _a !== void 0 ? _a : []).some(serviceUuid => getInfosForServiceUuid(serviceUuid, 'classic'));
341
- }
342
293
  const ANDROID_REQUEST_MTU = 256;
343
294
  const connectOptions = {
344
295
  requestMTU: ANDROID_REQUEST_MTU,
@@ -399,6 +350,7 @@ class ReactNativeBleTransport {
399
350
  this.stopped = false;
400
351
  this.scanTimeout = DEVICE_SCAN_TIMEOUT_MS;
401
352
  this.runPromise = null;
353
+ this.runPromiseDeviceId = null;
402
354
  this.firmwareUploadWriteRecoveryIds = new Set();
403
355
  this.deviceProtocol = new Map();
404
356
  this.deviceProtocolHints = new Map();
@@ -463,7 +415,6 @@ class ReactNativeBleTransport {
463
415
  return Promise.resolve(this.blePlxManager);
464
416
  }
465
417
  resolveCharacteristics(device) {
466
- var _a, _b, _c, _d;
467
418
  return __awaiter(this, void 0, void 0, function* () {
468
419
  yield device.discoverAllServicesAndCharacteristics();
469
420
  let infos = tryToGetConfiguration(device);
@@ -480,19 +431,11 @@ class ReactNativeBleTransport {
480
431
  }
481
432
  }
482
433
  }
483
- let fallbackServiceUuid;
484
434
  if (!infos) {
485
435
  const services = yield device.services();
486
436
  Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Known OneKey service UUID not found, discovered services:', services === null || services === void 0 ? void 0 : services.map(service => service.uuid));
487
- const knownService = services.find(service => getInfosForServiceUuid(service.uuid, 'classic'));
488
- const fallbackService = (_a = knownService !== null && knownService !== void 0 ? knownService : services.find(service => !isGenericBleService(service.uuid))) !== null && _a !== void 0 ? _a : services[0];
489
- if (fallbackService) {
490
- fallbackServiceUuid = fallbackService.uuid;
491
- characteristics = yield device.characteristicsForService(fallbackService.uuid);
492
- Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Using fallback BLE service:', fallbackService.uuid);
493
- }
494
437
  }
495
- if (!infos && !fallbackServiceUuid) {
438
+ if (!infos) {
496
439
  try {
497
440
  Log === null || Log === void 0 ? void 0 : Log.debug('cancel connection when service not found');
498
441
  yield device.cancelConnection();
@@ -502,9 +445,7 @@ class ReactNativeBleTransport {
502
445
  }
503
446
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleServiceNotFound);
504
447
  }
505
- const serviceUuid = (_b = infos === null || infos === void 0 ? void 0 : infos.serviceUuid) !== null && _b !== void 0 ? _b : fallbackServiceUuid;
506
- const writeUuid = (_c = infos === null || infos === void 0 ? void 0 : infos.writeUuid) !== null && _c !== void 0 ? _c : '00000002-0000-1000-8000-00805f9b34fb';
507
- const notifyUuid = (_d = infos === null || infos === void 0 ? void 0 : infos.notifyUuid) !== null && _d !== void 0 ? _d : '00000003-0000-1000-8000-00805f9b34fb';
448
+ const { serviceUuid, writeUuid, notifyUuid } = infos;
508
449
  if (!serviceUuid) {
509
450
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleServiceNotFound);
510
451
  }
@@ -562,10 +503,9 @@ class ReactNativeBleTransport {
562
503
  try {
563
504
  Log === null || Log === void 0 ? void 0 : Log.debug('device disconnect: ', device === null || device === void 0 ? void 0 : device.id);
564
505
  this.emitDeviceDisconnect(uuid, device === null || device === void 0 ? void 0 : device.name, monitorToken);
565
- if (this.runPromise) {
506
+ if (this.runPromise && this.runPromiseDeviceId === uuid) {
566
507
  const error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleConnectedError);
567
508
  this.runPromise.reject(error);
568
- this.rejectAllProtocolV2Frames(error);
569
509
  }
570
510
  }
571
511
  catch (e) {
@@ -665,7 +605,7 @@ class ReactNativeBleTransport {
665
605
  allowDuplicates: true,
666
606
  scanMode: reactNativeBlePlx.ScanMode.LowLatency,
667
607
  }, (error, device) => {
668
- var _a, _b, _c;
608
+ var _a;
669
609
  if (error) {
670
610
  Log === null || Log === void 0 ? void 0 : Log.debug('ble scan error: ', error);
671
611
  if ([reactNativeBlePlx.BleErrorCode.BluetoothPoweredOff, reactNativeBlePlx.BleErrorCode.BluetoothInUnknownState].includes(error.errorCode)) {
@@ -686,9 +626,12 @@ class ReactNativeBleTransport {
686
626
  return;
687
627
  }
688
628
  const displayName = getDeviceDisplayName(device);
689
- const isOneKey = hdShared.isOnekeyDevice((_b = device === null || device === void 0 ? void 0 : device.name) !== null && _b !== void 0 ? _b : null, device === null || device === void 0 ? void 0 : device.id) ||
690
- hdShared.isOnekeyDevice((_c = device === null || device === void 0 ? void 0 : device.localName) !== null && _c !== void 0 ? _c : null, device === null || device === void 0 ? void 0 : device.id) ||
691
- hasKnownOneKeyService(device);
629
+ const isOneKey = hdShared.isOnekeyBluetoothDevice({
630
+ id: device === null || device === void 0 ? void 0 : device.id,
631
+ name: device === null || device === void 0 ? void 0 : device.name,
632
+ localName: device === null || device === void 0 ? void 0 : device.localName,
633
+ serviceUuids: device === null || device === void 0 ? void 0 : device.serviceUUIDs,
634
+ });
692
635
  if (isOneKey) {
693
636
  addDevice(device);
694
637
  }
@@ -703,10 +646,15 @@ class ReactNativeBleTransport {
703
646
  });
704
647
  getConnectedDeviceIds(reactNative.Platform.OS === 'ios' ? getBluetoothServiceUuids() : []).then(devices => {
705
648
  for (const device of devices) {
706
- const { serviceUUIDs } = device;
707
- const hasCachedServiceUuid = Boolean(serviceUUIDs === null || serviceUUIDs === void 0 ? void 0 : serviceUUIDs.length);
708
- const keepDevice = reactNative.Platform.OS === 'ios' || hasCachedServiceUuid;
709
- if (keepDevice) {
649
+ const localName = 'localName' in device && typeof device.localName === 'string'
650
+ ? device.localName
651
+ : null;
652
+ if (hdShared.isOnekeyBluetoothDevice({
653
+ id: device.id,
654
+ name: device.name,
655
+ localName,
656
+ serviceUuids: device.serviceUUIDs,
657
+ })) {
710
658
  Log === null || Log === void 0 ? void 0 : Log.debug('search connected peripheral: ', device.id);
711
659
  addDevice(device);
712
660
  }
@@ -737,7 +685,7 @@ class ReactNativeBleTransport {
737
685
  });
738
686
  }
739
687
  acquire(input) {
740
- var _a;
688
+ var _a, _b;
741
689
  return __awaiter(this, void 0, void 0, function* () {
742
690
  const { uuid, forceCleanRunPromise, expectedProtocol } = input;
743
691
  if (!uuid) {
@@ -760,8 +708,8 @@ class ReactNativeBleTransport {
760
708
  if (forceCleanRunPromise && this.runPromise) {
761
709
  const error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleForceCleanRunPromise);
762
710
  this.runPromise.reject(error);
763
- this.rejectAllProtocolV2Frames(error);
764
711
  this.runPromise = null;
712
+ this.runPromiseDeviceId = null;
765
713
  Log === null || Log === void 0 ? void 0 : Log.debug('Force clean Bluetooth run promise, forceCleanRunPromise: ', forceCleanRunPromise);
766
714
  }
767
715
  const blePlxManager = yield this.getPlxManager();
@@ -846,7 +794,7 @@ class ReactNativeBleTransport {
846
794
  const { writeCharacteristic, notifyCharacteristic } = yield this.resolveCharacteristics(device);
847
795
  const protocolHint = expectedProtocol
848
796
  ? undefined
849
- : (_a = this.deviceProtocolHints.get(uuid)) !== null && _a !== void 0 ? _a : inferProtocolHintFromDeviceName(getDeviceDisplayName(device));
797
+ : (_b = (_a = input.protocolHint) !== null && _a !== void 0 ? _a : this.deviceProtocolHints.get(uuid)) !== null && _b !== void 0 ? _b : inferProtocolHintFromDeviceName(getDeviceDisplayName(device));
850
798
  yield this.release(uuid, true);
851
799
  if (protocolHint) {
852
800
  this.deviceProtocolHints.set(uuid, protocolHint);
@@ -911,7 +859,7 @@ class ReactNativeBleTransport {
911
859
  this.rejectProtocolV2Frames(uuid, hdShared.ERRORS.TypedError(errorCode));
912
860
  return;
913
861
  }
914
- if (this.runPromise) {
862
+ if (this.runPromise && this.runPromiseDeviceId === uuid) {
915
863
  let ERROR = hdShared.HardwareErrorCode.BleCharacteristicNotifyError;
916
864
  if ((_h = error.reason) === null || _h === void 0 ? void 0 : _h.includes('The connection has timed out unexpectedly')) {
917
865
  ERROR = hdShared.HardwareErrorCode.BleTimeoutError;
@@ -926,13 +874,11 @@ class ReactNativeBleTransport {
926
874
  ((_p = error.reason) === null || _p === void 0 ? void 0 : _p.includes('notify change failed for device'))) {
927
875
  const notifyError = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleCharacteristicNotifyChangeFailure);
928
876
  this.runPromise.reject(notifyError);
929
- this.rejectAllProtocolV2Frames(notifyError);
930
877
  Log === null || Log === void 0 ? void 0 : Log.debug(`${hdShared.HardwareErrorCode.BleCharacteristicNotifyChangeFailure} ${error.message} ${error.reason}`);
931
878
  return;
932
879
  }
933
880
  const notifyError = hdShared.ERRORS.TypedError(ERROR);
934
881
  this.runPromise.reject(notifyError);
935
- this.rejectAllProtocolV2Frames(notifyError);
936
882
  Log === null || Log === void 0 ? void 0 : Log.debug(': monitor notify error, and has unreleased Promise', Error);
937
883
  }
938
884
  return;
@@ -966,7 +912,9 @@ class ReactNativeBleTransport {
966
912
  const value = buffer.Buffer.from(buffer$1);
967
913
  bufferLength = 0;
968
914
  buffer$1 = [];
969
- (_q = this.runPromise) === null || _q === void 0 ? void 0 : _q.resolve(value.toString('hex'));
915
+ if (this.runPromiseDeviceId === uuid) {
916
+ (_q = this.runPromise) === null || _q === void 0 ? void 0 : _q.resolve(value.toString('hex'));
917
+ }
970
918
  }
971
919
  }
972
920
  catch (error) {
@@ -975,7 +923,7 @@ class ReactNativeBleTransport {
975
923
  if (this.deviceProtocol.get(uuid) === 'V2') {
976
924
  this.rejectProtocolV2Frames(uuid, notifyError);
977
925
  }
978
- else {
926
+ else if (this.runPromiseDeviceId === uuid) {
979
927
  (_r = this.runPromise) === null || _r === void 0 ? void 0 : _r.reject(notifyError);
980
928
  }
981
929
  }
@@ -992,11 +940,12 @@ class ReactNativeBleTransport {
992
940
  var _a, _b, _c, _d, _e, _f, _g;
993
941
  return __awaiter(this, void 0, void 0, function* () {
994
942
  const transport = transportCache[uuid];
995
- if (this.runPromise) {
943
+ if (this.runPromise && this.runPromiseDeviceId === uuid) {
996
944
  const error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleForceCleanRunPromise);
997
945
  this.runPromise.reject(error);
998
946
  this.runPromise = null;
999
- this.rejectAllProtocolV2Frames(error);
947
+ this.runPromiseDeviceId = null;
948
+ this.rejectProtocolV2Frames(uuid, error);
1000
949
  }
1001
950
  else {
1002
951
  this.resetProtocolV2Frames(uuid);
@@ -1076,6 +1025,7 @@ class ReactNativeBleTransport {
1076
1025
  const runPromise = hdShared.createDeferred();
1077
1026
  runPromise.promise.catch(() => undefined);
1078
1027
  this.runPromise = runPromise;
1028
+ this.runPromiseDeviceId = uuid;
1079
1029
  const messages = this._messages;
1080
1030
  const buffers = ProtocolV1.encodeTransportPackets(messages, name, data);
1081
1031
  let timeout;
@@ -1158,32 +1108,14 @@ class ReactNativeBleTransport {
1158
1108
  if (!retryType || attempt >= FIRMWARE_UPLOAD_WRITE_MAX_RETRIES) {
1159
1109
  throw error;
1160
1110
  }
1161
- const shouldReconnect = retryType === 'reconnectable';
1162
- const delayMs = shouldReconnect
1163
- ? FIRMWARE_UPLOAD_RECONNECT_RETRY_DELAY_MS
1164
- : resolveFirmwareUploadRetryDelay(attempt);
1111
+ const delayMs = resolveFirmwareUploadRetryDelay(attempt);
1165
1112
  Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] FirmwareUpload write retry:', {
1166
1113
  attempt: attempt + 1,
1167
1114
  delayMs,
1168
- reconnect: shouldReconnect,
1169
1115
  error,
1170
1116
  });
1171
- if (shouldReconnect) {
1172
- this.firmwareUploadWriteRecoveryIds.add(uuid);
1173
- }
1174
1117
  yield delay(delayMs);
1175
1118
  attempt += 1;
1176
- if (shouldReconnect) {
1177
- try {
1178
- yield this.reconnectFirmwareUploadTransport(uuid, transport);
1179
- }
1180
- catch (e) {
1181
- Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] FirmwareUpload reconnect error:', e);
1182
- if (attempt >= FIRMWARE_UPLOAD_WRITE_MAX_RETRIES) {
1183
- throw e;
1184
- }
1185
- }
1186
- }
1187
1119
  }
1188
1120
  }
1189
1121
  }), e => {
@@ -1232,12 +1164,17 @@ class ReactNativeBleTransport {
1232
1164
  return check.call(jsonData);
1233
1165
  }
1234
1166
  catch (e) {
1235
- if (name === 'Initialize' && (options === null || options === void 0 ? void 0 : options.timeoutMs) === PROTOCOL_PROBE_TIMEOUT_MS) {
1236
- Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Protocol V1 Initialize probe call failed:', e);
1167
+ if (name === 'GetFeatures' && (options === null || options === void 0 ? void 0 : options.timeoutMs) === PROTOCOL_PROBE_TIMEOUT_MS) {
1168
+ Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Protocol V1 GetFeatures probe call failed:', e);
1237
1169
  }
1238
1170
  else {
1239
1171
  Log === null || Log === void 0 ? void 0 : Log.error('call error: ', e);
1240
1172
  }
1173
+ const isProbeTimeout = name === 'GetFeatures' && (options === null || options === void 0 ? void 0 : options.timeoutMs) === PROTOCOL_PROBE_TIMEOUT_MS;
1174
+ if (!isProbeTimeout &&
1175
+ (e === null || e === void 0 ? void 0 : e.errorCode) === hdShared.HardwareErrorCode.BleTimeoutError) {
1176
+ yield this.disconnect(uuid);
1177
+ }
1241
1178
  throw e;
1242
1179
  }
1243
1180
  finally {
@@ -1245,6 +1182,7 @@ class ReactNativeBleTransport {
1245
1182
  clearTimeout(timeout);
1246
1183
  if (this.runPromise === runPromise) {
1247
1184
  this.runPromise = null;
1185
+ this.runPromiseDeviceId = null;
1248
1186
  }
1249
1187
  }
1250
1188
  });
@@ -1323,6 +1261,7 @@ class ReactNativeBleTransport {
1323
1261
  Log === null || Log === void 0 ? void 0 : Log.debug('transport-react-native transport cancel');
1324
1262
  if (this.runPromise) ;
1325
1263
  this.runPromise = null;
1264
+ this.runPromiseDeviceId = null;
1326
1265
  }
1327
1266
  getCachedTransport(uuid) {
1328
1267
  const transport = transportCache[uuid];
@@ -1335,7 +1274,7 @@ class ReactNativeBleTransport {
1335
1274
  return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Device protocol mismatch: expected ${expected}, but device did not respond to expected protocol`);
1336
1275
  }
1337
1276
  createProtocolDetectionError() {
1338
- return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleTimeoutError, 'Unable to detect BLE protocol: device did not respond to Protocol V1 Initialize or Protocol V2 Ping');
1277
+ return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleTimeoutError, 'Unable to detect BLE protocol: device did not respond to Protocol V1 GetFeatures or Protocol V2 Ping');
1339
1278
  }
1340
1279
  clearProbeProtocol(uuid, protocol) {
1341
1280
  if (this.deviceProtocol.get(uuid) === protocol) {
@@ -1373,6 +1312,13 @@ class ReactNativeBleTransport {
1373
1312
  const protocol = probeOrder[i];
1374
1313
  if (i > 0) {
1375
1314
  yield this.resetProbeStateAfterProtocolProbe(uuid, probeOrder[i - 1]);
1315
+ if (!transportCache[uuid]) {
1316
+ const reacquired = yield this.acquire({
1317
+ uuid,
1318
+ expectedProtocol: protocol,
1319
+ });
1320
+ return reacquired.protocolType;
1321
+ }
1376
1322
  }
1377
1323
  const detected = protocol === 'V1' ? yield this.probeProtocolV1(uuid) : yield this.probeProtocolV2(uuid);
1378
1324
  if (detected) {
@@ -1438,12 +1384,12 @@ class ReactNativeBleTransport {
1438
1384
  }
1439
1385
  try {
1440
1386
  this.deviceProtocol.set(uuid, 'V1');
1441
- yield this.callProtocolV1(uuid, 'Initialize', {}, { timeoutMs: PROTOCOL_PROBE_TIMEOUT_MS });
1387
+ yield this.callProtocolV1(uuid, 'GetFeatures', {}, { timeoutMs: PROTOCOL_PROBE_TIMEOUT_MS });
1442
1388
  return true;
1443
1389
  }
1444
1390
  catch (error) {
1445
1391
  this.clearProbeProtocol(uuid, 'V1');
1446
- Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Protocol V1 Initialize probe failed:', error);
1392
+ Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] Protocol V1 GetFeatures probe failed:', error);
1447
1393
  return false;
1448
1394
  }
1449
1395
  });
@@ -1512,16 +1458,8 @@ class ReactNativeBleTransport {
1512
1458
  }
1513
1459
  this.getProtocolV2FrameQueue(uuid).push(frame);
1514
1460
  }
1515
- rejectAllProtocolV2Frames(error) {
1516
- this.protocolV2FrameQueues.clear();
1517
- for (const framePromise of this.protocolV2FramePromises.values()) {
1518
- framePromise.reject(error);
1519
- }
1520
- this.protocolV2FramePromises.clear();
1521
- }
1522
1461
  resetProtocolV2Frames(uuid) {
1523
- this.protocolV2FrameQueues.delete(uuid);
1524
- this.protocolV2FramePromises.delete(uuid);
1462
+ this.rejectProtocolV2Frames(uuid, new Error(`Protocol V2 frame state reset for ${uuid}`));
1525
1463
  }
1526
1464
  rejectProtocolV2Frames(uuid, error) {
1527
1465
  this.protocolV2FrameQueues.delete(uuid);
@@ -1674,5 +1612,6 @@ class ReactNativeBleTransport {
1674
1612
 
1675
1613
  exports.configureProtocolV2BleTuning = configureProtocolV2BleTuning;
1676
1614
  exports["default"] = ReactNativeBleTransport;
1615
+ exports.getFirmwareUploadWriteRetryType = getFirmwareUploadWriteRetryType;
1677
1616
  exports.getProtocolV2BleTuning = getProtocolV2BleTuning;
1678
1617
  exports.resetProtocolV2BleTuning = resetProtocolV2BleTuning;
package/dist/types.d.ts CHANGED
@@ -7,5 +7,6 @@ export type BleAcquireInput = {
7
7
  uuid: string;
8
8
  forceCleanRunPromise?: boolean;
9
9
  expectedProtocol?: ProtocolType;
10
+ protocolHint?: ProtocolType;
10
11
  };
11
12
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,YAAY,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAExE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,gBAAgB,CAAC,EAAE,YAAY,CAAC;CACjC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,YAAY,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAExE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,gBAAgB,CAAC,EAAE,YAAY,CAAC;IAChC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-react-native",
3
- "version": "1.2.0-alpha.32",
3
+ "version": "1.2.0-alpha.34",
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.32",
24
- "@onekeyfe/hd-shared": "1.2.0-alpha.32",
25
- "@onekeyfe/hd-transport": "1.2.0-alpha.32",
23
+ "@onekeyfe/hd-core": "1.2.0-alpha.34",
24
+ "@onekeyfe/hd-shared": "1.2.0-alpha.34",
25
+ "@onekeyfe/hd-transport": "1.2.0-alpha.34",
26
26
  "@onekeyfe/react-native-ble-utils": "^0.1.6",
27
27
  "react-native-ble-plx": "3.5.1"
28
28
  },
29
- "gitHead": "468888b93df8b147a512f63a8cbdc40ca1c5c1cf"
29
+ "gitHead": "07f10b4c9fab177da7c36d976ec18b075492b57f"
30
30
  }
@@ -1,12 +1,5 @@
1
- import { BleErrorCode } from 'react-native-ble-plx';
2
- import { wait } from '@onekeyfe/hd-shared';
3
-
4
- import { bleLogger } from './logger';
5
-
6
1
  import type { Characteristic, Device, Subscription } from 'react-native-ble-plx';
7
2
 
8
- const Log = bleLogger;
9
-
10
3
  export default class BleTransport {
11
4
  id: string;
12
5
 
@@ -28,10 +21,6 @@ export default class BleTransport {
28
21
 
29
22
  monitorToken?: number;
30
23
 
31
- static MAX_RETRIES = 5;
32
-
33
- static RETRY_DELAY = 2000;
34
-
35
24
  constructor(
36
25
  device: Device,
37
26
  writeCharacteristic: Characteristic,
@@ -43,37 +32,7 @@ export default class BleTransport {
43
32
  this.notifyCharacteristic = notifyCharacteristic;
44
33
  }
45
34
 
46
- /**
47
- * @description only for pro / touch , while upgrade firmware
48
- * @param data
49
- * @param retryCount
50
- * @returns
51
- */
52
- async writeWithRetry(data: string, retryCount = BleTransport.MAX_RETRIES): Promise<void> {
53
- try {
54
- await this.writeCharacteristic.writeWithoutResponse(data);
55
- } catch (error) {
56
- Log?.debug(
57
- `Write retry attempt ${BleTransport.MAX_RETRIES - retryCount + 1}, error: ${error}`
58
- );
59
- if (retryCount > 0) {
60
- await wait(BleTransport.RETRY_DELAY);
61
- if (
62
- error.errorCode === BleErrorCode.DeviceDisconnected ||
63
- error.errorCode === BleErrorCode.CharacteristicNotFound
64
- ) {
65
- try {
66
- await this.device.connect();
67
- await this.device.discoverAllServicesAndCharacteristics();
68
- } catch (e) {
69
- Log?.debug(`Connect or discoverAllServicesAndCharacteristics error: ${e}`);
70
- }
71
- } else {
72
- Log?.debug(`writeCharacteristic error: ${error}`);
73
- }
74
- return this.writeWithRetry(data, retryCount - 1);
75
- }
76
- throw error;
77
- }
35
+ async writeWithRetry(data: string): Promise<void> {
36
+ await this.writeCharacteristic.writeWithoutResponse(data);
78
37
  }
79
38
  }