mirror of
https://github.com/meshtastic/firmware.git
synced 2025-05-10 07:11:59 +00:00

Some checks are pending
CI / setup (check) (push) Waiting to run
CI / setup (esp32) (push) Waiting to run
CI / setup (esp32c3) (push) Waiting to run
CI / setup (esp32c6) (push) Waiting to run
CI / setup (esp32s3) (push) Waiting to run
CI / setup (nrf52840) (push) Waiting to run
CI / setup (rp2040) (push) Waiting to run
CI / setup (stm32) (push) Waiting to run
CI / check (push) Blocked by required conditions
CI / build-esp32 (push) Blocked by required conditions
CI / build-esp32-s3 (push) Blocked by required conditions
CI / build-esp32-c3 (push) Blocked by required conditions
CI / build-esp32-c6 (push) Blocked by required conditions
CI / build-nrf52 (push) Blocked by required conditions
CI / build-rpi2040 (push) Blocked by required conditions
CI / build-stm32 (push) Blocked by required conditions
CI / package-raspbian (push) Waiting to run
CI / package-raspbian-armv7l (push) Waiting to run
CI / package-native (push) Waiting to run
CI / after-checks (push) Blocked by required conditions
CI / gather-artifacts (esp32) (push) Blocked by required conditions
CI / gather-artifacts (esp32c3) (push) Blocked by required conditions
CI / gather-artifacts (esp32c6) (push) Blocked by required conditions
CI / gather-artifacts (esp32s3) (push) Blocked by required conditions
CI / gather-artifacts (nrf52840) (push) Blocked by required conditions
CI / gather-artifacts (rp2040) (push) Blocked by required conditions
CI / gather-artifacts (stm32) (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / release-firmware (esp32) (push) Blocked by required conditions
CI / release-firmware (esp32c3) (push) Blocked by required conditions
CI / release-firmware (esp32c6) (push) Blocked by required conditions
CI / release-firmware (esp32s3) (push) Blocked by required conditions
CI / release-firmware (nrf52840) (push) Blocked by required conditions
CI / release-firmware (rp2040) (push) Blocked by required conditions
CI / release-firmware (stm32) (push) Blocked by required conditions
Flawfinder Scan / Flawfinder (push) Waiting to run
* Revert "Fix sending duplicate packets to PhoneAPI/MQTT (#5315)"
This reverts commit 40bc04b521
.
* Handle repeated packet after potentially canceling previous Tx
65 lines
2.3 KiB
C++
65 lines
2.3 KiB
C++
#pragma once
|
|
|
|
#include "PacketHistory.h"
|
|
#include "Router.h"
|
|
|
|
/**
|
|
* This is a mixin that extends Router with the ability to do Naive Flooding (in the standard mesh protocol sense)
|
|
*
|
|
* Rules for broadcasting (listing here for now, will move elsewhere eventually):
|
|
|
|
If to==BROADCAST and id==0, this is a simple broadcast (0 hops). It will be
|
|
sent only by the current node and other nodes will not attempt to rebroadcast
|
|
it.
|
|
|
|
If to==BROADCAST and id!=0, this is a "naive flooding" broadcast. The initial
|
|
node will send it on all local interfaces.
|
|
|
|
When other nodes receive this message, they will
|
|
first check if their recentBroadcasts table contains the (from, id) pair that
|
|
indicates this message. If so, we've already seen it - so we discard it. If
|
|
not, we add it to the table and then resend this message on all interfaces.
|
|
When resending we are careful to use the "from" ID of the original sender. Not
|
|
our own ID. When resending we pick a random delay between 0 and 10 seconds to
|
|
decrease the chance of collisions with transmitters we can not even hear.
|
|
|
|
Any entries in recentBroadcasts that are older than X seconds (longer than the
|
|
max time a flood can take) will be discarded.
|
|
*/
|
|
class FloodingRouter : public Router, protected PacketHistory
|
|
{
|
|
private:
|
|
bool isRebroadcaster();
|
|
|
|
/** Check if we should rebroadcast this packet, and do so if needed
|
|
* @return true if rebroadcasted */
|
|
bool perhapsRebroadcast(const meshtastic_MeshPacket *p);
|
|
|
|
public:
|
|
/**
|
|
* Constructor
|
|
*
|
|
*/
|
|
FloodingRouter();
|
|
|
|
/**
|
|
* Send a packet on a suitable interface. This routine will
|
|
* later free() the packet to pool. This routine is not allowed to stall.
|
|
* If the txmit queue is full it might return an error
|
|
*/
|
|
virtual ErrorCode send(meshtastic_MeshPacket *p) override;
|
|
|
|
protected:
|
|
/**
|
|
* Should this incoming filter be dropped?
|
|
*
|
|
* Called immediately on reception, before any further processing.
|
|
* @return true to abandon the packet
|
|
*/
|
|
virtual bool shouldFilterReceived(const meshtastic_MeshPacket *p) override;
|
|
|
|
/**
|
|
* Look for broadcasts we need to rebroadcast
|
|
*/
|
|
virtual void sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Routing *c) override;
|
|
}; |