From 184b02b3423d48ff6262ca8b7de7953eebe42fdf Mon Sep 17 00:00:00 2001 From: evgeny Date: Fri, 30 Oct 2026 12:46:27 +0100 Subject: [PATCH] Show per-device BLE receive counts in desktop rows --- tools/cgathui_common/tests/test_ble_etcp.c | 4 +++- tools/chatgui/tests/test_desktop_ble.cpp | 6 ++++++ tools/chatgui/transport/desktop_ble.cpp | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/cgathui_common/tests/test_ble_etcp.c b/tools/cgathui_common/tests/test_ble_etcp.c index d7839d0b..1dfca70d 100644 --- a/tools/cgathui_common/tests/test_ble_etcp.c +++ b/tools/cgathui_common/tests/test_ble_etcp.c @@ -342,7 +342,9 @@ int main(void) { ble_backend_broadcast(backends[0]->owner, &ep, bytes, len, -30); bytes[2] = BLE_IDENTITY_VERSION; assert(ble_etcp_neighbors(endpoints[0].driver, neighbors, 2) == 1 && neighbors[0].broadcast_received == 3); /* Отдельный сосед имеет свой счётчик; его объявление не меняет счёт первого. */ - int other_len = ble_identity_encode(self, endpoints[0].inst.node_id ^ 1, "other"); + uint64_t other_node = 1; + while (other_node == endpoints[0].inst.node_id || other_node == endpoints[1].inst.node_id) other_node++; + int other_len = ble_identity_encode(self, other_node, "other"); ble_backend_broadcast(backends[0]->owner, &ep, self, other_len, -55); assert(ble_etcp_neighbors(endpoints[0].driver, neighbors, 2) == 2); assert(neighbors[0].broadcast_received == 3 && neighbors[1].broadcast_received == 1); diff --git a/tools/chatgui/tests/test_desktop_ble.cpp b/tools/chatgui/tests/test_desktop_ble.cpp index 7a55d544..b2ec5a56 100644 --- a/tools/chatgui/tests/test_desktop_ble.cpp +++ b/tools/chatgui/tests/test_desktop_ble.cpp @@ -46,8 +46,14 @@ private slots: ble_backend_broadcast(backend.owner, &endpoint, bytes, length, -42); const auto peers = radio.snapshot().peers; QCOMPARE(peers.size(), 1); QVERIFY(peers.first().contains("Android")); QVERIFY(peers.first().contains("-42")); + QVERIFY(peers.first().endsWith("RX 1")); ble_backend_broadcast(backend.owner, &endpoint, bytes, length, -40); QCOMPARE(radio.snapshot().peers.size(), 1); + QVERIFY(radio.snapshot().peers.first().endsWith("RX 2")); + length = ble_identity_encode(bytes, 2, "Renamed peer"); strcpy(endpoint.id, "new-address"); + ble_backend_broadcast(backend.owner, &endpoint, bytes, length, -38); + const auto renamed = radio.snapshot().peers.first(); + QVERIFY(renamed.contains("Renamed peer") && renamed.contains("NEW-ADDRESS") && renamed.endsWith("RX 3")); radio.apply(1, "Renamed"); QVERIFY(advertised.isEmpty()); QCOMPARE(ble_backend_incoming(backend.owner, &endpoint), ble_link_id(0)); radio.apply(0, "Renamed"); QVERIFY(!radio.transport()); QCOMPARE(destructions, 1); diff --git a/tools/chatgui/transport/desktop_ble.cpp b/tools/chatgui/transport/desktop_ble.cpp index 0bb522be..92c9ba63 100644 --- a/tools/chatgui/transport/desktop_ble.cpp +++ b/tools/chatgui/transport/desktop_ble.cpp @@ -100,9 +100,9 @@ DesktopBleSnapshot DesktopBle::snapshot() { address = address.left(12); for (int offset = 10; offset >= 2; offset -= 2) address.insert(offset, ':'); } - m_snapshot.peers.append(QStringLiteral("%1 · %2 · %3 · %4 dBm").arg(QString::fromUtf8(peer.identity.name), + m_snapshot.peers.append(QStringLiteral("%1 · %2 · %3 · %4 dBm · RX %5").arg(QString::fromUtf8(peer.identity.name), QString::number(peer.identity.node_id, 16).rightJustified(16, '0'), address.toUpper(), - peer.rssi == 127 ? QStringLiteral("?") : QString::number(peer.rssi))); + peer.rssi == 127 ? QStringLiteral("?") : QString::number(peer.rssi)).arg(qulonglong(peer.broadcast_received))); } m_snapshot.connections = m_connections.size(); return m_snapshot;