From b576de75b6c614f2f823a8b8edc8606f56f9318e Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Thu, 2 Jul 2026 18:02:48 +0200 Subject: [PATCH] fix(prefs): bump schema sentinel for keyboard_type field (PR #21) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit keyboard_type was inserted into the append-only NodePrefs layout without bumping SCHEMA_SENTINEL, leaving it at 0xC0DE0019 — the same value plain main already uses without this field. A device already on that schema would silently misalign every field read after alarm_min once updated to a build containing this change. Bump to 0xC0DE001A and fix the migration comment's stale version label (it said 0xC0DE0018, which was already taken by the MAP home-page migration). Co-Authored-By: Claude Sonnet 5 --- examples/companion_radio/DataStore.cpp | 3 ++- examples/companion_radio/NodePrefs.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/companion_radio/DataStore.cpp b/examples/companion_radio/DataStore.cpp index da249942..818523b4 100644 --- a/examples/companion_radio/DataStore.cpp +++ b/examples/companion_radio/DataStore.cpp @@ -428,7 +428,8 @@ void DataStore::loadPrefsInt(const char *filename, NodePrefs& _prefs, double& no if (_prefs.alarm_on > 1) _prefs.alarm_on = 0; if (_prefs.alarm_hour > 23) _prefs.alarm_hour = 0; if (_prefs.alarm_min > 59) _prefs.alarm_min = 0; - // → 0xC0DE0018: keyboard type (QWERTY/T9). + // → 0xC0DE001A: keyboard type (QWERTY/T9). Pre-0x1A files leave stray sentinel + // tail bytes here; clamp back to the QWERTY default (0). rd(&_prefs.keyboard_type, sizeof(_prefs.keyboard_type)); if (_prefs.keyboard_type > 1) _prefs.keyboard_type = 0; // Pre-0x10 files leave stray sentinel bytes here, same as a never-configured diff --git a/examples/companion_radio/NodePrefs.h b/examples/companion_radio/NodePrefs.h index 9dd559d7..e89a4605 100644 --- a/examples/companion_radio/NodePrefs.h +++ b/examples/companion_radio/NodePrefs.h @@ -351,7 +351,7 @@ struct NodePrefs { // persisted to file // adding/removing/reordering fields in DataStore::savePrefs/loadPrefsInt so // older saves are detected on load and skipped (zero-init defaults kept). // High 24 bits identify the file format; low byte is the schema revision. - static const uint32_t SCHEMA_SENTINEL = 0xC0DE0019; + static const uint32_t SCHEMA_SENTINEL = 0xC0DE001A; // Bit-index for each home page. Used by page_order (entries store bit+1) and // by home_pages_mask. Single source of truth — both HomeScreen::pageBit/bitToPage