From 90744ee0b767b354b7194f05b570ad4ca154f25d Mon Sep 17 00:00:00 2001 From: Jason P Date: Fri, 1 May 2026 08:46:53 -0500 Subject: [PATCH] Update PhoneAPI.cpp to reduce chattiness (#10367) --- src/mesh/PhoneAPI.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 2a3a2a26c..9ff27d33e 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -512,11 +512,6 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) // LOG_INFO("nodeinfo: num=0x%x, lastseen=%u, id=%s, name=%s", nodeInfoForPhone.num, nodeInfoForPhone.last_heard, // nodeInfoForPhone.user.id, nodeInfoForPhone.user.long_name); - // Occasional progress logging. (readIndex==2 will be true for the first non-us node) - if (readIndex == 2 || readIndex % 20 == 0) { - LOG_DEBUG("nodeinfo: %d/%d", readIndex, nodeDB->getNumMeshNodes()); - } - fromRadioScratch.which_payload_variant = meshtastic_FromRadio_node_info_tag; fromRadioScratch.node_info = infoToSend; prefetchNodeInfos(); @@ -647,9 +642,11 @@ void PhoneAPI::releaseQueueStatusPhonePacket() void PhoneAPI::prefetchNodeInfos() { bool added = false; + bool wasEmpty = false; // Keep the queue topped up so BLE reads stay responsive even if DB fetches take a moment. { concurrency::LockGuard guard(&nodeInfoMutex); + wasEmpty = nodeInfoQueue.empty(); while (nodeInfoQueue.size() < kNodePrefetchDepth) { auto nextNode = nodeDB->readNextMeshNode(readIndex); if (!nextNode) @@ -663,11 +660,15 @@ void PhoneAPI::prefetchNodeInfos() info.via_mqtt = isUs ? false : info.via_mqtt; info.is_favorite = info.is_favorite || isUs; nodeInfoQueue.push_back(info); + // Log progress here (at fetch time) so readIndex is accurate and each value logs only once. + if (readIndex == 2 || readIndex % 20 == 0) { + LOG_DEBUG("nodeinfo: %d/%d", readIndex, nodeDB->getNumMeshNodes()); + } added = true; } } - if (added) + if (added && wasEmpty) onNowHasData(0); }