Commit Graph
110 Commits
Author SHA1 Message Date
DeFiDude b44d3743ec Fix announce flood performance: skip endpoint caching, defer culls, fix clean_caches
- Guard announce cache_packet(force=true) with transport_enabled() so
  endpoints skip 300-900ms flash writes per announce
- Defer cull_path_table/cull_announce_table until 10% over capacity
  instead of after every insert
- Rewrite clean_caches: endpoints just wipe stale files in one pass;
  transport nodes use std::set for O(N+M) instead of O(N*M) lookups
2026-03-19 15:24:10 -06:00
DeFiDude 813d9095d7 Fix PKCS7 padding, identity persistence, and packet routing 2026-03-13 04:20:04 -06:00
DeFiDude bb291795da Fix TCP outbound: stop get_path() from destroying valid routes + PSRAM allocator
- get_path(): Remove announce_packet null check that destroyed valid path
  entries when cache deserialization failed under heap pressure. Routing
  fields (_received_from, _hops, receiving_interface) are valid without it.
- hops_to(): Direct path table lookup instead of get_path() to avoid
  triggering expensive announce_packet lazy load from flash cache.
- path_request_handler(): Guard against null announce_packet gracefully.
- Persistence: Add PSRAM allocator for ArduinoJson JsonDocument on ESP32
  boards with PSRAM, preventing deserialization failures when heap is low.
2026-03-11 14:48:19 -06:00
DeFiDude bc33c0af64 Revert hops >= 1 to > 1 in Transport::outbound()
The >= 1 change made the hops==1 branch (hub topology) convert
packets to Header2 with potentially wrong transport_id before
send_outgoing() could apply the correct learned hub transport_id.
Reverting to > 1 matches the original Python logic and lets
hops==1 packets fall through as Header1 for proper wrapping.
2026-03-11 13:43:11 -06:00
DeFiDude 184e6b0250 Skip announce packet caching on non-transport endpoints
Only cache announce packets when transport is enabled, preventing
unnecessary storage on endpoint-only nodes that don't rebroadcast.
2026-03-10 22:40:57 -06:00
DeFiDude af9fbab780 Fix boot loop: Identity::remember() stale timestamp causes cull crash
std::map::insert() is a no-op for existing keys, so identities loaded
from persisted known_destinations kept their old timestamps. When
cull_known_destinations() ran after insert, it removed the "stale"
entry that was just validated — causing Identity::recall() to fail
and hexhash() to assert on a null identity.

Fix: use insert_or_assign() to always refresh the timestamp.

Also reverts the dead-code needs_transport_headers() virtual method
(the else-if at Transport.cpp:826 is unreachable because hops>=1
already catches hops==1 in the preceding if block).
2026-03-10 11:22:05 -06:00
DeFiDude 79271a018b Add needs_transport_headers() for TCP hub messaging fix
TCP interfaces behind a hub need HEADER_2 transport wrapping even at
hops==1, since the hub can't forward raw HEADER_1 packets. Added virtual
needs_transport_headers() to InterfaceImpl (defaults to false) so TCP
subclasses can override it without setting is_connected_to_shared_instance
(which would brick the device by skipping all Reticulum::loop processing).
2026-03-10 00:49:56 -06:00
DeFiDude 3bc64abbde Add Identity as friend of Reticulum for storagepath access 2026-03-08 22:42:34 -06:00
DeFiDude 425c2a9907 Fix TCP messaging via transport nodes and implement known_destinations persistence 2026-03-08 21:56:30 -06:00
Chad Attermann 392363c1b0 Added another missing header for Linux builds 2026-03-06 17:40:55 -07:00
Chad Attermann 491fbd034e Fixed unit test failures in Linux. 2026-03-06 17:25:41 -07:00
Chad Attermann c69087ba40 Merge pull request #31 from attermann/psram_allocator
Introduces a flexible two-class allocator architecture (RNS_DEFAULT_ALLOCATOR and RNS_CONTAINER_ALLOCATOR) supporting heap, PSRAM, and TLSF pool variants for fine-grained control over embedded memory layout.

