|
|
@ -10,53 +10,47 @@ import getCurrentFirmware from './getCurrentFirmware' |
|
|
|
import getDeviceVersion from './getDeviceVersion' |
|
|
|
|
|
|
|
export default async (deviceInfo: DeviceInfo) => { |
|
|
|
try { |
|
|
|
// Get device infos from targetId
|
|
|
|
const deviceVersion = await getDeviceVersion(deviceInfo.targetId, deviceInfo.providerId) |
|
|
|
|
|
|
|
// Get firmware infos with firmware name and device version
|
|
|
|
const seFirmwareVersion = await getCurrentFirmware({ |
|
|
|
fullVersion: deviceInfo.fullVersion, |
|
|
|
deviceId: deviceVersion.id, |
|
|
|
// Get device infos from targetId
|
|
|
|
const deviceVersion = await getDeviceVersion(deviceInfo.targetId, deviceInfo.providerId) |
|
|
|
|
|
|
|
// Get firmware infos with firmware name and device version
|
|
|
|
const seFirmwareVersion = await getCurrentFirmware({ |
|
|
|
fullVersion: deviceInfo.fullVersion, |
|
|
|
deviceId: deviceVersion.id, |
|
|
|
provider: deviceInfo.providerId, |
|
|
|
}) |
|
|
|
|
|
|
|
// Fetch next possible firmware
|
|
|
|
const { data } = await network({ |
|
|
|
method: 'POST', |
|
|
|
url: GET_LATEST_FIRMWARE, |
|
|
|
data: { |
|
|
|
current_se_firmware_final_version: seFirmwareVersion.id, |
|
|
|
device_version: deviceVersion.id, |
|
|
|
provider: deviceInfo.providerId, |
|
|
|
}) |
|
|
|
|
|
|
|
// Fetch next possible firmware
|
|
|
|
const { data } = await network({ |
|
|
|
method: 'POST', |
|
|
|
url: GET_LATEST_FIRMWARE, |
|
|
|
data: { |
|
|
|
current_se_firmware_final_version: seFirmwareVersion.id, |
|
|
|
device_version: deviceVersion.id, |
|
|
|
provider: deviceInfo.providerId, |
|
|
|
}, |
|
|
|
}) |
|
|
|
|
|
|
|
if (data.result === 'null') { |
|
|
|
return null |
|
|
|
} |
|
|
|
}, |
|
|
|
}) |
|
|
|
|
|
|
|
const { se_firmware_osu_version } = data |
|
|
|
const { next_se_firmware_final_version } = se_firmware_osu_version |
|
|
|
const seFirmwareFinalVersion = await getFinalFirmwareById(next_se_firmware_final_version) |
|
|
|
if (data.result === 'null') { |
|
|
|
return null |
|
|
|
} |
|
|
|
|
|
|
|
const mcus = await getMcus() |
|
|
|
const { se_firmware_osu_version } = data |
|
|
|
const { next_se_firmware_final_version } = se_firmware_osu_version |
|
|
|
const seFirmwareFinalVersion = await getFinalFirmwareById(next_se_firmware_final_version) |
|
|
|
|
|
|
|
const currentMcuVersionId = mcus |
|
|
|
.filter(mcu => mcu.name === deviceInfo.mcuVersion) |
|
|
|
.map(mcu => mcu.id) |
|
|
|
const mcus = await getMcus() |
|
|
|
|
|
|
|
if (!seFirmwareFinalVersion.mcu_versions.includes(...currentMcuVersionId)) { |
|
|
|
return { |
|
|
|
...se_firmware_osu_version, |
|
|
|
shouldFlashMcu: true, |
|
|
|
} |
|
|
|
} |
|
|
|
const currentMcuVersionId = mcus |
|
|
|
.filter(mcu => mcu.name === deviceInfo.mcuVersion) |
|
|
|
.map(mcu => mcu.id) |
|
|
|
|
|
|
|
return { ...se_firmware_osu_version, shouldFlashMcu: false } |
|
|
|
} catch (err) { |
|
|
|
const error = Error(err.message) |
|
|
|
error.stack = err.stack |
|
|
|
throw error |
|
|
|
if (!seFirmwareFinalVersion.mcu_versions.includes(...currentMcuVersionId)) { |
|
|
|
return { |
|
|
|
...se_firmware_osu_version, |
|
|
|
shouldFlashMcu: true, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return { ...se_firmware_osu_version, shouldFlashMcu: false } |
|
|
|
} |
|
|
|