From dc44164ea0c611cb2770f414b9c9059a725255c9 Mon Sep 17 00:00:00 2001 From: R0ck Date: Tue, 8 Sep 2026 23:39:12 +0100 Subject: [PATCH] companion: pin MAX_CONTACTS so every unit agrees on the contact table 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 Claude-Session: https://claude.ai/code/session_01Q9HbD44EKWWTRYgxbFGxf6 --- roles.d/companion_radio.flags | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/roles.d/companion_radio.flags b/roles.d/companion_radio.flags index 6cb7ba4..4e6e5b6 100644 --- a/roles.d/companion_radio.flags +++ b/roles.d/companion_radio.flags @@ -1,5 +1,19 @@ -# The companion holds group channels, and its command frame reports the -# capacity unconditionally. 40 is what upstream's flash-equipped variants -# use; a host has no such limit, so the number is a protocol constant here -# rather than a hardware one. +# These size arrays inside MeshCore's shared base classes (BaseChatMesh), and +# so must be identical in every translation unit or the layout of that base +# object differs between them: a field written through one .cpp is read at +# another's offset, silently. The companion's own MyMesh.h raises both above +# BaseChatMesh's defaults, and platformio passes the raised values to the whole +# build; this host build compiles each file on its own, so the values that only +# a header sets reach MyMesh.cpp and not BaseChatMesh.cpp. They are pinned here +# to reach both. +# +# MAX_GROUP_CHANNELS the companion also reports as a capacity in its command +# frame; 40 is what upstream's flash-equipped variants use, and a host has no +# such limit, so it is a protocol constant here rather than a hardware one. +# +# MAX_CONTACTS was missed, and the cost was exact: a companion loaded its +# contacts at boot and reported none to any client, because BaseChatMesh.cpp +# (default 32) and MyMesh.cpp (100) disagreed on where num_contacts lived, so +# a contact added under one layout was invisible under the other. -DMAX_GROUP_CHANNELS=40 +-DMAX_CONTACTS=100