From 92d9e37b917cd6b4f75776bcb9acb9c2508041f0 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 9 Jan 2022 10:48:17 -0800 Subject: [PATCH 1/4] Mac Version --- Meshtastic Client.xcodeproj/project.pbxproj | 4 ++-- MeshtasticClient/Views/Nodes/NodeDetail.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Meshtastic Client.xcodeproj/project.pbxproj b/Meshtastic Client.xcodeproj/project.pbxproj index 0a4f1479..fd70a2c9 100644 --- a/Meshtastic Client.xcodeproj/project.pbxproj +++ b/Meshtastic Client.xcodeproj/project.pbxproj @@ -718,7 +718,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; CODE_SIGN_ENTITLEMENTS = MeshtasticClient/MeshtasticClient.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 13; + CURRENT_PROJECT_VERSION = 14; DEVELOPMENT_ASSET_PATHS = "\"MeshtasticClient/Preview Content\""; DEVELOPMENT_TEAM = GCH7VS5Y9R; ENABLE_PREVIEWS = YES; @@ -746,7 +746,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; CODE_SIGN_ENTITLEMENTS = MeshtasticClient/MeshtasticClient.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 13; + CURRENT_PROJECT_VERSION = 14; DEVELOPMENT_ASSET_PATHS = "\"MeshtasticClient/Preview Content\""; DEVELOPMENT_TEAM = GCH7VS5Y9R; ENABLE_PREVIEWS = YES; diff --git a/MeshtasticClient/Views/Nodes/NodeDetail.swift b/MeshtasticClient/Views/Nodes/NodeDetail.swift index 8ae18b63..fcc9fa2a 100644 --- a/MeshtasticClient/Views/Nodes/NodeDetail.swift +++ b/MeshtasticClient/Views/Nodes/NodeDetail.swift @@ -269,7 +269,7 @@ struct NodeDetail: View { .edgesIgnoringSafeArea([.leading, .trailing]) } } - .navigationTitle(node.user!.longName ?? "Unknown") + .navigationTitle(node != nil ? String(node.user!.longName ?? "Unknown") : "Unknown") .navigationBarTitleDisplayMode(.inline) .navigationBarItems(trailing: From 42ff83e69cee38091aac5eb73c6af538f6c58d75 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 10 Jan 2022 07:02:12 -0800 Subject: [PATCH 2/4] V1.43 Build 15 --- Meshtastic Client.xcodeproj/project.pbxproj | 4 +- MeshtasticClient/Helpers/BLEManager.swift | 42 +++++++++++++------ .../Views/Messages/Contacts.swift | 2 +- .../Views/Messages/UserMessageList.swift | 6 +-- 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/Meshtastic Client.xcodeproj/project.pbxproj b/Meshtastic Client.xcodeproj/project.pbxproj index fd70a2c9..ae5d9f83 100644 --- a/Meshtastic Client.xcodeproj/project.pbxproj +++ b/Meshtastic Client.xcodeproj/project.pbxproj @@ -718,7 +718,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; CODE_SIGN_ENTITLEMENTS = MeshtasticClient/MeshtasticClient.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 14; + CURRENT_PROJECT_VERSION = 15; DEVELOPMENT_ASSET_PATHS = "\"MeshtasticClient/Preview Content\""; DEVELOPMENT_TEAM = GCH7VS5Y9R; ENABLE_PREVIEWS = YES; @@ -746,7 +746,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; CODE_SIGN_ENTITLEMENTS = MeshtasticClient/MeshtasticClient.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 14; + CURRENT_PROJECT_VERSION = 15; DEVELOPMENT_ASSET_PATHS = "\"MeshtasticClient/Preview Content\""; DEVELOPMENT_TEAM = GCH7VS5Y9R; ENABLE_PREVIEWS = YES; diff --git a/MeshtasticClient/Helpers/BLEManager.swift b/MeshtasticClient/Helpers/BLEManager.swift index 69bf1501..10beadc4 100644 --- a/MeshtasticClient/Helpers/BLEManager.swift +++ b/MeshtasticClient/Helpers/BLEManager.swift @@ -120,9 +120,9 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph } connectedPeripheral = nil - self.lastConnectionError = "đŸšĢ BLE Connecting Timeout after making \(timeoutTimerCount) attempts to connect to \(name)." - print("đŸšĢ BLE Connecting Timeout after making \(timeoutTimerCount) attempts to connect to \(name).") - if meshLoggingEnabled { MeshLogger.log("đŸšĢ BLE Connecting Timeout after making \(timeoutTimerCount) attempts to connect to \(String(name)).") } + self.lastConnectionError = "🚨 BLE Connection Timeout after making \(timeoutTimerCount) attempts to connect to \(name)." + print("🚨 BLE Connection Timeout after making \(timeoutTimerCount) attempts to connect to \(name).") + if meshLoggingEnabled { MeshLogger.log("🚨 BLE Connection Timeout after making \(timeoutTimerCount) attempts to connect to \(String(name)). This can occur when a device has been taken out of BLE range, or if a device is already connected to another phone, tablet or computer.") } self.timeoutTimerCount = 0 self.timeoutTimer?.invalidate() @@ -256,7 +256,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph // Happens when device is manually reset / powered off // We will try and re-connect to this device - lastConnectionError = "đŸšĢ \(e.localizedDescription) The app will automatically reconnect to the preferred radio if it reappears within 10 seconds." + lastConnectionError = "🚨 \(e.localizedDescription) The app will automatically reconnect to the preferred radio if it reappears within 10 seconds." if peripheral.identifier.uuidString == UserDefaults.standard.object(forKey: "preferredPeripheralId") as? String ?? "" { if meshLoggingEnabled { MeshLogger.log("â„šī¸ BLE Reconnecting: \(peripheral.name ?? "Unknown")") } print("â„šī¸ BLE Reconnecting: \(peripheral.name ?? "Unknown")") @@ -267,20 +267,20 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph // Seems to be what is received when a tbeam sleeps, immediately recconnecting does not work. lastConnectionError = e.localizedDescription - print("đŸšĢ BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(e.localizedDescription)") - if meshLoggingEnabled { MeshLogger.log("đŸšĢ BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(e.localizedDescription)") } + print("🚨 BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(e.localizedDescription)") + if meshLoggingEnabled { MeshLogger.log("🚨 BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(e.localizedDescription)") } } else if errorCode == 14 { // Peer removed pairing information // Forgetting and reconnecting seems to be necessary so we need to show the user an error telling them to do that - lastConnectionError = "đŸšĢ \(e.localizedDescription) This error usually cannot be fixed without forgetting the device unders Settings > Bluetooth and re-connecting to the radio." + lastConnectionError = "🚨 \(e.localizedDescription) This error usually cannot be fixed without forgetting the device unders Settings > Bluetooth and re-connecting to the radio." - if meshLoggingEnabled { MeshLogger.log("đŸšĢ BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(lastConnectionError)") } + if meshLoggingEnabled { MeshLogger.log("🚨 BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(lastConnectionError)") } } else { lastConnectionError = e.localizedDescription - print("đŸšĢ BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(e.localizedDescription)") - if meshLoggingEnabled { MeshLogger.log("đŸšĢ BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(e.localizedDescription)") } + print("🚨 BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(e.localizedDescription)") + if meshLoggingEnabled { MeshLogger.log("🚨 BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(e.localizedDescription)") } } } else { @@ -424,7 +424,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph // Swift does strings weird, this does work let lastDotIndex = decodedInfo.myInfo.firmwareVersion.lastIndex(of: ".")//.lastIndex(of: ".", offsetBy: -1) - var version = decodedInfo.myInfo.firmwareVersion[...(lastDotIndex ?? String.Index(encodedOffset:6))] + var version = decodedInfo.myInfo.firmwareVersion[...(lastDotIndex ?? String.Index(utf16Offset: 6, in: decodedInfo.myInfo.firmwareVersion))] version = version.dropLast() myInfo.firmwareVersion = String(version) lastConnnectionVersion = String(version) @@ -463,7 +463,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph fetchedMyInfo[0].hasGps = decodedInfo.myInfo.hasGps_p fetchedMyInfo[0].numBands = Int32(bitPattern: decodedInfo.myInfo.numBands) let lastDotIndex = decodedInfo.myInfo.firmwareVersion.lastIndex(of: ".")//.lastIndex(of: ".", offsetBy: -1) - var version = decodedInfo.myInfo.firmwareVersion[...(lastDotIndex ?? String.Index(encodedOffset:6))] + var version = decodedInfo.myInfo.firmwareVersion[...(lastDotIndex ?? String.Index(utf16Offset:6, in: decodedInfo.myInfo.firmwareVersion))] version = version.dropLast() fetchedMyInfo[0].firmwareVersion = String(version) lastConnnectionVersion = String(version) @@ -670,9 +670,24 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph let newMessage = MessageEntity(context: context!) newMessage.messageId = Int64(decodedInfo.packet.id) - newMessage.messageTimestamp = Int32(bitPattern: decodedInfo.packet.rxTime) + + + if decodedInfo.packet.rxTime == 0 { + + newMessage.messageTimestamp = Int32(Date().timeIntervalSince1970) + + } else { + + newMessage.messageTimestamp = Int32(bitPattern: decodedInfo.packet.rxTime) + } newMessage.receivedACK = false newMessage.direction = "IN" + newMessage.isTapback = decodedInfo.packet.isTapback + + if decodedInfo.packet.replyID > 0 { + + newMessage.replyID = Int64(decodedInfo.packet.replyID) + } if decodedInfo.packet.to == broadcastNodeNum && fetchedUsers.count == 1 { @@ -945,6 +960,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph var meshPacket = MeshPacket() meshPacket.to = UInt32(toUserNum) meshPacket.from = UInt32(fromUserNum) + meshPacket.isTapback = isTapback if replyID > 0 { meshPacket.replyID = UInt32(replyID) } diff --git a/MeshtasticClient/Views/Messages/Contacts.swift b/MeshtasticClient/Views/Messages/Contacts.swift index 2081819f..7c201f71 100644 --- a/MeshtasticClient/Views/Messages/Contacts.swift +++ b/MeshtasticClient/Views/Messages/Contacts.swift @@ -24,7 +24,7 @@ struct Contacts: View { List(users) { (user: UserEntity) in - let currentUserNum = self.bleManager.connectedPeripheral != nil ? self.bleManager.connectedPeripheral.num : 0 + //let currentUserNum = self.bleManager.connectedPeripheral != nil ? self.bleManager.connectedPeripheral.num : 0 let allMessages = user.value(forKey: "allMessages") as! [MessageEntity] diff --git a/MeshtasticClient/Views/Messages/UserMessageList.swift b/MeshtasticClient/Views/Messages/UserMessageList.swift index 8312afce..a9b61c88 100644 --- a/MeshtasticClient/Views/Messages/UserMessageList.swift +++ b/MeshtasticClient/Views/Messages/UserMessageList.swift @@ -310,9 +310,8 @@ struct UserMessageList: View { self.bleManager.context = context - messageCount = ((user.sentMessages?.count ?? 0) + (user.receivedMessages?.count ?? 0)) - - if messageCount > 0 { + if allMessages.count > 2 { + scrollView.scrollTo(allMessages.firstIndex(of: allMessages.last! ), anchor: .bottom) } }) @@ -325,7 +324,6 @@ struct UserMessageList: View { if index > 2 { scrollView.scrollTo(index, anchor: .bottom) - } }) } From aa1c801ecd2b113f4eb7595ba6429ea2d8303579 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 10 Jan 2022 07:29:48 -0800 Subject: [PATCH 3/4] Fix bottom menu on node detail page that periodically turns transparent --- MeshtasticClient/Helpers/BLEManager.swift | 1 + MeshtasticClient/Views/Nodes/NodeDetail.swift | 1 + 2 files changed, 2 insertions(+) diff --git a/MeshtasticClient/Helpers/BLEManager.swift b/MeshtasticClient/Helpers/BLEManager.swift index 10beadc4..87547c94 100644 --- a/MeshtasticClient/Helpers/BLEManager.swift +++ b/MeshtasticClient/Helpers/BLEManager.swift @@ -922,6 +922,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph print("đŸšĢ Message Users Not Found, Fail") success = false + } else if fetchedUsers.count >= 1 { let newMessage = MessageEntity(context: context!) diff --git a/MeshtasticClient/Views/Nodes/NodeDetail.swift b/MeshtasticClient/Views/Nodes/NodeDetail.swift index fcc9fa2a..32c4f7e9 100644 --- a/MeshtasticClient/Views/Nodes/NodeDetail.swift +++ b/MeshtasticClient/Views/Nodes/NodeDetail.swift @@ -267,6 +267,7 @@ struct NodeDetail: View { } } .edgesIgnoringSafeArea([.leading, .trailing]) + .padding(1) } } .navigationTitle(node != nil ? String(node.user!.longName ?? "Unknown") : "Unknown") From 1142211a9b7294248338343e6d7b2520b9279005 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 10 Jan 2022 18:02:28 -0800 Subject: [PATCH 4/4] Fix connect scanning buttons active states --- .../Views/Bluetooth/Connect.swift | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/MeshtasticClient/Views/Bluetooth/Connect.swift b/MeshtasticClient/Views/Bluetooth/Connect.swift index a6930406..e5c59b12 100644 --- a/MeshtasticClient/Views/Bluetooth/Connect.swift +++ b/MeshtasticClient/Views/Bluetooth/Connect.swift @@ -179,12 +179,18 @@ struct Connect: View { HStack(alignment: .center) { Spacer() Button(action: { + self.bleManager.startScanning() + }) { - Image(systemName: "play.fill").imageScale(.large).foregroundColor(.gray) + + Image(systemName: "play.circle") + .symbolRenderingMode(.hierarchical) + .imageScale(.large) + .foregroundColor(self.bleManager.isScanning ? .gray : .accentColor) Text("Start Scanning").font(.caption) .font(.caption) - .foregroundColor(.gray) + } .disabled(self.bleManager.isScanning) .padding() @@ -192,12 +198,18 @@ struct Connect: View { .clipShape(Capsule()) Spacer() Button(action: { + self.bleManager.stopScanning() + }) { - Image(systemName: "stop.fill").imageScale(.large).foregroundColor(.gray) + + Image(systemName: "stop.circle") + .symbolRenderingMode(.hierarchical) + .imageScale(.large) + .foregroundColor(!self.bleManager.isScanning ? .gray : .accentColor) Text("Stop Scanning") .font(.caption) - .foregroundColor(.gray) + } .disabled(!self.bleManager.isScanning) .padding()