companion: pin MAX_CONTACTS so every unit agrees on the contact table - #22
Merged
Merged
Conversation
MAX_CONTACTS sizes a contacts array inside the shared BaseChatMesh, and the companion's MyMesh.h raises it from the base default of 32 to 100. On real hardware platformio passes that to the whole build; this host build compiles each .cpp on its own, so BaseChatMesh.cpp kept 32 while MyMesh.cpp saw 100, and the BaseChatMesh subobject had two layouts. num_contacts lived at two offsets, so a contact added through one translation unit was invisible through another: a companion loaded its contacts3 at boot and reported none to any client, and every advert it learned went the same way. MAX_GROUP_CHANNELS was already pinned here for exactly this reason; this adds the one that was missed. Verified against a host companion built at companion-v1.17.1: it reported 0 contacts before and its full list after. MeshBench/meshbench#725 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q9HbD44EKWWTRYgxbFGxf6
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.
A native companion loads its contacts at boot and reports none to any client (MeshBench/meshbench#725). Traced to a One Definition Rule violation in this host build.
MAX_CONTACTSsizesContactInfo contacts[MAX_CONTACTS+MAX_ANON_CONTACTS]inside the sharedBaseChatMesh, withnum_contactsdeclared right after it. The companion'sexamples/companion_radio/MyMesh.hraisesMAX_CONTACTSfromBaseChatMesh.h's default 32 to 100. On hardware platformio passes that to every unit;build.shcompiles each.cppalone, soBaseChatMesh.cppkept 32 andMyMesh.cppsaw 100. TheBaseChatMeshsubobject then had two layouts, andnum_contactstwo offsets:addContact(compiled inBaseChatMesh.cpp) wrote it at one offset,getNumContacts/the iterator (inlined intoMyMesh.cpp) read it at another.Measured against a host companion at
companion-v1.17.1with a debug print:addContactwalksnum_contacts0→1→2→3 whilegetTotalContactSlots()reads 8 in the same run. With-DMAX_CONTACTS=100the same binary reportscount=3and yields all three contacts.MAX_GROUP_CHANNELSwas already pinned here for precisely this reason;MAX_CONTACTSwas the one that was missed. The comment now says why both are load-bearing.🤖 Generated with Claude Code
https://claude.ai/code/session_01Q9HbD44EKWWTRYgxbFGxf6