Repository navigation
AnnounceHandler: optional packet-carrying callback - #85
Conversation
Add a second virtual received_announce(destination_hash, identity, app_data, packet) that Transport now calls; its default forwards to the classic three-argument callback, so existing handlers are unaffected. Handlers that override the new form get the announce packet: receiving interface, hop count, RSSI/SNR and transport id — enough to build neighbour lists without re-parsing and re-verifying the raw packet.
|
Thanks for this, and for the clear write-up in #84. The default-forwarding approach keeps existing handlers working, so the design looks right to me. A few things are needed per the contribution policy (PR_POLICY.md) before it can merge:
CI didn't start on this PR, and I'll deal with that on my side. |
The loopback suite now replays its own announce with the destination deregistered, so it reaches announce handlers the way a remote one would. A handler overriding only the basic callback is still called; a handler overriding the packet-carrying one gets the packet (destination, type, receiving interface) and is not called twice. The header and README now say the Packet is only valid for the duration of the callback, and the README no longer suggests either callback may be overridden alone: the basic one is pure virtual. CHANGELOG entry added.
|
Thanks for the review. All five points are addressed on the branch, and master is merged in without conflicts.
|
|
Thanks for working through all of that so carefully. The test catching the local-destination case was a good find: it shows the existing announce handler test was never actually being exercised. One thing I'll look at before merging: Python RNS can pass the announce packet hash to the handler as an optional extra argument, while this passes the whole |
Problem
An
AnnounceHandlerreceives the destination hash, the announced identity and the app data, but nothing about how the announce arrived. Applications that keep a neighbour list or show link quality (which interface heard the node, how many hops away it is, its RSSI and SNR) cannot get that from the callback. Today the only route is to also hook the raw receive callback, then parse and verify every announce a second time to match it up, which duplicates Transport's work and doubles the signature checks on small MCUs. Requested in #84.Solution
Add a second virtual overload,
received_announce(destination_hash, announced_identity, app_data, packet), and have Transport call it. Its default implementation forwards to the existing three-argument callback, so every existing handler keeps working unchanged. Handlers that want the metadata override the new overload as well.The
Packetreference is only valid for the duration of the call. This is documented in the header and the README.Compatibility
RNS_*preprocessor guard (off by default): no divergence; this is an API additionTesting
Platforms tested (and how):
pio test -e native,native14,native17,native20pass 193/193 each, including the newtest_rns_loopbackcasetest_interop/): not run; no wire changePlatforms not tested, and why: nRF52 (no hardware). This repo's embedded PlatformIO environments were not built locally and are left to CI.
Docs
Closes #84.