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 37ed981 commit ceee2e2
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions src/js/tabs/firmware_flasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -1318,27 +1318,24 @@ firmware_flasher.verifyBoard = function() {
getBoardInfo();
}

function getBuildInfo() {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) && navigator.onLine && 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, () => {
async function getBuildInfo() {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) && FC.CONFIG.flightControllerIdentifier === 'BTFL') {
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 ceee2e2

Please sign in to comment.