diff --git a/Changelog.md b/Changelog.md index cff2a4a7..4487186e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,9 @@ +## Unreleased + +### Added + +- Write support for 91x + ## 4.5.0 - 2024-12-17 ### Changed diff --git a/src/actions/mcubootTargetActions.ts b/src/actions/mcubootTargetActions.ts index 0afbedf5..61bded27 100644 --- a/src/actions/mcubootTargetActions.ts +++ b/src/actions/mcubootTargetActions.ts @@ -62,7 +62,8 @@ export const performUpdate = async ( dfuFilePath: string, onProgress: (progress: Progress) => void, abortController: AbortController, - netCoreUploadDelay?: number + netCoreUploadDelay?: number, + target?: string ) => { logger.info(`Writing ${dfuFilePath} to device ${device.serialNumber}`); @@ -75,6 +76,7 @@ export const performUpdate = async ( undefined, { netCoreUploadDelay, + target, }, abortController ); diff --git a/src/components/McuUpdateDialogView.tsx b/src/components/McuUpdateDialogView.tsx index f9118299..a01ad094 100644 --- a/src/components/McuUpdateDialogView.tsx +++ b/src/components/McuUpdateDialogView.tsx @@ -17,12 +17,18 @@ import { classNames, clearConfirmBeforeClose, clearWaitForDevice, + convertToDropDownItems, DialogButton, + Dropdown, + DropdownItem, GenericDialog, getPersistentStore, + getSelectedDropdownItem, logger, NumberInlineInput, + Overlay, selectedDevice, + selectedDeviceInfo, setWaitForDevice, Slider, Toggle, @@ -40,6 +46,8 @@ import { WithRequired } from '../util/types'; const TOOLTIP_TEXT = 'Delay duration to allow successful image swap from RAM NET to NET core after image upload. Recommended default timeout is 40s. Should be increased for the older Thingy:53 devices'; +const TOOLTIP_TEXT_MULTIPLE_TARGETS = + 'Your device has multiple targets. Please select the target you want to program.'; const NET_CORE_UPLOAD_DELAY = 120; @@ -56,8 +64,19 @@ const McuUpdateDialogView = () => { const isVisible = useSelector(getShowMcuBootProgrammingDialog); const mcubootFwPath = useSelector(getMcubootFilePath); const zipFilePath = useSelector(getZipFilePath); + const deviceInfo = useSelector(selectedDeviceInfo); + + const programmingOptions = + deviceInfo?.mcuStateOptions?.filter(s => s.type === 'Programming') ?? + []; + + const targetDropdownItems = convertToDropDownItems( + programmingOptions.map(s => s.arguments?.target), + false + ); const fwPath = mcubootFwPath || zipFilePath; + const [chosenTarget, setChosenTarget] = useState(''); const writingHasStarted = writing || writingFail || writingSucceed; @@ -111,6 +130,12 @@ const McuUpdateDialogView = () => { } }, [device, showDelayTimeout]); + useEffect(() => { + if (targetDropdownItems.length > 0) { + setChosenTarget(targetDropdownItems[0].value); + } + }, [targetDropdownItems]); + const onCancel = () => { dispatch(clearWaitForDevice()); dispatch(setShowMcuBootProgrammingDialog(false)); @@ -175,7 +200,8 @@ Are you sure you want to continue?`, setProgress(updatedProgress); }, abortController.current, - showDelayTimeout ? uploadDelay : undefined + showDelayTimeout ? uploadDelay : undefined, + mcubootFwPath ? chosenTarget : undefined ) .then(() => { setWritingSucceed(true); @@ -231,7 +257,14 @@ Are you sure you want to continue?`, 1 && + !chosenTarget && + !!mcubootFwPath) + } > Write @@ -247,6 +280,38 @@ Are you sure you want to continue?`, {` ${mcubootFwPath || zipFilePath}`} + + {programmingOptions.length > 1 && !zipFilePath && ( + + + Target: + {TOOLTIP_TEXT_MULTIPLE_TARGETS} + } + keepShowingOnHoverTooltip + tooltipId="test" + placement="right" + > + + + + { + setChosenTarget(item.value); + }} + selectedItem={getSelectedDropdownItem( + targetDropdownItems, + chosenTarget + )} + disabled={writingHasStarted} + /> + + )} + {writing && (