@onekeyfe/hd-core 1.2.8-alpha.120 → 1.2.8-alpha.121
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__/protocol-v2.test.ts +0 -542
- package/dist/api/FirmwareUpdateV4.d.ts +0 -5
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/index.js +46 -225
- package/dist/utils/logger.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +61 -314
- package/src/utils/logger.ts +0 -4
- package/__tests__/logger.test.ts +0 -18
package/dist/index.js
CHANGED
|
@@ -40784,9 +40784,6 @@ class Log$n {
|
|
|
40784
40784
|
}
|
|
40785
40785
|
const _logs = {};
|
|
40786
40786
|
const initLog = (prefix, enabled) => {
|
|
40787
|
-
const existing = _logs[prefix];
|
|
40788
|
-
if (existing)
|
|
40789
|
-
return existing;
|
|
40790
40787
|
const instance = new Log$n(prefix, !!enabled);
|
|
40791
40788
|
_logs[prefix] = instance;
|
|
40792
40789
|
return instance;
|
|
@@ -52634,8 +52631,6 @@ const PROTOCOL_V2_CONNECT_POLL_INTERVAL = 500;
|
|
|
52634
52631
|
const PROTOCOL_V2_CONNECT_SINGLE_TIMEOUT = 75 * 1000;
|
|
52635
52632
|
const PROTOCOL_V2_DEVICE_INFO_READY_TIMEOUT = 30 * 1000;
|
|
52636
52633
|
const PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT = 3;
|
|
52637
|
-
const PROTOCOL_V2_RESOURCE_HEADER_RECOVERY_LIMIT = 2;
|
|
52638
|
-
const PROTOCOL_V2_BLE_FILE_WRITE_WINDOW_MIN_BOOTLOADER_VERSION = '1.0.4';
|
|
52639
52634
|
const PROTOCOL_V2_TRANSFER_PROGRESS_HEARTBEAT_MS = 1000;
|
|
52640
52635
|
const PROTOCOL_V2_INSTALL_STATUS_CONFLICT_CODE = 'FirmwareInstallStatusConflict';
|
|
52641
52636
|
const PROTOCOL_V2_INSTALL_FAILED_CODE = 'FirmwareInstallFailed';
|
|
@@ -52683,11 +52678,6 @@ function assertProtocolV2FirmwareTargetsSupported(deviceType, params, hasExplici
|
|
|
52683
52678
|
: `Cannot safely update ${targetList} without a confirmed Pro2 device type`;
|
|
52684
52679
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportMethod, message);
|
|
52685
52680
|
}
|
|
52686
|
-
function supportsProtocolV2BleFileWriteWindow(bootloaderVersion, minBootloaderVersion = PROTOCOL_V2_BLE_FILE_WRITE_WINDOW_MIN_BOOTLOADER_VERSION) {
|
|
52687
|
-
return (!!minBootloaderVersion &&
|
|
52688
|
-
!!semver__default["default"].valid(bootloaderVersion) &&
|
|
52689
|
-
semver__default["default"].gte(bootloaderVersion, minBootloaderVersion));
|
|
52690
|
-
}
|
|
52691
52681
|
const getProtocolV2DeviceTransferProgress = (bytesBeforeChunk, bytesAfterChunk, totalBytes) => {
|
|
52692
52682
|
if (!Number.isFinite(totalBytes) || totalBytes <= 0) {
|
|
52693
52683
|
return 0;
|
|
@@ -52697,8 +52687,6 @@ const getProtocolV2DeviceTransferProgress = (bytesBeforeChunk, bytesAfterChunk,
|
|
|
52697
52687
|
}
|
|
52698
52688
|
return Math.min(Math.max(Math.ceil((bytesAfterChunk / totalBytes) * 100), 1), 99);
|
|
52699
52689
|
};
|
|
52700
|
-
const getProtocolV2TransferRate = (bytes, elapsedMs) => elapsedMs > 0 ? Math.round((bytes / elapsedMs) * 1000) : undefined;
|
|
52701
|
-
const getProtocolV2ElapsedMs = (startedAt, now = Date.now()) => Math.max(now - startedAt, 0);
|
|
52702
52690
|
const PROTOCOL_V2_REMOTE_COMPONENT_TARGETS = {
|
|
52703
52691
|
BOOTLOADER: {
|
|
52704
52692
|
fileName: 'bootloader.bin',
|
|
@@ -52799,21 +52787,6 @@ const getProtocolV2ErrorCode = (error) => {
|
|
|
52799
52787
|
const causeCode = errorCode !== null && errorCode !== void 0 ? errorCode : code;
|
|
52800
52788
|
return typeof causeCode === 'number' || typeof causeCode === 'string' ? causeCode : undefined;
|
|
52801
52789
|
};
|
|
52802
|
-
const isProtocolV2ResourceHeaderLinkError = (error) => {
|
|
52803
|
-
if (isProtocolV2DeviceDisconnectedError(error))
|
|
52804
|
-
return true;
|
|
52805
|
-
const errorCode = getProtocolV2ErrorCode(error);
|
|
52806
|
-
if (errorCode === hdShared.HardwareErrorCode.BleTimeoutError)
|
|
52807
|
-
return true;
|
|
52808
|
-
const message = getProtocolV2UnknownErrorText(error);
|
|
52809
|
-
if (errorCode === hdShared.HardwareErrorCode.TransportNotFound && /not connected/i.test(message)) {
|
|
52810
|
-
return true;
|
|
52811
|
-
}
|
|
52812
|
-
return (message.includes('ProtocolV2LinkError') ||
|
|
52813
|
-
message.includes('Device protocol has not been detected') ||
|
|
52814
|
-
message.includes('Electron BLE device state cleaned') ||
|
|
52815
|
-
message.includes('Electron BLE transport released'));
|
|
52816
|
-
};
|
|
52817
52790
|
const isProtocolV2TerminalInstallStatusError = (error) => {
|
|
52818
52791
|
var _a;
|
|
52819
52792
|
return error instanceof hdShared.HardwareError &&
|
|
@@ -52944,7 +52917,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52944
52917
|
this.protocolV2InstallTerminalSuccessObserved = false;
|
|
52945
52918
|
this.protocolV2LastTransferProgressAt = 0;
|
|
52946
52919
|
this.protocolV2LastTransferredBytes = 0;
|
|
52947
|
-
this.protocolV2FileWriteWindowDisabled = false;
|
|
52948
52920
|
}
|
|
52949
52921
|
getSupportedProtocols() {
|
|
52950
52922
|
return ['V2'];
|
|
@@ -53091,7 +53063,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53091
53063
|
componentArtifacts: preparedPlan ? undefined : payload.componentArtifacts,
|
|
53092
53064
|
};
|
|
53093
53065
|
}
|
|
53094
|
-
getProtocolV2FirmwareChunkSize(direction, filePath
|
|
53066
|
+
getProtocolV2FirmwareChunkSize(direction, filePath) {
|
|
53095
53067
|
var _a, _b;
|
|
53096
53068
|
const payloadChunkSize = Number((_a = this.params) === null || _a === void 0 ? void 0 : _a.chunkSize);
|
|
53097
53069
|
const env = DataManager.getSettings('env');
|
|
@@ -53101,9 +53073,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53101
53073
|
if (direction === 'read') {
|
|
53102
53074
|
maxChunkSize = hdTransport.PROTOCOL_V2_BLE_FILE_READ_CHUNK_SIZE;
|
|
53103
53075
|
}
|
|
53104
|
-
else if (fileWriteWindow) {
|
|
53105
|
-
maxChunkSize = hdTransport.PROTOCOL_V2_BLE_FILE_CHUNK_SIZE;
|
|
53106
|
-
}
|
|
53107
53076
|
else {
|
|
53108
53077
|
maxChunkSize = PROTOCOL_V2_FIRMWARE_STAGING_PATHS.has(filePath !== null && filePath !== void 0 ? filePath : '')
|
|
53109
53078
|
? hdTransport.PROTOCOL_V2_BLE_FIRMWARE_FILE_CHUNK_SIZE
|
|
@@ -53918,33 +53887,11 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53918
53887
|
return true;
|
|
53919
53888
|
}
|
|
53920
53889
|
catch (error) {
|
|
53921
|
-
if (isProtocolV2ResourceHeaderLinkError(error))
|
|
53922
|
-
throw error;
|
|
53923
53890
|
Log$6.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check failed: `, error);
|
|
53924
53891
|
return false;
|
|
53925
53892
|
}
|
|
53926
53893
|
});
|
|
53927
53894
|
}
|
|
53928
|
-
isProtocolV2ResourceBundleUpToDateWithRecovery(bundle, recovery) {
|
|
53929
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53930
|
-
for (;;) {
|
|
53931
|
-
try {
|
|
53932
|
-
return yield this.isProtocolV2ResourceBundleUpToDate(bundle);
|
|
53933
|
-
}
|
|
53934
|
-
catch (error) {
|
|
53935
|
-
this.throwIfAborted();
|
|
53936
|
-
if (recovery.remaining <= 0) {
|
|
53937
|
-
Log$6.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check lost the link; reconnect budget used up: `, getProtocolV2UnknownErrorText(error));
|
|
53938
|
-
return false;
|
|
53939
|
-
}
|
|
53940
|
-
recovery.remaining -= 1;
|
|
53941
|
-
Log$6.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check lost the link; reconnecting: `, getProtocolV2UnknownErrorText(error));
|
|
53942
|
-
}
|
|
53943
|
-
yield this.recoverProtocolV2FileTransfer();
|
|
53944
|
-
this.throwIfAborted();
|
|
53945
|
-
}
|
|
53946
|
-
});
|
|
53947
|
-
}
|
|
53948
53895
|
isProtocolV2BootloaderMode() {
|
|
53949
53896
|
var _a, _b, _c;
|
|
53950
53897
|
if (typeof this.device.isBootloader === 'function') {
|
|
@@ -54123,9 +54070,8 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54123
54070
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54124
54071
|
let totalSize = installSources.reduce((total, item) => total + item.source.size, 0);
|
|
54125
54072
|
const resourcesToSync = [];
|
|
54126
|
-
const headerRecovery = { remaining: PROTOCOL_V2_RESOURCE_HEADER_RECOVERY_LIMIT };
|
|
54127
54073
|
for (const resource of resourceSources) {
|
|
54128
|
-
if (yield this.
|
|
54074
|
+
if (yield this.isProtocolV2ResourceBundleUpToDate(resource)) {
|
|
54129
54075
|
Log$6.log(`[FirmwareUpdateV4] skip RESC bundle ${resource.name}; already up to date`);
|
|
54130
54076
|
}
|
|
54131
54077
|
else {
|
|
@@ -54170,20 +54116,13 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54170
54116
|
});
|
|
54171
54117
|
}
|
|
54172
54118
|
if (totalSize > 0) {
|
|
54173
|
-
const elapsedMs =
|
|
54174
|
-
const rateBytesPerSecond = getProtocolV2TransferRate(totalSize, elapsedMs);
|
|
54119
|
+
const elapsedMs = Math.max(Date.now() - transferStartedAt, 0);
|
|
54175
54120
|
this.postProgressMessage(100, 'transferData', {
|
|
54176
54121
|
transferredBytes: totalSize,
|
|
54177
54122
|
totalBytes: totalSize,
|
|
54178
|
-
rateBytesPerSecond,
|
|
54123
|
+
rateBytesPerSecond: elapsedMs > 0 ? Math.round((totalSize / elapsedMs) * 1000) : undefined,
|
|
54179
54124
|
elapsedMs,
|
|
54180
54125
|
});
|
|
54181
|
-
Log$6.debug('[FirmwareUpdateV4] Protocol V2 transfer completed', {
|
|
54182
|
-
files: resourcesToSync.length + installSources.length,
|
|
54183
|
-
totalBytes: totalSize,
|
|
54184
|
-
elapsedMs,
|
|
54185
|
-
rateBytesPerSecond,
|
|
54186
|
-
});
|
|
54187
54126
|
}
|
|
54188
54127
|
if (stagedInstallTargets.length === 0) {
|
|
54189
54128
|
return;
|
|
@@ -54193,15 +54132,10 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54193
54132
|
target_id: item.targetId,
|
|
54194
54133
|
path: item.path,
|
|
54195
54134
|
}));
|
|
54196
|
-
const installStartedAt = Date.now();
|
|
54197
54135
|
try {
|
|
54198
54136
|
yield this.protocolV2StartFirmwareUpdate({ targets });
|
|
54199
54137
|
yield hdShared.wait(PROTOCOL_V2_INSTALL_STATUS_INITIAL_DELAY);
|
|
54200
54138
|
yield this.waitForProtocolV2FirmwareUpdateComplete(targets, true);
|
|
54201
|
-
Log$6.debug('[FirmwareUpdateV4] Protocol V2 install completed', {
|
|
54202
|
-
targets: targets.length,
|
|
54203
|
-
elapsedMs: getProtocolV2ElapsedMs(installStartedAt),
|
|
54204
|
-
});
|
|
54205
54139
|
}
|
|
54206
54140
|
finally {
|
|
54207
54141
|
(_a = this.device) === null || _a === void 0 ? void 0 : _a.clearCancelableAction();
|
|
@@ -54210,84 +54144,51 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54210
54144
|
}
|
|
54211
54145
|
protocolV2SourceUpdateProcess({ source, filePath, processedSize, totalSize, transferStartedAt = Date.now(), }) {
|
|
54212
54146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54213
|
-
const reportConfirmedChunk = (chunkEnd) => {
|
|
54214
|
-
const transferredBytes = processedSize + chunkEnd;
|
|
54215
|
-
const now = Date.now();
|
|
54216
|
-
const elapsedMs = getProtocolV2ElapsedMs(transferStartedAt, now);
|
|
54217
|
-
const progress = Math.min(Math.ceil((transferredBytes / totalSize) * 100), 99);
|
|
54218
|
-
const shouldPostProgress = transferredBytes >= this.protocolV2LastTransferredBytes &&
|
|
54219
|
-
(progress !== this.protocolV2LastTransferProgress ||
|
|
54220
|
-
now - this.protocolV2LastTransferProgressAt >=
|
|
54221
|
-
PROTOCOL_V2_TRANSFER_PROGRESS_HEARTBEAT_MS ||
|
|
54222
|
-
chunkEnd === source.size);
|
|
54223
|
-
if (shouldPostProgress) {
|
|
54224
|
-
this.protocolV2LastTransferProgress = progress;
|
|
54225
|
-
this.protocolV2LastTransferProgressAt = now;
|
|
54226
|
-
this.protocolV2LastTransferredBytes = transferredBytes;
|
|
54227
|
-
this.postProgressMessage(progress, 'transferData', {
|
|
54228
|
-
transferredBytes,
|
|
54229
|
-
totalBytes: totalSize,
|
|
54230
|
-
rateBytesPerSecond: getProtocolV2TransferRate(transferredBytes, elapsedMs),
|
|
54231
|
-
elapsedMs,
|
|
54232
|
-
});
|
|
54233
|
-
}
|
|
54234
|
-
};
|
|
54235
54147
|
let lastError;
|
|
54236
54148
|
for (let attempt = 1; attempt <= PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT; attempt += 1) {
|
|
54237
54149
|
this.throwIfAborted();
|
|
54238
|
-
const attemptStartedAt = Date.now();
|
|
54239
|
-
let windowed = false;
|
|
54240
54150
|
try {
|
|
54241
|
-
|
|
54242
|
-
|
|
54243
|
-
|
|
54244
|
-
|
|
54245
|
-
|
|
54246
|
-
|
|
54247
|
-
|
|
54248
|
-
|
|
54249
|
-
|
|
54250
|
-
|
|
54251
|
-
|
|
54252
|
-
|
|
54253
|
-
|
|
54254
|
-
|
|
54255
|
-
|
|
54256
|
-
|
|
54257
|
-
|
|
54258
|
-
|
|
54259
|
-
this.
|
|
54260
|
-
|
|
54261
|
-
|
|
54262
|
-
|
|
54263
|
-
|
|
54264
|
-
|
|
54265
|
-
|
|
54266
|
-
|
|
54267
|
-
|
|
54268
|
-
|
|
54269
|
-
|
|
54270
|
-
|
|
54271
|
-
|
|
54272
|
-
|
|
54273
|
-
|
|
54274
|
-
|
|
54275
|
-
|
|
54276
|
-
elapsedMs: getProtocolV2ElapsedMs(attemptStartedAt),
|
|
54277
|
-
attempt,
|
|
54278
|
-
fileWriteWindow: windowed ? hdTransport.PROTOCOL_V2_FILE_WRITE_PIPELINE_WINDOW : 1,
|
|
54151
|
+
yield writeFirmwareByteSource({
|
|
54152
|
+
source,
|
|
54153
|
+
chunkSize: this.getProtocolV2FirmwareChunkSize('write', filePath),
|
|
54154
|
+
write: ({ data, sourceOffset, length, first }) => __awaiter(this, void 0, void 0, function* () {
|
|
54155
|
+
this.throwIfAborted();
|
|
54156
|
+
const chunkEnd = sourceOffset + length;
|
|
54157
|
+
const deviceProgress = getProtocolV2DeviceTransferProgress(processedSize + sourceOffset, processedSize + chunkEnd, totalSize);
|
|
54158
|
+
const response = yield this.fileWriteChunk(filePath, source.size, sourceOffset, data, first, deviceProgress);
|
|
54159
|
+
const rawProcessedByte = response.message.processed_byte;
|
|
54160
|
+
const nextOffset = rawProcessedByte === undefined ? chunkEnd : Number(rawProcessedByte);
|
|
54161
|
+
if (!Number.isFinite(nextOffset) || nextOffset !== chunkEnd) {
|
|
54162
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, `invalid processed_byte ${rawProcessedByte} for offset ${sourceOffset}`);
|
|
54163
|
+
}
|
|
54164
|
+
const transferredBytes = processedSize + chunkEnd;
|
|
54165
|
+
const now = Date.now();
|
|
54166
|
+
const elapsedMs = Math.max(now - transferStartedAt, 0);
|
|
54167
|
+
const progress = Math.min(Math.ceil((transferredBytes / totalSize) * 100), 99);
|
|
54168
|
+
const shouldPostProgress = transferredBytes >= this.protocolV2LastTransferredBytes &&
|
|
54169
|
+
(progress !== this.protocolV2LastTransferProgress ||
|
|
54170
|
+
now - this.protocolV2LastTransferProgressAt >=
|
|
54171
|
+
PROTOCOL_V2_TRANSFER_PROGRESS_HEARTBEAT_MS ||
|
|
54172
|
+
chunkEnd === source.size);
|
|
54173
|
+
if (shouldPostProgress) {
|
|
54174
|
+
this.protocolV2LastTransferProgress = progress;
|
|
54175
|
+
this.protocolV2LastTransferProgressAt = now;
|
|
54176
|
+
this.protocolV2LastTransferredBytes = transferredBytes;
|
|
54177
|
+
this.postProgressMessage(progress, 'transferData', {
|
|
54178
|
+
transferredBytes,
|
|
54179
|
+
totalBytes: totalSize,
|
|
54180
|
+
rateBytesPerSecond: elapsedMs > 0 ? Math.round((transferredBytes / elapsedMs) * 1000) : undefined,
|
|
54181
|
+
elapsedMs,
|
|
54182
|
+
});
|
|
54183
|
+
}
|
|
54184
|
+
return length;
|
|
54185
|
+
}),
|
|
54279
54186
|
});
|
|
54280
54187
|
return processedSize + source.size;
|
|
54281
54188
|
}
|
|
54282
54189
|
catch (error) {
|
|
54283
54190
|
this.throwIfAborted();
|
|
54284
54191
|
lastError = error;
|
|
54285
|
-
Log$6.debug('[FirmwareUpdateV4] Protocol V2 file transfer attempt failed', {
|
|
54286
|
-
path: filePath,
|
|
54287
|
-
attempt,
|
|
54288
|
-
fileWriteWindow: windowed ? hdTransport.PROTOCOL_V2_FILE_WRITE_PIPELINE_WINDOW : 1,
|
|
54289
|
-
error: getProtocolV2UnknownErrorText(error),
|
|
54290
|
-
});
|
|
54291
54192
|
if (attempt < PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT) {
|
|
54292
54193
|
yield this.recoverProtocolV2FileTransfer();
|
|
54293
54194
|
this.throwIfAborted();
|
|
@@ -54970,96 +54871,16 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54970
54871
|
return writeRes;
|
|
54971
54872
|
});
|
|
54972
54873
|
}
|
|
54973
|
-
shouldUseProtocolV2BleFileWriteWindow(minBootloaderVersion = PROTOCOL_V2_BLE_FILE_WRITE_WINDOW_MIN_BOOTLOADER_VERSION) {
|
|
54974
|
-
var _a, _b;
|
|
54975
|
-
const env = DataManager.getSettings('env');
|
|
54976
|
-
if ((env !== 'react-native' && env !== 'desktop-web-ble') ||
|
|
54977
|
-
!this.isProtocolV2BootloaderMode()) {
|
|
54978
|
-
return false;
|
|
54979
|
-
}
|
|
54980
|
-
const bootloaderVersion = getDeviceBootloaderVersion(this.device.features).join('.');
|
|
54981
|
-
const enabled = supportsProtocolV2BleFileWriteWindow(bootloaderVersion, minBootloaderVersion);
|
|
54982
|
-
Log$6.debug('[FirmwareUpdateV4] BLE FileWrite window', {
|
|
54983
|
-
enabled,
|
|
54984
|
-
bootloaderVersion,
|
|
54985
|
-
bootloaderBuildId: (_b = (_a = this.device.features) === null || _a === void 0 ? void 0 : _a.verify) === null || _b === void 0 ? void 0 : _b.bootloaderBuildId,
|
|
54986
|
-
});
|
|
54987
|
-
return enabled;
|
|
54988
|
-
}
|
|
54989
|
-
writeProtocolV2SourceWindowed({ source, filePath, chunkSize, processedSize, totalSize, onChunkConfirmed, }) {
|
|
54990
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
54991
|
-
let sendOffset = 0;
|
|
54992
|
-
let sourceError;
|
|
54993
|
-
const readRequest = () => __awaiter(this, void 0, void 0, function* () {
|
|
54994
|
-
const offset = sendOffset;
|
|
54995
|
-
const length = Math.min(chunkSize, source.size - offset);
|
|
54996
|
-
const data = yield source.readAt(offset, length);
|
|
54997
|
-
sendOffset += length;
|
|
54998
|
-
return {
|
|
54999
|
-
file: { path: filePath, offset, total_size: source.size, data },
|
|
55000
|
-
overwrite: offset === 0,
|
|
55001
|
-
append: false,
|
|
55002
|
-
ui_percentage: getProtocolV2DeviceTransferProgress(processedSize + offset, processedSize + sendOffset, totalSize),
|
|
55003
|
-
};
|
|
55004
|
-
});
|
|
55005
|
-
const nextRequest = () => __awaiter(this, void 0, void 0, function* () {
|
|
55006
|
-
var _a;
|
|
55007
|
-
if (((_a = this.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) || sendOffset >= source.size)
|
|
55008
|
-
return undefined;
|
|
55009
|
-
try {
|
|
55010
|
-
return yield readRequest();
|
|
55011
|
-
}
|
|
55012
|
-
catch (error) {
|
|
55013
|
-
sourceError = error;
|
|
55014
|
-
return undefined;
|
|
55015
|
-
}
|
|
55016
|
-
});
|
|
55017
|
-
this.throwIfAborted();
|
|
55018
|
-
if (source.size === 0)
|
|
55019
|
-
return;
|
|
55020
|
-
const firstRequest = yield readRequest();
|
|
55021
|
-
const response = yield this.device
|
|
55022
|
-
.getCommands()
|
|
55023
|
-
.typedCall('FilesystemFileWrite', 'FilesystemFile', firstRequest, {
|
|
55024
|
-
timeoutMs: PROTOCOL_V2_FILE_WRITE_RESPONSE_TIMEOUT,
|
|
55025
|
-
writeWithResponse: false,
|
|
55026
|
-
fileWritePipeline: {
|
|
55027
|
-
next: nextRequest,
|
|
55028
|
-
onResponse: confirmed => {
|
|
55029
|
-
onChunkConfirmed(Number(confirmed.message.processed_byte));
|
|
55030
|
-
},
|
|
55031
|
-
},
|
|
55032
|
-
})
|
|
55033
|
-
.catch((error) => {
|
|
55034
|
-
this.protocolV2FileWriteWindowDisabled = true;
|
|
55035
|
-
throw error;
|
|
55036
|
-
});
|
|
55037
|
-
this.throwIfAborted();
|
|
55038
|
-
if (sourceError)
|
|
55039
|
-
throw sourceError;
|
|
55040
|
-
const rawProcessedByte = response.message.processed_byte;
|
|
55041
|
-
if (Number(rawProcessedByte) !== source.size) {
|
|
55042
|
-
this.protocolV2FileWriteWindowDisabled = true;
|
|
55043
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, `invalid processed_byte ${rawProcessedByte} for file size ${source.size}`);
|
|
55044
|
-
}
|
|
55045
|
-
});
|
|
55046
|
-
}
|
|
55047
54874
|
recoverProtocolV2FileTransfer() {
|
|
55048
54875
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55049
|
-
|
|
55050
|
-
|
|
55051
|
-
|
|
55052
|
-
yield hdShared.wait(3000);
|
|
55053
|
-
}
|
|
55054
|
-
yield this.reconnectProtocolV2Device();
|
|
55055
|
-
yield this.verifyProtocolV2ReconnectIdentity();
|
|
55056
|
-
yield this.device.initialize();
|
|
55057
|
-
yield hdShared.wait(2000);
|
|
55058
|
-
}
|
|
55059
|
-
catch (error) {
|
|
55060
|
-
this.throwIfAborted();
|
|
55061
|
-
throw error;
|
|
54876
|
+
const env = DataManager.getSettings('env');
|
|
54877
|
+
if (DataManager.isBleConnect(env)) {
|
|
54878
|
+
yield hdShared.wait(3000);
|
|
55062
54879
|
}
|
|
54880
|
+
yield this.reconnectProtocolV2Device();
|
|
54881
|
+
yield this.verifyProtocolV2ReconnectIdentity();
|
|
54882
|
+
yield this.device.initialize();
|
|
54883
|
+
yield hdShared.wait(2000);
|
|
55063
54884
|
});
|
|
55064
54885
|
}
|
|
55065
54886
|
acquireProtocolV2BleDevice(skipProtocolProbe = false) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,GAAG,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAMF,cAAM,GAAG;IACP,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,EAAE,OAAO,CAAC;IAEjB,QAAQ,EAAE,UAAU,EAAE,CAAC;gBAEX,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAM5C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAYxD,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASlB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASpB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASnB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;CAQrB;AAID,eAAO,MAAM,OAAO,WAAY,MAAM,YAAY,OAAO,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,GAAG,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAMF,cAAM,GAAG;IACP,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,EAAE,OAAO,CAAC;IAEjB,QAAQ,EAAE,UAAU,EAAE,CAAC;gBAEX,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAM5C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAYxD,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASlB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASpB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASnB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;CAQrB;AAID,eAAO,MAAM,OAAO,WAAY,MAAM,YAAY,OAAO,QAIxD,CAAC;AAEF,eAAO,MAAM,SAAS,aAAc,OAAO,SAI1C,CAAC;AAEF,eAAO,MAAM,iBAAiB,WAAY,MAAM,WAAW,OAAO,SAIjE,CAAC;AAEF,eAAO,MAAM,MAAM,oBAOlB,CAAC;AAEF,eAAO,MAAM,oBAAoB,4BAA6B,WAAW,KAAK,IAAI,SAEjF,CAAC;AAuCF,oBAAY,WAAW;IACrB,IAAI,oBAAoB;IACxB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IACnC,UAAU,eAAe;IACzB,UAAU,eAAe;IACzB,kBAAkB,+BAA+B;IACjD,QAAQ,uBAAuB;IAC/B,eAAe,8BAA8B;IAC7C,mBAAmB,kCAAkC;IACrD,cAAc,6BAA6B;IAC3C,iBAAiB,iCAAiC;IAClD,iBAAiB,gCAAgC;IACjD,kBAAkB,kCAAkC;IACpD,OAAO,oBAAoB;IAC3B,MAAM,WAAW;IACjB,WAAW,kBAAkB;IAC7B,MAAM,aAAa;CACpB;AAED,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;CAoBrB,CAAC;AAEF,eAAO,MAAM,SAAS,QAAS,WAAW,QAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.2.8-alpha.
|
|
3
|
+
"version": "1.2.8-alpha.121",
|
|
4
4
|
"description": "Core processes and APIs for communicating with OneKey hardware devices.",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-shared": "1.2.8-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.8-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.8-alpha.121",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.8-alpha.121",
|
|
30
30
|
"axios": "1.15.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"buffer": "^6.0.3",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"@types/w3c-web-usb": "^1.0.10",
|
|
47
47
|
"@types/web-bluetooth": "^0.0.21"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "ce1078610eca281844be4caa5444d8dd2023fed4"
|
|
50
50
|
}
|