-
Notifications
You must be signed in to change notification settings - Fork 1
iOS: fix the three High OTA and profile-builder bugs (#141, #142, #143) #252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,70 @@ | ||
| import Foundation | ||
|
|
||
| /// Smallest usable ramp rate, as a magnitude so cooling segments (negative | ||
| /// rates) are held to the same floor. | ||
| /// | ||
| /// Mirrors `MIN_ABS_RAMP_RATE_C_PER_HR` in `web_ui/src/app/types/kiln.ts`, so | ||
| /// the two clients accept the same profiles. Deliberately stricter than the | ||
| /// firmware, which only rejects zero and non-finite (`api_handlers.c`): 0.1°C/hr | ||
| /// passes that check and describes a 5800-hour firing. | ||
| let minAbsRampRateCPerHr: Double = 1 | ||
|
|
||
| /// Ceiling on the points in a whole charted profile, matching the web UI's | ||
| /// `MAX_PROFILE_PATH_POINTS`. Divided across the segments by the path builder — | ||
| /// applying it per segment would let a 16-segment profile reach 32,000 marks, | ||
| /// which is what it exists to prevent. | ||
| let maxProfilePathPoints = 2000 | ||
|
|
||
| struct FiringSegment: Codable, Identifiable, Hashable { | ||
| let id: String | ||
| var name: String | ||
| var rampRate: Double // degrees per hour | ||
| var targetTemp: Double // degrees C | ||
| var holdTime: Double // minutes (0 = hold indefinitely) | ||
|
|
||
| /// Whether the ramp arithmetic can be evaluated at all. | ||
| /// | ||
| /// The firmware's rule — finite, nonzero (`api_handlers.c`) — deliberately | ||
| /// looser than `validationError`. A profile already stored with, say, | ||
| /// 0.5°C/hr is one the controller accepts and will fire, so the chart has to | ||
| /// draw it: dropping it would misplace every later segment's temperature and | ||
| /// timing, which is worse than plotting a very slow ramp. Only zero and | ||
| /// non-finite values are genuinely uncomputable — those are the ones that | ||
| /// used to trap in `Int(_:)` (#143). | ||
| var isComputable: Bool { | ||
| rampRate.isFinite && rampRate != 0 && targetTemp.isFinite && holdTime.isFinite | ||
| } | ||
|
|
||
| /// Why this segment may not be *saved*, or nil if it is fine. | ||
| /// | ||
| /// The builder's policy, stricter than the firmware's: see | ||
| /// `minAbsRampRateCPerHr`. Not used to decide what to chart. | ||
| var validationError: String? { | ||
| guard rampRate.isFinite, targetTemp.isFinite, holdTime.isFinite else { | ||
| return "\(name): values must be numbers" | ||
| } | ||
| guard abs(rampRate) >= minAbsRampRateCPerHr else { | ||
| return "\(name): ramp rate must be at least \(Int(minAbsRampRateCPerHr))°C/hr to heat " | ||
| + "or -\(Int(minAbsRampRateCPerHr))°C/hr to cool" | ||
| } | ||
| guard targetTemp > 0, targetTemp <= 1400 else { | ||
| return "\(name): target temperature must be between 1 and 1400°C" | ||
| } | ||
| guard holdTime >= 0 else { | ||
| return "\(name): hold time cannot be negative" | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| var formattedDescription: String { | ||
| "\(rampRate > 0 ? "+" : "")\(Int(rampRate))°C/hr → \(Int(targetTemp))°C\(holdTime > 0 ? ", hold \(Int(holdTime))m" : "")" | ||
| /* `Int(_:)` on a non-finite or out-of-range Double is a fatal error, not | ||
| a garbage number — the same trap as #143, reachable here from a | ||
| malformed profile decoded off the API rather than from the editor. */ | ||
| func whole(_ v: Double) -> String { | ||
| v.isFinite && abs(v) < 1e9 ? String(Int(v)) : "—" | ||
| } | ||
| let sign = rampRate > 0 ? "+" : "" | ||
| let hold = holdTime > 0 ? ", hold \(whole(holdTime))m" : "" | ||
| return "\(sign)\(whole(rampRate))°C/hr → \(whole(targetTemp))°C\(hold)" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When fetching the release manifest takes more than 10 seconds,
checkOTA()still uses the short shared session and fails before the controller responds, so the normal UI never exposes the Install action. This is reachable with the firmware's default 15-second OTA transfer timeout—and that setting permits up to 120 seconds—becausehandle_ota_checksynchronously waits forota_check()(components/web_server/api_handlers.c:1142-1145,components/ota/Kconfig:21-24). PassotaSessiontocheckOTA()as well asinstallOTA().Useful? React with 👍 / 👎.