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>
This commit is contained in:
parent
df2a03f15a
commit
2306c10d32
2 changed files with 4 additions and 1 deletions
|
|
@ -274,6 +274,9 @@ extension BLEManager: CBCentralManagerDelegate {
|
|||
)
|
||||
discoveredBeacons.append(beacon)
|
||||
}
|
||||
|
||||
// Keep list sorted by RSSI (strongest/closest first)
|
||||
discoveredBeacons.sort { $0.rssi > $1.rssi }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue