Skip to content

feat(settings): save ESC settings to a file and load them back - #597

Open
Jschmiedd wants to merge 3 commits into
stylesuxx:developfrom
Jschmiedd:feat/settings-file
Open

Jschmiedd wants to merge 3 commits into
stylesuxx:developfrom
Jschmiedd:feat/settings-file

Conversation

@Jschmiedd

Copy link
Copy Markdown

Part 1 of #596: save the ESC settings to a JSON file and load them back. Editing a file without ESCs connected will follow in a second PR.

Save

  • "Save settings to file" writes the settings of all BLHeli_S and Bluejay ESCs to one .json file, with the number of ESCs, and for each ESC its position, firmware name, layout revision and settings. No UID, signature or bootloader data.

Load

  • "Load settings from file" refuses the whole file if the number of ESCs differs.
  • Each ESC only takes the saved ESC at its position, and only if firmware, version (MAIN_REVISION/SUB_REVISION), layout revision and LAYOUT are the same. Otherwise it is skipped and logged.
  • Only settings described on the settings screen are written, within its bounds (bool, enum, number, and the startup melody of the same length, with its wait (never the erased value 0xFFFF)). Out-of-bounds values are skipped and listed in the log. MOTOR_DIRECTION and the identity keys are never written.
  • Before writing: one confirmation with every change (ESC 1 · Beep strength: 40 → 80), then the current settings are saved to a file. Nothing is written if that save fails or the user cancels.
  • After writing: the ESCs are read back and each written value is compared; the log says "read back, same as written" or lists the differences.

Code

  • The logic is in src/utils/SettingsFile.js (pure functions with tests). App/index.jsx only wires the buttons, and writing goes through the existing write path (writeEscs, now shared with "Write settings").
  • Tests: 42 new; the full suite passes (487).

The version of this feature in my fork was tested on the bench with 4 Bluejay ESCs, props off. The code of this PR itself is covered by the unit and app tests only.

Two new buttons in the button bar save the settings of BLHeli_S and Bluejay ESCs to a JSON file and load such a file back. Hardware identifiers are never saved.

A file is only loaded on the same number of ESCs, each one running the same firmware, version and layout. Only described settings within the bounds of the settings screen are written, with the startup melody, never the motor direction. The changes are shown for confirmation, the current settings are saved first, and the ESCs are read back and checked after writing.
@Jschmiedd Jschmiedd changed the title Feat/settings file feat(settings): save ESC settings to a file and load them back Nov 23, 2026
@codacy-production

codacy-production Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 277 complexity · 24 duplication

Metric Results
Complexity 277
Duplication 24

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@Jschmiedd
Jschmiedd changed the base branch from master to develop November 23, 2026 11:18
@Jschmiedd
Jschmiedd marked this pull request as ready for review November 23, 2026 11:21
@stylesuxx stylesuxx added this to the v0.34.0 milestone Nov 30, 2026
@stylesuxx

Copy link
Copy Markdown
Owner

Thank you!

So far this is looking very good. I have marked this as part for the next release, so I am not going to merge that at this point, instead I would ask you to add the 2nd part to this PR too. Structure is good - it was not as intrusive as I would have imagined.

A settings file can be opened from the home page while no port is connected. Its ESCs are shown in the settings screen with a note that nothing is written to them. The settings can be changed and saved to a new file, which is then loaded on the ESCs like any other settings file.

While a file is open no port can be connected and the flash buttons are disabled, so no read, write, flash or motor command reaches an ESC. Unplugging a port keeps the file open. Closing the file goes back to the home page, after asking when the changes are not saved. The "Missing ESC?" box is not shown offline.
@codecov

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.84615% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.92%. Comparing base (344d65c) to head (057a9d6).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
src/utils/SettingsFile.js 97.17% 5 Missing ⚠️
src/Containers/App/index.jsx 98.38% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #597      +/-   ##
===========================================
+ Coverage    82.56%   83.92%   +1.35%     
===========================================
  Files           78       79       +1     
  Lines         3607     3918     +311     
  Branches       605      702      +97     
===========================================
+ Hits          2978     3288     +310     
- Misses         562      563       +1     
  Partials        67       67              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Jschmiedd

Copy link
Copy Markdown
Author

Thanks so Much!

I added the second part: editing a settings file without ESCs connected.

What it adds

  • A "Settings files" section on the home page with an "Edit settings file" button. It is shown while no port is connected.
  • The ESCs from the file are shown in the normal settings screen, with a note that nothing is written to the ESCs.
  • The settings can be changed and saved to a new file with "Save settings to file". "Close file" goes back to the home page, and asks first when the changes are not saved to a file.
  • The edited file is loaded on the ESCs later with "Load settings from file", with the same preview, backup, read-back check and strict checks as before (same position, firmware, version and layout, values within bounds, never the motor direction).

Safety

  • No port is open while a file is edited: a file can not be opened while connected or connecting, and Connect is refused while a file is open.
  • The flash and dump buttons are disabled. The read, write, reset, flash all, motor control and melody buttons are not shown.
  • Unplugging a port keeps the file open and touches no port.
  • The "Missing ESC?" box is not shown offline, as there is no port to check.
  • No check was added to the write, flash and motor functions: keeping the port closed while a file is edited is the safety, so the core stays untouched.

Structure

  • It reuses the file format, parser and checks from the first part. getFileEscs() in utils/SettingsFile.js builds the ESCs to show from a parsed file.
  • isOffline in the state slice. selectCanEdit lets the settings be edited offline while selectCanFlash stays false.

Tests

  • New tests for getFileEscs(), the home page button, the offline screen and the container (open, refuse while connected or connecting, save what the screen shows, refuse Connect, unplug, close, ask before closing unsaved changes) and for the hidden "Missing ESC?" box. All of them fail without the change.
  • A browser test found two small details, fixed in a second commit: closing no longer asks when a value was changed and set back, and choosing the same file twice is read again.
  • All tests pass (504) and lint shows no new warnings. The test report is attached.

PR597-part2-test-report.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants