* Add general-purpose packet cache
This commit adds a caching system that will save packet data in a much
more compact form than the regular MeshPacket protobuf. It cannot be
worked with directly to the same degree (although the packet header is
available), but consumes *much* less memory, and as a result can be used
to temporarily store large numbers of packets.
Cached packets can be retrieved either by their (from, id) tuple, or by
their hash.
This cache is a pre-requisite for the upcoming packet replay feature.
* Remove debug initialiser
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Fix ordering
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Add missing size assignment
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Add comments for hash & bucket macros
* Make it clear that this field stores a map of the original data
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
Ham Mode ignores region regulatory limits, so regardless of whether
we set a single TX_GAIN_LORA or an array with a non-linear PA,
we shouldn't limit the power.
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
* feat: add adaptive polling intervals to WebServer
Replace fixed 5ms polling with adaptive intervals based on HTTP activity:
- 50ms during active periods (first 5 seconds after request)
- 200ms during medium activity (5-30 seconds)
- 1000ms during idle periods (30+ seconds)
Reduces CPU usage significantly during idle periods while maintaining
responsiveness when handling HTTP requests.
* Fix integer overflow and magic numbers in WebServer
- Handle millis() overflow in getAdaptiveInterval()
- Replace magic numbers with named constants
- Improve code readability and maintainability
* Null out user.id except for sending to phone
* Fix
* Update src/modules/NodeInfoModule.cpp
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Copilot garbage
* This is unnecessary, because we don't stored user.id on userlite
* Don't need this
* Fix warning
* Just alter the protobuf
* Alter protobuf doesn't do anything with the altered data, so let's re-encode it
* Check inputbroker before access
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Add FACTORY_INSTALL option to do a filesystem reset on first boot
* Check for valid file handle before using
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* RoutingModule::sendAckNak takes ackWantsAck arg to set want_ack on the ACK itself
* Use reliable delivery for traceroute requests (which will be copied to traceroute responses by setReplyTo)
* Update ReliableRouter::sniffReceived to use ReliableRouter::shouldSuccessAckWithWantAck
* Use isFromUs
* Update MockRoutingModule::sendAckNak to include ackWantsAck argument (currently ignored)
---------
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
* Introduce non-linear TX_GAIN_LORA
Previously, our TX_GAIN_LORA setting was a single number, intended
to represent the signal gain going through a power amp (plus or minus
antenna, attenuator, and other parts of the RF chain).
It turns out the relationship between the input power (i.e. from an SX1262)
and total output power is often non-linear. While we fudged a 1dBm difference
here and there with existing chips, the Heltec v4 has a 5dBm difference in gain
depending on which end of the input power (and frequency) you are at.
To allow people to run their Heltec v4 at max power when legal, and future
proof our code, this patch introduced an optional array-based TX_GAIN_LORA.
Define NUM_PA_POINTS and set TX_GAIN_LORA to gain values for a given input
power in 1dBm increments, and all will work.
For linear systems, just continue to define TX_GAIN_LORA as a number.
Fixes https://github.com/meshtastic/firmware/issues/8070
* Remove temporary power limit on heltec v4
* Add function RadioLibInterface::checkOutputPower
* Ensure SX126x reaches minimum supported power.
* Keep it simple, instead.
* Add seenRecently = true if wasUpgraded is true but unable to remove from queue (i.e. already sent/processed).
* Consistent comment between FloodingRouter and HopRouter
* Add seenRecently = true if wasUpgraded is true but unable to remove from queue (i.e. already sent/processed).
* Consistent comment between FloodingRouter and HopRouter
Obsolete since #7652 returns false for mismatching keys
Co-authored-by: dfsx1 <dfsx1@users.noreply.github.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
* If a packet is heard multiple times, rebroadcast using the highest hop limit
Sometimes a packet will be in the TX queue waiting to be transmitted,
when it is overheard being rebroadcast by another node, with a higher
hop limit remaining. When this occurs, modify the pending packet in
the TX queue to avoid unnecessarily wasting hops.
* Reprocess instead of modifying queued packet
In order to ensure that the traceroute module works correctly, rather
than modifying the hop limnit of the existing queued version of the
packet, simply drop it ifrom the queue and reprocess the version of the
packet with the superior hop limit.
* Update protobufs submodule
* Merge upstream/develop into overheard-hoptimisation branch
Resolved conflicts in:
- src/mesh/FloodingRouter.cpp: Integrated hop limit optimization with refactored duplicate handling
- src/mesh/MeshPacketQueue.h: Kept both hop_limit_lt parameter and new find() method
* Improve method naming and code clarity
- Rename findPacket() to getPacketFromQueue() for better clarity
- Make code DRY by having find() use getPacketFromQueue() internally
- Resolves method overloading conflict with clearer naming
* If a packet is heard multiple times, rebroadcast using the highest hop limit
Sometimes a packet will be in the TX queue waiting to be transmitted,
when it is overheard being rebroadcast by another node, with a higher
hop limit remaining. When this occurs, modify the pending packet in
the TX queue to avoid unnecessarily wasting hops.
* Improve router role checking using IS_ONE_OF macro
- Replace multiple individual role checks with cleaner IS_ONE_OF macro
- Add CLIENT_BASE support as suggested in PR #7992
- Include MeshTypes.h for IS_ONE_OF macro
- Makes code more maintainable and consistent with other parts of codebase
* Apply IS_ONE_OF improvement to NextHopRouter.cpp
- Replace multiple individual role checks with cleaner IS_ONE_OF macro
- Add CLIENT_BASE support for consistency
- Include MeshTypes.h for IS_ONE_OF macro
- Matches the pattern used in FloodingRouter.cpp
* Create and apply IS_ROUTER_ROLE() macro across codebase
- Add IS_ROUTER_ROLE() macro to meshUtils.h for consistent router role checking
- Update FloodingRouter.cpp to use macro in multiple locations
- Update NextHopRouter.cpp to use macro
- Include CLIENT_BASE role support
* Core Changes:
- Add hop_limit field to PacketRecord (17B→20B due to alignment)
- Extend wasSeenRecently() with wasUpgraded parameter
- Enable router optimization without duplicate app delivery
- Handle ROUTER_LATE delayed transmission properly
Technical Details:
- Memory overhead: ~4000 bytes for 1000 records
- Prevents duplicate message delivery while enabling routing optimization
- Maintains protocol integrity for ACK/NAK handling
- Supports upgrade from hop_limit=0 to hop_limit>0 scenarios
* Delete files accdentally added for merge
* Trunk formatting
* Packets are supposed to be unsigned. Thankfully, it's only a log message.
* Upgrade all packets, not just 0 hop packets.
* Not just unsigned, but hex. Updating packet log IDs.
* Fixed order of operations issue that prevented packetrs from being removed from the queue
* Fixing some bugs after testing. Only storing the maximum hop value in PacketRecord which makes sense. Also, updating messaging to make more sense in the logs.
* Fixed flow logic about how to handle re-inserting duplicate packets. Removed IS_ROUTER_ROLE macro and replaced it with better isRebroadcaster().
* Add logic to re-run modules, but avoid re-sending to phone.
* Refactor how to process the new packet with hops. Only update nodeDB and traceRouteModule.
* - Apply changes to both FloodingRouter and NextHopRouter classes to make packets mutable for traceroute
- MESHTASTIC_EXCLUDE_TRACEROUTE guard for when we don't want traceroute
* Allow MeshPacket to be modified in-place in processUpgradePacket
* let's not make a copy where a copy is unncessary.
---------
Co-authored-by: Clive Blackledge <clive@ansible.org>
Co-authored-by: Clive Blackledge <git@ansible.org>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
* feat: implement router hop preservation for router-to-router communication
- Preserve hop_limit when both local device and previous relay are routers/CLIENT_BASE
- Only preserve hops for favorite routers to prevent abuse
- Apply to both FloodingRouter and NextHopRouter
- Update hop counting logic in MeshService for router-to-router communication
This allows routers to communicate over longer distances without
consuming hop limits, improving mesh network efficiency for
infrastructure nodes.
* chore: update protobufs submodule to latest
* Optimized to check friend list first before nodedb.
* Reverting unintended changes
* revert: remove protobufs submodule update
This reverts the protobufs submodule back to a84657c22 to remove
unintended changes from this branch.
* Slight rewrite to remove flawed NO_RELAY_NODE logic and added logic to add isFirstHop. If isFirstHop, always decrease hop_limit to avoid retry logic.
* DRY code. Remove NodeInfo logic that was left over.
* Trunk formatting