From e354b78b46e2c04630a541dfb2d8afe11a86eec4 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Wed, 3 Jun 2026 14:11:03 +0200 Subject: [PATCH] fix(nav): ping result never appeared after Send MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit startPingForKey() set the "RTT: ..." line but didn't rebuild the ping menu, and updatePingMenuState only rebuilt on a string-count change it computed after the mutation — so the menu stayed at a lone "Send" row and nothing visibly happened after pressing Send, whether or not a reply came. - Rebuild the menu right after starting the ping so "RTT: ..." shows at once; on send failure show "RTT: send fail" instead of a blank. - Sync the menu against its actual row count (_ping_menu._count) as result lines populate, so RTT/SNR rows appear when the reply lands. Co-Authored-By: Claude Opus 4.8 --- examples/companion_radio/ui-new/NearbyScreen.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/companion_radio/ui-new/NearbyScreen.h b/examples/companion_radio/ui-new/NearbyScreen.h index a236b63b..832ba6f0 100644 --- a/examples/companion_radio/ui-new/NearbyScreen.h +++ b/examples/companion_radio/ui-new/NearbyScreen.h @@ -218,8 +218,9 @@ class NearbyScreen : public UIScreen { _pinging = true; _ping_started_ms = millis(); } else { - _ping_time_str[0] = '\0'; + snprintf(_ping_time_str, sizeof(_ping_time_str), "RTT: send fail"); } + if (_ping_menu.active) rebuildPingMenu(); // surface "RTT: ..." immediately } void updatePingMenuState() { @@ -228,7 +229,6 @@ class NearbyScreen : public UIScreen { int16_t snr_out = 0, snr_back = 0; uint32_t rtt = 0; _task->getPingResult(snr_out, snr_back, rtt); - int before = pingRowCount(); if (_pinging && (snr_out != 0 || snr_back != 0 || rtt != 0)) { if (rtt > 0 && rtt < 10000) { @@ -250,9 +250,9 @@ class NearbyScreen : public UIScreen { _pinging = false; if (_task) _task->clearPing(); } - // Grow the menu in place as result lines populate, so they never show as - // blank rows beforehand. - if (pingRowCount() != before) rebuildPingMenu(); + // Keep the menu in sync with the populated result lines (grows as the + // reply arrives; never shows blank rows). + if (pingRowCount() != _ping_menu._count) rebuildPingMenu(); } bool handlePingMenuInput(char c, const uint8_t* pub_key, bool allow_enter_to_open = false) {