diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index c6631df8..d1972ede 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -814,6 +814,7 @@ void MyMesh::onControlDataRecv(mesh::Packet *packet) { r.is_known = false; } r.type = node_type; + r.rssi = (int8_t)_radio->getLastRSSI(); r.timestamp = getRTCClock()->getCurrentTime(); } if (_ui) _ui->notify(UIEventType::newContactMessage); diff --git a/examples/companion_radio/MyMesh.h b/examples/companion_radio/MyMesh.h index 9d063a99..de95afa4 100644 --- a/examples/companion_radio/MyMesh.h +++ b/examples/companion_radio/MyMesh.h @@ -89,6 +89,7 @@ struct DiscoverResult { char name[32]; // contact name if known, "" if unknown (use type label) uint8_t type; // ADV_TYPE_REPEATER / ADV_TYPE_SENSOR / ADV_TYPE_ROOM bool is_known; // true = in contacts[], false = new unknown node + int8_t rssi; // RSSI of the response as received by us (dBm) uint32_t timestamp; }; diff --git a/examples/companion_radio/ui-new/NearbyScreen.h b/examples/companion_radio/ui-new/NearbyScreen.h index 59d131c9..014d0441 100644 --- a/examples/companion_radio/ui-new/NearbyScreen.h +++ b/examples/companion_radio/ui-new/NearbyScreen.h @@ -212,12 +212,15 @@ class NearbyScreen : public UIScreen { display.translateUTF8ToBlocks(filtered, label, sizeof(filtered)); display.drawTextEllipsized(2, y, DIST_COL - 4, filtered); - // right: short type name; prefix '*' for nodes not in contacts + // right: type+RSSI for known ("Rpt-87"), just RSSI with '*' for new ("*-87") 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); + char rtype[12]; + if (r.is_known) + snprintf(rtype, sizeof(rtype), "%s%d", st, (int)r.rssi); + else + snprintf(rtype, sizeof(rtype), "*%d", (int)r.rssi); display.setCursor(DIST_COL, y); display.print(rtype); }