New Memory.h/cpp with ContainerAllocator, heap/PSRAM/pool allocator types, and heap stats reporting
IdentityTable and PathTable now use ContainerAllocator
Replaced RNS_USE_TLSF/RNS_USE_ALLOCATOR/RNS_USE_PSRAM flags with per-class allocator flags (RNS_DEFAULT_ALLOCATOR, RNS_CONTAINER_ALLOCATOR)
Added ESP32 PSRAM allocator support (RNS_PSRAM_ALLOCATOR, RNS_PSRAM_POOL_ALLOCATOR)
Added Transport::get_path()/remove_path() helpers
Added loop callback (set_loop_callback) to enable more responsive app during long operations (like clean_cache)
Aded guard against re-entrancy to clean_cache()
Added callback option to list_directory() to avoid heap allocation
Added OOM auto-restart (ESP.restart/NVIC_SystemReset) in Interface send/receive and Reticulum loop.
Renamed setLogCallback to set_log_callback
Made Link/Identity static members private
Added native14 env to CI and platformio.ini
Bumped version to 0.2.10
2026-03-06 17:10:37 -07:00
Chad Attermann 4d6f0b9de2 Added dual-class PSRAM/TLSF allocator system and refactored memory management
Introduces a flexible two-class allocator architecture (RNS_DEFAULT_ALLOCATOR and RNS_CONTAINER_ALLOCATOR) supporting heap, PSRAM, and TLSF pool variants for fine-grained control over embedded memory layout.

