Skip to content

Commit

Permalink
Append craftname (#3637)
Browse files Browse the repository at this point in the history
* Append craftname to filename

* Reorder craftname for better sort
  • Loading branch information
haslinghuis authored Nov 18, 2023
1 parent 86043fa commit f0fc111
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/js/tabs/firmware_flasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,11 +654,13 @@ firmware_flasher.initialize = function (callback) {
}

MSP.send_message(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.BUILD_KEY), false, () => {
if (buildKeyExists()) {
self.releaseLoader.requestBuildOptions(FC.CONFIG.buildKey, onLoadCloudBuild, getBoardInfo);
} else {
getBoardInfo();
}
MSP.send_message(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.CRAFT_NAME), false, () => {
if (buildKeyExists()) {
self.releaseLoader.requestBuildOptions(FC.CONFIG.buildKey, onLoadCloudBuild, getBoardInfo);
} else {
getBoardInfo();
}
});
});
} else {
getBoardInfo();
Expand All @@ -670,9 +672,7 @@ firmware_flasher.initialize = function (callback) {
MSP.send_message(MSPCodes.MSP_API_VERSION, false, false, () => {
gui_log(i18n.getMessage('apiVersionReceived', FC.CONFIG.apiVersion));

if (FC.CONFIG.apiVersion.includes('null')) {
onClose(false); // not supported
} else if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
if (FC.CONFIG.apiVersion.includes('null') || semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
onClose(false); // not supported
} else {
MSP.send_message(MSPCodes.MSP_FC_VARIANT, false, false, getBuildInfo);
Expand Down
13 changes: 8 additions & 5 deletions src/js/utils/generate_filename.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ export function generateFilename(prefix, suffix) {
const date = new Date();
const yyyymmdd = `${date.getFullYear()}${zeroPad(date.getMonth() + 1, 2)}${zeroPad(date.getDate(), 2)}`;
const hhmmss = `${zeroPad(date.getHours(), 2)}${zeroPad(date.getMinutes(), 2)}${zeroPad(date.getSeconds(), 2)}`;
const craftName = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ? FC.CONFIG.craftName : FC.CONFIG.name;
let filename = `${FC.CONFIG.flightControllerIdentifier || 'UNKNOWN'}_${prefix}`;

let filename = `${FC.CONFIG.flightControllerIdentifier || 'UNKNOWN'}_${prefix}_${yyyymmdd}_${hhmmss}`;
if (craftName.length) {
filename += `_${craftName.trim().replace(" ", "_").toUpperCase()}`;
}

if (FC.CONFIG) {
const craftName = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ? FC.CONFIG.craftName : FC.CONFIG.name;
const boardName = FC.CONFIG.boardName || craftName.trim().replace(" ", "_");
filename += `_${yyyymmdd}_${hhmmss}`;

filename = `${filename}_${boardName}`;
if (FC.CONFIG.boardName) {
filename += `_${FC.CONFIG.boardName}`;
}

return `${filename}.${suffix}`;
Expand Down

0 comments on commit f0fc111

Please sign in to comment.