mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-09-22 02:46:37 +00:00
fix(companion): prefs schema corruption, broken multi-scope, stale relay filter, cursor row
Follow-up review of f589b9b2 -- five defects in that commit's own changes.
- repeat_scope_only + repeat_extra_scopes were read/written in the MIDDLE of
the prefs stream, beside their repeat_* siblings. loadPrefsInt()'s rd() is a
plain sequential reader gated only on file.available(), with no per-field
versioning, so on any pre-existing file those 25 bytes were taken from the
fields that follow, shifting EVERY later field: repeater profile (incl. a
float freq), track_shared_loc, all of loc_share_*, trail, bot, GPIO modes.
Moved to the struct/file tail, sentinel bumped to 0xC0DE0027 with 0xC0DE0026
marked burned. sizeof stays 2752 (confirmed by build); the tripwire procedure
now spells out the append-only rule that "in struct order" left implicit.
- rebuildRepeatScopes() called getAutoKeyFor() with id 0 for every entry, but
that cache is keyed on the id alone and ignores the name on a hit -- so every
extra scope after the first silently got the first one's key, making the
comma-separated list do nothing. Distinct id per scope now.
- interference_threshold had no load clamp, so an upgrader read 0x23 (35) out
of the old file's sentinel tail instead of 0.
- CMD_SET_DEFAULT_FLOOD_SCOPE wrote default_scope_key without rebuilding the
relay filter, so setting or clearing the scope from the app left the repeater
filtering on the previous key until reboot. The on-device path already did.
- The keyboard preview derived the cursor's row a second time from byte
offsets, disagreeing with the cursor_line the scroll window already computes:
it pinned the cursor to the end of a full line (drawing '_' one character
past the display width) at every wrap boundary. Use cursor_line directly.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -691,7 +691,11 @@ void MyMesh::rebuildRepeatScopes() {
|
||||
if (*tok != '\0') {
|
||||
char hashtag[1 + sizeof(_prefs.repeat_extra_scopes)];
|
||||
snprintf(hashtag, sizeof(hashtag), "#%s", tok);
|
||||
temp.getAutoKeyFor(0, hashtag, repeat_scopes[repeat_scope_count++]);
|
||||
// Distinct id per scope: getAutoKeyFor() keys its cache on the id ALONE
|
||||
// and ignores the name on a hit, so reusing one id here would hand every
|
||||
// scope after the first the first one's key.
|
||||
temp.getAutoKeyFor(repeat_scope_count, hashtag, repeat_scopes[repeat_scope_count]);
|
||||
repeat_scope_count++;
|
||||
}
|
||||
tok = strtok(NULL, ",");
|
||||
}
|
||||
@@ -2807,6 +2811,7 @@ void MyMesh::handleCmdFrame(size_t len) {
|
||||
if (n > 0 && n < 31) {
|
||||
strcpy(_prefs.default_scope_name, (char *) &cmd_frame[1]);
|
||||
memcpy(_prefs.default_scope_key, &cmd_frame[1+31], 16);
|
||||
rebuildRepeatScopes(); // slot 0 of the relay filter tracks this key
|
||||
savePrefs();
|
||||
writeOKFrame();
|
||||
} else {
|
||||
@@ -2815,6 +2820,7 @@ void MyMesh::handleCmdFrame(size_t len) {
|
||||
} else {
|
||||
memset(_prefs.default_scope_name, 0, sizeof(_prefs.default_scope_name)); // set default scope to null
|
||||
memset(_prefs.default_scope_key, 0, sizeof(_prefs.default_scope_key));
|
||||
rebuildRepeatScopes(); // drop it from the relay filter too, not just from sends
|
||||
savePrefs();
|
||||
writeOKFrame();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user