- New Memory.h/cpp with ContainerAllocator<T>, heap/PSRAM/pool allocator types, and heap stats reporting
- IdentityTable and PathTable now use ContainerAllocator
- Replaced RNS_USE_TLSF/RNS_USE_ALLOCATOR/RNS_USE_PSRAM flags with per-class allocator flags (RNS_DEFAULT_ALLOCATOR, RNS_CONTAINER_ALLOCATOR)
- Added ESP32 PSRAM allocator support (RNS_PSRAM_ALLOCATOR, RNS_PSRAM_POOL_ALLOCATOR)
- Added Transport::get_path()/remove_path() helpers
- Added loop callback (set_loop_callback) to enable more responsive app during long operations (like clean_cache)
- Aded guard against re-entrancy to clean_cache()
- Added callback option to list_directory() to avoid heap allocation
- Added OOM auto-restart (ESP.restart/NVIC_SystemReset) in Interface send/receive and Reticulum loop.
- Renamed setLogCallback to set_log_callback
- Made Link/Identity static members private
- Added native14 env to CI and platformio.ini
- Bumped version to 0.2.10
2026-03-06 16:43:04 -07:00
Chad Attermann 49ccbc2827 Major bug fixes and performance enhancements
- Fixed bug in path table loading from flash storage wherein the raw
(packed) announce packet associated with each path entry was not being
unpacked prior to use.
- Fixed bug in path table entry announce packet loading where critical
changes to the announce packet (like hops increment) was being
overwriteen each time packet was re-loaded from cache.
- Optimized path table entries to lazy-load both announce packet and
receive interface so that memory is consumed by these structures until
if/when the path is actually used.
- Updated several global timers and sizes to match new RNS 1.x values.
- Bumped version to 0.2.9
0.2.9
2026-03-03 17:53:06 -07:00
Chad Attermann a968fdfc64 Bumped version to 0.2.8 0.2.8 2026-03-01 18:29:47 -07:00
Chad Attermann 9da37b29ac Added RNS 1.x Link MTU handling to Transport 2026-03-01 18:22:09 -07:00
Chad Attermann 89dce2c73b Merge pull request #30 from O11v3r/master
Fixed LINKREQUEST
2026-03-01 14:02:55 -07:00
O11v3r e3a128ed2d Fixed LINKREQUEST 2026-03-01 21:15:08 +01:00
Chad Attermann 9289da1a19 Bump to version 0.2.7. 0.2.7 2026-03-01 12:45:35 -07:00
Chad Attermann d670dd00d3 Merge pull request #29 from attermann/log_opt
Replace string-concatenation logging with printf-style F-variants
2026-03-01 12:32:55 -07:00
Chad Attermann 448695ca7a Merge pull request #28 from O11v3r/master
Fixed link compatibility with Reticulum python implementation
2026-03-01 12:13:43 -07:00
Chad Attermann 79b75bbd4e Replace string-concatenation logging with printf-style F-variants
Converted log calls across src/, examples/, and test/ to use DEBUGF/TRACEF/ERRORF/etc. macros instead of std::string + operator+. This eliminates temporary heap allocations on every log call, which matters on memory-constrained MCUs.
2026-03-01 10:59:33 -07:00
O11v3r 5864a3c6fc Fixed link compatibility with Reticulum python implementation 2026-03-01 16:24:41 +01:00
Chad Attermann 3babdc001d Merge pull request #27 from attermann/memory_bugs
Add announce table culling, fix use-after-free, and refactor build/log
2026-02-28 20:03:15 -07:00
Chad Attermann e86481e121 Add announce table culling, fix use-after-free, and refactor build/log
- Add cull_announce_table() with OOM-safe min_element fallback, matching pattern from cull_path_table() and cull_known_destinations()
- Call cull immediately after every announce/path/known-destination insert
- Fix use-after-free: guard announce_entry access with announce_erased flag
- remove_path() now also deletes cached packet files
- Path table insert now removes existing entry first to prevent duplicates
- Rename env:mcu -> env:embedded; add env:native_debug and heltec_wifi_lora_32_V4
- Make TLSF buffer size configurable via RNS_TLSF_BUFFER_SIZE macro
- Refactor log macros to unified RNS::log() path; add doHeadLog with callback support
- Prefix all bad_alloc error messages with "bad_alloc -" for easier grepping
2026-02-28 19:54:15 -07:00
Chad Attermann 086aac87b5 Bumped version to 0.2.6 0.2.6 2026-02-27 13:25:40 -07:00
Chad Attermann c40adfb4ec Merge pull request #25 from attermann/oom_fix
OOM hardening and memory tuning
2026-02-27 13:14:38 -07:00
Chad Attermann b0681fe33f Additional defines for tuning memory usage
Added more defines for setting storage and persistence limits:
- RNS_RATE_TIMESTAMPS_MAX
- RNS_RANDOM_BLOBS_PERSIST_MAX
- RNS_RANDOM_BLOBS_MAX
2026-02-27 13:05:14 -07:00
Chad Attermann f5a23a5a56 Add OOM hardening across Transport, Identity, Destination, and Packet
- Transport::inbound(): pre-emptive cull before destination-table insert;
  try/catch around insert for explicit OOM diagnostics
- Transport::jobs(): split stale-entry culling into 5 independent
  per-phase try/catch blocks so a failure in one phase doesn't abort
  the others; reserve() before push_back loops in each phase
- cull_path_table()/cull_known_destinations(): std::min_element fallback
  when sort-index allocation fails, breaking the cull-OOM-still-full loop
- Identity::remember(): wrapped _known_destinations.insert in try/catch
  for explicit OOM diagnostic logging
- Destination::announce(): outer try/catch covers all OOM-prone ops
  (Bytes concat, sign, Packet ctor, send); inner _path_responses.insert
  catch preserved for degraded-mode behavior
- Packet::unpack(): dedicated std::bad_alloc catch returns false cleanly
- Type.h: MAX_RECEIPTS and MAX_QUEUED_ANNOUNCES now overridable at
  compile time via RNS_RECEIPTS_MAX / RNS_QUEUED_ANNOUNCES_MAX
- Transport.h: hashlist_maxsize and max_pr_tags exposed as runtime
  accessors for dynamic capacity tuning
