Skip to content

Commit

Permalink
Merge pull request #647 from ExpressLRS/add-zip-flashing-type
Browse files Browse the repository at this point in the history
Add zip flashing method, handle unknown flashing methods gracefully.
  • Loading branch information
jurgelenas authored Aug 29, 2024
2 parents adb7ef8 + 324af11 commit 7c7b97c
Show file tree
Hide file tree
Showing 7 changed files with 591 additions and 1,282 deletions.
6 changes: 6 additions & 0 deletions graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,12 @@
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "Zip",
"description": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
Expand Down
1 change: 1 addition & 0 deletions src/api/src/models/enum/FlashingMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ enum FlashingMethod {
Stock_BL = 'Bootloader',
UART = 'UART',
WIFI = 'WIFI',
Zip = 'Zip',
EdgeTxPassthrough = 'EdgeTxPassthrough',
Passthrough = 'Passthrough',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ export default class DeviceDescriptionsLoader {
this.deviceOptionsMutex = new Mutex();
}

private uploadMethodToFlashingMethod(uploadMethod: string): FlashingMethod {
private uploadMethodToFlashingMethod(
uploadMethod: string
): FlashingMethod | null {
switch (uploadMethod.toLowerCase()) {
case 'betaflight':
return FlashingMethod.BetaflightPassthrough;
Expand All @@ -74,8 +76,11 @@ export default class DeviceDescriptionsLoader {
return FlashingMethod.WIFI;
case 'stock':
return FlashingMethod.Stock_BL;
case 'zip':
return FlashingMethod.Zip;
default:
throw new Error(`Upload Method ${uploadMethod} Not Recognized!`);
this.logger.warn(`Upload Method ${uploadMethod} Not Recognized!`);
return null;
}
}

Expand All @@ -84,18 +89,22 @@ export default class DeviceDescriptionsLoader {
category: string,
config: DeviceDescription
): Device {
const uploadMethods: Target[] = config.upload_methods
.filter(
(uploadMethod) =>
this.uploadMethodToFlashingMethod(uploadMethod) !== null
)
.map((uploadMethod) => {
const targetName = `${id}.${uploadMethod}`;
const mappedUploadMethod =
this.uploadMethodToFlashingMethod(uploadMethod);
return new Target(targetName, targetName, mappedUploadMethod!);
});
return new Device(
id,
config.product_name,
category,
config.upload_methods.map((uploadMethod) => {
const targetName = `${id}.${uploadMethod}`;
return new Target(
targetName,
targetName,
this.uploadMethodToFlashingMethod(uploadMethod)
);
}),
uploadMethods,
[],
DeviceType.ExpressLRS,
true,
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"UART": "This method allows you to flash your receiver or transmitter via its USB port or wiring up an FTDI device.",
"WIFI": "This method creates a firmware file you can upload to your receiver or transmitter by connecting to its built in wifi.",
"EdgeTxPassthrough": "This method allows you to flash your transmitter module while it is connected to your transmitter by using the passthrough feature of the EdgeTX firmware.",
"Passthrough": "This method allows you to flash your module while it is connected to your transmitter by using the passthrough feature."
"Passthrough": "This method allows you to flash your module while it is connected to your transmitter by using the passthrough feature.",
"Zip": "This method creates an archive of all files required for your device."
},
"FlashingMethodOptions": {
"FlashingMethod": "Flashing Method"
Expand Down
16 changes: 16 additions & 0 deletions src/ui/components/FlashingMethodDescription/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,22 @@ const FlashingMethodDescription: FunctionComponent<
</p>
</div>
);
case FlashingMethod.Zip:
return (
<div>
<p>{t('FlashingMethodDescription.Zip')}</p>
<p>
<DocumentationLink
url={
wikiUrl ??
'https://www.expresslrs.org/quick-start/getting-started/'
}
>
{t('FlashingMethodDescription.GeneralWiki')}
</DocumentationLink>
</p>
</div>
);
default:
return '';
}
Expand Down
Loading

0 comments on commit 7c7b97c

Please sign in to comment.