@onekeyfe/hd-transport-react-native 1.1.26-alpha.12 → 1.1.26-alpha.30

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.
@@ -0,0 +1,14 @@
1
+ type LogMethod = (...args: unknown[]) => void;
2
+ type TransportLogger = {
3
+ debug?: LogMethod;
4
+ error?: LogMethod;
5
+ warn?: LogMethod;
6
+ };
7
+ export declare const setBleLogger: (logger?: TransportLogger) => void;
8
+ export declare const bleLogger: {
9
+ debug: (...args: unknown[]) => void | undefined;
10
+ error: (...args: unknown[]) => void | undefined;
11
+ warn: (...args: unknown[]) => void | undefined;
12
+ };
13
+ export {};
14
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;AAE9C,KAAK,eAAe,GAAG;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB,CAAC;AAIF,eAAO,MAAM,YAAY,YAAa,eAAe,SAEpD,CAAC;AAEF,eAAO,MAAM,SAAS;qBACH,OAAO,EAAE;qBACT,OAAO,EAAE;oBACV,OAAO,EAAE;CAC1B,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ProtocolType } from '@onekeyfe/hd-transport';
1
2
  export type { BleManager as BlePlxManager } from 'react-native-ble-plx';
2
3
  export type TransportOptions = {
3
4
  scanTimeout?: number;
@@ -5,5 +6,6 @@ export type TransportOptions = {
5
6
  export type BleAcquireInput = {
6
7
  uuid: string;
7
8
  forceCleanRunPromise?: boolean;
9
+ expectedProtocol?: ProtocolType;
8
10
  };
9
11
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,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;CAChC,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;CACjC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-react-native",
3
- "version": "1.1.26-alpha.12",
3
+ "version": "1.1.26-alpha.30",
4
4
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -19,11 +19,11 @@
19
19
  "lint:fix": "eslint . --fix"
20
20
  },
21
21
  "dependencies": {
22
- "@onekeyfe/hd-core": "1.1.26-alpha.12",
23
- "@onekeyfe/hd-shared": "1.1.26-alpha.12",
24
- "@onekeyfe/hd-transport": "1.1.26-alpha.12",
22
+ "@onekeyfe/hd-core": "1.1.26-alpha.30",
23
+ "@onekeyfe/hd-shared": "1.1.26-alpha.30",
24
+ "@onekeyfe/hd-transport": "1.1.26-alpha.30",
25
25
  "@onekeyfe/react-native-ble-utils": "^0.1.4",
26
26
  "react-native-ble-plx": "3.5.1"
27
27
  },
28
- "gitHead": "f9e7f7f5bdca2609e817898efd4b54c8c871bb2b"
28
+ "gitHead": "88ec305cb60347e09cf9e0c8e921d414f7fe3656"
29
29
  }
package/src/BleManager.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import BleUtils from '@onekeyfe/react-native-ble-utils';
2
2
  import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
3
- import { LoggerNames, getLogger } from '@onekeyfe/hd-core';
4
3
 
5
4
  import type { Peripheral } from '@onekeyfe/react-native-ble-utils';
6
5
 
7
- const Logger = getLogger(LoggerNames.HdBleTransport);
6
+ import { bleLogger } from './logger';
7
+
8
+ const Logger = bleLogger;
8
9
 
9
10
  /**
10
11
  * get the device basic info of connected devices
@@ -1,10 +1,11 @@
1
1
  import { BleErrorCode } from 'react-native-ble-plx';
2
- import { LoggerNames, getLogger, wait } from '@onekeyfe/hd-core';
2
+ import { wait } from '@onekeyfe/hd-shared';
3
3
 
4
4
  import type { Characteristic, Device, Subscription } from 'react-native-ble-plx';
5
- // import { wait } from '@onekeyfe/hd-core/src/utils';
6
5
 
7
- const Log = getLogger(LoggerNames.HdBleTransport);
6
+ import { bleLogger } from './logger';
7
+
8
+ const Log = bleLogger;
8
9
 
9
10
  export default class BleTransport {
10
11
  id: string;
@@ -23,6 +24,10 @@ export default class BleTransport {
23
24
 
24
25
  disconnectSubscription?: Subscription;
25
26
 
27
+ notifyTransactionId?: string;
28
+
29
+ monitorToken?: number;
30
+
26
31
  static MAX_RETRIES = 5;
27
32
 
28
33
  static RETRY_DELAY = 2000;
package/src/constants.ts CHANGED
@@ -35,9 +35,32 @@ export const getInfosForServiceUuid = (serviceUuid: string, deviceType: 'classic
35
35
  if (!services) {
36
36
  return null;
37
37
  }
38
- const service = services[serviceUuid];
38
+ const normalizedServiceUuid = normalizeBleUuid(serviceUuid);
39
+ const service =
40
+ services[serviceUuid] ??
41
+ Object.values(services).find(
42
+ item => normalizeBleUuid(item.serviceUuid) === normalizedServiceUuid
43
+ );
39
44
  if (!service) {
40
45
  return null;
41
46
  }
42
47
  return service;
43
48
  };
49
+
50
+ export const normalizeBleUuid = (uuid?: string | null) =>
51
+ (uuid ?? '').replace(/-/g, '').toLowerCase();
52
+
53
+ export const getBleUuidKey = (uuid?: string | null) => {
54
+ const normalized = normalizeBleUuid(uuid);
55
+ return normalized.length >= 8 ? normalized.substring(4, 8) : normalized;
56
+ };
57
+
58
+ export const isSameBleUuid = (left?: string | null, right?: string | null) => {
59
+ const normalizedLeft = normalizeBleUuid(left);
60
+ const normalizedRight = normalizeBleUuid(right);
61
+
62
+ return (
63
+ normalizedLeft === normalizedRight ||
64
+ (getBleUuidKey(left) !== '' && getBleUuidKey(left) === getBleUuidKey(right))
65
+ );
66
+ };