2026-02-27 12:53:49 -07:00
Chad Attermann 20a7022241 Bumped version to 0.2.5 0.2.5 2026-02-26 11:38:48 -07:00
Chad Attermann 6d31c9cd2b Merge pull request #20 from DanBeard/fix/bytes-and-transport-bugs
Fix receipt cull logic and bytes edge case.
2026-02-24 13:31:46 -07:00
Chad Attermann d76bfce7ce Update test_main.cpp
Disabled `test_receipt_timeout_callback` test which is currently failing.
2026-02-24 13:24:29 -07:00
Chad Attermann 3c4978f294 WIP: Fixes for link validation and announce retries
Fix for link validation failure when poackets contain new MTU in payload
from RNS 1.0 (courtesy of @jlpoolen).
Optimization of announce re-broadcasts from RNS 1.0.
0.2.4
2026-02-15 09:59:25 -07:00
Chad Attermann 3cc7c2a55d WIP: Added local project support for RAK boards 2026-02-14 11:00:12 -07:00
Chad Attermann cddc86e8c0 WIP: Added support for RNS packet context_flag
Added support for new `context_flag` in RNS packet header that is used
to indicate the use of ratchets.
Note that ratchet support is still missing from the implementation, but
this fix enables received ratchets to be able to handled gracefully.
0.2.3
2026-02-13 22:39:14 -07:00
Dan BeardandClaude Opus 4.6 6a705bc582 Add transport and Bytes unit tests
Tests for Bytes::assignHex, appendHex, mid() edge cases, and
Transport receipt culling logic. 18 test cases covering the bugs
fixed in the previous commit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 23:46:39 -06:00
Dan BeardandClaude Opus 4.6 b2dc394623 Fix Bytes hex parsing and Transport receipt culling bugs
- Bytes::assignHex/appendHex: truncate to even length before parsing
  to prevent reading past buffer on odd-length hex strings
- Bytes::mid(): fix off-by-one in bounds check (>= vs >)
- Transport: fix receipt culling loop iterating wrong list, which
  caused stale receipts to accumulate instead of being removed

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 23:46:36 -06:00
Chad Attermann 838cede2e1 Incremented library version. 0.2.2 2026-02-09 13:58:25 -07:00
Chad Attermann 27433edb19 Updates for MCU builds broken by previous dev. 2026-02-09 13:52:13 -07:00
Chad Attermann bd9b76f93a Revert "Enabled wiscore_rak4631 env in CI."
This reverts commit 813f6b82ca.
2026-01-21 14:53:36 -07:00
Chad Attermann 0004ca1717 Added build support for LILYGO T-Beam SUPREME 2026-01-21 13:53:37 -07:00
Chad Attermann 813f6b82ca Enabled wiscore_rak4631 env in CI. 2026-01-21 12:45:40 -07:00
Chad Attermann d3429dfbe8 Merge pull request #12 from mofosyne/master
Add CI
2026-01-21 12:42:54 -07:00
Chad Attermann 818782382a Enhance Bytes, fix for Lins, test/example updates
- Added convenience methods to Bytes class
- Fix for logic error in Link class compliments of @cobraPA
- Added unit tests
- Updated example apps
2026-01-21 12:38:13 -07:00
Brian a26fc0fa14 Update cmake-single-platform.yml 2025-10-01 01:00:57 +10:00
Brian 1187456fe9 Update cmake-single-platform.yml 2025-10-01 00:53:56 +10:00
Brian b82301bb77 Update cmake-single-platform.yml 2025-10-01 00:47:38 +10:00
Brian 513fe046b4 Create cmake-single-platform.yml 2025-10-01 00:35:39 +10:00
Chad Attermann b8be484624 WIP: Major refactor of unit and integration tests 2025-08-26 21:05:36 -06:00
Chad Attermann fe687d391b WIP: Migrated a few unit tests to Unity 2025-08-26 10:49:37 -06:00