Skip to content

Add Companion Selective Repeat Ability (CSRA) - #2717

Open
copelaje wants to merge 3 commits into
meshcore-dev:devfrom
copelaje:feature/companion-selective-repeat
Open

copelaje wants to merge 3 commits into
meshcore-dev:devfrom
copelaje:feature/companion-selective-repeat

Conversation

@copelaje

@copelaje copelaje commented Jun 7, 2026 •

Copy link
Copy Markdown

Note for reviewers: selective repeat currently defaults to on so people testing custom builds get it without setup. The intended default for merge is off (one literal in NodePrefs.h, marked with a comment). I'll flip it on request.

What it does

Lets a companion relay a narrow, user-chosen slice of traffic on its normal frequency, instead of the all-or-nothing choice between "no repeat" and "full repeat on a repeater frequency".

With selective repeat on (and full repeat off), a companion forwards only:

  • flood packets to or from a favourited chat or room-server contact, including logins/anonymous requests sent by a favourite
  • flood group messages on channels the companion is subscribed to
  • direct-routed packets where it is already the next hop (the ACK / path-return legs of conversations it relayed)

Everything else is dropped, as on a stock companion.

Typical use: a vehicle or base-station companion that gives a handheld coverage, without becoming a general-purpose mobile repeater.

How it is controlled

  • Allowlist: the existing contact favorite flag and existing channel subscriptions. Both are already managed in the client apps, so no app changes are needed.
  • On/off: new companion CLI command, set repeat.selective on|off / get repeat.selective.
  • Stored as one new key in prefs.json (comp.sel_rpt).

Known limitations

  • The companion has no region map, so it does not filter relays by region itself (downstream repeaters still do).
  • No flood-hop or loop limits beyond the core's seen-packet table and maximum path length. Left out to keep this small; easy to add if wanted.
  • Matching uses the 1-byte on-wire hashes, so an unrelated node sharing a favourite's hash is also relayed.
  • The app's repeat indicator shows "off" while selective repeat is active, since the device-info byte is unchanged.

Related: #2261, #2396, #2599. #1707 also affects paths through a selective relay.

Prebuilt companion firmware for personal testing here: https://github.com/copelaje/MeshCore/releases/tag/companion-v1.18.0csra1

@copelaje

copelaje commented Jun 7, 2026 •

Copy link
Copy Markdown
Author

Over the past week or so I've attempted to engage devs in the #development channel on meshcore.io discord but haven't received any response. I recall someone attempting something like this in a thread on the old discord, but don't think that topic started again post-split. I may add one for discussion on this if needed. There are already several "issues" regarding a capability like this #2261 #2396 #2599

Lets see if we can get a workable solution!

@copelaje

copelaje commented Jun 8, 2026

Copy link
Copy Markdown
Author

Testing has shown that #1707 applies to CSRA paths as well. Everything functions right, but companion contributions to paths will always be unknown due to reasonable constraints mentioned by @liamcottle in that issue.

@ifeth0

ifeth0 commented Jun 16, 2026

Copy link
Copy Markdown

Awesome work so far! I've had success in relaying packets from my low power t1000 to heltec v4 running your firmware. The only question I have is regarding the auto functionality of repeats. I'm currently sitting in a dead spot with my low power companion and the custom firmware seems to not trigger the repeat functionality immediately. I'll have to take a deeper dive but just wanted to give you some additional feedback. I hope you're able to get acknowledged by the dev team and get this implemented. It's greatly needed in my area that isn't MC heavy.

@copelaje

Copy link
Copy Markdown
Author

@ifeth0 , thanks for testing and providing the feedback! I took a look at things again and I don't see any reason why repeat off a CSRA enabled companion would be excessively delayed. Is the message for flood or DM message? Could it be that your t1000 has to re-learn a new path through the heltek v4 and the delay is the retry logic up until it floods again and learns the path? Is is also slow on 2nd message after path learned through companion? What kind of delay we talking? If you've got more details I can take a look closer.

