Space out periodic broadcasts of modules automatically (#5931)

* Space out periodic broadcasts of modules automatically

* Add warning for function usage

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
GUVWAF
2025-01-26 20:59:59 +01:00
committed by GitHub
parent 10d553087c
commit 4747e73f37
10 changed files with 37 additions and 16 deletions

View File

@@ -10,6 +10,7 @@
std::vector<MeshModule *> *MeshModule::modules;
const meshtastic_MeshPacket *MeshModule::currentRequest;
uint8_t MeshModule::numPeriodicModules = 0;
/**
* If any of the current chain of modules has already sent a reply, it will be here. This is useful to allow
@@ -35,6 +36,15 @@ MeshModule::~MeshModule()
modules->erase(it);
}
// ⚠️ **Only call once** to set the initial delay before a module starts broadcasting periodically
int32_t MeshModule::setStartDelay()
{
int32_t startDelay = MESHMODULE_MIN_BROADCAST_DELAY_MS + numPeriodicModules * MESHMODULE_BROADCAST_SPACING_MS;
numPeriodicModules++;
return startDelay;
}
meshtastic_MeshPacket *MeshModule::allocAckNak(meshtastic_Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex,
uint8_t hopLimit)
{