@onekeyfe/hd-transport-react-native 0.1.36 → 0.1.37

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EACL,UAAU,IAAI,aAAa,EAC3B,MAAM,EAEN,cAAc,EAEf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAiC,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAkB,QAAQ,EAA6B,MAAM,qBAAqB,CAAC;AAC1F,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AAavC,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAmBjE,MAAM,CAAC,OAAO,OAAO,uBAAuB;IAC1C,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IAEzC,SAAS,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAEnE,UAAU,UAAS;IAEnB,OAAO,UAAS;IAEhB,WAAW,SAAQ;IAEnB,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IAExC,GAAG,CAAC,EAAE,GAAG,CAAC;IAEV,OAAO,CAAC,EAAE,YAAY,CAAC;gBAEX,OAAO,EAAE,gBAAgB;IAIrC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY;IAKvC,SAAS,CAAC,UAAU,EAAE,GAAG;IAMzB,MAAM;IAIN,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;IAYjC,SAAS;IAyET,OAAO,CAAC,KAAK,EAAE,eAAe;;;IAuLpC,sBAAsB,CAAC,cAAc,EAAE,cAAc;IA4D/C,OAAO,CAAC,IAAI,EAAE,MAAM;IAcpB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE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AmFpE,IAAI;IAIJ,MAAM;CAOP"}
package/dist/index.js CHANGED
@@ -309,6 +309,10 @@ class ReactNativeBleTransport {
309
309
  this.Log.debug('first try to reconnect without params');
310
310
  device = yield blePlxManager.connectToDevice(uuid);
311
311
  }
312
+ else if (e.errorCode === reactNativeBlePlx.BleErrorCode.DeviceAlreadyConnected) {
313
+ this.Log.debug('device already connected');
314
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleAlreadyConnected);
315
+ }
312
316
  else {
313
317
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleConnectedError, (_a = e.reason) !== null && _a !== void 0 ? _a : e);
314
318
  }
@@ -368,6 +372,13 @@ class ReactNativeBleTransport {
368
372
  }
369
373
  }
370
374
  if (!infos) {
375
+ try {
376
+ this.Log.debug('cancel connection when service not found');
377
+ yield device.cancelConnection();
378
+ }
379
+ catch (e) {
380
+ this.Log.debug('cancel connection error when service not found: ', e.message || e.reason);
381
+ }
371
382
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleServiceNotFound);
372
383
  }
373
384
  const { serviceUuid, writeUuid, notifyUuid } = infos;
@@ -464,15 +475,13 @@ class ReactNativeBleTransport {
464
475
  };
465
476
  }
466
477
  release(uuid) {
467
- var _a, _b;
478
+ var _a;
468
479
  return __awaiter(this, void 0, void 0, function* () {
469
480
  const transport = transportCache[uuid];
470
481
  if (transport) {
471
482
  delete transportCache[uuid];
472
483
  (_a = transport.nofitySubscription) === null || _a === void 0 ? void 0 : _a.call(transport);
473
- if (reactNative.Platform.OS === 'android') {
474
- yield ((_b = this.blePlxManager) === null || _b === void 0 ? void 0 : _b.cancelDeviceConnection(uuid));
475
- }
484
+ if (reactNative.Platform.OS === 'android') ;
476
485
  }
477
486
  return Promise.resolve(true);
478
487
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-react-native",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -20,10 +20,10 @@
20
20
  "lint:fix": "eslint . --fix"
21
21
  },
22
22
  "dependencies": {
23
- "@onekeyfe/hd-shared": "^0.1.36",
24
- "@onekeyfe/hd-transport": "^0.1.36",
23
+ "@onekeyfe/hd-shared": "^0.1.37",
24
+ "@onekeyfe/hd-transport": "^0.1.37",
25
25
  "react-native-ble-manager": "^8.1.0",
26
26
  "react-native-ble-plx": "^2.0.3"
27
27
  },
28
- "gitHead": "46ed925a322c0717c74c6bb2e0bb5e7f5df21fcf"
28
+ "gitHead": "c7aaa0d4af5ade4c9e07229f142ed85ee14db096"
29
29
  }
package/src/index.ts CHANGED
@@ -214,6 +214,9 @@ export default class ReactNativeBleTransport {
214
214
  connectOptions = {};
215
215
  this.Log.debug('first try to reconnect without params');
216
216
  device = await blePlxManager.connectToDevice(uuid);
217
+ } else if (e.errorCode === BleErrorCode.DeviceAlreadyConnected) {
218
+ this.Log.debug('device already connected');
219
+ throw ERRORS.TypedError(HardwareErrorCode.BleAlreadyConnected);
217
220
  } else {
218
221
  throw ERRORS.TypedError(HardwareErrorCode.BleConnectedError, e.reason ?? e);
219
222
  }
@@ -281,6 +284,12 @@ export default class ReactNativeBleTransport {
281
284
  }
282
285
 
283
286
  if (!infos) {
287
+ try {
288
+ this.Log.debug('cancel connection when service not found');
289
+ await device.cancelConnection();
290
+ } catch (e) {
291
+ this.Log.debug('cancel connection error when service not found: ', e.message || e.reason);
292
+ }
284
293
  throw ERRORS.TypedError(HardwareErrorCode.BleServiceNotFound);
285
294
  }
286
295
 
@@ -412,8 +421,9 @@ export default class ReactNativeBleTransport {
412
421
  if (transport) {
413
422
  delete transportCache[uuid];
414
423
  transport.nofitySubscription?.();
424
+ // Temporary close the Android disconnect after each request
415
425
  if (Platform.OS === 'android') {
416
- await this.blePlxManager?.cancelDeviceConnection(uuid);
426
+ // await this.blePlxManager?.cancelDeviceConnection(uuid);
417
427
  }
418
428
  }
419
429