@onekeyfe/hd-transport-web-device 1.2.0-alpha.0 → 1.2.0-alpha.1
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.
|
@@ -28,6 +28,25 @@ const protocolV1Schema = {
|
|
|
28
28
|
|
|
29
29
|
const protocolV2Schema = {
|
|
30
30
|
nested: {
|
|
31
|
+
GetProtoVersion: {
|
|
32
|
+
fields: {},
|
|
33
|
+
},
|
|
34
|
+
ProtoVersion: {
|
|
35
|
+
fields: {
|
|
36
|
+
major_version: {
|
|
37
|
+
type: 'uint32',
|
|
38
|
+
id: 1,
|
|
39
|
+
},
|
|
40
|
+
minor_version: {
|
|
41
|
+
type: 'uint32',
|
|
42
|
+
id: 2,
|
|
43
|
+
},
|
|
44
|
+
patch_version: {
|
|
45
|
+
type: 'uint32',
|
|
46
|
+
id: 3,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
31
50
|
Ping: {
|
|
32
51
|
fields: {
|
|
33
52
|
message: {
|
|
@@ -46,6 +65,8 @@ const protocolV2Schema = {
|
|
|
46
65
|
},
|
|
47
66
|
MessageType: {
|
|
48
67
|
values: {
|
|
68
|
+
MessageType_GetProtoVersion: 60200,
|
|
69
|
+
MessageType_ProtoVersion: 60201,
|
|
49
70
|
MessageType_Ping: 60206,
|
|
50
71
|
MessageType_Success: 60207,
|
|
51
72
|
},
|
|
@@ -109,13 +130,10 @@ describe('ElectronBleTransport protocol detection', () => {
|
|
|
109
130
|
const device = { id: 'unknown-pro2-id', name: 'Unknown BLE Device' };
|
|
110
131
|
const nobleBle = createNobleBle(device);
|
|
111
132
|
let notificationHandler: ((deviceId: string, data: string) => void) | undefined;
|
|
112
|
-
let writeCount = 0;
|
|
113
133
|
const probeResponse = ProtocolV2.encodeFrame(
|
|
114
134
|
schemas,
|
|
115
135
|
'Success',
|
|
116
|
-
{
|
|
117
|
-
message: 'probe',
|
|
118
|
-
},
|
|
136
|
+
{ message: 'ok' },
|
|
119
137
|
{ router: PROTOCOL_V2_CHANNEL_BLE_UART }
|
|
120
138
|
);
|
|
121
139
|
|
|
@@ -123,9 +141,10 @@ describe('ElectronBleTransport protocol detection', () => {
|
|
|
123
141
|
notificationHandler = handler;
|
|
124
142
|
return jest.fn();
|
|
125
143
|
});
|
|
144
|
+
let writeCount = 0;
|
|
126
145
|
nobleBle.write.mockImplementation(() => {
|
|
127
146
|
writeCount += 1;
|
|
128
|
-
if (writeCount
|
|
147
|
+
if (writeCount === 2) {
|
|
129
148
|
setTimeout(() => notificationHandler?.(device.id, bytesToHex(probeResponse)), 0);
|
|
130
149
|
}
|
|
131
150
|
return Promise.resolve();
|
|
@@ -199,9 +218,7 @@ describe('ElectronBleTransport protocol detection', () => {
|
|
|
199
218
|
const probeResponse = ProtocolV2.encodeFrame(
|
|
200
219
|
schemas,
|
|
201
220
|
'Success',
|
|
202
|
-
{
|
|
203
|
-
message: 'probe',
|
|
204
|
-
},
|
|
221
|
+
{ message: 'ok' },
|
|
205
222
|
{ router: PROTOCOL_V2_CHANNEL_BLE_UART }
|
|
206
223
|
);
|
|
207
224
|
|
package/dist/index.js
CHANGED
|
@@ -1365,7 +1365,7 @@ class ElectronBleTransport {
|
|
|
1365
1365
|
if (!this._messages || !this._messagesV2) {
|
|
1366
1366
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportNotConfigured);
|
|
1367
1367
|
}
|
|
1368
|
-
const forceRun = name === 'Initialize' || name === 'Cancel' || name === '
|
|
1368
|
+
const forceRun = name === 'Initialize' || name === 'Cancel' || name === 'Ping';
|
|
1369
1369
|
if (this.runPromise) {
|
|
1370
1370
|
if (!forceRun) {
|
|
1371
1371
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportCallInProgress);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-web-device",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.1",
|
|
4
4
|
"author": "OneKey",
|
|
5
5
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"lint:fix": "eslint . --fix"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
24
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
23
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.1",
|
|
24
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@onekeyfe/hd-transport-electron": "1.2.0-alpha.
|
|
27
|
+
"@onekeyfe/hd-transport-electron": "1.2.0-alpha.1",
|
|
28
28
|
"@types/w3c-web-usb": "^1.0.6",
|
|
29
29
|
"@types/web-bluetooth": "^0.0.17"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "4f4aae3a47be7bd54b4db4a10c400056784e01bd"
|
|
32
32
|
}
|
|
@@ -776,7 +776,7 @@ export default class ElectronBleTransport {
|
|
|
776
776
|
throw ERRORS.TypedError(HardwareErrorCode.TransportNotConfigured);
|
|
777
777
|
}
|
|
778
778
|
|
|
779
|
-
const forceRun = name === 'Initialize' || name === 'Cancel' || name === '
|
|
779
|
+
const forceRun = name === 'Initialize' || name === 'Cancel' || name === 'Ping';
|
|
780
780
|
if (this.runPromise) {
|
|
781
781
|
if (!forceRun) {
|
|
782
782
|
throw ERRORS.TypedError(HardwareErrorCode.TransportCallInProgress);
|