@onekeyfe/hd-transport-react-native 1.2.0-alpha.144 → 1.2.0-alpha.145
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 +2 -10
- package/package.json +5 -5
- package/src/__tests__/protocolV2Link.test.ts +3 -3
- package/src/index.ts +3 -13
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,EAIL,UAAU,IAAI,aAAa,EAG5B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAS,EAAE,EAChB,KAAK,oBAAoB,EAIzB,KAAK,YAAY,EAKjB,KAAK,oBAAoB,EAI1B,MAAM,wBAAwB,CAAC;AA0BhC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAI1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAgBjE,KAAK,4BAA4B,GAAG,WAAW,CAAC;AAChD,KAAK,0BAA0B,GAAG;IAChC,mBAAmB,EAAE,cAAc,CAAC;IACpC,oBAAoB,EAAE,cAAc,CAAC;CACtC,CAAC;AAkCF,eAAO,MAAM,+BAA+B,UACnC,OAAO,KACb,4BAA4B,GAAG,IAsBjC,CAAC;AAcF,eAAO,MAAM,2BAA2B,QAAS,CAAC;AAClD,eAAO,MAAM,8BAA8B,OAAQ,CAAC;AAOpD,eAAO,MAAM,yCAAyC,IAAI,CAAC;AAI3D,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,CAAC,EAAE,MAAM,CA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E,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,oBAAoB;YA6BlB,cAAc;IAyP5B,IAAI;IAIE,UAAU,CAAC,OAAO,EAAE,MAAM;YAIlB,kBAAkB;YAkFlB,iBAAiB;IAkC/B,OAAO,CAAC,4BAA4B;YAQtB,qBAAqB;IAoBnC,MAAM;YAUQ,kBAAkB;YAkClB,iCAAiC;IAwC/C,OAAO,CAAC,wBAAwB;IAgChC,OAAO,CAAC,kBAAkB;YAcZ,cAAc;IA8C5B,OAAO,CAAC,kBAAkB;IA6B1B,OAAO,CAAC,eAAe;IAoDvB,OAAO,CAAC,2BAA2B;IAkBnC,OAAO,CAAC,4BAA4B;IAOpC,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,iBAAiB;YAIX,cAAc;YA4Gd,iCAAiC;YAoDjC,eAAe;YAwBf,eAAe;IA0B7B,OAAO,CAAC,4BAA4B;IA2BpC,OAAO,CAAC,uBAAuB;IAS/B,OAAO,CAAC,sBAAsB;IAU9B,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,sBAAsB;YAShB,mBAAmB;YAiBnB,qBAAqB;YA2DrB,oBAAoB;YAgCpB,cAAc;YAqEd,iCAAiC;IAiB/C,OAAO,CAAC,8BAA8B;YAQxB,mCAAmC;IAsBjD,OAAO,CAAC,yCAAyC;YAanC,gCAAgC;IAoB9C,OAAO,CAAC,uBAAuB;IAmD/B,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;CAGxD"}
|
package/dist/index.js
CHANGED
|
@@ -311,9 +311,6 @@ function resetProtocolV2BleTuning() {
|
|
|
311
311
|
function getProtocolV2BleTuning() {
|
|
312
312
|
return Object.assign({}, protocolV2BleTuning);
|
|
313
313
|
}
|
|
314
|
-
function inferProtocolHintFromDeviceName(name) {
|
|
315
|
-
return /\bpro\s*2\b/i.test(name !== null && name !== void 0 ? name : '') ? 'V2' : undefined;
|
|
316
|
-
}
|
|
317
314
|
function getDeviceDisplayName(device) {
|
|
318
315
|
return (device === null || device === void 0 ? void 0 : device.name) || (device === null || device === void 0 ? void 0 : device.localName) || null;
|
|
319
316
|
}
|
|
@@ -723,16 +720,11 @@ class ReactNativeBleTransport {
|
|
|
723
720
|
var _a;
|
|
724
721
|
if (deviceList.every(d => d.id !== device.id)) {
|
|
725
722
|
const displayName = (_a = getDeviceDisplayName(device)) !== null && _a !== void 0 ? _a : 'Unknown BLE Device';
|
|
726
|
-
const protocolHint = inferProtocolHintFromDeviceName(displayName);
|
|
727
|
-
if (protocolHint) {
|
|
728
|
-
this.deviceProtocolHints.set(device.id, protocolHint);
|
|
729
|
-
}
|
|
730
723
|
deviceList.push(Object.assign(Object.assign({}, device), { name: displayName, commType: 'ble' }));
|
|
731
724
|
Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] OneKey BLE device discovered', {
|
|
732
725
|
deviceId: device.id,
|
|
733
726
|
name: displayName,
|
|
734
727
|
serviceUUIDs: device.serviceUUIDs,
|
|
735
|
-
protocolHint,
|
|
736
728
|
});
|
|
737
729
|
}
|
|
738
730
|
};
|
|
@@ -804,7 +796,7 @@ class ReactNativeBleTransport {
|
|
|
804
796
|
});
|
|
805
797
|
}
|
|
806
798
|
acquireUnlocked(input) {
|
|
807
|
-
var _a
|
|
799
|
+
var _a;
|
|
808
800
|
return __awaiter(this, void 0, void 0, function* () {
|
|
809
801
|
const { uuid, forceCleanRunPromise, expectedProtocol } = input;
|
|
810
802
|
const cachedTransport = transportCache[uuid];
|
|
@@ -918,7 +910,7 @@ class ReactNativeBleTransport {
|
|
|
918
910
|
const { writeCharacteristic, notifyCharacteristic } = yield this.resolveCharacteristicsWithTimeout(uuid, acquiredDevice);
|
|
919
911
|
const protocolHint = expectedProtocol
|
|
920
912
|
? undefined
|
|
921
|
-
: (
|
|
913
|
+
: (_a = input.protocolHint) !== null && _a !== void 0 ? _a : this.deviceProtocolHints.get(uuid);
|
|
922
914
|
yield this.releaseUnlocked(uuid, true);
|
|
923
915
|
if (protocolHint) {
|
|
924
916
|
this.deviceProtocolHints.set(uuid, protocolHint);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-react-native",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.145",
|
|
4
4
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"lint:fix": "eslint . --fix"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@onekeyfe/hd-core": "1.2.0-alpha.
|
|
24
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
25
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
23
|
+
"@onekeyfe/hd-core": "1.2.0-alpha.145",
|
|
24
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.145",
|
|
25
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.145",
|
|
26
26
|
"@onekeyfe/react-native-ble-utils": "^0.1.6",
|
|
27
27
|
"react-native-ble-plx": "3.5.1"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "9a136f881865c15e603ef271ae820c2b5a991dcc"
|
|
30
30
|
}
|
|
@@ -405,7 +405,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
|
|
|
405
405
|
await transport.release(uuid, true);
|
|
406
406
|
});
|
|
407
407
|
|
|
408
|
-
test('
|
|
408
|
+
test('detects Protocol V2 on iOS without using the BLE name as a protocol hint', async () => {
|
|
409
409
|
const { transport, uuid, device, sentSeqs, writeCharacteristic } = createHarness({
|
|
410
410
|
deviceName: 'Pro2 6E9E',
|
|
411
411
|
});
|
|
@@ -415,12 +415,12 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
|
|
|
415
415
|
protocolType: 'V2',
|
|
416
416
|
});
|
|
417
417
|
expect(device.requestMTU).toHaveBeenCalledWith(247);
|
|
418
|
-
expect(writeCharacteristic.writeWithResponse).
|
|
418
|
+
expect(writeCharacteristic.writeWithResponse.mock.calls.length).toBeGreaterThan(1);
|
|
419
419
|
|
|
420
420
|
await expect(
|
|
421
421
|
transport.call(uuid, 'Ping', { message: 'first-core-command' })
|
|
422
422
|
).resolves.toBeDefined();
|
|
423
|
-
expect(sentSeqs).toEqual([1, 2]);
|
|
423
|
+
expect(sentSeqs.filter(seq => seq > 0)).toEqual([1, 2]);
|
|
424
424
|
await transport.release(uuid, true);
|
|
425
425
|
});
|
|
426
426
|
|
package/src/index.ts
CHANGED
|
@@ -203,10 +203,6 @@ export function getProtocolV2BleTuning() {
|
|
|
203
203
|
return { ...protocolV2BleTuning };
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
function inferProtocolHintFromDeviceName(name?: string | null): ProtocolType | undefined {
|
|
207
|
-
return /\bpro\s*2\b/i.test(name ?? '') ? 'V2' : undefined;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
206
|
function getDeviceDisplayName(device?: Device | null) {
|
|
211
207
|
return device?.name || device?.localName || null;
|
|
212
208
|
}
|
|
@@ -771,10 +767,7 @@ export default class ReactNativeBleTransport {
|
|
|
771
767
|
const addDevice = (device: Device) => {
|
|
772
768
|
if (deviceList.every(d => d.id !== device.id)) {
|
|
773
769
|
const displayName = getDeviceDisplayName(device) ?? 'Unknown BLE Device';
|
|
774
|
-
|
|
775
|
-
if (protocolHint) {
|
|
776
|
-
this.deviceProtocolHints.set(device.id, protocolHint);
|
|
777
|
-
}
|
|
770
|
+
|
|
778
771
|
deviceList.push({
|
|
779
772
|
...device,
|
|
780
773
|
name: displayName,
|
|
@@ -784,7 +777,6 @@ export default class ReactNativeBleTransport {
|
|
|
784
777
|
deviceId: device.id,
|
|
785
778
|
name: displayName,
|
|
786
779
|
serviceUUIDs: device.serviceUUIDs,
|
|
787
|
-
protocolHint,
|
|
788
780
|
});
|
|
789
781
|
}
|
|
790
782
|
};
|
|
@@ -1021,9 +1013,7 @@ export default class ReactNativeBleTransport {
|
|
|
1021
1013
|
|
|
1022
1014
|
const protocolHint = expectedProtocol
|
|
1023
1015
|
? undefined
|
|
1024
|
-
: input.protocolHint ??
|
|
1025
|
-
this.deviceProtocolHints.get(uuid) ??
|
|
1026
|
-
inferProtocolHintFromDeviceName(getDeviceDisplayName(acquiredDevice));
|
|
1016
|
+
: input.protocolHint ?? this.deviceProtocolHints.get(uuid);
|
|
1027
1017
|
|
|
1028
1018
|
// release transport before new transport instance
|
|
1029
1019
|
await this.releaseUnlocked(uuid, true);
|
|
@@ -1254,7 +1244,7 @@ export default class ReactNativeBleTransport {
|
|
|
1254
1244
|
|
|
1255
1245
|
this.deviceProtocol.delete(uuid);
|
|
1256
1246
|
this.probingProtocols.delete(uuid);
|
|
1257
|
-
//
|
|
1247
|
+
// Confirmed protocol and caller hints stay in deviceProtocol / protocolHint.
|
|
1258
1248
|
this.protocolV2Assemblers.get(uuid)?.reset();
|
|
1259
1249
|
this.protocolV2Assemblers.delete(uuid);
|
|
1260
1250
|
this.resetProtocolV2Frames(uuid);
|