mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-10 07:35:00 +00:00
Fix position exchange throttling issue (#7079)
* Fix position exchange throttling race condition Separate tracking of position broadcasts vs replies to fix exchange position functionality. Previously, allocReply() would refuse to send position replies if any position packet (broadcast or reply) was sent within the last 3 minutes. This caused the exchange position feature to fail when a device had recently sent a position broadcast. Changes: - Add lastSentReply member to track position reply timestamps separately - Update allocReply() to only throttle based on previous replies, not broadcasts - This allows position exchange to work even after recent position broadcasts The fix maintains the 3-minute throttling for replies to prevent spam while allowing legitimate position exchange functionality to work properly. * Remove unused lastSentToMesh variable Variable was no longer used after separating reply throttling logic.
This commit is contained in:
parent
e9d5e36738
commit
56e67cb434
@ -265,7 +265,6 @@ meshtastic_MeshPacket *PositionModule::allocPositionPacket()
|
||||
}
|
||||
|
||||
LOG_INFO("Position packet: time=%i lat=%i lon=%i", p.time, p.latitude_i, p.longitude_i);
|
||||
lastSentToMesh = millis();
|
||||
|
||||
// TAK Tracker devices should send their position in a TAK packet over the ATAK port
|
||||
if (config.device.role == meshtastic_Config_DeviceConfig_Role_TAK_TRACKER)
|
||||
@ -276,13 +275,18 @@ meshtastic_MeshPacket *PositionModule::allocPositionPacket()
|
||||
|
||||
meshtastic_MeshPacket *PositionModule::allocReply()
|
||||
{
|
||||
if (config.device.role != meshtastic_Config_DeviceConfig_Role_LOST_AND_FOUND && lastSentToMesh &&
|
||||
Throttle::isWithinTimespanMs(lastSentToMesh, 3 * 60 * 1000)) {
|
||||
LOG_DEBUG("Skip Position reply since we sent it <3min ago");
|
||||
if (config.device.role != meshtastic_Config_DeviceConfig_Role_LOST_AND_FOUND && lastSentReply &&
|
||||
Throttle::isWithinTimespanMs(lastSentReply, 3 * 60 * 1000)) {
|
||||
LOG_DEBUG("Skip Position reply since we sent a reply <3min ago");
|
||||
ignoreRequest = true; // Mark it as ignored for MeshModule
|
||||
return nullptr;
|
||||
}
|
||||
return allocPositionPacket();
|
||||
|
||||
meshtastic_MeshPacket *reply = allocPositionPacket();
|
||||
if (reply) {
|
||||
lastSentReply = millis(); // Track when we sent this reply
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
||||
meshtastic_MeshPacket *PositionModule::allocAtakPli()
|
||||
|
@ -63,7 +63,7 @@ class PositionModule : public ProtobufModule<meshtastic_Position>, private concu
|
||||
void sendLostAndFoundText();
|
||||
bool hasQualityTimesource();
|
||||
bool hasGPS();
|
||||
uint32_t lastSentToMesh = 0; // Last time we sent our position to the mesh
|
||||
uint32_t lastSentReply = 0; // Last time we sent a position reply (used for reply throttling only)
|
||||
|
||||
const uint32_t minimumTimeThreshold =
|
||||
Default::getConfiguredOrDefaultMs(config.position.broadcast_smart_minimum_interval_secs, 30);
|
||||
|
Loading…
Reference in New Issue
Block a user