From 756444c53c4a7a7a38f1afc359efe70b9bc417d0 Mon Sep 17 00:00:00 2001 From: Chris Cassano <1285652+glitch003@users.noreply.github.com> Date: Sun, 31 Jul 2022 19:05:47 -0400 Subject: [PATCH] trying to debug why we aren't getting channel settings back. only routing packets --- Meshtastic.xcodeproj/project.pbxproj | 8 +- .../xcschemes/Meshtastic.xcscheme | 98 +++++++++++++++++++ Meshtastic/Helpers/BLEManager.swift | 53 +++++++++- Meshtastic/Helpers/MeshPackets.swift | 1 + Meshtastic/Views/Settings/ShareChannel.swift | 7 ++ 5 files changed, 162 insertions(+), 5 deletions(-) create mode 100644 Meshtastic.xcodeproj/xcshareddata/xcschemes/Meshtastic.xcscheme diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index be06040b..252463b9 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -866,7 +866,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"Meshtastic/Preview Content\""; - DEVELOPMENT_TEAM = GCH7VS5Y9R; + DEVELOPMENT_TEAM = QWER3PMRVZ; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = Meshtastic/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Meshtastic; @@ -876,7 +876,7 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = 1.3.27; - PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; + PRODUCT_BUNDLE_IDENTIFIER = cvc.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; @@ -898,7 +898,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"Meshtastic/Preview Content\""; - DEVELOPMENT_TEAM = GCH7VS5Y9R; + DEVELOPMENT_TEAM = QWER3PMRVZ; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = Meshtastic/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Meshtastic; @@ -908,7 +908,7 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = 1.3.27; - PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; + PRODUCT_BUNDLE_IDENTIFIER = cvc.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = YES; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; diff --git a/Meshtastic.xcodeproj/xcshareddata/xcschemes/Meshtastic.xcscheme b/Meshtastic.xcodeproj/xcshareddata/xcschemes/Meshtastic.xcscheme new file mode 100644 index 00000000..ec979844 --- /dev/null +++ b/Meshtastic.xcodeproj/xcshareddata/xcschemes/Meshtastic.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 8bc54686..a37697c6 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -451,6 +451,9 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph print(characteristic.value!) } + print("Incoming packet with portnum", decodedInfo.packet.decoded.portnum) + print("decodedInfo.packet.decoded", decodedInfo.packet.decoded) + switch decodedInfo.packet.decoded.portnum { // Handle Any local only packets we get over BLE @@ -465,7 +468,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph let myInfo = myInfoPacket(myInfo: decodedInfo.myInfo, meshLogging: meshLoggingEnabled, context: context!) if myInfo != nil { - + print("my info packet", decodedInfo.myInfo) self.connectedPeripheral.bitrate = myInfo!.bitrate self.connectedPeripheral.num = myInfo!.myNodeNum lastConnnectionVersion = myInfo?.firmwareVersion ?? myInfo!.firmwareVersion ?? "Unknown" @@ -1169,6 +1172,54 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph return 0 } + public func getChannel(channelIndex: UInt32, wantResponse: Bool) -> Bool { + + var adminPacket = AdminMessage() + adminPacket.getChannelRequest = channelIndex + + + var meshPacket: MeshPacket = MeshPacket() + meshPacket.to = UInt32(connectedPeripheral.num) + meshPacket.from = 0 //UInt32(connectedPeripheral.num) + meshPacket.id = UInt32.random(in: UInt32(UInt8.max).. Bool { var adminPacket = AdminMessage() diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index 3a7670b7..370cd226 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -1205,6 +1205,7 @@ func positionPacket (packet: MeshPacket, meshLogging: Bool, context: NSManagedOb } func routingPacket (packet: MeshPacket, meshLogging: Bool, context: NSManagedObjectContext) { + print("Routing packet", packet) if let routingMessage = try? Routing(serializedData: packet.decoded.payload) { diff --git a/Meshtastic/Views/Settings/ShareChannel.swift b/Meshtastic/Views/Settings/ShareChannel.swift index 0615b803..614ea480 100644 --- a/Meshtastic/Views/Settings/ShareChannel.swift +++ b/Meshtastic/Views/Settings/ShareChannel.swift @@ -86,6 +86,13 @@ struct ShareChannel: View { .onAppear { self.bleManager.context = context + var i: UInt32 = 1; + while i < 9 { + print("requesting channel",i) + let resp = self.bleManager.getChannel(channelIndex: i, wantResponse: true) + print("resp from getChannel", resp) + i+=1; + } } }