@onekeyfe/hd-core 1.1.16 → 1.1.18-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.
- package/dist/api/BaseMethod.d.ts +4 -4
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
- package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts +1 -1
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +3 -2
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +2 -2
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts +2 -2
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/device/DeviceFullyUploadResource.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +6 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +6 -3
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/releaseHelper.d.ts +7 -2
- package/dist/api/firmware/releaseHelper.d.ts.map +1 -1
- package/dist/api/firmware/updateBootloader.d.ts +7 -2
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +16 -9
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/index.d.ts +43 -21
- package/dist/index.js +199 -70
- package/dist/types/api/checkAllFirmwareRelease.d.ts +3 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkBootloaderRelease.d.ts +5 -2
- package/dist/types/api/checkBootloaderRelease.d.ts.map +1 -1
- package/dist/types/api/checkFirmwareRelease.d.ts +6 -2
- package/dist/types/api/checkFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceFullyUploadResource.d.ts +6 -1
- package/dist/types/api/deviceFullyUploadResource.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +6 -3
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +3 -1
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/settings.d.ts +3 -0
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +7 -5
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/release.d.ts +1 -1
- package/dist/utils/release.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +17 -7
- package/src/api/CheckAllFirmwareRelease.ts +13 -6
- package/src/api/CheckBootloaderRelease.ts +13 -2
- package/src/api/CheckFirmwareRelease.ts +9 -2
- package/src/api/FirmwareUpdate.ts +7 -5
- package/src/api/FirmwareUpdateV2.ts +26 -14
- package/src/api/FirmwareUpdateV3.ts +29 -18
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +10 -11
- package/src/api/device/DeviceFullyUploadResource.ts +8 -2
- package/src/api/device/DeviceUpdateBootloader.ts +21 -5
- package/src/api/firmware/getBinary.ts +15 -4
- package/src/api/firmware/releaseHelper.ts +22 -11
- package/src/api/firmware/updateBootloader.ts +17 -9
- package/src/api/sui/SuiSignTransaction.ts +7 -1
- package/src/core/index.ts +3 -1
- package/src/data-manager/DataManager.ts +126 -22
- package/src/types/api/checkAllFirmwareRelease.ts +3 -1
- package/src/types/api/checkBootloaderRelease.ts +7 -3
- package/src/types/api/checkFirmwareRelease.ts +10 -2
- package/src/types/api/deviceFullyUploadResource.ts +7 -1
- package/src/types/api/deviceUpdateBootloader.ts +8 -4
- package/src/types/api/firmwareUpdate.ts +4 -1
- package/src/types/settings.ts +37 -0
- package/src/utils/deviceFeaturesUtils.ts +22 -10
- package/src/utils/release.ts +2 -1
package/dist/index.js
CHANGED
|
@@ -24930,7 +24930,54 @@ const findLatestRelease = (releases) => {
|
|
|
24930
24930
|
};
|
|
24931
24931
|
|
|
24932
24932
|
var _a$1;
|
|
24933
|
+
const FIRMWARE_FIELDS = [
|
|
24934
|
+
'firmware',
|
|
24935
|
+
'firmware-v2',
|
|
24936
|
+
'firmware-v7',
|
|
24937
|
+
'firmware-btc-v7',
|
|
24938
|
+
];
|
|
24939
|
+
const FIRMWARE_FIELD_TYPE_MAP = {
|
|
24940
|
+
firmware: hdShared.EFirmwareType.Universal,
|
|
24941
|
+
'firmware-v2': hdShared.EFirmwareType.Universal,
|
|
24942
|
+
'firmware-v7': hdShared.EFirmwareType.Universal,
|
|
24943
|
+
'firmware-btc-v7': hdShared.EFirmwareType.BitcoinOnly,
|
|
24944
|
+
};
|
|
24945
|
+
function getFirmwareTypeFromField(firmwareField) {
|
|
24946
|
+
const firmwareType = FIRMWARE_FIELD_TYPE_MAP[firmwareField];
|
|
24947
|
+
if (firmwareType === undefined) {
|
|
24948
|
+
return hdShared.EFirmwareType.Universal;
|
|
24949
|
+
}
|
|
24950
|
+
return firmwareType;
|
|
24951
|
+
}
|
|
24933
24952
|
class DataManager {
|
|
24953
|
+
static enrichFirmwareReleaseInfo(deviceData) {
|
|
24954
|
+
if (!deviceData || typeof deviceData !== 'object') {
|
|
24955
|
+
return {
|
|
24956
|
+
firmware: [],
|
|
24957
|
+
ble: [],
|
|
24958
|
+
};
|
|
24959
|
+
}
|
|
24960
|
+
const enrichedData = Object.assign({}, deviceData);
|
|
24961
|
+
FIRMWARE_FIELDS.forEach(field => {
|
|
24962
|
+
const releases = enrichedData[field];
|
|
24963
|
+
if (!releases || !Array.isArray(releases) || releases.length === 0) {
|
|
24964
|
+
return;
|
|
24965
|
+
}
|
|
24966
|
+
try {
|
|
24967
|
+
enrichedData[field] = releases.map(release => {
|
|
24968
|
+
if (!release || typeof release !== 'object' || !!release.firmwareType) {
|
|
24969
|
+
return release;
|
|
24970
|
+
}
|
|
24971
|
+
const firmwareType = getFirmwareTypeFromField(field);
|
|
24972
|
+
return Object.assign(Object.assign({}, release), { firmwareType });
|
|
24973
|
+
});
|
|
24974
|
+
}
|
|
24975
|
+
catch (error) {
|
|
24976
|
+
console.error(`Error enriching firmware field "${field}":`, error);
|
|
24977
|
+
}
|
|
24978
|
+
});
|
|
24979
|
+
return enrichedData;
|
|
24980
|
+
}
|
|
24934
24981
|
static load(settings) {
|
|
24935
24982
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24936
24983
|
this.settings = settings;
|
|
@@ -24945,12 +24992,12 @@ class DataManager {
|
|
|
24945
24992
|
timeout: 7000,
|
|
24946
24993
|
});
|
|
24947
24994
|
this.deviceMap = {
|
|
24948
|
-
[hdShared.EDeviceType.Classic]: data.classic,
|
|
24949
|
-
[hdShared.EDeviceType.Classic1s]: data.classic1s,
|
|
24950
|
-
[hdShared.EDeviceType.ClassicPure]: data.classicpure,
|
|
24951
|
-
[hdShared.EDeviceType.Mini]: data.mini,
|
|
24952
|
-
[hdShared.EDeviceType.Touch]: data.touch,
|
|
24953
|
-
[hdShared.EDeviceType.Pro]: data.pro,
|
|
24995
|
+
[hdShared.EDeviceType.Classic]: this.enrichFirmwareReleaseInfo(data.classic),
|
|
24996
|
+
[hdShared.EDeviceType.Classic1s]: this.enrichFirmwareReleaseInfo(data.classic1s),
|
|
24997
|
+
[hdShared.EDeviceType.ClassicPure]: this.enrichFirmwareReleaseInfo(data.classicpure),
|
|
24998
|
+
[hdShared.EDeviceType.Mini]: this.enrichFirmwareReleaseInfo(data.mini),
|
|
24999
|
+
[hdShared.EDeviceType.Touch]: this.enrichFirmwareReleaseInfo(data.touch),
|
|
25000
|
+
[hdShared.EDeviceType.Pro]: this.enrichFirmwareReleaseInfo(data.pro),
|
|
24954
25001
|
};
|
|
24955
25002
|
this.assets = {
|
|
24956
25003
|
bridge: data.bridge,
|
|
@@ -25021,11 +25068,12 @@ DataManager.messages = {
|
|
|
25021
25068
|
v1: MessagesLegacyV1JSON,
|
|
25022
25069
|
};
|
|
25023
25070
|
DataManager.lastCheckTimestamp = 0;
|
|
25024
|
-
DataManager.getFirmwareStatus = (features) => {
|
|
25071
|
+
DataManager.getFirmwareStatus = (features, firmwareType) => {
|
|
25025
25072
|
var _b, _c;
|
|
25026
25073
|
const deviceType = getDeviceType(features);
|
|
25027
25074
|
if (deviceType === hdShared.EDeviceType.Unknown)
|
|
25028
25075
|
return 'unknown';
|
|
25076
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
25029
25077
|
const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
|
|
25030
25078
|
if (features.firmware_present === false) {
|
|
25031
25079
|
return 'none';
|
|
@@ -25033,12 +25081,19 @@ DataManager.getFirmwareStatus = (features) => {
|
|
|
25033
25081
|
if (DeviceModelToTypes.model_mini.includes(deviceType) && features.bootloader_mode) {
|
|
25034
25082
|
return 'unknown';
|
|
25035
25083
|
}
|
|
25036
|
-
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25084
|
+
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25085
|
+
features,
|
|
25086
|
+
updateType: 'firmware',
|
|
25087
|
+
firmwareType,
|
|
25088
|
+
});
|
|
25037
25089
|
const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
25038
|
-
|
|
25090
|
+
let currentVersion = deviceFirmwareVersion.join('.');
|
|
25091
|
+
if (targetDeviceConfigList.length > 0 && deviceFirmwareType !== firmwareType) {
|
|
25092
|
+
currentVersion = '0.0.0';
|
|
25093
|
+
}
|
|
25039
25094
|
return getReleaseStatus(targetDeviceConfigList, currentVersion);
|
|
25040
25095
|
};
|
|
25041
|
-
DataManager.getSysResourcesLatestRelease = (features, forcedUpdateRes) => {
|
|
25096
|
+
DataManager.getSysResourcesLatestRelease = ({ features, forcedUpdateRes, firmwareType, }) => {
|
|
25042
25097
|
var _b, _c, _d;
|
|
25043
25098
|
const deviceType = getDeviceType(features);
|
|
25044
25099
|
const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
|
|
@@ -25047,6 +25102,7 @@ DataManager.getSysResourcesLatestRelease = (features, forcedUpdateRes) => {
|
|
|
25047
25102
|
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25048
25103
|
features,
|
|
25049
25104
|
updateType: 'firmware',
|
|
25105
|
+
firmwareType,
|
|
25050
25106
|
});
|
|
25051
25107
|
const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
25052
25108
|
const currentVersion = deviceFirmwareVersion.join('.');
|
|
@@ -25055,7 +25111,7 @@ DataManager.getSysResourcesLatestRelease = (features, forcedUpdateRes) => {
|
|
|
25055
25111
|
: semver__default["default"].gt(item.version.join('.'), currentVersion) && !!item.resource);
|
|
25056
25112
|
return (_d = findLatestRelease(targetDeviceConfig)) === null || _d === void 0 ? void 0 : _d.resource;
|
|
25057
25113
|
};
|
|
25058
|
-
DataManager.getSysFullResource = (features) => {
|
|
25114
|
+
DataManager.getSysFullResource = (features, firmwareType) => {
|
|
25059
25115
|
var _b, _c, _d;
|
|
25060
25116
|
const deviceType = getDeviceType(features);
|
|
25061
25117
|
if (deviceType === hdShared.EDeviceType.Unknown)
|
|
@@ -25065,12 +25121,13 @@ DataManager.getSysFullResource = (features) => {
|
|
|
25065
25121
|
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25066
25122
|
features,
|
|
25067
25123
|
updateType: 'firmware',
|
|
25124
|
+
firmwareType,
|
|
25068
25125
|
});
|
|
25069
25126
|
const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
25070
25127
|
const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.fullResource);
|
|
25071
25128
|
return (_d = findLatestRelease(targetDeviceConfig)) === null || _d === void 0 ? void 0 : _d.fullResource;
|
|
25072
25129
|
};
|
|
25073
|
-
DataManager.getBootloaderResource = (features) => {
|
|
25130
|
+
DataManager.getBootloaderResource = (features, firmwareType) => {
|
|
25074
25131
|
var _b, _c, _d;
|
|
25075
25132
|
const deviceType = getDeviceType(features);
|
|
25076
25133
|
if (deviceType === hdShared.EDeviceType.Unknown)
|
|
@@ -25080,6 +25137,7 @@ DataManager.getBootloaderResource = (features) => {
|
|
|
25080
25137
|
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25081
25138
|
features,
|
|
25082
25139
|
updateType: 'firmware',
|
|
25140
|
+
firmwareType,
|
|
25083
25141
|
});
|
|
25084
25142
|
const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
25085
25143
|
if (targetDeviceConfigList.length === 0) {
|
|
@@ -25088,7 +25146,7 @@ DataManager.getBootloaderResource = (features) => {
|
|
|
25088
25146
|
const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.bootloaderResource);
|
|
25089
25147
|
return (_d = findLatestRelease(targetDeviceConfig)) === null || _d === void 0 ? void 0 : _d.bootloaderResource;
|
|
25090
25148
|
};
|
|
25091
|
-
DataManager.getBootloaderTargetVersion = (features) => {
|
|
25149
|
+
DataManager.getBootloaderTargetVersion = (features, firmwareType) => {
|
|
25092
25150
|
var _b, _c, _d, _e;
|
|
25093
25151
|
const deviceType = getDeviceType(features);
|
|
25094
25152
|
if (deviceType === hdShared.EDeviceType.Unknown)
|
|
@@ -25096,12 +25154,13 @@ DataManager.getBootloaderTargetVersion = (features) => {
|
|
|
25096
25154
|
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25097
25155
|
features,
|
|
25098
25156
|
updateType: 'firmware',
|
|
25157
|
+
firmwareType,
|
|
25099
25158
|
});
|
|
25100
25159
|
const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
25101
25160
|
const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.bootloaderResource);
|
|
25102
25161
|
return (_e = (_d = targetDeviceConfig === null || targetDeviceConfig === void 0 ? void 0 : targetDeviceConfig[0]) === null || _d === void 0 ? void 0 : _d.bootloaderVersion) !== null && _e !== void 0 ? _e : undefined;
|
|
25103
25162
|
};
|
|
25104
|
-
DataManager.getBootloaderRelatedFirmwareVersion = (features) => {
|
|
25163
|
+
DataManager.getBootloaderRelatedFirmwareVersion = (features, firmwareType) => {
|
|
25105
25164
|
var _b, _c, _d, _e;
|
|
25106
25165
|
const deviceType = getDeviceType(features);
|
|
25107
25166
|
if (deviceType === hdShared.EDeviceType.Unknown)
|
|
@@ -25111,12 +25170,13 @@ DataManager.getBootloaderRelatedFirmwareVersion = (features) => {
|
|
|
25111
25170
|
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25112
25171
|
features,
|
|
25113
25172
|
updateType: 'firmware',
|
|
25173
|
+
firmwareType,
|
|
25114
25174
|
});
|
|
25115
25175
|
const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
25116
25176
|
const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.bootloaderRelatedFirmwareVersion);
|
|
25117
25177
|
return (_e = (_d = targetDeviceConfig === null || targetDeviceConfig === void 0 ? void 0 : targetDeviceConfig[0]) === null || _d === void 0 ? void 0 : _d.bootloaderRelatedFirmwareVersion) !== null && _e !== void 0 ? _e : undefined;
|
|
25118
25178
|
};
|
|
25119
|
-
DataManager.getFirmwareChangelog = (features) => {
|
|
25179
|
+
DataManager.getFirmwareChangelog = (features, firmwareType) => {
|
|
25120
25180
|
var _b, _c;
|
|
25121
25181
|
const deviceType = getDeviceType(features);
|
|
25122
25182
|
if (deviceType === hdShared.EDeviceType.Unknown)
|
|
@@ -25125,6 +25185,7 @@ DataManager.getFirmwareChangelog = (features) => {
|
|
|
25125
25185
|
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25126
25186
|
features,
|
|
25127
25187
|
updateType: 'firmware',
|
|
25188
|
+
firmwareType,
|
|
25128
25189
|
});
|
|
25129
25190
|
const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
25130
25191
|
if (features.firmware_present === false ||
|
|
@@ -25134,7 +25195,7 @@ DataManager.getFirmwareChangelog = (features) => {
|
|
|
25134
25195
|
const currentVersion = deviceFirmwareVersion.join('.');
|
|
25135
25196
|
return getReleaseChangelog(targetDeviceConfigList, currentVersion);
|
|
25136
25197
|
};
|
|
25137
|
-
DataManager.getFirmwareLatestRelease = (features) => {
|
|
25198
|
+
DataManager.getFirmwareLatestRelease = (features, firmwareType) => {
|
|
25138
25199
|
var _b, _c;
|
|
25139
25200
|
const deviceType = getDeviceType(features);
|
|
25140
25201
|
if (deviceType === hdShared.EDeviceType.Unknown)
|
|
@@ -25142,13 +25203,14 @@ DataManager.getFirmwareLatestRelease = (features) => {
|
|
|
25142
25203
|
const firmwareUpdateField = getFirmwareUpdateField({
|
|
25143
25204
|
features,
|
|
25144
25205
|
updateType: 'firmware',
|
|
25206
|
+
firmwareType,
|
|
25145
25207
|
});
|
|
25146
25208
|
const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
25147
25209
|
const target = findLatestRelease(targetDeviceConfigList);
|
|
25148
25210
|
if (!target)
|
|
25149
25211
|
return target;
|
|
25150
25212
|
if (!target.resource) {
|
|
25151
|
-
const resource = _a$1.getSysResourcesLatestRelease(features);
|
|
25213
|
+
const resource = _a$1.getSysResourcesLatestRelease({ features, firmwareType });
|
|
25152
25214
|
return Object.assign(Object.assign({}, target), { resource });
|
|
25153
25215
|
}
|
|
25154
25216
|
return target;
|
|
@@ -25347,28 +25409,35 @@ const supportModifyHomescreen = (features) => {
|
|
|
25347
25409
|
}
|
|
25348
25410
|
return { support: semver__default["default"].gte(currentVersion, '3.4.0') };
|
|
25349
25411
|
};
|
|
25350
|
-
const
|
|
25412
|
+
const getLatestFirmwareField = (firmwareType) => {
|
|
25413
|
+
if (firmwareType === 'bitcoinonly') {
|
|
25414
|
+
return `firmware-btc-v7`;
|
|
25415
|
+
}
|
|
25416
|
+
return `firmware-v7`;
|
|
25417
|
+
};
|
|
25418
|
+
const getFirmwareUpdateField = ({ features, updateType, targetVersion, firmwareType, }) => {
|
|
25351
25419
|
const deviceType = getDeviceType(features);
|
|
25352
25420
|
const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
|
|
25353
25421
|
if (updateType === 'ble') {
|
|
25354
25422
|
return 'ble';
|
|
25355
25423
|
}
|
|
25424
|
+
const latestFirmwareField = getLatestFirmwareField(firmwareType);
|
|
25356
25425
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
25357
|
-
return
|
|
25426
|
+
return latestFirmwareField;
|
|
25358
25427
|
}
|
|
25359
25428
|
if (deviceType === hdShared.EDeviceType.Touch) {
|
|
25360
25429
|
if (targetVersion) {
|
|
25361
25430
|
if (semver__default["default"].eq(targetVersion, '4.0.0'))
|
|
25362
25431
|
return 'firmware-v2';
|
|
25363
25432
|
if (semver__default["default"].gt(targetVersion, '4.0.0'))
|
|
25364
|
-
return
|
|
25433
|
+
return latestFirmwareField;
|
|
25365
25434
|
}
|
|
25366
25435
|
if (semver__default["default"].lt(deviceFirmwareVersion.join('.'), '3.4.0'))
|
|
25367
25436
|
return 'firmware';
|
|
25368
|
-
return
|
|
25437
|
+
return latestFirmwareField;
|
|
25369
25438
|
}
|
|
25370
25439
|
if (deviceType === hdShared.EDeviceType.Pro) {
|
|
25371
|
-
return
|
|
25440
|
+
return latestFirmwareField;
|
|
25372
25441
|
}
|
|
25373
25442
|
return 'firmware';
|
|
25374
25443
|
};
|
|
@@ -25550,20 +25619,20 @@ function isEnteredManuallyBoot(features, updateType) {
|
|
|
25550
25619
|
return isMini || isBoot183ClassicUpBle;
|
|
25551
25620
|
}
|
|
25552
25621
|
|
|
25553
|
-
function checkNeedUpdateBootForTouch(features) {
|
|
25622
|
+
function checkNeedUpdateBootForTouch(features, firmwareType) {
|
|
25554
25623
|
const deviceType = getDeviceType(features);
|
|
25555
25624
|
if (!DeviceModelToTypes.model_touch.includes(deviceType))
|
|
25556
25625
|
return false;
|
|
25557
25626
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
25558
25627
|
const bootloaderVersion = getDeviceBootloaderVersion(features).join('.');
|
|
25559
|
-
const targetBootloaderVersion = DataManager.getBootloaderTargetVersion(features);
|
|
25628
|
+
const targetBootloaderVersion = DataManager.getBootloaderTargetVersion(features, firmwareType);
|
|
25560
25629
|
if (!targetBootloaderVersion)
|
|
25561
25630
|
return false;
|
|
25562
25631
|
return (semver__default["default"].gte(currentVersion, '3.2.0') &&
|
|
25563
25632
|
semver__default["default"].gte(currentVersion, '4.1.0') &&
|
|
25564
25633
|
semver__default["default"].lte(bootloaderVersion, targetBootloaderVersion.join('.')));
|
|
25565
25634
|
}
|
|
25566
|
-
function checkNeedUpdateBootForClassicAndMini(features, willUpdateFirmware) {
|
|
25635
|
+
function checkNeedUpdateBootForClassicAndMini({ features, willUpdateFirmware, firmwareType, }) {
|
|
25567
25636
|
const deviceType = getDeviceType(features);
|
|
25568
25637
|
if (!DeviceModelToTypes.model_mini.includes(deviceType))
|
|
25569
25638
|
return false;
|
|
@@ -25571,11 +25640,11 @@ function checkNeedUpdateBootForClassicAndMini(features, willUpdateFirmware) {
|
|
|
25571
25640
|
return false;
|
|
25572
25641
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
25573
25642
|
const bootloaderVersion = getDeviceBootloaderVersion(features).join('.');
|
|
25574
|
-
const targetBootloaderVersion = DataManager.getBootloaderTargetVersion(features);
|
|
25643
|
+
const targetBootloaderVersion = DataManager.getBootloaderTargetVersion(features, firmwareType);
|
|
25575
25644
|
if (targetBootloaderVersion && semver__default["default"].gte(bootloaderVersion, targetBootloaderVersion.join('.'))) {
|
|
25576
25645
|
return false;
|
|
25577
25646
|
}
|
|
25578
|
-
const bootloaderRelatedFirmwareVersion = DataManager.getBootloaderRelatedFirmwareVersion(features);
|
|
25647
|
+
const bootloaderRelatedFirmwareVersion = DataManager.getBootloaderRelatedFirmwareVersion(features, firmwareType);
|
|
25579
25648
|
if (!bootloaderRelatedFirmwareVersion)
|
|
25580
25649
|
return false;
|
|
25581
25650
|
return shouldUpdateBootloaderForClassicAndMini({
|
|
@@ -27445,10 +27514,10 @@ class DeviceList extends events.exports {
|
|
|
27445
27514
|
}
|
|
27446
27515
|
}
|
|
27447
27516
|
|
|
27448
|
-
const getFirmwareReleaseInfo = (features) => {
|
|
27449
|
-
const firmwareStatus = DataManager.getFirmwareStatus(features);
|
|
27450
|
-
const changelog = DataManager.getFirmwareChangelog(features);
|
|
27451
|
-
const release = DataManager.getFirmwareLatestRelease(features);
|
|
27517
|
+
const getFirmwareReleaseInfo = (features, firmwareType) => {
|
|
27518
|
+
const firmwareStatus = DataManager.getFirmwareStatus(features, firmwareType);
|
|
27519
|
+
const changelog = DataManager.getFirmwareChangelog(features, firmwareType);
|
|
27520
|
+
const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
|
|
27452
27521
|
const bootloaderMode = !!features.bootloader_mode;
|
|
27453
27522
|
return {
|
|
27454
27523
|
status: firmwareStatus,
|
|
@@ -27469,8 +27538,8 @@ const getBleFirmwareReleaseInfo = (features) => {
|
|
|
27469
27538
|
bootloaderMode,
|
|
27470
27539
|
};
|
|
27471
27540
|
};
|
|
27472
|
-
const getBootloaderReleaseInfo = (features, willUpdateFirmwareVersion) => {
|
|
27473
|
-
const release = DataManager.getFirmwareLatestRelease(features);
|
|
27541
|
+
const getBootloaderReleaseInfo = ({ features, willUpdateFirmwareVersion, firmwareType, }) => {
|
|
27542
|
+
const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
|
|
27474
27543
|
const changelog = [release === null || release === void 0 ? void 0 : release.bootloaderChangelog].filter(item => item != null &&
|
|
27475
27544
|
typeof item === 'object' &&
|
|
27476
27545
|
Object.prototype.hasOwnProperty.call(item, 'zh-CN') &&
|
|
@@ -27479,10 +27548,14 @@ const getBootloaderReleaseInfo = (features, willUpdateFirmwareVersion) => {
|
|
|
27479
27548
|
let shouldUpdate = false;
|
|
27480
27549
|
const deviceType = getDeviceType(features);
|
|
27481
27550
|
if (DeviceModelToTypes.model_mini.includes(deviceType)) {
|
|
27482
|
-
shouldUpdate = !!checkNeedUpdateBootForClassicAndMini(
|
|
27551
|
+
shouldUpdate = !!checkNeedUpdateBootForClassicAndMini({
|
|
27552
|
+
features,
|
|
27553
|
+
willUpdateFirmware: willUpdateFirmwareVersion,
|
|
27554
|
+
firmwareType,
|
|
27555
|
+
});
|
|
27483
27556
|
}
|
|
27484
27557
|
else if (DeviceModelToTypes.model_touch.includes(deviceType)) {
|
|
27485
|
-
shouldUpdate = checkNeedUpdateBootForTouch(features);
|
|
27558
|
+
shouldUpdate = checkNeedUpdateBootForTouch(features, firmwareType);
|
|
27486
27559
|
}
|
|
27487
27560
|
return {
|
|
27488
27561
|
status: shouldUpdate ? 'outdated' : 'valid',
|
|
@@ -27526,7 +27599,8 @@ class BaseMethod {
|
|
|
27526
27599
|
checkFirmwareRelease() {
|
|
27527
27600
|
if (!this.device || !this.device.features)
|
|
27528
27601
|
return;
|
|
27529
|
-
const
|
|
27602
|
+
const firmwareType = getFirmwareType(this.device.features);
|
|
27603
|
+
const releaseInfo = getFirmwareReleaseInfo(this.device.features, firmwareType);
|
|
27530
27604
|
this.postMessage(createFirmwareMessage(FIRMWARE.RELEASE_INFO, Object.assign(Object.assign({}, releaseInfo), { device: this.device.toMessageObject() })));
|
|
27531
27605
|
const bleReleaseInfo = getBleFirmwareReleaseInfo(this.device.features);
|
|
27532
27606
|
this.postMessage(createFirmwareMessage(FIRMWARE.BLE_RELEASE_INFO, Object.assign(Object.assign({}, bleReleaseInfo), { device: this.device.toMessageObject() })));
|
|
@@ -27726,8 +27800,12 @@ class CheckFirmwareRelease extends BaseMethod {
|
|
|
27726
27800
|
this.skipForceUpdateCheck = true;
|
|
27727
27801
|
}
|
|
27728
27802
|
run() {
|
|
27803
|
+
var _a;
|
|
27804
|
+
const payload = this.payload;
|
|
27729
27805
|
if (this.device.features) {
|
|
27730
|
-
const
|
|
27806
|
+
const deviceFirmwareType = getFirmwareType(this.device.features);
|
|
27807
|
+
const firmwareType = (_a = payload.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
|
|
27808
|
+
const releaseInfo = getFirmwareReleaseInfo(this.device.features, firmwareType);
|
|
27731
27809
|
return Promise.resolve(releaseInfo);
|
|
27732
27810
|
}
|
|
27733
27811
|
return Promise.resolve(null);
|
|
@@ -27868,12 +27946,20 @@ class CheckBootloaderRelease extends BaseMethod {
|
|
|
27868
27946
|
this.skipForceUpdateCheck = true;
|
|
27869
27947
|
}
|
|
27870
27948
|
run() {
|
|
27949
|
+
var _a;
|
|
27871
27950
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27872
27951
|
if (!this.device.features) {
|
|
27873
27952
|
return null;
|
|
27874
27953
|
}
|
|
27875
27954
|
const { features } = this.device;
|
|
27876
|
-
const
|
|
27955
|
+
const payload = this.payload;
|
|
27956
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
27957
|
+
const firmwareType = (_a = payload.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
|
|
27958
|
+
const releaseInfo = getBootloaderReleaseInfo({
|
|
27959
|
+
features,
|
|
27960
|
+
willUpdateFirmwareVersion: payload.willUpdateFirmwareVersion,
|
|
27961
|
+
firmwareType,
|
|
27962
|
+
});
|
|
27877
27963
|
return Promise.resolve(releaseInfo);
|
|
27878
27964
|
});
|
|
27879
27965
|
}
|
|
@@ -27889,11 +27975,14 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
27889
27975
|
var _a, _b;
|
|
27890
27976
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27891
27977
|
const { features } = this.device;
|
|
27892
|
-
const { checkBridgeRelease } = this
|
|
27978
|
+
const { checkBridgeRelease, firmwareType: firmwareTypeParams } = this
|
|
27979
|
+
.payload;
|
|
27893
27980
|
if (!features) {
|
|
27894
27981
|
return Promise.resolve(null);
|
|
27895
27982
|
}
|
|
27896
|
-
const
|
|
27983
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
27984
|
+
const firmwareType = firmwareTypeParams !== null && firmwareTypeParams !== void 0 ? firmwareTypeParams : deviceFirmwareType;
|
|
27985
|
+
const firmwareRelease = getFirmwareReleaseInfo(features, firmwareType);
|
|
27897
27986
|
const currentFirmwareVersion = getDeviceFirmwareVersion(features).join('.');
|
|
27898
27987
|
const willUpdateFirmwareVersion = (_b = (_a = firmwareRelease.release) === null || _a === void 0 ? void 0 : _a.version) === null || _b === void 0 ? void 0 : _b.join('.');
|
|
27899
27988
|
const deviceType = getDeviceType(features);
|
|
@@ -27906,7 +27995,11 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
27906
27995
|
willUpdateFirmwareVersion,
|
|
27907
27996
|
});
|
|
27908
27997
|
}
|
|
27909
|
-
const bootloaderRelease = getBootloaderReleaseInfo(
|
|
27998
|
+
const bootloaderRelease = getBootloaderReleaseInfo({
|
|
27999
|
+
features,
|
|
28000
|
+
willUpdateFirmwareVersion,
|
|
28001
|
+
firmwareType,
|
|
28002
|
+
});
|
|
27910
28003
|
const bleFirmwareReleaseInfo = getBleFirmwareReleaseInfo(features);
|
|
27911
28004
|
return {
|
|
27912
28005
|
firmware: firmwareRelease,
|
|
@@ -28552,8 +28645,13 @@ class DeviceWipe extends BaseMethod {
|
|
|
28552
28645
|
}
|
|
28553
28646
|
}
|
|
28554
28647
|
|
|
28555
|
-
const getBinary = ({ features, updateType, version, isUpdateBootloader, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28556
|
-
const releaseInfo = getInfo({
|
|
28648
|
+
const getBinary = ({ features, updateType, version, isUpdateBootloader, firmwareType, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28649
|
+
const releaseInfo = getInfo({
|
|
28650
|
+
features,
|
|
28651
|
+
updateType,
|
|
28652
|
+
targetVersion: version === null || version === void 0 ? void 0 : version.join('.'),
|
|
28653
|
+
firmwareType,
|
|
28654
|
+
});
|
|
28557
28655
|
if (!releaseInfo) {
|
|
28558
28656
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'no firmware found for this device');
|
|
28559
28657
|
}
|
|
@@ -28590,7 +28688,7 @@ const getSysResourceBinary = (url) => __awaiter(void 0, void 0, void 0, function
|
|
|
28590
28688
|
binary: fw,
|
|
28591
28689
|
};
|
|
28592
28690
|
});
|
|
28593
|
-
const getInfo = ({ features, updateType, targetVersion }) => {
|
|
28691
|
+
const getInfo = ({ features, updateType, targetVersion, firmwareType }) => {
|
|
28594
28692
|
var _a, _b;
|
|
28595
28693
|
const deviceType = getDeviceType(features);
|
|
28596
28694
|
if (deviceType === 'unknown') {
|
|
@@ -28601,6 +28699,7 @@ const getInfo = ({ features, updateType, targetVersion }) => {
|
|
|
28601
28699
|
features,
|
|
28602
28700
|
updateType,
|
|
28603
28701
|
targetVersion,
|
|
28702
|
+
firmwareType,
|
|
28604
28703
|
});
|
|
28605
28704
|
const releaseInfo = (_b = (_a = deviceMap === null || deviceMap === void 0 ? void 0 : deviceMap[deviceType]) === null || _a === void 0 ? void 0 : _a[firmwareUpdateField]) !== null && _b !== void 0 ? _b : [];
|
|
28606
28705
|
return findLatestRelease(releaseInfo);
|
|
@@ -28943,15 +29042,19 @@ class DeviceFullyUploadResource extends BaseMethod {
|
|
|
28943
29042
|
return isTouchMode && semver__default["default"].gte(currentVersion, '3.4.0');
|
|
28944
29043
|
}
|
|
28945
29044
|
run() {
|
|
29045
|
+
var _a;
|
|
28946
29046
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28947
29047
|
const { device } = this;
|
|
28948
29048
|
const { features } = device;
|
|
29049
|
+
const payload = this.payload;
|
|
29050
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
29051
|
+
const firmwareType = (_a = payload.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
|
|
28949
29052
|
if (!(features === null || features === void 0 ? void 0 : features.bootloader_mode) && features) {
|
|
28950
29053
|
if (features) {
|
|
28951
29054
|
let { binary } = this.payload;
|
|
28952
29055
|
if (!binary) {
|
|
28953
29056
|
this.postTipMessage('CheckLatestUiResource');
|
|
28954
|
-
const resourceUrl = DataManager.getSysFullResource(features);
|
|
29057
|
+
const resourceUrl = DataManager.getSysFullResource(features, firmwareType);
|
|
28955
29058
|
if (resourceUrl) {
|
|
28956
29059
|
this.postTipMessage('DownloadLatestUiResource');
|
|
28957
29060
|
const resource = yield getSysResourceBinary(resourceUrl);
|
|
@@ -29315,12 +29418,14 @@ class DeviceUpdateBootloader extends FirmwareUpdateBaseMethod {
|
|
|
29315
29418
|
return true;
|
|
29316
29419
|
});
|
|
29317
29420
|
}
|
|
29318
|
-
updateTouchBootloader(device, features) {
|
|
29421
|
+
updateTouchBootloader({ device, features, firmwareType, }) {
|
|
29319
29422
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29320
29423
|
let { binary } = this.payload;
|
|
29321
29424
|
if (!binary) {
|
|
29322
29425
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.CheckLatestUiResource);
|
|
29323
|
-
const resourceUrl = features
|
|
29426
|
+
const resourceUrl = features
|
|
29427
|
+
? DataManager.getBootloaderResource(features, firmwareType)
|
|
29428
|
+
: null;
|
|
29324
29429
|
if (resourceUrl) {
|
|
29325
29430
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.DownloadLatestBootloaderResource);
|
|
29326
29431
|
const resource = yield getSysResourceBinary(resourceUrl);
|
|
@@ -29344,12 +29449,16 @@ class DeviceUpdateBootloader extends FirmwareUpdateBaseMethod {
|
|
|
29344
29449
|
});
|
|
29345
29450
|
}
|
|
29346
29451
|
run() {
|
|
29452
|
+
var _a;
|
|
29347
29453
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29348
29454
|
const { device } = this;
|
|
29349
29455
|
const { features } = device;
|
|
29456
|
+
const payload = this.payload;
|
|
29350
29457
|
const deviceType = getDeviceType(features);
|
|
29458
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
29459
|
+
const firmwareType = (_a = payload.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
|
|
29351
29460
|
if (DeviceModelToTypes.model_touch.includes(deviceType)) {
|
|
29352
|
-
return this.updateTouchBootloader(device, features);
|
|
29461
|
+
return this.updateTouchBootloader({ device, features, firmwareType });
|
|
29353
29462
|
}
|
|
29354
29463
|
return Promise.resolve(true);
|
|
29355
29464
|
});
|
|
@@ -29541,6 +29650,7 @@ class FirmwareUpdate extends BaseMethod {
|
|
|
29541
29650
|
features: device.features,
|
|
29542
29651
|
version: params.version,
|
|
29543
29652
|
updateType: params.updateType,
|
|
29653
|
+
firmwareType: hdShared.EFirmwareType.Universal,
|
|
29544
29654
|
});
|
|
29545
29655
|
binary = firmware.binary;
|
|
29546
29656
|
this.postTipMessage('DownloadFirmwareSuccess');
|
|
@@ -29584,6 +29694,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29584
29694
|
{ name: 'binary', type: 'buffer' },
|
|
29585
29695
|
{ name: 'forcedUpdateRes', type: 'boolean' },
|
|
29586
29696
|
{ name: 'platform', type: 'string', required: true },
|
|
29697
|
+
{ name: 'firmwareType', type: 'string' },
|
|
29587
29698
|
]);
|
|
29588
29699
|
if (!payload.updateType) {
|
|
29589
29700
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'updateType is required');
|
|
@@ -29594,7 +29705,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29594
29705
|
isUpdateBootloader: payload.isUpdateBootloader,
|
|
29595
29706
|
};
|
|
29596
29707
|
if ('version' in payload) {
|
|
29597
|
-
this.params = Object.assign(Object.assign({}, this.params), { version: payload.version });
|
|
29708
|
+
this.params = Object.assign(Object.assign({}, this.params), { version: payload.version, firmwareType: payload.firmwareType });
|
|
29598
29709
|
}
|
|
29599
29710
|
if ('binary' in payload) {
|
|
29600
29711
|
this.params = Object.assign(Object.assign({}, this.params), { binary: payload.binary });
|
|
@@ -29715,7 +29826,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29715
29826
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
29716
29827
|
return isTouchMode && semver__default["default"].gte(currentVersion, '3.2.0');
|
|
29717
29828
|
}
|
|
29718
|
-
checkVersionForCopyTouchResource(features) {
|
|
29829
|
+
checkVersionForCopyTouchResource(features, firmwareType) {
|
|
29719
29830
|
var _a;
|
|
29720
29831
|
if (!features)
|
|
29721
29832
|
return;
|
|
@@ -29723,7 +29834,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29723
29834
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
29724
29835
|
const targetVersion = (_a = this.params.version) === null || _a === void 0 ? void 0 : _a.join('.');
|
|
29725
29836
|
const { updateType } = this.params;
|
|
29726
|
-
const releaseInfo = getInfo({ features, updateType });
|
|
29837
|
+
const releaseInfo = getInfo({ features, updateType, firmwareType });
|
|
29727
29838
|
if (!releaseInfo)
|
|
29728
29839
|
return;
|
|
29729
29840
|
const { fullResourceRange } = releaseInfo;
|
|
@@ -29739,12 +29850,14 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29739
29850
|
}
|
|
29740
29851
|
}
|
|
29741
29852
|
run() {
|
|
29742
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
29853
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
29743
29854
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29744
29855
|
const { device, params } = this;
|
|
29745
29856
|
const { features, commands } = device;
|
|
29746
29857
|
const deviceType = getDeviceType(features);
|
|
29747
|
-
|
|
29858
|
+
const deviceFirmwareType = getFirmwareType(device.features);
|
|
29859
|
+
const firmwareType = (_a = params.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
|
|
29860
|
+
this.checkVersionForCopyTouchResource(features, firmwareType);
|
|
29748
29861
|
if (!(features === null || features === void 0 ? void 0 : features.bootloader_mode) && features) {
|
|
29749
29862
|
const uuid = getDeviceUUID(features);
|
|
29750
29863
|
if (this.isEnteredManuallyBoot(features)) {
|
|
@@ -29752,7 +29865,11 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29752
29865
|
}
|
|
29753
29866
|
if (features && this.isSupportResourceUpdate(features, params.updateType)) {
|
|
29754
29867
|
this.postTipMessage('CheckLatestUiResource');
|
|
29755
|
-
const resourceUrl = DataManager.getSysResourcesLatestRelease(
|
|
29868
|
+
const resourceUrl = DataManager.getSysResourcesLatestRelease({
|
|
29869
|
+
features,
|
|
29870
|
+
forcedUpdateRes: params.forcedUpdateRes,
|
|
29871
|
+
firmwareType,
|
|
29872
|
+
});
|
|
29756
29873
|
if (resourceUrl) {
|
|
29757
29874
|
this.postTipMessage('DownloadLatestUiResource');
|
|
29758
29875
|
const resource = yield getSysResourceBinary(resourceUrl);
|
|
@@ -29762,7 +29879,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29762
29879
|
}
|
|
29763
29880
|
}
|
|
29764
29881
|
}
|
|
29765
|
-
(
|
|
29882
|
+
(_c = (_b = this.device) === null || _b === void 0 ? void 0 : _b.commands) === null || _c === void 0 ? void 0 : _c.checkDisposed();
|
|
29766
29883
|
try {
|
|
29767
29884
|
this.postTipMessage('AutoRebootToBootloader');
|
|
29768
29885
|
const bootRes = yield commands.typedCall('DeviceBackToBoot', 'Success');
|
|
@@ -29775,9 +29892,9 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29775
29892
|
DevicePool.clearDeviceCache(uuid);
|
|
29776
29893
|
}
|
|
29777
29894
|
delete DevicePool.devicesCache[''];
|
|
29778
|
-
yield ((
|
|
29895
|
+
yield ((_d = this.checkPromise) === null || _d === void 0 ? void 0 : _d.promise);
|
|
29779
29896
|
this.checkPromise = null;
|
|
29780
|
-
(
|
|
29897
|
+
(_f = (_e = this.device) === null || _e === void 0 ? void 0 : _e.commands) === null || _f === void 0 ? void 0 : _f.checkDisposed();
|
|
29781
29898
|
const isTouch = DeviceModelToTypes.model_touch.includes(deviceType);
|
|
29782
29899
|
yield wait(isTouch ? 3000 : 1500);
|
|
29783
29900
|
}
|
|
@@ -29804,15 +29921,16 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
29804
29921
|
version: params.version,
|
|
29805
29922
|
updateType: params.updateType,
|
|
29806
29923
|
isUpdateBootloader: params.isUpdateBootloader,
|
|
29924
|
+
firmwareType,
|
|
29807
29925
|
});
|
|
29808
29926
|
binary = firmware.binary;
|
|
29809
29927
|
this.postTipMessage('DownloadFirmwareSuccess');
|
|
29810
29928
|
}
|
|
29811
29929
|
}
|
|
29812
29930
|
catch (err) {
|
|
29813
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, (
|
|
29931
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, (_g = err.message) !== null && _g !== void 0 ? _g : err);
|
|
29814
29932
|
}
|
|
29815
|
-
(
|
|
29933
|
+
(_j = (_h = this.device) === null || _h === void 0 ? void 0 : _h.commands) === null || _j === void 0 ? void 0 : _j.checkDisposed();
|
|
29816
29934
|
yield this.device.acquire();
|
|
29817
29935
|
const response = yield uploadFirmware(params.updateType, this.device.getCommands().typedCall.bind(this.device.getCommands()), this.postMessage, device, { payload: binary, rebootOnSuccess: true });
|
|
29818
29936
|
if (this.connectId) {
|
|
@@ -29845,6 +29963,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29845
29963
|
{ name: 'forcedUpdateRes', type: 'boolean' },
|
|
29846
29964
|
{ name: 'bootloaderVersion', type: 'array' },
|
|
29847
29965
|
{ name: 'bootloaderBinary', type: 'buffer' },
|
|
29966
|
+
{ name: 'firmwareType', type: 'string' },
|
|
29848
29967
|
{ name: 'platform', type: 'string' },
|
|
29849
29968
|
]);
|
|
29850
29969
|
this.params = {
|
|
@@ -29856,11 +29975,12 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29856
29975
|
bootloaderBinary: payload.bootloaderBinary,
|
|
29857
29976
|
firmwareVersion: payload.firmwareVersion,
|
|
29858
29977
|
resourceBinary: payload.resourceBinary,
|
|
29978
|
+
firmwareType: payload.firmwareType,
|
|
29859
29979
|
platform: payload.platform,
|
|
29860
29980
|
};
|
|
29861
29981
|
}
|
|
29862
29982
|
run() {
|
|
29863
|
-
var _a;
|
|
29983
|
+
var _a, _b;
|
|
29864
29984
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29865
29985
|
const { device } = this;
|
|
29866
29986
|
const { features } = device;
|
|
@@ -29870,18 +29990,20 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29870
29990
|
if (!features) {
|
|
29871
29991
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Device features not available');
|
|
29872
29992
|
}
|
|
29993
|
+
const deviceFirmwareType = getFirmwareType(features);
|
|
29994
|
+
const firmwareType = (_a = this.params.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
|
|
29873
29995
|
let resourceBinary = null;
|
|
29874
29996
|
let fwBinaryMap = [];
|
|
29875
29997
|
let bootloaderBinary = null;
|
|
29876
29998
|
try {
|
|
29877
29999
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.StartDownloadFirmware);
|
|
29878
|
-
resourceBinary = yield this.prepareResourceBinary();
|
|
29879
|
-
fwBinaryMap = yield this.prepareFirmwareAndBleBinary();
|
|
29880
|
-
bootloaderBinary = yield this.prepareBootloaderBinary();
|
|
30000
|
+
resourceBinary = yield this.prepareResourceBinary(firmwareType);
|
|
30001
|
+
fwBinaryMap = yield this.prepareFirmwareAndBleBinary(firmwareType);
|
|
30002
|
+
bootloaderBinary = yield this.prepareBootloaderBinary(firmwareType);
|
|
29881
30003
|
this.postTipMessage(exports.FirmwareUpdateTipMessage.FinishDownloadFirmware);
|
|
29882
30004
|
}
|
|
29883
30005
|
catch (err) {
|
|
29884
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, (
|
|
30006
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, (_b = err.message) !== null && _b !== void 0 ? _b : err);
|
|
29885
30007
|
}
|
|
29886
30008
|
if (!bootloaderBinary && fwBinaryMap.length === 0) {
|
|
29887
30009
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, 'No firmware to update');
|
|
@@ -29906,7 +30028,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29906
30028
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'bootloader version needs to be updated');
|
|
29907
30029
|
}
|
|
29908
30030
|
}
|
|
29909
|
-
prepareResourceBinary() {
|
|
30031
|
+
prepareResourceBinary(firmwareType) {
|
|
29910
30032
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29911
30033
|
if (this.params.resourceBinary) {
|
|
29912
30034
|
return this.params.resourceBinary;
|
|
@@ -29914,7 +30036,11 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29914
30036
|
const { features } = this.device;
|
|
29915
30037
|
if (!features)
|
|
29916
30038
|
return null;
|
|
29917
|
-
const resourceUrl = DataManager.getSysResourcesLatestRelease(
|
|
30039
|
+
const resourceUrl = DataManager.getSysResourcesLatestRelease({
|
|
30040
|
+
features,
|
|
30041
|
+
forcedUpdateRes: this.params.forcedUpdateRes,
|
|
30042
|
+
firmwareType,
|
|
30043
|
+
});
|
|
29918
30044
|
if (resourceUrl) {
|
|
29919
30045
|
const resource = (yield getSysResourceBinary(resourceUrl)).binary;
|
|
29920
30046
|
return resource;
|
|
@@ -29923,7 +30049,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29923
30049
|
return null;
|
|
29924
30050
|
});
|
|
29925
30051
|
}
|
|
29926
|
-
prepareBootloaderBinary() {
|
|
30052
|
+
prepareBootloaderBinary(firmwareType) {
|
|
29927
30053
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29928
30054
|
if (this.params.bootloaderBinary) {
|
|
29929
30055
|
return this.params.bootloaderBinary;
|
|
@@ -29932,7 +30058,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29932
30058
|
if (!features)
|
|
29933
30059
|
return null;
|
|
29934
30060
|
if (this.params.bootloaderVersion) {
|
|
29935
|
-
const bootResourceUrl = DataManager.getBootloaderResource(features);
|
|
30061
|
+
const bootResourceUrl = DataManager.getBootloaderResource(features, firmwareType);
|
|
29936
30062
|
if (bootResourceUrl) {
|
|
29937
30063
|
const bootBinary = (yield getSysResourceBinary(bootResourceUrl)).binary;
|
|
29938
30064
|
return bootBinary;
|
|
@@ -29941,7 +30067,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29941
30067
|
return null;
|
|
29942
30068
|
});
|
|
29943
30069
|
}
|
|
29944
|
-
prepareFirmwareAndBleBinary() {
|
|
30070
|
+
prepareFirmwareAndBleBinary(firmwareType) {
|
|
29945
30071
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29946
30072
|
const fwBinaryMap = [];
|
|
29947
30073
|
if (this.params.firmwareBinary) {
|
|
@@ -29958,6 +30084,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29958
30084
|
version: this.params.firmwareVersion,
|
|
29959
30085
|
updateType: 'firmware',
|
|
29960
30086
|
isUpdateBootloader: false,
|
|
30087
|
+
firmwareType,
|
|
29961
30088
|
})).binary;
|
|
29962
30089
|
fwBinaryMap.push({
|
|
29963
30090
|
fileName: 'firmware.bin',
|
|
@@ -29978,6 +30105,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
|
|
|
29978
30105
|
features,
|
|
29979
30106
|
version: this.params.bleVersion,
|
|
29980
30107
|
updateType: 'ble',
|
|
30108
|
+
firmwareType,
|
|
29981
30109
|
});
|
|
29982
30110
|
fwBinaryMap.push({
|
|
29983
30111
|
fileName: 'ble-firmware.bin',
|
|
@@ -39333,7 +39461,8 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
39333
39461
|
throw hdShared.createDefectiveFirmwareError(defectiveInfo.serialNo, defectiveInfo.seVersion || 'Unknown', defectiveInfo.deviceType, method.connectId, method.deviceId);
|
|
39334
39462
|
}
|
|
39335
39463
|
}
|
|
39336
|
-
const
|
|
39464
|
+
const deviceFirmwareType = getFirmwareType(device.features);
|
|
39465
|
+
const newVersionStatus = DataManager.getFirmwareStatus(device.features, deviceFirmwareType);
|
|
39337
39466
|
const bleVersionStatus = DataManager.getBLEFirmwareStatus(device.features);
|
|
39338
39467
|
const currentFirmwareVersion = getDeviceFirmwareVersion(device.features).join('.');
|
|
39339
39468
|
const currentBleVersion = getDeviceBLEFirmwareVersion(device.features).join('.');
|