diff --git a/Modules/Bluetooth/main.swift b/Modules/Bluetooth/main.swift index 58adc3d7..0d018d6e 100644 --- a/Modules/Bluetooth/main.swift +++ b/Modules/Bluetooth/main.swift @@ -15,6 +15,7 @@ import CoreBluetooth public struct BLEDevice { let uuid: UUID + let address: String let name: String var RSSI: Int? diff --git a/Modules/Bluetooth/popup.swift b/Modules/Bluetooth/popup.swift index 7a24aaef..5908581f 100644 --- a/Modules/Bluetooth/popup.swift +++ b/Modules/Bluetooth/popup.swift @@ -38,6 +38,7 @@ internal class Popup: NSStackView, Popup_p { self.addArrangedSubview(BLEView( width: self.frame.width, uuid: ble.uuid, + address: ble.address, name: ble.name, batteryLevel: ble.batteryLevel )) @@ -59,7 +60,7 @@ internal class BLEView: NSStackView { return CGSize(width: self.bounds.width, height: self.bounds.height) } - public init(width: CGFloat, uuid: UUID, name: String, batteryLevel: [KeyValue_t]) { + public init(width: CGFloat, uuid: UUID, address: String, name: String, batteryLevel: [KeyValue_t]) { self.uuid = uuid super.init(frame: NSRect(x: 0, y: 0, width: width, height: 30)) @@ -73,7 +74,7 @@ internal class BLEView: NSStackView { let nameView: NSTextField = TextView(frame: NSRect(x: 0, y: 0, width: 0, height: 16)) nameView.font = NSFont.systemFont(ofSize: 13, weight: .light) nameView.stringValue = name - nameView.toolTip = uuid.uuidString + nameView.toolTip = address self.addArrangedSubview(nameView) self.addArrangedSubview(NSView()) diff --git a/Modules/Bluetooth/readers.swift b/Modules/Bluetooth/readers.swift index 16ad6a82..8a733497 100644 --- a/Modules/Bluetooth/readers.swift +++ b/Modules/Bluetooth/readers.swift @@ -72,6 +72,7 @@ class BluetoothDelegate: NSObject, CBCentralManagerDelegate, CBPeripheralDelegat } else { self.devices.append(BLEDevice( uuid: cache.uuid, + address: device.addressString, name: device.nameOrAddress, RSSI: rssi, batteryLevel: cache.batteryLevel, @@ -108,6 +109,9 @@ class BluetoothDelegate: NSObject, CBCentralManagerDelegate, CBPeripheralDelegat switch pair.value { case let value as Int: percentage = value + if "\(pair.value)" == "1.00" { + percentage *= 100 + } case let value as Double: percentage = Int(value*100) default: continue