mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-02 10:51:57 +00:00
fix(companion): hashtag join trims like the app, prefs survive a downgrade, a sender named Me
- Joining #topic drops surrounding spaces and keeps the case, as meshcore-open's derivePskFromHashtag() does. - /prefs written by a newer build (bigger NodePrefs, same version): the extra bytes are read through the CRC and skipped instead of resetting every setting. - A channel post from someone named "Me" is filed as "\"Me\": ...", so the views don't take it for our own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -445,7 +445,18 @@ void DataStore::loadPrefs(NodePrefs& prefs, double& node_lat, double& node_lon)
|
||||
ok = file.read((uint8_t*)tmp, n) == (int)n;
|
||||
uint32_t crc = crc32(0, (const uint8_t*)&lat, sizeof(lat));
|
||||
crc = crc32(crc, (const uint8_t*)&lon, sizeof(lon));
|
||||
ok = ok && crc32(crc, (const uint8_t*)tmp, n) == h.crc;
|
||||
crc = crc32(crc, (const uint8_t*)tmp, n);
|
||||
// Written by a newer build (a downgrade): its extra fields are skipped,
|
||||
// but the CRC covers them, so read them through it rather than losing
|
||||
// every setting to a mismatch.
|
||||
for (size_t left = h.size - n; ok && left > 0; ) {
|
||||
uint8_t buf[32];
|
||||
size_t k = left < sizeof(buf) ? left : sizeof(buf);
|
||||
ok = file.read(buf, k) == (int)k;
|
||||
crc = crc32(crc, buf, k);
|
||||
left -= k;
|
||||
}
|
||||
ok = ok && crc == h.crc;
|
||||
}
|
||||
file.close();
|
||||
if (ok) { prefs = *tmp; node_lat = lat; node_lon = lon; }
|
||||
|
||||
Reference in New Issue
Block a user