@onekeyfe/hd-transport-react-native 1.1.26 → 1.1.27-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.
- package/dist/BleManager.d.ts.map +1 -1
- package/dist/BleTransport.d.ts +2 -0
- package/dist/BleTransport.d.ts.map +1 -1
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +47 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +574 -66
- package/dist/logger.d.ts +14 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/BleManager.ts +3 -2
- package/src/BleTransport.ts +8 -3
- package/src/constants.ts +24 -1
- package/src/index.ts +679 -55
- package/src/logger.ts +19 -0
- package/src/types.ts +3 -0
- package/src/utils/validateNotify.ts +4 -4
package/dist/logger.d.ts
ADDED
|
@@ -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
|
package/dist/types.d.ts.map
CHANGED
|
@@ -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;
|
|
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.
|
|
3
|
+
"version": "1.1.27-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.
|
|
23
|
-
"@onekeyfe/hd-shared": "1.1.
|
|
24
|
-
"@onekeyfe/hd-transport": "1.1.
|
|
22
|
+
"@onekeyfe/hd-core": "1.1.27-alpha.30",
|
|
23
|
+
"@onekeyfe/hd-shared": "1.1.27-alpha.30",
|
|
24
|
+
"@onekeyfe/hd-transport": "1.1.27-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": "
|
|
28
|
+
"gitHead": "f1e3a93e766463007436eaa9aff4a271ffd8830c"
|
|
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
|
-
|
|
6
|
+
import { bleLogger } from './logger';
|
|
7
|
+
|
|
8
|
+
const Logger = bleLogger;
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* get the device basic info of connected devices
|
package/src/BleTransport.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { BleErrorCode } from 'react-native-ble-plx';
|
|
2
|
-
import {
|
|
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
|
-
|
|
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
|
|
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
|
+
};
|