Skip to content

feat(companion): DMC companion receive filter - #18

Merged
Elektr0Vodka merged 5 commits into
dmc-devfrom
enhancement/dmc-dev-companion-filter
Oct 16, 2026
Merged

Elektr0Vodka merged 5 commits into
dmc-devfrom
enhancement/dmc-dev-companion-filter

Conversation

@Elektr0Vodka

@Elektr0Vodka Elektr0Vodka commented Oct 16, 2026 •

Copy link
Copy Markdown

Adds a DMC receive filter to the companion firmware, so a companion can hide junk and unwanted channel messages before they reach the app. Off by default (filter on to enable).

  • Shared rule engine: the repeater filter's malformed scan, age check, path block and sender/text rules move into shared headers (MessageContent.h, MessageAge.h, PathBlock.h, SenderRules.h), so repeater and companion parse rules and format replies identically.
  • Companion filter (CompanionFilter.cpp/.h, CompanionFilterHook.cpp): hooked via filterRecvFloodPacket and onChannelMessageRecv. Malformed / age / path = drop (not shown, not repeated); sender / text = hide (not shown, still repeated in client-repeat mode). Flood traffic only; DMs are never touched. Settings in /cfilter.json. Commands work over USB serial, the app's CLI frame and remote CLI.
  • meshcomod upgrade import (MeshcomodImport.cpp): keeps radio/CAD prefs (both 141-byte and older 136-byte layouts) and Wi-Fi credentials from meshcomod's NVS when upgrading with the app .bin.
  • Docs: docs/companion_filter_reference.md, CLI pages, dmc-docs (nl/en/de) custom CLI + migration.

Needed for the companion option on the DMC Firmware Release button (#19), which builds every *_companion_radio_ble and *_companion_radio_wifi env from dmc-dev.

Verification

  • pio test -e native: all 13 suites pass, incl. new test_companion_filter and test_meshcomod_import.
  • Built: Heltec_v3_companion_radio_wifi, Heltec_v3_companion_radio_ble, RAK_4631_companion_radio_ble, Xiao_C3_companion_radio_wifi (77.8% flash), PicoW_companion_radio_wifi, heltec_v4_companion_radio_ble.
  • Not yet flash-tested on hardware.

🤖 Generated with Claude Code

Move the repeater filter's malformed-text scan (validMessageContent,
isValidUTF8) into the header-only MessageContent.h, and its sender/text
rule add/remove, path-prefix add/remove and `filter age` argument parsing
into SenderRules.h, PathBlock.h and MessageAge.h. Filter.cpp now delegates
to them with unchanged signatures, replies and behaviour.

This makes the logic usable by the companion receive filter and testable
on the native env.
A `filter` CLI on the companion firmware that keeps junk and unwanted
channel traffic out of the app: malformed group text, group text older
than N minutes, floods relayed by a blocked repeater prefix, and sender
or text rules (block, throttle, dose) reusing the repeater rule engine.

Junk (malformed, age, path) is dropped before the mesh handles it, so a
companion with repeat enabled does not repeat it either. Sender and text
rules only hide: the message is still repeated, so one user's mute list
never censors the mesh. Direct and addressed traffic is never filtered.

Settings persist as JSON in /cfilter.json; off by default. The shared
MyMesh files only gain one-line calls into CompanionFilterHook.cpp.
meshcomod keeps identity, contacts, channels and blobs in the same files
and formats, and its binary /new_prefs is already migrated by upstream's
loadPrefs(). Three things were still lost or garbled on the first boot:

- the hardware-CAD toggle, a trailing byte (141-byte file);
- on files from meshcomod v1.16 and older (136 bytes, no gps_interval),
  auto-add, RX boost and the default flood scope, which upstream's layout
  reads 4 bytes off;
- the Wi-Fi credentials, which meshcomod keeps in NVS ("meshcomod").

importMeshcomodSettings() runs once, only while /prefs.json does not yet
exist, lets upstream migrate, then applies those fields. NVS is read-only
and Wi-Fi is only imported into an empty SSID.
@Elektr0Vodka
Elektr0Vodka merged commit b467e5d into dmc-dev Oct 16, 2026
1 check passed
Elektr0Vodka added a commit that referenced this pull request Oct 16, 2026
…ion-snmp-ota

feat(companion): SNMP, pull OTA and MAC commands (stacked on #18)
Elektr0Vodka added a commit that referenced this pull request Oct 19, 2026
…filter limiters, true TX duty, SenseCAP GPS) into dmc-dev-packetlog
Elektr0Vodka added a commit that referenced this pull request Oct 19, 2026
…filter limiters, true TX duty, SenseCAP GPS) into dmc-observer-dev

Conflict resolutions:
- Dispatcher.h, build.sh: kept observer (radio watchdog; observer build.sh already
  emits partsig for every ESP32 env).
- CommonCLI.cpp: kept observer's /mqtt.json-gated legacy migration, then the
  GPS_DEFAULT_ON apply; dropped the obsolete "old default 70" comment now that
  the prefs key is dc_gate_duty.
- variants/sensecap_solar: took dmc-dev (ENV_INCLUDE_GPS + GPS_DEFAULT_ON). The
  observer's -UENV_INCLUDE_GPS came from the old bulk revert 22eb9b8, not a
  deliberate choice.
- platformio.ini native env, docs/cli_commands.md: took dmc-dev additions.
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.

1 participant