diff --git a/Platforms/platform-esp32/source/drivers/bluetooth/esp32_ble_scan.cpp b/Platforms/platform-esp32/source/drivers/bluetooth/esp32_ble_scan.cpp index 728eae33..554845e1 100644 --- a/Platforms/platform-esp32/source/drivers/bluetooth/esp32_ble_scan.cpp +++ b/Platforms/platform-esp32/source/drivers/bluetooth/esp32_ble_scan.cpp @@ -57,7 +57,6 @@ int ble_gap_disc_event_handler(struct ble_gap_event* event, void* arg) { } } - bool should_publish = false; { xSemaphoreTake(ctx->scan_mutex, portMAX_DELAY); bool found = false; @@ -69,41 +68,29 @@ int ble_gap_disc_event_handler(struct ble_gap_event* event, void* arg) { } ctx->scan_results[i].rssi = record.rssi; found = true; - should_publish = true; break; } } - if (!found && record.name[0] != '\0' && ctx->scan_count < 64) { + if (!found && ctx->scan_count < 64) { ctx->scan_results[ctx->scan_count] = record; ctx->scan_addrs[ctx->scan_count] = disc.addr; // full addr (type+val) ctx->scan_count++; - should_publish = true; } xSemaphoreGive(ctx->scan_mutex); } - if (should_publish) { - LOG_I(TAG, "Peer found: name='%s' addr=%02x:%02x:%02x:%02x:%02x:%02x rssi=%d", - record.name, - record.addr[0], record.addr[1], record.addr[2], - record.addr[3], record.addr[4], record.addr[5], - record.rssi); - struct BtEvent e = {}; - e.type = BT_EVENT_PEER_FOUND; - e.peer = record; - ble_publish_event(device, e); - } + struct BtEvent e = {}; + e.type = BT_EVENT_PEER_FOUND; + e.peer = record; + ble_publish_event(device, e); break; } case BLE_GAP_EVENT_DISC_COMPLETE: LOG_I(TAG, "Scan complete (reason=%d)", event->disc_complete.reason); - ble_set_scan_active(device, false); - { - struct BtEvent e = {}; - e.type = BT_EVENT_SCAN_FINISHED; - ble_publish_event(device, e); - } + // Keep scan_active=true; resolveNextUnnamedPeer clears it and fires ScanFinished + // once name resolution finishes, so the UI spinner stays active throughout. + ble_resolve_next_unnamed_peer(device, 0); break; default: