Add max channels to peripheral

This commit is contained in:
Garth Vander Houwen 2022-09-16 08:50:37 -07:00
parent dceb20b42f
commit a548253b07
3 changed files with 11 additions and 3 deletions

View file

@ -204,7 +204,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
peripheralName = name
}
let newPeripheral = Peripheral(id: peripheral.identifier.uuidString, num: 0, name: peripheralName, shortName: last4Code, longName: peripheralName, lastFourCode: last4Code, firmwareVersion: "Unknown", rssi: RSSI.intValue, bitrate: nil, channelUtilization: nil, airTime: nil, lastUpdate: Date(), subscribed: false, peripheral: peripheral)
let newPeripheral = Peripheral(id: peripheral.identifier.uuidString, num: 0, name: peripheralName, shortName: last4Code, longName: peripheralName, lastFourCode: last4Code, firmwareVersion: "Unknown", rssi: RSSI.intValue, bitrate: nil, channelUtilization: nil, airTime: nil, maxChannels: 0, lastUpdate: Date(), subscribed: false, peripheral: peripheral)
let peripheralIndex = peripherals.firstIndex(where: { $0.id == newPeripheral.id })
if peripheralIndex != nil && newPeripheral.peripheral.state != CBPeripheralState.connected {
@ -515,6 +515,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
self.connectedPeripheral.firmwareVersion = myInfo!.firmwareVersion ?? "Unknown"
self.connectedPeripheral.name = myInfo!.bleName ?? "Unknown"
self.connectedPeripheral.longName = myInfo!.bleName ?? "Unknown"
self.connectedPeripheral.maxChannels = myInfo!.maxChannels
}
}

View file

@ -13,11 +13,12 @@ struct Peripheral: Identifiable {
var bitrate: Float?
var channelUtilization: Float?
var airTime: Float?
var maxChannels: Int32
var lastUpdate: Date
var subscribed: Bool
var peripheral: CBPeripheral
init(id: String, num: Int64, name: String, shortName: String, longName: String, lastFourCode: String, firmwareVersion: String, rssi: Int, bitrate: Float?, channelUtilization: Float?, airTime: Float?, lastUpdate: Date, subscribed: Bool, peripheral: CBPeripheral) {
init(id: String, num: Int64, name: String, shortName: String, longName: String, lastFourCode: String, firmwareVersion: String, rssi: Int, bitrate: Float?, channelUtilization: Float?, airTime: Float?, maxChannels: Int32, lastUpdate: Date, subscribed: Bool, peripheral: CBPeripheral) {
self.id = id
self.num = num
self.name = name
@ -29,6 +30,7 @@ struct Peripheral: Identifiable {
self.bitrate = bitrate
self.channelUtilization = channelUtilization
self.airTime = airTime
self.maxChannels = maxChannels
self.lastUpdate = lastUpdate
self.subscribed = subscribed
self.peripheral = peripheral

View file

@ -147,6 +147,11 @@ struct NodeDetail: View {
Divider()
}
Image(hwModelString)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 200, height: 200)
.cornerRadius(5)
HStack {
@ -154,7 +159,7 @@ struct NodeDetail: View {
Text("AKA").font(.largeTitle)
.foregroundColor(.gray).fixedSize()
.offset(y:15)
.offset(y:5)
CircleText(text: node.user?.shortName ?? "???", color: .accentColor, circleSize: 75, fontSize: 26)
}
.padding()