@ifeth0

ifeth0 commented Jun 18, 2026

Copy link
Copy Markdown

I guess I'm trying to understand the expected behavior while being out of range within the MC app. When I'm near areas that have repeaters I'll see 2+ repeats with the one repeat being unknown (the radio running your firmware). When I'm in an area without coverage I never see the app show a repeat. I still haven't had a chance yet to dive further into troubleshooting yet sorry!

@copelaje

Copy link
Copy Markdown
Author

@ifeth0 , I got a chance to test today in total isolation and it worked as I'd expect. The setup was a normal 1.16 companion (lets call A), and a CSRA 1.16 companion B, with no other repeaters present. I assume you're talking about channel messages since you're talking about # repeaters observed. CSRA companion will only repeat channel messages for those channels to which it is subscribed. So in my setup, if B is not configured for a channel, it won't be repeated.

When A sends a channel message to a group that B IS subscribed to, A indicates 1 repeat (the key from CSRA node B). When I send channel message to group that B does NOT have subscribed, no repeat is observed on A. If you find otherwise I need more info to understand.

NOTE: the fact that CSRA repeats based on what groups it is subscribed to the easy capability I could use to get selective repeat behaviors without requiring companion app feature updates. I'm open to having specific flags for channels that should repeat rather than just configured channels if that's what the devs feel best. Still waiting feedback though...

@copelaje

Copy link
Copy Markdown
Author

I see a merge conflict has developed as dev has moved on. Since no dev engagement thus far I'll just let it ride until next release. If that changes let me know and I'll make the necessary updates for merge.

@vanous

vanous commented Aug 26, 2026

Copy link
Copy Markdown

I do similar thing for selective local coverage by using regions. It is similar but not the same as this PR. It uses the current standard MC building blocks and doesn't require another node type - further complexity for the users.

@IoTThinks

Copy link
Copy Markdown
Contributor

situations where you want a well-positioned companion (always powered, good antenna) to extend the reach of another device stuck in poor coverage,

Convert it to become a repeater.
Then done.

@copelaje

Copy link
Copy Markdown
Author

I do similar thing for selective local coverage by using regions. It is similar but not the same as this PR. It uses the current standard MC building blocks and doesn't require another node type - further complexity for the users.

This is not another node type, it's just a checkbox in companion options (at least in final form). Is there some MR where your approach can be examined?

situations where you want a well-positioned companion (always powered, good antenna) to extend the reach of another device stuck in poor coverage,

Convert it to become a repeater. Then done.

The whole point of this is to mitigate the ill effects of mobile repeaters (literally the 2nd paragraph) by being selective in what is repeated. Are you suggesting that mobile repeaters wouldn't be a problem?

@copelaje
copelaje force-pushed the feature/companion-selective-repeat branch from a945bfe to 6c36a3e Compare November 17, 2026 03:56
@copelaje

Copy link
Copy Markdown
Author

Rebased this onto current dev to account for prefs.json configuration changes and simplified it a lot. The diff is now 5 files, about 90 lines.

What changed since the last version:

  • Reworked for the new prefs/CLI system. Selective repeat is now a single flag in prefs.json, toggled with the companion CLI (set repeat.selective on|off). The separate binary command (which collided with CMD_RUN_CLI_COMMAND), the tri-state repeat mode and the extra stats fields are gone.
  • No protocol or app changes at all. Favorites and channel subscriptions are still the allowlist; full repeat and CMD_SET_RADIO_PARAMS are untouched.
  • Fix: logins/anonymous requests from a favorite (e.g. remote admin login to a repeater) are now relayed. Previously only logins to a favorited room were.
  • Default is on in this branch for the benefit of testers; intended default for merge is off — noted in the code and the description.

The previous implementation is kept at feature/companion-selective-repeat-v1 for anyone still running the June test builds. If you are upgrading a device from one of those builds, selective repeat carries over.

Description above is updated to match. Feedback from maintainers welcome. I'm glad to adjust the default, naming, scope, etc.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants