Assorted nil cleanup from crash reports

This commit is contained in:
Garth Vander Houwen 2022-11-11 18:13:32 -08:00
parent fb326b7573
commit 836b3fb007
4 changed files with 12 additions and 18 deletions

View file

@ -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

View file

@ -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)")

View file

@ -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)) {

View file

@ -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())