@onekeyfe/hd-transport-react-native 0.1.2 → 0.1.5
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 +10 -3
- package/package.json +3 -3
- package/src/index.ts +13 -6
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,SAAiC,MAAM,wBAAwB,CAAC;AACvE,OAAO,EACL,UAAU,IAAI,aAAa,EAC3B,MAAM,EAEN,cAAc,EAEf,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACL,gBAAgB,EAChB,cAAc,EAMf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAA4B,MAAM,kBAAkB,CAAC;AAItE,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;gBAE5B,OAAO,EAAE,gBAAgB;IAIrC,IAAI;IAEJ,SAAS,CAAC,UAAU,EAAE,GAAG;IAMzB,MAAM;IAIN,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;IAYjC,SAAS;IAoET,OAAO,CAAC,KAAK,EAAE,eAAe;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,SAAiC,MAAM,wBAAwB,CAAC;AACvE,OAAO,EACL,UAAU,IAAI,aAAa,EAC3B,MAAM,EAEN,cAAc,EAEf,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACL,gBAAgB,EAChB,cAAc,EAMf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAA4B,MAAM,kBAAkB,CAAC;AAItE,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;gBAE5B,OAAO,EAAE,gBAAgB;IAIrC,IAAI;IAEJ,SAAS,CAAC,UAAU,EAAE,GAAG;IAMzB,MAAM;IAIN,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;IAYjC,SAAS;IAoET,OAAO,CAAC,KAAK,EAAE,eAAe;;;IA4JpC,sBAAsB,CAAC,cAAc,EAAE,cAAc;IAmD/C,OAAO,CAAC,IAAI,EAAE,MAAM;IAcpB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IA+EpE,IAAI;IAIJ,MAAM;CAOP;AAED,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -410,6 +410,7 @@ class ReactNativeBleTransport {
|
|
|
410
410
|
transport.nofitySubscription = this._monitorCharacteristic(transport.notifyCharacteristic);
|
|
411
411
|
transportCache[uuid] = transport;
|
|
412
412
|
device.onDisconnected(() => {
|
|
413
|
+
console.log('device disconnect: ', device === null || device === void 0 ? void 0 : device.id);
|
|
413
414
|
this.release(uuid);
|
|
414
415
|
});
|
|
415
416
|
return { uuid };
|
|
@@ -421,7 +422,7 @@ class ReactNativeBleTransport {
|
|
|
421
422
|
const subscription = characteristic.monitor((error, c) => {
|
|
422
423
|
var _a, _b;
|
|
423
424
|
if (error) {
|
|
424
|
-
console.log(`error monitor ${characteristic.uuid}: ${error}`);
|
|
425
|
+
console.log(`error monitor ${characteristic.uuid}, deviceId: ${characteristic.deviceID}: ${error}`);
|
|
425
426
|
return;
|
|
426
427
|
}
|
|
427
428
|
if (!c) {
|
|
@@ -454,12 +455,15 @@ class ReactNativeBleTransport {
|
|
|
454
455
|
};
|
|
455
456
|
}
|
|
456
457
|
release(uuid) {
|
|
457
|
-
var _a;
|
|
458
|
+
var _a, _b;
|
|
458
459
|
return __awaiter(this, void 0, void 0, function* () {
|
|
459
460
|
const transport = transportCache[uuid];
|
|
460
461
|
if (transport) {
|
|
461
462
|
delete transportCache[uuid];
|
|
462
463
|
(_a = transport.nofitySubscription) === null || _a === void 0 ? void 0 : _a.call(transport);
|
|
464
|
+
if (reactNative.Platform.OS === 'android') {
|
|
465
|
+
yield ((_b = this.blePlxManager) === null || _b === void 0 ? void 0 : _b.cancelDeviceConnection(uuid));
|
|
466
|
+
}
|
|
463
467
|
}
|
|
464
468
|
return Promise.resolve(true);
|
|
465
469
|
});
|
|
@@ -511,9 +515,12 @@ class ReactNativeBleTransport {
|
|
|
511
515
|
const outData = o.toString('base64');
|
|
512
516
|
console.log('@onekey/hd-ble-sdk send hex strting: ', o.toString('hex'));
|
|
513
517
|
try {
|
|
514
|
-
yield transport.writeCharacteristic.
|
|
518
|
+
yield transport.writeCharacteristic.writeWithoutResponse(outData);
|
|
515
519
|
}
|
|
516
520
|
catch (e) {
|
|
521
|
+
if (e.errorCode === reactNativeBlePlx.BleErrorCode.DeviceDisconnected) {
|
|
522
|
+
throw new Error('device is not bonded');
|
|
523
|
+
}
|
|
517
524
|
this.runPromise = null;
|
|
518
525
|
console.log('writeCharacteristic write error: ', e);
|
|
519
526
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-react-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"lint:fix": "eslint . --fix"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@onekeyfe/hd-transport": "^0.1.
|
|
23
|
+
"@onekeyfe/hd-transport": "^0.1.5",
|
|
24
24
|
"react-native-ble-manager": "^8.1.0",
|
|
25
25
|
"react-native-ble-plx": "^2.0.3"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "26a2b960d5e1917d3f2217cef449269200a1a376"
|
|
28
28
|
}
|
package/src/index.ts
CHANGED
|
@@ -301,6 +301,7 @@ export default class ReactNativeBleTransport {
|
|
|
301
301
|
transportCache[uuid] = transport;
|
|
302
302
|
|
|
303
303
|
device.onDisconnected(() => {
|
|
304
|
+
console.log('device disconnect: ', device?.id);
|
|
304
305
|
this.release(uuid);
|
|
305
306
|
});
|
|
306
307
|
|
|
@@ -312,7 +313,11 @@ export default class ReactNativeBleTransport {
|
|
|
312
313
|
let buffer: any[] = [];
|
|
313
314
|
const subscription = characteristic.monitor((error, c) => {
|
|
314
315
|
if (error) {
|
|
315
|
-
console.log(
|
|
316
|
+
console.log(
|
|
317
|
+
`error monitor ${characteristic.uuid}, deviceId: ${characteristic.deviceID}: ${
|
|
318
|
+
error as unknown as string
|
|
319
|
+
}`
|
|
320
|
+
);
|
|
316
321
|
return;
|
|
317
322
|
}
|
|
318
323
|
|
|
@@ -360,12 +365,11 @@ export default class ReactNativeBleTransport {
|
|
|
360
365
|
if (transport) {
|
|
361
366
|
delete transportCache[uuid];
|
|
362
367
|
transport.nofitySubscription?.();
|
|
368
|
+
if (Platform.OS === 'android') {
|
|
369
|
+
await this.blePlxManager?.cancelDeviceConnection(uuid);
|
|
370
|
+
}
|
|
363
371
|
}
|
|
364
372
|
|
|
365
|
-
/**
|
|
366
|
-
* The current strategy does not require disconnection
|
|
367
|
-
*/
|
|
368
|
-
// await blePlxManager.cancelDeviceConnection(uuid);
|
|
369
373
|
return Promise.resolve(true);
|
|
370
374
|
}
|
|
371
375
|
|
|
@@ -418,8 +422,11 @@ export default class ReactNativeBleTransport {
|
|
|
418
422
|
const outData = o.toString('base64');
|
|
419
423
|
console.log('@onekey/hd-ble-sdk send hex strting: ', o.toString('hex'));
|
|
420
424
|
try {
|
|
421
|
-
await transport.writeCharacteristic.
|
|
425
|
+
await transport.writeCharacteristic.writeWithoutResponse(outData);
|
|
422
426
|
} catch (e) {
|
|
427
|
+
if (e.errorCode === BleErrorCode.DeviceDisconnected) {
|
|
428
|
+
throw new Error('device is not bonded');
|
|
429
|
+
}
|
|
423
430
|
this.runPromise = null;
|
|
424
431
|
console.log('writeCharacteristic write error: ', e);
|
|
425
432
|
return;
|