diff --git a/.swiftlint.yml b/.swiftlint.yml index 31529875..6bfb418a 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -29,6 +29,8 @@ identifier_name: - NetworkReaders - SensorsList - Alignments + - _devices + - _uuidAddress line_length: 200 diff --git a/Modules/Bluetooth/readers.swift b/Modules/Bluetooth/readers.swift index 10581384..64be6953 100644 --- a/Modules/Bluetooth/readers.swift +++ b/Modules/Bluetooth/readers.swift @@ -15,13 +15,35 @@ import CoreBluetooth import IOBluetooth internal class DevicesReader: Reader<[BLEDevice]>, CBCentralManagerDelegate, CBPeripheralDelegate { - private var devices: [BLEDevice] = [] - + private let queue = DispatchQueue(label: "eu.exelban.Stats.Bluetooth.reader", attributes: .concurrent) private var manager: CBCentralManager! - private var uuidAddress: [UUID: String] = [:] + + private var _devices: [BLEDevice] = [] + private var _uuidAddress: [UUID: String] = [:] private var peripherals: [CBPeripheral] = [] private var characteristicsDict: [UUID: CBCharacteristic] = [:] + private var devices: [BLEDevice] { + get { + self.queue.sync { self._devices } + } + set { + self.queue.async(flags: .barrier) { + self._devices = newValue + } + } + } + private var uuidAddress: [UUID: String] { + get { + self.queue.sync { self._uuidAddress } + } + set { + self.queue.async(flags: .barrier) { + self._uuidAddress = newValue + } + } + } + private let batteryServiceUUID = CBUUID(string: "0x180F") private let batteryCharacteristicsUUID = CBUUID(string: "0x2A19") @@ -89,7 +111,7 @@ internal class DevicesReader: Reader<[BLEDevice]>, CBCentralManagerDelegate, CBP return } - if let uuid = UUID(uuidString: key) { + if let uuid = UUID(uuidString: key), self.uuidAddress[uuid] == nil { self.uuidAddress[uuid] = value } } diff --git a/Stats.xcodeproj/xcshareddata/xcschemes/Stats.xcscheme b/Stats.xcodeproj/xcshareddata/xcschemes/Stats.xcscheme index 981014d3..550917d6 100644 --- a/Stats.xcodeproj/xcshareddata/xcschemes/Stats.xcscheme +++ b/Stats.xcodeproj/xcshareddata/xcschemes/Stats.xcscheme @@ -89,6 +89,13 @@ isEnabled = "NO"> + + + + CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 298 + 299 Description Simple macOS system monitor in your menu bar LSApplicationCategoryType