fix(RegionMap): compact storage /regions3, fix save/load return values, add paged region CLI output#2236
Open
jirogit wants to merge 1 commit intomeshcore-dev:devfrom
Open
fix(RegionMap): compact storage /regions3, fix save/load return values, add paged region CLI output#2236jirogit wants to merge 1 commit intomeshcore-dev:devfrom
jirogit wants to merge 1 commit intomeshcore-dev:devfrom
Conversation
…egion output
- Replace /regions2 (128-byte pad/record, 5258B total) with /regions3
(64-byte pad/record, 3210B total) to fit within nRF52 InternalFS limits
- Auto-migrate from /regions2 on first save(); delete /regions2 after success
- Fix save() hardcoded 'return true' -> return success
- Fix load() hardcoded 'return true' -> return num_regions > 0 || success
- Add paged output to 'region' CLI command:
- 'region' shows first page (wildcard + entries from index 0)
- 'region N' shows entries from index N
- Footer '>N' indicates next start index; no footer = last page
- Fixes silent truncation at ~5 entries due to single-packet reply limit
- Note: mobile app UI still shows only ~5 regions; this is a separate
app-side issue outside the scope of this fix
Fixes meshcore-dev#1880
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.
Fixes #1880 – region name memory space max out
Problem
On nRF52840 (T1000-e), the
/regions2binary format used 128 bytes of padding per record:This exceeds the available space in nRF52 InternalFS when shared with preferences and identity data.
save()would fail silently (hardcodedreturn true), and on next bootload()would read a truncated file, losing region names beyond ~11 entries.Additionally, the
regionCLI command was silently truncated to ~5 entries due to the single-packet reply buffer limit (~161 bytes), making it impossible to verify how many regions were actually stored.Changes
src/helpers/RegionMap.cpp/regions3format: 64-byte padding per record (100 bytes/record, 3,210 bytes for 32 entries = 78% of one 4096B LittleFS block)load()prefers/regions3; falls back to/regions2(128-byte pad) for automatic migration on nextsave()save()to/regions3, deletes/regions2if it existssave(): hardcodedreturn true→return successload(): hardcodedreturn true→return num_regions > 0 || successexamples/simple_repeater/MyMesh.cppregioncommand now supports paged output:region— first page (wildcard*+ entries from index 0)region N— entries from index N onward>Nat end of each page indicates the next start index-none-= no entries at allStorage size comparison
/regions2(old)/regions3(new)Testing
Tested on Seeedstudio T1000-e:
region savereturnsOKregion/region 4/region 8... paging works correctly with>Nfooter/regions2→/regions3not tested on physical hardware (code path verified by review only)Fixes #2166