Skip to content

Commit 87fc128

Browse files
committed
Rename nearbyPeripherals -> discoveredPeripherals
Since we unfortunately no longer get notified about disconnects, we rename this to avoid confusion, since discovered peripherals will be kept even after they disconnect.
1 parent bc4dc14 commit 87fc128

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

DistributedChatBluetooth/Sources/DistributedChatBluetooth/Controller/BluetoothLinuxTransport.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class BluetoothLinuxTransport: ChatTransport {
3333

3434
private var listeners = [(String) -> Void]()
3535

36-
private var nearbyPeripherals: [Peripheral: DiscoveredPeripheral] = [:]
36+
private var discoveredPeripherals: [Peripheral: DiscoveredPeripheral] = [:]
3737

3838
private class DiscoveredPeripheral {
3939
// TODO: Discover and store user name/id here
@@ -155,11 +155,11 @@ public class BluetoothLinuxTransport: ChatTransport {
155155
let peripheral = scanData.peripheral
156156
log.debug("Central: Discovered peripheral \(peripheral.id) (RSSI: \(scanData.rssi), connectable: \(scanData.isConnectable))")
157157

158-
if !nearbyPeripherals.keys.contains(peripheral) {
158+
if !discoveredPeripherals.keys.contains(peripheral) {
159159
do {
160160
try await localCentral.connect(to: peripheral)
161161
let state = DiscoveredPeripheral()
162-
nearbyPeripherals[peripheral] = state
162+
discoveredPeripherals[peripheral] = state
163163
log.info("Central: Connected to \(peripheral.id), discovering services...")
164164

165165
let services = try await localCentral.discoverServices([serviceUUID], for: peripheral)
@@ -188,7 +188,7 @@ public class BluetoothLinuxTransport: ChatTransport {
188188
return
189189
}
190190

191-
for (peripheral, state) in nearbyPeripherals {
191+
for (peripheral, state) in discoveredPeripherals {
192192
if let characteristic = state.inboxCharacteristic {
193193
Task {
194194
do {

0 commit comments

Comments
 (0)