diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index c495c295..238eb167 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -520,8 +520,8 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph if nodeInfo != nil { if self.connectedPeripheral != nil && self.connectedPeripheral.num == nodeInfo!.num { if nodeInfo!.user != nil { - connectedPeripheral.shortName = nodeInfo!.user!.shortName ?? "????" - connectedPeripheral.longName = nodeInfo!.user!.longName ?? "Unknown" + connectedPeripheral.shortName = nodeInfo?.user?.shortName ?? "????" + connectedPeripheral.longName = nodeInfo?.user?.longName ?? "Unknown" } } } @@ -776,17 +776,17 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph positionPacket.altitude = Int32(LocationHelper.currentAltitude) positionPacket.timestamp = UInt32(LocationHelper.currentTimestamp.timeIntervalSince1970) positionPacket.groundSpeed = UInt32(LocationHelper.currentSpeed) - //positionPacket.groundTrack = UInt32(LocationHelper.currentHeading) - - var waypointPacket = Waypoint() - waypointPacket.latitudeI = Int32(LocationHelper.currentLocation.latitude * 1e7) - waypointPacket.longitudeI = Int32(LocationHelper.currentLocation.longitude * 1e7) - - let oneWeekFromNow = Calendar.current.date(byAdding: .day, value: 7, to: Date()) - waypointPacket.expire = UInt32(oneWeekFromNow!.timeIntervalSince1970) - waypointPacket.name = "Test Waypoint" + if LocationHelper.currentHeading > 0 { + positionPacket.groundTrack = UInt32(LocationHelper.currentHeading) + } + //var waypointPacket = Waypoint() + //waypointPacket.latitudeI = Int32(LocationHelper.currentLocation.latitude * 1e7) + //waypointPacket.longitudeI = Int32(LocationHelper.currentLocation.longitude * 1e7) + //let oneWeekFromNow = Calendar.current.date(byAdding: .day, value: 7, to: Date()) + //waypointPacket.expire = UInt32(oneWeekFromNow!.timeIntervalSince1970) + //waypointPacket.name = "Test Waypoint" var meshPacket = MeshPacket() meshPacket.to = UInt32(destNum) meshPacket.from = 0 // Send 0 as from from phone to device to avoid warning about client trying to set node num diff --git a/Meshtastic/MeshtasticApp.swift b/Meshtastic/MeshtasticApp.swift index 0eae4e88..aa567280 100644 --- a/Meshtastic/MeshtasticApp.swift +++ b/Meshtastic/MeshtasticApp.swift @@ -7,15 +7,13 @@ import CoreData struct MeshtasticAppleApp: App { let persistenceController = PersistenceController.shared - @ObservedObject private var bleManager: BLEManager = BLEManager.shared @ObservedObject private var userSettings: UserSettings = UserSettings() + @Environment(\.scenePhase) var scenePhase @State var saveChannels = false @State var incomingUrl: URL? @State var channelSettings: String? - - @Environment(\.scenePhase) var scenePhase var body: some Scene { WindowGroup { diff --git a/Meshtastic/Views/Bluetooth/Connect.swift b/Meshtastic/Views/Bluetooth/Connect.swift index 37acf87d..92c813d0 100644 --- a/Meshtastic/Views/Bluetooth/Connect.swift +++ b/Meshtastic/Views/Bluetooth/Connect.swift @@ -103,7 +103,7 @@ struct Connect: View { Text("Num: \(String(node!.num))") Text("Short Name: \(node?.user?.shortName ?? "????")") Text("Long Name: \(node?.user?.longName ?? "Unknown")") - Text("Max Channels: \(String(node!.myInfo!.maxChannels))") + Text("Max Channels: \(String(node?.myInfo?.maxChannels ?? 0))") Text("Bitrate: \(String(format: "%.2f", node?.myInfo?.bitrate ?? 0.00))") Text("BLE RSSI: \(bleManager.connectedPeripheral.rssi)") diff --git a/Meshtastic/Views/Messages/Contacts.swift b/Meshtastic/Views/Messages/Contacts.swift index 8fdb867d..bae3b8c8 100644 --- a/Meshtastic/Views/Messages/Contacts.swift +++ b/Meshtastic/Views/Messages/Contacts.swift @@ -29,8 +29,8 @@ struct Contacts: View { List { Section(header: Text("Channels (groups)")) { // Display Contacts for the rest of the non admin channels - if node != nil { - ForEach(node!.myInfo!.channels?.array as! [ChannelEntity], id: \.self) { (channel: ChannelEntity) in + if node != nil && node!.myInfo != nil && node!.myInfo!.channels != nil { + ForEach(node!.myInfo!.channels!.array as! [ChannelEntity], id: \.self) { (channel: ChannelEntity) in if channel.name?.lowercased() ?? "" != "admin" && channel.name?.lowercased() ?? "" != "gpio" { VStack { NavigationLink(destination: ChannelMessageList(channel: channel)) { diff --git a/Meshtastic/Views/Nodes/DeviceMetricsLog.swift b/Meshtastic/Views/Nodes/DeviceMetricsLog.swift index abb3c8b6..77b7afb1 100644 --- a/Meshtastic/Views/Nodes/DeviceMetricsLog.swift +++ b/Meshtastic/Views/Nodes/DeviceMetricsLog.swift @@ -21,12 +21,6 @@ struct DeviceMetricsLog: View { var node: NodeInfoEntity - struct MountPrice: Identifiable { - var id = UUID() - var mount: String - var value: Double - } - var body: some View { NavigationStack { let oneDayAgo = Calendar.current.date(byAdding: .day, value: -3, to: Date())