useFirmwareUpdate
useFirmwareUpdate(
deviceId):FirmwareUpdateResult
Defined in: console-sdk/src/react/hooks/useFirmwareUpdate.ts:141
The OTA update machine for one device (SDK_PLAN.md §3.7 row 18, §3.6.7): a
FirmwareUpdateResult discriminated union whose variant carries only
the actions legal in its state. Reads the provider-owned firmware store
reactively (useSyncExternalStore), so a screen re-mounted mid-update
re-attaches to live progress. Safe from the first render (returns idle when
there is no device / no running update); throws OutsideProviderError when no
<ConsoleProvider> is above the caller.
Parameters
Section titled “Parameters”deviceId
Section titled “deviceId”DeviceId | null | undefined
the device whose update machine to drive, or null/undefined
for “no device” (returns the idle variant with a resolved-no-op start).
Returns
Section titled “Returns”the current FirmwareUpdateResult variant with its embedded actions bound to the provider-owned engine.
Example
Section titled “Example”const update = useFirmwareUpdate(deviceId);switch (update.status) { case 'idle': return <Button title="Update" onPress={update.start} />; case 'updating': return <Progress phase={update.phase} value={update.progress} onCancel={update.cancel} />; case 'done': return <Done onDismiss={update.reset} />; case 'cancelled': return <Resume onPress={update.reset} />; case 'error': return <Retry error={update.error} onRetry={update.retry} />;}