Double-press: fall back to first channel with position enabled when primary precision == 0 (#11005)

* Double-press: fall back to first channel with position enabled when primary precision == 0
* Add missing include
* Fix trunk fmt
* Enhance logging for fallback nodeinfo sending
---------
Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>
This commit is contained in:
Federico Gimenez Molinelli
2026-07-16 14:58:02 +02:00
committed by GitHub
co-authored by GitHub Thomas Göttgens
parent deea7be89b
commit 75f406745d
+26 -2
View File
@@ -63,6 +63,7 @@ Allocator<meshtastic_ClientNotification> &clientNotificationPool = staticClientN
Allocator<meshtastic_QueueStatus> &queueStatusPool = staticQueueStatusPool;
#include "PositionPrecision.h"
#include "Router.h"
MeshService::MeshService()
@@ -348,8 +349,31 @@ bool MeshService::trySendPosition(NodeNum dest, bool wantReplies)
LOG_DEBUG("Skip position ping; no fresh position since boot");
return false;
}
LOG_INFO("Send position ping to 0x%08x, wantReplies=%d, channel=%d", dest, wantReplies, node->channel);
positionModule->sendOurPosition(dest, wantReplies, node->channel);
// Prefer the node's current channel, but fall back to the first channel with
// position enabled (matching PositionModule::sendOurPosition() behavior).
uint8_t sendChan = node->channel;
if (getPositionPrecisionForChannel(sendChan) == 0) {
bool found = false;
for (uint8_t ch = 0; ch < 8; ++ch) {
if (getPositionPrecisionForChannel(ch) != 0) {
sendChan = ch;
found = true;
break;
}
}
if (!found) {
// No channel with position enabled: fall back to sending nodeinfo, as before.
if (nodeInfoModule) {
LOG_INFO(
"No channel with position enabled; sending nodeinfo instead to 0x%08x, wantReplies=%d, channel=%d",
dest, wantReplies, node->channel);
nodeInfoModule->sendOurNodeInfo(dest, wantReplies, node->channel);
}
return false;
}
}
LOG_INFO("Send position ping to 0x%08x, wantReplies=%d, channel=%d", dest, wantReplies, sendChan);
positionModule->sendOurPosition(dest, wantReplies, sendChan);
return true;
}
} else {