From a548253b07da1a690d344b87a66511389f9f977b Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Fri, 16 Sep 2022 08:50:37 -0700 Subject: [PATCH] Add max channels to peripheral --- Meshtastic/Helpers/BLEManager.swift | 3 ++- Meshtastic/Model/PeripheralModel.swift | 4 +++- Meshtastic/Views/Nodes/NodeDetail.swift | 7 ++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 9c3dd9eb..10b3c638 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -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 } } diff --git a/Meshtastic/Model/PeripheralModel.swift b/Meshtastic/Model/PeripheralModel.swift index cfdadc44..8587a795 100644 --- a/Meshtastic/Model/PeripheralModel.swift +++ b/Meshtastic/Model/PeripheralModel.swift @@ -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 diff --git a/Meshtastic/Views/Nodes/NodeDetail.swift b/Meshtastic/Views/Nodes/NodeDetail.swift index 292de1a8..20f79db5 100644 --- a/Meshtastic/Views/Nodes/NodeDetail.swift +++ b/Meshtastic/Views/Nodes/NodeDetail.swift @@ -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()