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:
co-authored by
Thomas Göttgens
parent
deea7be89b
commit
75f406745d
@@ -63,6 +63,7 @@ Allocator<meshtastic_ClientNotification> &clientNotificationPool = staticClientN
|
|||||||
|
|
||||||
Allocator<meshtastic_QueueStatus> &queueStatusPool = staticQueueStatusPool;
|
Allocator<meshtastic_QueueStatus> &queueStatusPool = staticQueueStatusPool;
|
||||||
|
|
||||||
|
#include "PositionPrecision.h"
|
||||||
#include "Router.h"
|
#include "Router.h"
|
||||||
|
|
||||||
MeshService::MeshService()
|
MeshService::MeshService()
|
||||||
@@ -348,8 +349,31 @@ bool MeshService::trySendPosition(NodeNum dest, bool wantReplies)
|
|||||||
LOG_DEBUG("Skip position ping; no fresh position since boot");
|
LOG_DEBUG("Skip position ping; no fresh position since boot");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LOG_INFO("Send position ping to 0x%08x, wantReplies=%d, channel=%d", dest, wantReplies, node->channel);
|
// Prefer the node's current channel, but fall back to the first channel with
|
||||||
positionModule->sendOurPosition(dest, wantReplies, node->channel);
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user