@onekeyfe/hd-core 1.2.0-alpha.1 → 1.2.0-alpha.10
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/__tests__/connectSettings.test.ts +19 -0
- package/__tests__/device-wallet-session-store.test.ts +131 -0
- package/__tests__/preInitialize.test.ts +33 -0
- package/__tests__/protocol-v2-firmware-targets.test.ts +19 -0
- package/__tests__/protocol-v2.test.ts +1784 -502
- package/dist/api/ClearSessionCache.d.ts +9 -0
- package/dist/api/ClearSessionCache.d.ts.map +1 -0
- package/dist/api/FileRead.d.ts.map +1 -1
- package/dist/api/FileWrite.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +24 -3
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +4 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/progressThrottle.d.ts +3 -0
- package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
- package/dist/api/index.d.ts +8 -10
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +1 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +3 -2
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/{DeviceGetDeviceInfo.d.ts → DeviceInfoGet.d.ts} +10 -10
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceSessionGet.d.ts +9 -0
- package/dist/api/protocol-v2/DeviceSessionGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -1
- package/dist/api/protocol-v2/{FilesystemFixPermission.d.ts → FilesystemPermissionFix.d.ts} +2 -2
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +6 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -0
- package/dist/api/protocol-v2/helpers.d.ts +27 -18
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/api/ton/TonSignData.d.ts +1 -5
- package/dist/api/ton/TonSignData.d.ts.map +1 -1
- package/dist/api/tron/TronSignMessage.d.ts +0 -1
- package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts +0 -1
- package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +1 -1
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +6 -3
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceWalletSessionStore.d.ts +15 -0
- package/dist/device/DeviceWalletSessionStore.d.ts.map +1 -0
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
- package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -1
- package/dist/index.d.ts +96 -55
- package/dist/index.js +2077 -1609
- package/dist/inject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts +12 -14
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.d.ts +11 -9
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/index.d.ts +1 -0
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts +13 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdate.d.ts +4 -6
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/getDeviceInfo.d.ts +2 -0
- package/dist/types/api/getDeviceInfo.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +11 -11
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +16 -17
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/api/sessionCache.d.ts +10 -0
- package/dist/types/api/sessionCache.d.ts.map +1 -0
- package/dist/types/device.d.ts +1 -0
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +1 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +21 -2
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +2 -0
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/ClearSessionCache.ts +28 -0
- package/src/api/FileRead.ts +16 -3
- package/src/api/FileWrite.ts +14 -1
- package/src/api/FirmwareUpdateV4.ts +1075 -264
- package/src/api/GetOnekeyFeatures.ts +1 -1
- package/src/api/GetPassphraseState.ts +4 -1
- package/src/api/device/DeviceRebootToBoardloader.ts +4 -4
- package/src/api/device/DeviceRebootToBootloader.ts +4 -4
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +18 -4
- package/src/api/firmware/progressThrottle.ts +44 -0
- package/src/api/index.ts +8 -10
- package/src/api/protocol-v2/{FactoryGetDeviceInfo.ts → DeviceFactoryInfoGet.ts} +3 -3
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +32 -0
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +3 -5
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +39 -5
- package/src/api/protocol-v2/{DeviceGetDeviceInfo.ts → DeviceInfoGet.ts} +52 -22
- package/src/api/protocol-v2/DeviceReboot.ts +1 -1
- package/src/api/protocol-v2/DeviceSessionGet.ts +26 -0
- package/src/api/protocol-v2/DeviceStatusGet.ts +14 -0
- package/src/api/protocol-v2/FilesystemFormat.ts +4 -1
- package/src/api/protocol-v2/{FilesystemFixPermission.ts → FilesystemPermissionFix.ts} +2 -2
- package/src/api/protocol-v2/{GetProtoVersion.ts → ProtocolInfoRequest.ts} +2 -2
- package/src/api/protocol-v2/helpers.ts +71 -47
- package/src/api/ton/TonSignData.ts +1 -5
- package/src/api/tron/TronSignMessage.ts +0 -1
- package/src/api/tron/TronSignTransaction.ts +0 -1
- package/src/core/index.ts +19 -5
- package/src/data/messages/messages-protocol-v2.json +599 -1033
- package/src/data/messages/messages.json +8 -0
- package/src/data-manager/DataManager.ts +7 -0
- package/src/data-manager/connectSettings.ts +2 -4
- package/src/device/Device.ts +89 -70
- package/src/device/DeviceWalletSessionStore.ts +78 -0
- package/src/deviceProfile/buildDeviceFeatures.ts +60 -63
- package/src/deviceProfile/buildDeviceProfile.ts +77 -58
- package/src/inject.ts +13 -16
- package/src/protocols/protocol-v2/features.ts +26 -63
- package/src/protocols/protocol-v2/firmware.ts +12 -36
- package/src/protocols/protocol-v2/index.ts +1 -0
- package/src/protocols/protocol-v2/walletSession.ts +83 -0
- package/src/types/api/firmwareUpdate.ts +16 -20
- package/src/types/api/getDeviceInfo.ts +2 -0
- package/src/types/api/index.ts +17 -20
- package/src/types/api/protocolV2.ts +36 -40
- package/src/types/api/sessionCache.ts +14 -0
- package/src/types/device.ts +1 -0
- package/src/types/params.ts +4 -0
- package/src/types/settings.ts +42 -35
- package/src/utils/deviceFeaturesUtils.ts +44 -13
- package/dist/api/protocol-v2/DevReboot.d.ts +0 -7
- package/dist/api/protocol-v2/DevReboot.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +0 -1
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +0 -7
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +0 -1
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +0 -6
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +0 -1
- package/dist/api/protocol-v2/GetProtoVersion.d.ts +0 -6
- package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +0 -1
- package/src/api/protocol-v2/DevReboot.ts +0 -24
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +0 -16
- package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +0 -29
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DeviceRebootType } from '@onekeyfe/hd-transport';
|
|
2
2
|
|
|
3
3
|
import { invalidParameter, validateNonEmptyString } from '../helpers/filesystemValidation';
|
|
4
|
+
import { ProtocolV2FirmwareTargetType } from '../../protocols/protocol-v2/firmware';
|
|
4
5
|
|
|
5
6
|
import type {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
DeviceFirmwareTarget,
|
|
8
|
+
DeviceFirmwareTargetType,
|
|
9
|
+
DeviceFirmwareUpdateRecordFields,
|
|
8
10
|
TransportCallOptions,
|
|
9
11
|
} from '@onekeyfe/hd-transport';
|
|
10
12
|
|
|
11
|
-
export type RebootTypeInput =
|
|
12
|
-
| DevRebootType
|
|
13
|
-
| keyof typeof DevRebootType
|
|
14
|
-
| string
|
|
15
|
-
| number;
|
|
13
|
+
export type RebootTypeInput = DeviceRebootType | keyof typeof DeviceRebootType | string | number;
|
|
16
14
|
|
|
17
15
|
export type DeviceRebootParams = {
|
|
18
16
|
rebootType?: RebootTypeInput;
|
|
@@ -20,48 +18,58 @@ export type DeviceRebootParams = {
|
|
|
20
18
|
};
|
|
21
19
|
|
|
22
20
|
export type DeviceFirmwareTargetInput =
|
|
23
|
-
|
|
|
21
|
+
| DeviceFirmwareTarget
|
|
24
22
|
| {
|
|
25
|
-
targetId?:
|
|
26
|
-
target_id?:
|
|
23
|
+
targetId?: DeviceFirmwareTargetType | string | number;
|
|
24
|
+
target_id?: DeviceFirmwareTargetType | string | number;
|
|
27
25
|
path: string;
|
|
28
26
|
};
|
|
29
27
|
|
|
30
28
|
export type DeviceFirmwareUpdateParams = {
|
|
31
29
|
targets?: DeviceFirmwareTargetInput[];
|
|
32
|
-
targetId?:
|
|
33
|
-
target_id?:
|
|
30
|
+
targetId?: DeviceFirmwareTargetType | string | number;
|
|
31
|
+
target_id?: DeviceFirmwareTargetType | string | number;
|
|
34
32
|
path?: string;
|
|
35
33
|
};
|
|
36
34
|
|
|
37
|
-
export type
|
|
38
|
-
|
|
39
|
-
serialNo?: string;
|
|
40
|
-
cpu_info?: string;
|
|
41
|
-
cpuInfo?: string;
|
|
42
|
-
pre_firmware?: string;
|
|
43
|
-
preFirmware?: string;
|
|
35
|
+
export type DeviceFirmwareUpdateStatusGetParams = {
|
|
36
|
+
fields?: DeviceFirmwareUpdateRecordFields;
|
|
44
37
|
};
|
|
45
38
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
39
|
+
export type DeviceFactoryInfoSetParams = {
|
|
40
|
+
version?: number;
|
|
41
|
+
serial_number?: string;
|
|
42
|
+
burn_in_completed?: boolean;
|
|
43
|
+
factory_test_completed?: boolean;
|
|
44
|
+
manufacture_time?: {
|
|
45
|
+
year: number;
|
|
46
|
+
month: number;
|
|
47
|
+
day: number;
|
|
48
|
+
hour: number;
|
|
49
|
+
minute: number;
|
|
50
|
+
second: number;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const DEVICE_REBOOT_TYPES: Record<string, DeviceRebootType> = {
|
|
55
|
+
Normal: DeviceRebootType.Normal,
|
|
56
|
+
normal: DeviceRebootType.Normal,
|
|
57
|
+
Romloader: DeviceRebootType.Romloader,
|
|
58
|
+
romloader: DeviceRebootType.Romloader,
|
|
59
|
+
Boardloader: DeviceRebootType.Romloader,
|
|
60
|
+
boardloader: DeviceRebootType.Romloader,
|
|
61
|
+
Bootloader: DeviceRebootType.Bootloader,
|
|
62
|
+
bootloader: DeviceRebootType.Bootloader,
|
|
55
63
|
};
|
|
56
64
|
|
|
57
65
|
export const PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS: TransportCallOptions = {
|
|
58
|
-
intermediateTypes: ['
|
|
66
|
+
intermediateTypes: ['DeviceFirmwareUpdateStatus'],
|
|
59
67
|
};
|
|
60
68
|
|
|
61
69
|
export const PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES: (
|
|
62
70
|
| 'Success'
|
|
63
|
-
| '
|
|
64
|
-
)[] = ['Success', '
|
|
71
|
+
| 'DeviceFirmwareUpdateStatus'
|
|
72
|
+
)[] = ['Success', 'DeviceFirmwareUpdateStatus'];
|
|
65
73
|
|
|
66
74
|
export const getProtocolV2UnknownErrorText = (error: unknown) => {
|
|
67
75
|
if (!error) {
|
|
@@ -120,40 +128,56 @@ export const isProtocolV2DeviceDisconnectedError = (error: unknown) => {
|
|
|
120
128
|
);
|
|
121
129
|
};
|
|
122
130
|
|
|
123
|
-
export function normalizeRebootType(value: RebootTypeInput | undefined):
|
|
131
|
+
export function normalizeRebootType(value: RebootTypeInput | undefined): DeviceRebootType {
|
|
124
132
|
if (typeof value === 'number') return value;
|
|
125
133
|
if (typeof value === 'string') {
|
|
126
134
|
const numeric = Number(value);
|
|
127
135
|
if (Number.isFinite(numeric)) return numeric;
|
|
128
|
-
if (value in
|
|
136
|
+
if (value in DEVICE_REBOOT_TYPES) return DEVICE_REBOOT_TYPES[value];
|
|
129
137
|
}
|
|
130
|
-
return
|
|
138
|
+
return DeviceRebootType.Normal;
|
|
131
139
|
}
|
|
132
140
|
|
|
133
|
-
//
|
|
134
|
-
const
|
|
141
|
+
// 与 firmware-pro2 的 proto_target_to_firmware_target 安装白名单保持一致。
|
|
142
|
+
const INSTALLABLE_FIRMWARE_TARGET_IDS = new Set<number>([
|
|
143
|
+
ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_CRATE,
|
|
144
|
+
ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_BOOTLOADER,
|
|
145
|
+
ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P1,
|
|
146
|
+
ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P2,
|
|
147
|
+
ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_COPROCESSOR,
|
|
148
|
+
ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE01,
|
|
149
|
+
ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE02,
|
|
150
|
+
ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE03,
|
|
151
|
+
ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE04,
|
|
152
|
+
]);
|
|
153
|
+
const FIRMWARE_TARGET_ID_BY_NAME = new Map<string, DeviceFirmwareTargetType>(
|
|
154
|
+
Object.entries(ProtocolV2FirmwareTargetType).flatMap(([key, value]) =>
|
|
155
|
+
INSTALLABLE_FIRMWARE_TARGET_IDS.has(value) ? [[key, value as DeviceFirmwareTargetType]] : []
|
|
156
|
+
)
|
|
157
|
+
);
|
|
135
158
|
|
|
136
159
|
function normalizeTargetId(
|
|
137
|
-
value:
|
|
160
|
+
value: DeviceFirmwareTargetType | string | number | undefined,
|
|
138
161
|
name: string
|
|
139
|
-
):
|
|
162
|
+
): DeviceFirmwareTargetType {
|
|
140
163
|
if (value === undefined || value === null) {
|
|
141
164
|
throw invalidParameter(`Missing required parameter: ${name}`);
|
|
142
165
|
}
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return numeric as DevFirmwareTargetType;
|
|
166
|
+
const named = typeof value === 'string' ? FIRMWARE_TARGET_ID_BY_NAME.get(value) : undefined;
|
|
167
|
+
const numeric = named ?? (typeof value === 'number' ? value : Number(value));
|
|
168
|
+
if (Number.isSafeInteger(numeric) && INSTALLABLE_FIRMWARE_TARGET_IDS.has(numeric)) {
|
|
169
|
+
return numeric as DeviceFirmwareTargetType;
|
|
148
170
|
}
|
|
149
171
|
throw invalidParameter(
|
|
150
|
-
`Parameter [${name}] must be
|
|
151
|
-
...
|
|
172
|
+
`Parameter [${name}] must be an installable firmware target id (one of ${[
|
|
173
|
+
...INSTALLABLE_FIRMWARE_TARGET_IDS,
|
|
152
174
|
].join(', ')}).`
|
|
153
175
|
);
|
|
154
176
|
}
|
|
155
177
|
|
|
156
|
-
export function normalizeFirmwareTargets(
|
|
178
|
+
export function normalizeFirmwareTargets(
|
|
179
|
+
params: DeviceFirmwareUpdateParams
|
|
180
|
+
): DeviceFirmwareTarget[] {
|
|
157
181
|
const targets =
|
|
158
182
|
params.targets ??
|
|
159
183
|
(params.path
|
package/src/core/index.ts
CHANGED
|
@@ -56,7 +56,6 @@ import TransportManager from '../data-manager/TransportManager';
|
|
|
56
56
|
import DeviceConnector from '../device/DeviceConnector';
|
|
57
57
|
import RequestQueue from './RequestQueue';
|
|
58
58
|
import { getSynchronize } from '../utils/getSynchronize';
|
|
59
|
-
import { setProtocolV2DeviceInfoMock } from '../protocols/protocol-v2/features';
|
|
60
59
|
|
|
61
60
|
import type { ConnectSettings, Features, KnownDevice } from '../types';
|
|
62
61
|
import type { CoreMessage, IFrameCallMessage, UiPromise, UiPromiseResponse } from '../events';
|
|
@@ -96,6 +95,7 @@ const parseInitOptions = (method?: BaseMethod): InitOptions => ({
|
|
|
96
95
|
deviceId: method?.payload.deviceId,
|
|
97
96
|
deriveCardano: method && hasDeriveCardano(method),
|
|
98
97
|
connectProtocol: method?.payload.connectProtocol,
|
|
98
|
+
protocolV2DeviceInfoTimeoutMs: method?.payload.protocolV2DeviceInfoTimeoutMs,
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
let _core: Core;
|
|
@@ -223,9 +223,15 @@ const handlePreWarmSignal = async (
|
|
|
223
223
|
message: CoreMessage,
|
|
224
224
|
method: BaseMethod
|
|
225
225
|
): Promise<any> => {
|
|
226
|
+
const createAckResponse = () => {
|
|
227
|
+
completeMethodRequestContext(method);
|
|
228
|
+
method.dispose();
|
|
229
|
+
return createResponseMessage(method.responseID, true, true);
|
|
230
|
+
};
|
|
231
|
+
|
|
226
232
|
// no connectId: can't target a device safely, skip pre-warm (ack only)
|
|
227
233
|
if (!method.connectId) {
|
|
228
|
-
return
|
|
234
|
+
return createAckResponse();
|
|
229
235
|
}
|
|
230
236
|
|
|
231
237
|
const key = method.getPreWarmKey();
|
|
@@ -238,12 +244,12 @@ const handlePreWarmSignal = async (
|
|
|
238
244
|
} catch {
|
|
239
245
|
// pre-warm is best-effort; ignore its failure for the coalesced caller
|
|
240
246
|
}
|
|
241
|
-
return
|
|
247
|
+
return createAckResponse();
|
|
242
248
|
}
|
|
243
249
|
|
|
244
250
|
const doneAt = preWarmDoneAt.get(key);
|
|
245
251
|
if (typeof doneAt === 'number' && Date.now() - doneAt <= method.preWarmTtl) {
|
|
246
|
-
return
|
|
252
|
+
return createAckResponse();
|
|
247
253
|
}
|
|
248
254
|
|
|
249
255
|
const run = onCallDevice(context, message, method);
|
|
@@ -732,6 +738,15 @@ function initDevice(method: BaseMethod) {
|
|
|
732
738
|
|
|
733
739
|
if (method.connectId) {
|
|
734
740
|
device = _deviceList.getDevice(method.connectId);
|
|
741
|
+
if (!device && method.name === 'firmwareUpdateV4' && allDevices.length === 1) {
|
|
742
|
+
const [singleDevice] = allDevices;
|
|
743
|
+
if (singleDevice.isBootloader()) {
|
|
744
|
+
Log.debug(
|
|
745
|
+
'firmwareUpdateV4 uses the only bootloader device when connectId changed after reboot'
|
|
746
|
+
);
|
|
747
|
+
device = singleDevice;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
735
750
|
} else if (allDevices.length === 1) {
|
|
736
751
|
[device] = allDevices;
|
|
737
752
|
} else if (allDevices.length > 1) {
|
|
@@ -1439,7 +1454,6 @@ export const init = async (
|
|
|
1439
1454
|
try {
|
|
1440
1455
|
try {
|
|
1441
1456
|
await DataManager.load(settings);
|
|
1442
|
-
setProtocolV2DeviceInfoMock(settings.protocolV2DeviceInfoMockEnabled ?? false);
|
|
1443
1457
|
initTransport(Transport, plugin);
|
|
1444
1458
|
} catch {
|
|
1445
1459
|
Log.error('DataManager.load error');
|