fix: sort beacons by RSSI (closest first) #33
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