@onekeyfe/hd-transport-react-native 1.1.11-alpha.1 → 1.1.11-alpha.2
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/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- package/package.json +5 -5
- package/src/index.ts +16 -4
package/dist/index.d.ts.map
CHANGED
|
@@ -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,EAIf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAkD,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAEL,QAAQ,EAIT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EACL,UAAU,IAAI,aAAa,EAC3B,MAAM,EAEN,cAAc,EAIf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAkD,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAEL,QAAQ,EAIT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AAiBvC,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAoDjE,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,IAAI,SAA6B;IAEjC,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;IAWjC,SAAS;IA6FT,OAAO,CAAC,KAAK,EAAE,eAAe;;;IAyNpC,sBAAsB,CAAC,cAAc,EAAE,cAAc;IAkF/C,OAAO,CAAC,IAAI,EAAE,MAAM;IAepB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIjE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IA2HpE,IAAI;IAIJ,MAAM;CAOP"}
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
47
47
|
|
|
48
48
|
const Logger = hdCore.getLogger(hdCore.LoggerNames.HdBleTransport);
|
|
49
49
|
const getConnectedDeviceIds = (serviceUuids) => BleUtils__default["default"].getConnectedPeripherals(serviceUuids);
|
|
50
|
+
const getBondedDevices = () => BleUtils__default["default"].getBondedPeripherals();
|
|
50
51
|
const pairDevice = (macAddress) => BleUtils__default["default"].pairDevice(macAddress);
|
|
51
52
|
const onDeviceBondState = (bleMacAddress) => new Promise((resolve, reject) => {
|
|
52
53
|
let timeout;
|
|
@@ -373,9 +374,13 @@ class ReactNativeBleTransport {
|
|
|
373
374
|
throw error;
|
|
374
375
|
}
|
|
375
376
|
if (reactNative.Platform.OS === 'android') {
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
377
|
+
const bondedDevices = yield getBondedDevices();
|
|
378
|
+
const existsBondedList = bondedDevices.find(device => device.id.toLowerCase() === uuid.toLowerCase());
|
|
379
|
+
if (!existsBondedList) {
|
|
380
|
+
const bondState = yield pairDevice(uuid);
|
|
381
|
+
if (bondState.bonding) {
|
|
382
|
+
yield onDeviceBondState(uuid);
|
|
383
|
+
}
|
|
379
384
|
}
|
|
380
385
|
}
|
|
381
386
|
if (!device) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-react-native",
|
|
3
|
-
"version": "1.1.11-alpha.
|
|
3
|
+
"version": "1.1.11-alpha.2",
|
|
4
4
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"lint:fix": "eslint . --fix"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@onekeyfe/hd-shared": "1.1.11-alpha.
|
|
23
|
-
"@onekeyfe/hd-transport": "1.1.11-alpha.
|
|
24
|
-
"@onekeyfe/react-native-ble-utils": "
|
|
22
|
+
"@onekeyfe/hd-shared": "1.1.11-alpha.2",
|
|
23
|
+
"@onekeyfe/hd-transport": "1.1.11-alpha.2",
|
|
24
|
+
"@onekeyfe/react-native-ble-utils": "npm:react-native-ble-utils@^0.1.7",
|
|
25
25
|
"react-native-ble-plx": "3.5.0"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "4c2adec6fa4eaca0b5b97cdfbdca8cebfa10943d"
|
|
28
28
|
}
|
package/src/index.ts
CHANGED
|
@@ -19,7 +19,12 @@ import {
|
|
|
19
19
|
isOnekeyDevice,
|
|
20
20
|
} from '@onekeyfe/hd-shared';
|
|
21
21
|
import type EventEmitter from 'events';
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
getConnectedDeviceIds,
|
|
24
|
+
onDeviceBondState,
|
|
25
|
+
pairDevice,
|
|
26
|
+
getBondedDevices,
|
|
27
|
+
} from './BleManager';
|
|
23
28
|
import { subscribeBleOn } from './subscribeBleOn';
|
|
24
29
|
import {
|
|
25
30
|
getBluetoothServiceUuids,
|
|
@@ -260,9 +265,16 @@ export default class ReactNativeBleTransport {
|
|
|
260
265
|
|
|
261
266
|
// check device is bonded
|
|
262
267
|
if (Platform.OS === 'android') {
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
268
|
+
const bondedDevices = await getBondedDevices();
|
|
269
|
+
const existsBondedList = bondedDevices.find(
|
|
270
|
+
device => device.id.toLowerCase() === uuid.toLowerCase()
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
if (!existsBondedList) {
|
|
274
|
+
const bondState = await pairDevice(uuid);
|
|
275
|
+
if (bondState.bonding) {
|
|
276
|
+
await onDeviceBondState(uuid);
|
|
277
|
+
}
|
|
266
278
|
}
|
|
267
279
|
}
|
|
268
280
|
|