mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-03 18:56:15 +00:00
fix: remove isBLEConnected guard from discover response handling
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
64098bc4dc
commit
6249e63ec0
@@ -788,9 +788,9 @@ int MyMesh::getDiscoverResults(DiscoverResult dest[], int max_count) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MyMesh::onControlDataRecv(mesh::Packet *packet) {
|
void MyMesh::onControlDataRecv(mesh::Packet *packet) {
|
||||||
// handle node discovery responses when in standalone UI mode (no companion app connected)
|
// If we have an active standalone discover, check if this is a matching response.
|
||||||
if (!_serial->isBLEConnected() &&
|
// Tag matching provides isolation — no isBLEConnected check needed.
|
||||||
(packet->payload[0] & 0xF0) == CTL_TYPE_NODE_DISCOVER_RESP &&
|
if ((packet->payload[0] & 0xF0) == CTL_TYPE_NODE_DISCOVER_RESP &&
|
||||||
packet->payload_len >= 6 + PUB_KEY_SIZE &&
|
packet->payload_len >= 6 + PUB_KEY_SIZE &&
|
||||||
_pending_node_discover_tag != 0 &&
|
_pending_node_discover_tag != 0 &&
|
||||||
!millisHasNowPassed(_pending_node_discover_until)) {
|
!millisHasNowPassed(_pending_node_discover_until)) {
|
||||||
@@ -817,8 +817,8 @@ void MyMesh::onControlDataRecv(mesh::Packet *packet) {
|
|||||||
r.timestamp = getRTCClock()->getCurrentTime();
|
r.timestamp = getRTCClock()->getCurrentTime();
|
||||||
}
|
}
|
||||||
if (_ui) _ui->notify(UIEventType::newContactMessage);
|
if (_ui) _ui->notify(UIEventType::newContactMessage);
|
||||||
|
return; // our discover — don't forward to BLE app
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packet->payload_len + 4 > sizeof(out_frame)) {
|
if (packet->payload_len + 4 > sizeof(out_frame)) {
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ class NearbyScreen : public UIScreen {
|
|||||||
|
|
||||||
display.setColor(DisplayDriver::LIGHT);
|
display.setColor(DisplayDriver::LIGHT);
|
||||||
|
|
||||||
// name: known contact → actual name; unknown → "[Type]"
|
// left: contact name if known, otherwise "[Type]"
|
||||||
char label[32];
|
char label[32];
|
||||||
if (r.name[0]) {
|
if (r.name[0]) {
|
||||||
strncpy(label, r.name, sizeof(label) - 1);
|
strncpy(label, r.name, sizeof(label) - 1);
|
||||||
@@ -212,9 +212,14 @@ class NearbyScreen : public UIScreen {
|
|||||||
display.translateUTF8ToBlocks(filtered, label, sizeof(filtered));
|
display.translateUTF8ToBlocks(filtered, label, sizeof(filtered));
|
||||||
display.drawTextEllipsized(2, y, DIST_COL - 4, 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.setCursor(DIST_COL, y);
|
||||||
display.print(r.is_known ? "known" : "NEW");
|
display.print(rtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
display.setColor(DisplayDriver::LIGHT);
|
display.setColor(DisplayDriver::LIGHT);
|
||||||
|
|||||||
Reference in New Issue
Block a user