mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
fix: fix BLE level when the value in cache is 1 (#551)
feat: change UUID to address in the BLE device toolTip
This commit is contained in:
@@ -15,6 +15,7 @@ import CoreBluetooth
|
||||
|
||||
public struct BLEDevice {
|
||||
let uuid: UUID
|
||||
let address: String
|
||||
let name: String
|
||||
|
||||
var RSSI: Int?
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user