From 75f406745ddb957a8713ad3ab3b8e24f543ef09a Mon Sep 17 00:00:00 2001 From: Federico Gimenez Molinelli <8161434+fgimenezm@users.noreply.github.com> Date: Thu, 16 Jul 2026 09:58:02 -0300 Subject: [PATCH] Double-press: fall back to first channel with position enabled when primary precision == 0 (#11005) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- src/mesh/MeshService.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 48ef93672..29be2769c 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -63,6 +63,7 @@ Allocator &clientNotificationPool = staticClientN Allocator &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 {