From 6249e63ec088a6522c5a48c7941d83b1b78a21de Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Thu, 21 May 2026 08:37:17 +0200 Subject: [PATCH] fix: remove isBLEConnected guard from discover response handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The !isBLEConnected() check was too restrictive — if BLE happened to be connected (app in background) the standalone discover would silently drop all responses. Tag matching already provides correct isolation: responses matching _pending_node_discover_tag are handled by the standalone UI and not forwarded to the BLE app; responses with a different tag fall through to the normal forward path. Also show short type names (Rpt/Snsr/Room) in the discover results list instead of generic "known"/"NEW", with a '*' prefix for nodes not yet in contacts — matching the repeater/sensor distinction the app shows. Co-Authored-By: Claude Sonnet 4.6 --- examples/companion_radio/MyMesh.cpp | 8 ++++---- examples/companion_radio/ui-new/NearbyScreen.h | 11 ++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index 4ee19131..c6631df8 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -788,9 +788,9 @@ int MyMesh::getDiscoverResults(DiscoverResult dest[], int max_count) { } void MyMesh::onControlDataRecv(mesh::Packet *packet) { - // handle node discovery responses when in standalone UI mode (no companion app connected) - if (!_serial->isBLEConnected() && - (packet->payload[0] & 0xF0) == CTL_TYPE_NODE_DISCOVER_RESP && + // If we have an active standalone discover, check if this is a matching response. + // Tag matching provides isolation — no isBLEConnected check needed. + if ((packet->payload[0] & 0xF0) == CTL_TYPE_NODE_DISCOVER_RESP && packet->payload_len >= 6 + PUB_KEY_SIZE && _pending_node_discover_tag != 0 && !millisHasNowPassed(_pending_node_discover_until)) { @@ -817,8 +817,8 @@ void MyMesh::onControlDataRecv(mesh::Packet *packet) { r.timestamp = getRTCClock()->getCurrentTime(); } if (_ui) _ui->notify(UIEventType::newContactMessage); + return; // our discover — don't forward to BLE app } - return; } if (packet->payload_len + 4 > sizeof(out_frame)) { diff --git a/examples/companion_radio/ui-new/NearbyScreen.h b/examples/companion_radio/ui-new/NearbyScreen.h index ec3f5421..59d131c9 100644 --- a/examples/companion_radio/ui-new/NearbyScreen.h +++ b/examples/companion_radio/ui-new/NearbyScreen.h @@ -200,7 +200,7 @@ class NearbyScreen : public UIScreen { display.setColor(DisplayDriver::LIGHT); - // name: known contact → actual name; unknown → "[Type]" + // left: contact name if known, otherwise "[Type]" char label[32]; if (r.name[0]) { strncpy(label, r.name, sizeof(label) - 1); @@ -212,9 +212,14 @@ class NearbyScreen : public UIScreen { display.translateUTF8ToBlocks(filtered, label, sizeof(filtered)); display.drawTextEllipsized(2, y, DIST_COL - 4, filtered); - // right column: type label, dimmed for known / bright for new + // right: short type name; prefix '*' for nodes not in contacts + const char* st = (r.type == ADV_TYPE_REPEATER) ? "Rpt" : + (r.type == ADV_TYPE_SENSOR) ? "Snsr" : + (r.type == ADV_TYPE_ROOM) ? "Room" : "?"; + char rtype[8]; + snprintf(rtype, sizeof(rtype), r.is_known ? "%s" : "*%s", st); display.setCursor(DIST_COL, y); - display.print(r.is_known ? "known" : "NEW"); + display.print(rtype); } display.setColor(DisplayDriver::LIGHT);