Compare commits

...

2 commits

Author SHA1 Message Date
c879ecd442 Merge pull request 'fix: sort beacons by RSSI (closest first)' (#33) from schwifty/sort-beacons-by-rssi into main 2026-03-22 23:03:36 +00:00
2306c10d32 fix: sort discovered beacons by RSSI (closest first)
Sort the beacon list so strongest signal (closest beacon) appears at the
top. Sorting happens both in BLEManager as beacons are discovered and in
the ScanView list rendering.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 23:03:18 +00:00
2 changed files with 4 additions and 1 deletions

View file

@ -274,6 +274,9 @@ extension BLEManager: CBCentralManagerDelegate {
)
discoveredBeacons.append(beacon)
}
// Keep list sorted by RSSI (strongest/closest first)
discoveredBeacons.sort { $0.rssi > $1.rssi }
}
}
}

View file

@ -301,7 +301,7 @@ struct ScanView: View {
.padding()
}
} else {
List(bleManager.discoveredBeacons) { beacon in
List(bleManager.discoveredBeacons.sorted { $0.rssi > $1.rssi }) { beacon in
Button {
selectedBeacon = beacon
Task { await startProvisioning(beacon) }