Repository navigation
system/wifibridge: keep the configuration across resets - #3893
Open
daniel-p-carvalho wants to merge 1 commit into
Open
daniel-p-carvalho wants to merge 1 commit into
daniel-p-carvalho wants to merge 1 commit into
Conversation
daniel-p-carvalho
force-pushed
the
feat/wifibridge-persist
branch
from
October 21, 2026 10:06
43a4d1d to
2e4f7ca
Compare
| * | ||
| * Description: | ||
| * Read what wifibridge_save() kept and set the matching fields of the | ||
| * configuration. The SSID and the passphrase are copied to the buffers |
Contributor
There was a problem hiding this comment.
should we change to array
Contributor
Author
There was a problem hiding this comment.
Done, ssid and passphrase are now arrays with the sizes in the prototype.
| int fd; | ||
|
|
||
| fd = open(CONFIG_NETUTILS_WIFIBRIDGE_STORAGE, | ||
| write ? O_RDWR | O_CREAT : O_RDONLY, 0600); |
Contributor
There was a problem hiding this comment.
should we add O_TRUCT
Contributor
Author
There was a problem hiding this comment.
Done, the write opens with O_WRONLY | O_CREAT | O_TRUNC. Tested on the simulator: a 400-byte file is left with the 116 bytes of the record.
|
|
||
| if (write) | ||
| { | ||
| nbytes = pwrite(fd, record, sizeof(*record), 0); |
Contributor
Author
There was a problem hiding this comment.
Done, it is a plain write() now (the offset was always 0). I renamed the bool argument of wifibridge_record_io() to store, since it hid write().
| } | ||
| else | ||
| { | ||
| nbytes = pread(fd, record, sizeof(*record), 0); |
Contributor
Author
There was a problem hiding this comment.
Done, a plain read() now.
Add the save and clear commands, and the wifibridge_save(), wifibridge_load() and wifibridge_clear() functions behind them, enabled by NETUTILS_WIFIBRIDGE_PERSIST. save keeps the SSID, the passphrase, the channel, the security, the address and the DHCP server option; start then uses them instead of the defaults of the configuration, and the options of start win for that run only. clear forgets them. The configuration is a record with a magic number, a version and a CRC-32, written at the start of NETUTILS_WIFIBRIDGE_STORAGE: a file of a file system mounted at boot, or a block device such as the MTD of a few pages of flash. A record that is missing or damaged is ignored and the defaults are used. The passphrase is stored as is. The parameters of the SoftAP are now checked in one place, also by start before anything is changed. Tested on an EV49N51A with the MTD of two pages of the program flash (PIC32MZ_PROGMEM, FTL and BCH, as /dev/mtdblock1): start with an empty storage uses the defaults; after save -s Persist -p persist1234 -c 11 -a 10.0.0.7 -d, start comes up with that SSID, channel, address and the DHCP server, also after a reset; the options of start override it for one run; clear brings the defaults back; save refuses a short passphrase. Assisted-by: Claude Code:claude-sonnet-5-5 Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
daniel-p-carvalho
force-pushed
the
feat/wifibridge-persist
branch
from
October 21, 2026 17:06
2e4f7ca to
727a84d
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Let the
wifibridgecommand keep its configuration across resets. This is the follow-up to #3876, which left saving the SSID and the passphrase out.savewrites the SSID, the passphrase, the channel, the security, the bridge address and the DHCP server option.startthen uses them instead of the Kconfig defaults, and the options given tostartwin for that run only.clearforgets them.-Doption: do not run the DHCP server. With-dit lets one run override a saved choice either way, the last one on the command line wins.CONFIG_NETUTILS_WIFIBRIDGE_STORAGE: a file of a file system mounted at boot, or a block device such as the MTD of a few pages of flash. A missing or damaged record is ignored and the defaults are used. The passphrase is stored as is.wifibridge_save(),wifibridge_load()andwifibridge_clear()innetutils/wifibridge, behindCONFIG_NETUTILS_WIFIBRIDGE_PERSIST(defaultn). The SoftAP parameters are now checked in one place, also bystartbefore anything is changed.The library is generic. On the EV49N51A the storage is the program flash exposed as an MTD by apache/nuttx#20788, which this PR needs on that board. Other boards only need a file system or a block device.
Impact
New, optional, default
n. WithoutCONFIG_NETUTILS_WIFIBRIDGE_PERSISTnothing changes, except thatstartandsaveaccept-Dand the parameter checks moved to one function.Testing
Host: Ubuntu Linux, XC32 v6.00. Target: EV49N51A (PIC32MZ-W1),
PIC32MZ_PROGMEMwith FTL and BCH as/dev/mtdblock1(apache/nuttx#20788),CONFIG_NETUTILS_WIFIBRIDGE_DHCPD=y, flashed with a PICkit 3.startuses the defaults (NuttX-BR, no DHCP server).save -s TestD -p abcd1234 -d, thenstart: the AP isTestDanddhcpd br0runs; the same after a reset.stopends the DHCP server too.start -Dover a saved-d: no DHCP server. Aftersave -Dand a reset,start: none;start -dover it: the DHCP server runs.start -d -Druns without the DHCP server andstart -D -dwith it.savewith a short passphrase fails withEINVALand keeps the previous record.clearand a reset: the defaults are back.-c 11 -a 10.0.0.7: the record kept the SSID, channel and address across resets, and the options ofstartoverrode them for one run.checkpatchpasses.Not tested: WPA3 (
-3) saved in the record, which needs the BA414E engine.