mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-25 01:42:15 +00:00
remove random delay hack from broadcast, since we now do that for all transmits
This commit is contained in:
parent
86ae69d360
commit
9f05ad2927
@ -208,8 +208,6 @@ void setup()
|
|||||||
|
|
||||||
service.init();
|
service.init();
|
||||||
|
|
||||||
realRouter.setup(); // required for our periodic task (kinda skanky FIXME)
|
|
||||||
|
|
||||||
#ifdef SX1262_ANT_SW
|
#ifdef SX1262_ANT_SW
|
||||||
// make analog PA vs not PA switch on SX1262 eval board work properly
|
// make analog PA vs not PA switch on SX1262 eval board work properly
|
||||||
pinMode(SX1262_ANT_SW, OUTPUT);
|
pinMode(SX1262_ANT_SW, OUTPUT);
|
||||||
|
@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
static bool supportFlooding = true; // Sometimes to simplify debugging we want jusT simple broadcast only
|
static bool supportFlooding = true; // Sometimes to simplify debugging we want jusT simple broadcast only
|
||||||
|
|
||||||
FloodingRouter::FloodingRouter() : toResend(MAX_NUM_NODES)
|
FloodingRouter::FloodingRouter() : toResend(MAX_NUM_NODES) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a packet on a suitable interface. This routine will
|
* Send a packet on a suitable interface. This routine will
|
||||||
@ -22,18 +20,6 @@ ErrorCode FloodingRouter::send(MeshPacket *p)
|
|||||||
return Router::send(p);
|
return Router::send(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a delay in msec before sending the next packet
|
|
||||||
uint32_t getRandomDelay()
|
|
||||||
{
|
|
||||||
return random(200, 10 * 1000L); // between 200ms and 10s
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Now that our generalized packet send code has a random delay - I don't think we need to wait here
|
|
||||||
* But I'm leaving this bool until I rip the code out for good.
|
|
||||||
*/
|
|
||||||
bool needDelay = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called from loop()
|
* Called from loop()
|
||||||
* Handle any packet that is received by an interface on this node.
|
* Handle any packet that is received by an interface on this node.
|
||||||
@ -52,21 +38,11 @@ void FloodingRouter::handleReceived(MeshPacket *p)
|
|||||||
if (p->id != 0) {
|
if (p->id != 0) {
|
||||||
MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
|
MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
|
||||||
|
|
||||||
if (needDelay) {
|
DEBUG_MSG("Rebroadcasting received floodmsg to neighbors, fr=0x%x,to=0x%x,id=%d\n", p->from, p->to, p->id);
|
||||||
uint32_t delay = getRandomDelay();
|
// Note: we are careful to resend using the original senders node id
|
||||||
|
// We are careful not to call our hooked version of send() - because we don't want to check this again
|
||||||
|
Router::send(tosend);
|
||||||
|
|
||||||
DEBUG_MSG("Rebroadcasting received floodmsg to neighbors in %u msec, fr=0x%x,to=0x%x,id=%d\n", delay,
|
|
||||||
p->from, p->to, p->id);
|
|
||||||
|
|
||||||
toResend.enqueue(tosend);
|
|
||||||
setPeriod(delay); // This will work even if we were already waiting a random delay
|
|
||||||
} else {
|
|
||||||
DEBUG_MSG("Rebroadcasting received floodmsg to neighbors, fr=0x%x,to=0x%x,id=%d\n", p->from, p->to,
|
|
||||||
p->id);
|
|
||||||
// Note: we are careful to resend using the original senders node id
|
|
||||||
// We are careful not to call our hooked version of send() - because we don't want to check this again
|
|
||||||
Router::send(tosend);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Ignoring a simple (0 hop) broadcast\n");
|
DEBUG_MSG("Ignoring a simple (0 hop) broadcast\n");
|
||||||
}
|
}
|
||||||
@ -78,21 +54,3 @@ void FloodingRouter::handleReceived(MeshPacket *p)
|
|||||||
} else
|
} else
|
||||||
Router::handleReceived(p);
|
Router::handleReceived(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FloodingRouter::doTask()
|
|
||||||
{
|
|
||||||
MeshPacket *p = toResend.dequeuePtr(0);
|
|
||||||
|
|
||||||
if (p) {
|
|
||||||
DEBUG_MSG("Sending delayed message!\n");
|
|
||||||
// Note: we are careful to resend using the original senders node id
|
|
||||||
// We are careful not to call our hooked version of send() - because we don't want to check this again
|
|
||||||
Router::send(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toResend.isEmpty())
|
|
||||||
disable(); // no more work right now
|
|
||||||
else {
|
|
||||||
setPeriod(getRandomDelay());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include "PeriodicTask.h"
|
#include "PeriodicTask.h"
|
||||||
#include "Router.h"
|
#include "Router.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a mixin that extends Router with the ability to do Naive Flooding (in the standard mesh protocol sense)
|
* This is a mixin that extends Router with the ability to do Naive Flooding (in the standard mesh protocol sense)
|
||||||
*
|
*
|
||||||
@ -28,10 +27,9 @@
|
|||||||
Any entries in recentBroadcasts that are older than X seconds (longer than the
|
Any entries in recentBroadcasts that are older than X seconds (longer than the
|
||||||
max time a flood can take) will be discarded.
|
max time a flood can take) will be discarded.
|
||||||
*/
|
*/
|
||||||
class FloodingRouter : public Router, public PeriodicTask, private PacketHistory
|
class FloodingRouter : public Router, private PacketHistory
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Packets we've received that we need to resend after a short delay
|
* Packets we've received that we need to resend after a short delay
|
||||||
*/
|
*/
|
||||||
@ -60,6 +58,4 @@ class FloodingRouter : public Router, public PeriodicTask, private PacketHistory
|
|||||||
* Note: this method will free the provided packet
|
* Note: this method will free the provided packet
|
||||||
*/
|
*/
|
||||||
virtual void handleReceived(MeshPacket *p);
|
virtual void handleReceived(MeshPacket *p);
|
||||||
|
|
||||||
virtual void doTask();
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user