Vanity pubkeys are ground to match at the leading bytes (c0ffee,
deadbeef), and sometimes at trailing bytes, so contiguous prefix keys
collide far above random chance within a vanity club — worst case,
every repeater sharing a 4-byte vanity shares one cache entry, and the
least-frequent advertiser gets suppressed indefinitely.
Sample the 4-byte key at fixed offsets {8,14,20,26}, clear of the
vanity zones at both ends: grinded keys stay uniformly random there,
restoring ~2^-32 pairwise collision odds. No RAM change (same 8-byte
entry); the cache is RAM-only so there is no config-format impact.
Two no-loss-of-function storage reductions, -1520 B measured on all
targets (fork total 6734 -> 5214 B):
- AdvertSeenEntry pubkey prefix 6 -> 4 bytes: entry drops from 12 to
8 B (padding gone). Prefix collisions are a ~0.001% chance per 256
distinct nodes; worst case is one falsely suppressed advert per
window. The cache is RAM-only, so no config-format impact.
- FilterChannel.hash 32 -> 1 byte: core's GroupChannel.hash is
PATH_HASH_SIZE (1) and only hash[0] is ever compared or copied
(same pattern as stock BaseChatMesh); Utils::sha256 truncates to
hash_len. Saves 31 B per channel entry.
Config format comment updated to cover both v3 layout changes.
chan_mask was one bit per channel and one byte wide, capping the store at
8. Widen it to 16 bits (guard, delChannel remap arithmetic, ~128 B per
rule slot) and double FILTER_MAX_CHANNELS to 16 (+712 B RAM, verified
across nRF52/RP2040/ESP32 targets). Config format v3: older configs are
discarded on upgrade.
matchone() compared the pattern char (unsigned char) against the subject
char (signed char), so any byte >= 0x80 promoted to different values and
never matched. All multi-byte UTF-8 (emoji, accented characters) in
sender/text regex patterns silently failed to match; ASCII was unaffected.
Compare as unsigned char so literal UTF-8 sequences match byte-for-byte.
Document the byte-wise matching semantics in FILTER.md and note the
divergence in TinyRegex.h.
/filter_cfg previously stored raw FilterRule structs, which included the
per-rule hits counter: a config change saved whatever the counters were
at that moment, and a reboot restored stale counts. Persisting stats was
never intended - only configuration belongs in the file.
Rule records on disk now end at the hits field (offsetof(FilterRule,
hits)); counters and the advert cache are RAM-only and reset on reboot.
Format version bumped to 2; version-1 files are discarded on load.
FILTER.md updated to match.
Describes the rule model and evaluation phases (packet-level vs
decrypted-content), the keyed channel store, the per-origin advert rate
limiter, persistence, the full 'filter ...' CLI with predicate syntax,
use-case walkthroughs, remote administration, and behaviour notes.
delChannel() shifts the channel store down one slot, but rule chan_mask
bits were left untouched, so rules silently retargeted the wrong channels
after deleting any channel below them (and kept a dangling bit for the
deleted slot itself). Now the deleted channel's bit is dropped and masks
above the deleted slot shift down to match the store.
Found during on-device testing: a rule 'chan=#zC' became 'chan=#zB'
after deleting '#zA'.
Interval endpoints are stored as uint16 but compared via int16_t casts
(negative quarter-dB SNR shares the representation); cap non-SNR values
at 32767 so out-of-range values are rejected at 'filter add' time
instead of wrapping.
Adds a personal-fork packet filter to the simple_repeater firmware:
configurable drop/logonly rules over the repeater CLI, evaluated at
MyMesh::allowPacketForward() and onGroupDataRecv().
- PacketFilter.h/.cpp: rule model (type/route/hops/len/snr/chanhash/
path/hashsize packet-level predicates; keyed-channel, sender-regex and
text-regex content predicates evaluated on MAC-verified decrypted group
payloads), keyed channel store (Public pre-provisioned; '#' channels
auto-provisioned from sha256(name)[0..15]), per-node advert rate limiter
(RAM-only 6-byte pubkey-prefix cache), /filter_cfg persistence, and the
'filter ...' CLI (list/get/add/del/enable/disable/clear/chan/ratelimit/
stats, all replies within the 160-byte CLI buffer).
- PacketFilterConfig.h: build-time tunables (rule/channel/cache counts,
pattern lengths) with #ifndef defaults.
- TinyRegex.h/.cpp: vendored kokke/tiny-regex-c (public domain) with a
backtracking step budget; fail-open on exhaustion, aborts counted in
'filter stats'.
- MyMesh.h/.cpp: minimal hook lines only (one checkPacket call, two
virtual overrides, one CLI dispatch line, begin/loop save wiring).
All fork-owned logic lives in new files; no changes to src/.
SPI pins that are set to -1 cause OOB reads on NRF52. The unused Serial2 pin definitions were removed to avoid potential issues with the Uart framework.
Setting SPI pins to values that are OOB of the g_ADigitalPinMap[] array causes OOB reads. This variant.h has pin 0 as 0xFF which passes through as NRFX_SPIM_PIN_NOT_USED.
Introduced consistent preferences for external LoRa FEM RX and TX gain settings in NodePrefs. Updated companion MyMesh to apply these settings during initialization and transmission. Added unit tests to verify the round-trip serialization of these new preferences.