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