Skip to content

Commit

Permalink
Reduce brain overload
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed Apr 20, 2024
1 parent d2da37a commit fc5ee00
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/js/tabs/firmware_flasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -1320,27 +1320,24 @@ firmware_flasher.verifyBoard = function() {
getBoardInfo();
}

function getBuildInfo() {
async function getBuildInfo() {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) && FC.CONFIG.flightControllerIdentifier === 'BTFL') {
MSP.send_message(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.BUILD_KEY), false, () => {
MSP.send_message(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.CRAFT_NAME), false, () => {
MSP.send_message(MSPCodes.MSP_BUILD_INFO, false, false, () => {
await MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.BUILD_KEY));
await MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.CRAFT_NAME));
await MSP.promise(MSPCodes.MSP_BUILD_INFO);

// store FC.CONFIG.buildKey as the object gets destroyed after disconnect
self.cloudBuildKey = FC.CONFIG.buildKey;
// store FC.CONFIG.buildKey as the object gets destroyed after disconnect
self.cloudBuildKey = FC.CONFIG.buildKey;

// 3/21/2024 is the date when the build key was introduced
const supportedDate = new Date('3/21/2024');
const buildDate = new Date(FC.CONFIG.buildInfo);
// 3/21/2024 is the date when the build key was introduced
const supportedDate = new Date('3/21/2024');
const buildDate = new Date(FC.CONFIG.buildInfo);

if (self.validateBuildKey() && (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_46) || buildDate < supportedDate)) {
self.buildApi.requestBuildOptions(self.cloudBuildKey, getCloudBuildOptions, getBoardInfo);
} else {
getBoardInfo();
}
});
});
});
if (self.validateBuildKey() && (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_46) || buildDate < supportedDate)) {
self.buildApi.requestBuildOptions(self.cloudBuildKey, getCloudBuildOptions, getBoardInfo);
} else {
getBoardInfo();
}
} else {
getBoardInfo();
}
Expand Down

0 comments on commit fc5ee00

Please sign in to comment.