prefs: move led_brightness after wifi_pwd; enable PWM in board.conf

led_brightness sat at companion offset 174, in front of the WiFi
fields, so a 272-byte file written by upstream dev decoded with the
wrong led_brightness and a shifted SSID. Append it after wifi_pwd
(offset 272) and restore the original test offsets and the 208/272
historical lengths.

WT2 and V4.3 only got CONFIG_PWM through esp32s3_pwm_led.conf, which
the release build never passes, so release links would fail. Set
CONFIG_PWM=y in each board.conf instead. board.conf is app-only and
mcuboot does not inherit it, so the mcuboot link failure that rules out
the defconfig does not apply.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ZephCore T096
2026-10-08 18:27:00 +02:00
co-authored by Claude Sonnet 5
parent 263171bdd4
commit ad2e17e5e6
4 changed files with 12 additions and 9 deletions
+3 -3
View File
@@ -29,8 +29,8 @@ const Field kCompanion[] = {
F(153, v_battery_alert_mv), F(155, cad_auto), F(156, cad_offset), F(157, probe_interval),
F(158, cad_busycap), F(159, adc_multiplier), F(163, extra_sf), F(166, v_contact_flags),
F(167, fem_rxgain), F(168, display_rotate), F(169, input_rotate), F(170, cad_base),
F(171, tz_offset), F(172, leds_radio_mode), F(173, leds_hb_mode), F(174, led_brightness),
F(175, wifi_enabled), F(176, wifi_ssid), F(209, wifi_pwd),
F(171, tz_offset), F(172, leds_radio_mode), F(173, leds_hb_mode), F(174, wifi_enabled),
F(175, wifi_ssid), F(208, wifi_pwd), F(272, led_brightness),
};
// Server /lfs/repeater/prefs, 312 bytes. Offset 120 is leds_disabled as a
@@ -154,7 +154,7 @@ TEST(prefs_companion_short, "UNIT-PREFS-003", "Short companion files keep the ca
// Every field boundary: each length the format has had ends on one.
const size_t lens[] = { 91, 92, 93, 94, 95, 96, 127, 143, 144, 145, 146, 148, 150, 151,
152, 153, 155, 156, 157, 158, 159, 163, 166, 167, 168, 169, 170,
171, 172, 173, 174, 175, 176, 209, 273 };
171, 172, 173, 174, 175, 208, 272, 273 };
for (size_t len : lens) {
NodePrefs got = defaults();
CHECK(companionPrefsDecode(got, full, len));
@@ -28,3 +28,6 @@ CONFIG_ZEPHCORE_DEFAULT_TX_POWER_DBM=12
# board.overlay): the default 500ms double-press confirm window (shutdown/
# DFU/offgrid) is too short for two ~1s holds, see Kconfig help text.
CONFIG_ZEPHCORE_UI_CONFIRM_WINDOW_MS=3000
# PWM for LED brightness. Kept here, not in the defconfig: the defconfig is shared with mcuboot, which fails to link with it.
CONFIG_PWM=y
@@ -28,3 +28,6 @@ CONFIG_ZEPHCORE_DEFAULT_TX_POWER_DBM=9
# board.overlay): the default 500ms double-press confirm window (shutdown/
# DFU/offgrid) is too short for two ~1s holds, see Kconfig help text.
CONFIG_ZEPHCORE_UI_CONFIRM_WINDOW_MS=3000
# PWM for LED brightness. Kept here, not in the defconfig: the defconfig is shared with mcuboot, which fails to link with it.
CONFIG_PWM=y
+3 -6
View File
@@ -106,10 +106,10 @@ size_t companionPrefsEncode(const NodePrefs &p, uint8_t *buf, size_t cap)
w.put(&p.tz_offset, 1);
w.put(&p.leds_radio_mode, 1);
w.put(&p.leds_hb_mode, 1);
w.put(&p.led_brightness, 1);
w.put(&p.wifi_enabled, 1);
w.put(p.wifi_ssid, sizeof(p.wifi_ssid));
w.put(p.wifi_pwd, sizeof(p.wifi_pwd));
w.put(&p.led_brightness, 1);
return w.off;
}
@@ -188,14 +188,11 @@ bool companionPrefsDecode(NodePrefs &prefs, const uint8_t *buf, size_t len)
r.take(&p.tz_offset, 1);
r.take(&p.leds_radio_mode, 1);
r.take(&p.leds_hb_mode, 1);
/* led_brightness (ZephCore extension, since 1.17.4). Absent in files
* written before this field existed; the no-op EOF read leaves the
* initNodePrefs() default ZEPHCORE_LED_DEFAULT_BRIGHTNESS_PCT (10%),
* same value a fresh node already showed before this was persisted. */
r.take(&p.led_brightness, 1);
r.take(&p.wifi_enabled, 1);
r.take(p.wifi_ssid, sizeof(p.wifi_ssid));
r.take(p.wifi_pwd, sizeof(p.wifi_pwd));
/* led_brightness at offset 272, after wifi_pwd: a 272-byte file leaves it at the initNodePrefs() default. */
r.take(&p.led_brightness, 1);
/* The one validator: bounds, NaNs, and the unterminated char fields */
sanitizeNodePrefs(&p);