diff --git a/Meshtastic Client.xcodeproj/project.pbxproj b/Meshtastic Client.xcodeproj/project.pbxproj index d292f5d1..8a302fa9 100644 --- a/Meshtastic Client.xcodeproj/project.pbxproj +++ b/Meshtastic Client.xcodeproj/project.pbxproj @@ -60,6 +60,7 @@ DDC4D568275499A500A4208E /* Persistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDC4D567275499A500A4208E /* Persistence.swift */; }; DDD94A502845C8F5004A87A0 /* DateTimeText.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD94A4F2845C8F5004A87A0 /* DateTimeText.swift */; }; DDD9E4E4284B208E003777C5 /* UserEntityExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD9E4E3284B208E003777C5 /* UserEntityExtension.swift */; }; + DDE393BA284E535700473991 /* ChannelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE393B9284E535700473991 /* ChannelHelper.swift */; }; DDF924CA26FBB953009FE055 /* ConnectedDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDF924C926FBB953009FE055 /* ConnectedDevice.swift */; }; /* End PBXBuildFile section */ @@ -142,6 +143,7 @@ DDCA31312826009C00207175 /* PassKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PassKit.framework; path = System/Library/Frameworks/PassKit.framework; sourceTree = SDKROOT; }; DDD94A4F2845C8F5004A87A0 /* DateTimeText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateTimeText.swift; sourceTree = ""; }; DDD9E4E3284B208E003777C5 /* UserEntityExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserEntityExtension.swift; sourceTree = ""; }; + DDE393B9284E535700473991 /* ChannelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelHelper.swift; sourceTree = ""; }; DDF924C926FBB953009FE055 /* ConnectedDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectedDevice.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -377,6 +379,7 @@ DD913638270DFF4C00D7ACF3 /* LocalNotificationManager.swift */, DD8169F8271F1A6100F4AB02 /* MeshLogger.swift */, DDA6B2E828419CF2003E8C16 /* MeshPackets.swift */, + DDE393B9284E535700473991 /* ChannelHelper.swift */, ); path = Helpers; sourceTree = ""; @@ -589,6 +592,7 @@ DD2E65262767A01F00E45FC5 /* NodeDetail.swift in Sources */, DDA6B2E928419CF2003E8C16 /* MeshPackets.swift in Sources */, DDD94A502845C8F5004A87A0 /* DateTimeText.swift in Sources */, + DDE393BA284E535700473991 /* ChannelHelper.swift in Sources */, C9A88B57278B559900BD810A /* apponly.pb.swift in Sources */, DD4C158E2824AA7E0032668E /* config.pb.swift in Sources */, DD47E3D926F3093800029299 /* MessageBubble.swift in Sources */, @@ -761,7 +765,7 @@ CODE_SIGN_ENTITLEMENTS = MeshtasticClient/MeshtasticClient.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 15; + CURRENT_PROJECT_VERSION = 11; DEVELOPMENT_ASSET_PATHS = "\"MeshtasticClient/Preview Content\""; DEVELOPMENT_TEAM = GCH7VS5Y9R; ENABLE_PREVIEWS = YES; @@ -793,7 +797,7 @@ CODE_SIGN_ENTITLEMENTS = MeshtasticClient/MeshtasticClient.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 15; + CURRENT_PROJECT_VERSION = 11; 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 5f0165d5..ce78febd 100644 --- a/MeshtasticClient/Helpers/BLEManager.swift +++ b/MeshtasticClient/Helpers/BLEManager.swift @@ -194,9 +194,9 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph } } - let today = Date() - let visibleDuration = Calendar.current.date(byAdding: .second, value: -5, to: today)! - peripherals.removeAll(where: { $0.lastUpdate <= visibleDuration}) + // let today = Date() + // let visibleDuration = Calendar.current.date(byAdding: .second, value: -7, to: Date())! + // peripherals.removeAll(where: { $0.lastUpdate <= visibleDuration}) } // Called when a peripheral is connected @@ -296,6 +296,11 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph } } } + + func peripheral(_ peripheral: CBPeripheral, didModifyServices invalidatedServices: [CBService]) { + + print(invalidatedServices) + } // MARK: Discover Characteristics Event func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) { diff --git a/MeshtasticClient/Helpers/ChannelHelper.swift b/MeshtasticClient/Helpers/ChannelHelper.swift new file mode 100644 index 00000000..0c7f42ed --- /dev/null +++ b/MeshtasticClient/Helpers/ChannelHelper.swift @@ -0,0 +1,26 @@ +// +// ChannelHelper.swift +// MeshtasticClient +// +// Created by Garth Vander Houwen on 6/6/22. +// + +//import Foundation +// +// +//private fun urlToChannels(url: Uri): AppOnlyProtos.ChannelSet { +// val urlStr = url.toString() +// +// val pathRegex = Regex("$prefix(.*)", RegexOption.IGNORE_CASE) +// val (base64) = pathRegex.find(urlStr)?.destructured +// ?: throw MalformedURLException("Not a meshtastic URL: ${urlStr.take(40)}") +// val bytes = Base64.decode(base64, base64Flags) +// +// return AppOnlyProtos.ChannelSet.parseFrom(bytes) +// } +// +//func urlToChannels(url: URL) { +// +// let urlString = url.absoluteString +// +//} diff --git a/MeshtasticClient/Helpers/MeshPackets.swift b/MeshtasticClient/Helpers/MeshPackets.swift index e84abb0c..483629b7 100644 --- a/MeshtasticClient/Helpers/MeshPackets.swift +++ b/MeshtasticClient/Helpers/MeshPackets.swift @@ -550,6 +550,8 @@ func textMessageAppPacket(packet: MeshPacket, connectedNode: Int64, meshLogging: newMessage.fromUser = fetchedUsers.first(where: { $0.num == packet.from }) newMessage.messagePayload = messageText + newMessage.fromUser?.objectWillChange.send() + newMessage.toUser?.objectWillChange.send() do { diff --git a/MeshtasticClient/Views/Messages/UserMessageList.swift b/MeshtasticClient/Views/Messages/UserMessageList.swift index f9acc49b..98340563 100644 --- a/MeshtasticClient/Views/Messages/UserMessageList.swift +++ b/MeshtasticClient/Views/Messages/UserMessageList.swift @@ -32,6 +32,7 @@ struct UserMessageList: View { @State private var sendPositionWithMessage: Bool = false @State private var messageCount = 0 + @State private var refreshId = UUID() var body: some View { @@ -335,6 +336,7 @@ struct UserMessageList: View { self.bleManager.userSettings = userSettings messageCount = user.messageList.count + refreshId = UUID() }) .onChange(of: messageCount, perform: { value in @@ -343,6 +345,7 @@ struct UserMessageList: View { }) .onChange(of: user.messageList, perform: { messages in + refreshId = UUID() messageCount = messages.count }) }