From 6559b2a9fdcce34359d801fc0bcc0d345daf3274 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 18 Sep 2021 16:28:35 -0700 Subject: [PATCH] Additional file cleanup --- Meshtastic Client.xcodeproj/project.pbxproj | 16 +--- MeshtasticClient/Helpers/BLEManager.swift | 6 +- MeshtasticClient/Info.plist | 6 +- MeshtasticClient/Model/Device.swift | 37 --------- MeshtasticClient/Model/Device2.swift | 45 ----------- MeshtasticClient/Model/ModelData.swift | 6 +- MeshtasticClient/Resources/deviceData.json | 81 ------------------- .../Views/Devices/DeviceBLE.swift | 8 +- .../Views/Helpers/CircleText.swift | 2 +- MeshtasticClient/Views/Nodes/NodeDetail.swift | 7 +- 10 files changed, 14 insertions(+), 200 deletions(-) delete mode 100644 MeshtasticClient/Model/Device.swift delete mode 100644 MeshtasticClient/Model/Device2.swift delete mode 100644 MeshtasticClient/Resources/deviceData.json diff --git a/Meshtastic Client.xcodeproj/project.pbxproj b/Meshtastic Client.xcodeproj/project.pbxproj index 0c811938..a046a922 100644 --- a/Meshtastic Client.xcodeproj/project.pbxproj +++ b/Meshtastic Client.xcodeproj/project.pbxproj @@ -31,7 +31,6 @@ DDAF8C6926ED0D070058C060 /* deviceonly.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDAF8C6826ED0D070058C060 /* deviceonly.pb.swift */; }; DDAF8C6B26ED0DD80058C060 /* environmental_measurement.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDAF8C6A26ED0DD80058C060 /* environmental_measurement.pb.swift */; }; DDAF8C6E26ED19040058C060 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDAF8C6D26ED19040058C060 /* Extensions.swift */; }; - DDAF8C7026ED1DD20058C060 /* Device2.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDAF8C6F26ED1DD20058C060 /* Device2.swift */; }; DDC2E15826CE248E0042C5E4 /* MeshtasticClientApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDC2E15726CE248E0042C5E4 /* MeshtasticClientApp.swift */; }; DDC2E15C26CE248F0042C5E4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DDC2E15B26CE248F0042C5E4 /* Assets.xcassets */; }; DDC2E15F26CE248F0042C5E4 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DDC2E15E26CE248F0042C5E4 /* Preview Assets.xcassets */; }; @@ -41,8 +40,6 @@ DDC2E19126CE26290042C5E4 /* Messages.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDC2E19026CE26290042C5E4 /* Messages.swift */; }; DDC2E19B26CE27150042C5E4 /* CircleImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDC2E19A26CE27150042C5E4 /* CircleImage.swift */; }; DDC2E19D26CE27580042C5E4 /* ModelData.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDC2E19C26CE27580042C5E4 /* ModelData.swift */; }; - DDC2E19F26CE27630042C5E4 /* Device.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDC2E19E26CE27630042C5E4 /* Device.swift */; }; - DDC2E1A226CE29AC0042C5E4 /* deviceData.json in Resources */ = {isa = PBXBuildFile; fileRef = DDC2E18A26CE25690042C5E4 /* deviceData.json */; }; DDC2E1A426CE2F940042C5E4 /* DeviceBLE.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDC2E1A326CE2F940042C5E4 /* DeviceBLE.swift */; }; DDC2E1A726CEB3400042C5E4 /* LocationHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDC2E1A626CEB3400042C5E4 /* LocationHelper.swift */; }; DDC2E1AB26DD89EC0042C5E4 /* packets.json in Resources */ = {isa = PBXBuildFile; fileRef = DDC2E1AA26DD89EC0042C5E4 /* packets.json */; }; @@ -91,7 +88,6 @@ DDAF8C6826ED0D070058C060 /* deviceonly.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = deviceonly.pb.swift; sourceTree = ""; }; DDAF8C6A26ED0DD80058C060 /* environmental_measurement.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = environmental_measurement.pb.swift; sourceTree = ""; }; DDAF8C6D26ED19040058C060 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = ""; }; - DDAF8C6F26ED1DD20058C060 /* Device2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Device2.swift; sourceTree = ""; }; DDAF8C7126ED2AD80058C060 /* nodeInfo.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = nodeInfo.json; sourceTree = ""; }; DDC2E15426CE248E0042C5E4 /* MeshtasticClient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MeshtasticClient.app; sourceTree = BUILT_PRODUCTS_DIR; }; DDC2E15726CE248E0042C5E4 /* MeshtasticClientApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshtasticClientApp.swift; sourceTree = ""; }; @@ -104,12 +100,10 @@ DDC2E17526CE248F0042C5E4 /* MeshtasticClientUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MeshtasticClientUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; DDC2E17926CE248F0042C5E4 /* MeshtasticClientUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshtasticClientUITests.swift; sourceTree = ""; }; DDC2E17B26CE248F0042C5E4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - DDC2E18A26CE25690042C5E4 /* deviceData.json */ = {isa = PBXFileReference; explicitFileType = text.json; fileEncoding = 4; path = deviceData.json; sourceTree = ""; }; DDC2E18E26CE25FE0042C5E4 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; DDC2E19026CE26290042C5E4 /* Messages.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Messages.swift; sourceTree = ""; }; DDC2E19A26CE27150042C5E4 /* CircleImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleImage.swift; sourceTree = ""; }; DDC2E19C26CE27580042C5E4 /* ModelData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelData.swift; sourceTree = ""; }; - DDC2E19E26CE27630042C5E4 /* Device.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Device.swift; sourceTree = ""; }; DDC2E1A326CE2F940042C5E4 /* DeviceBLE.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceBLE.swift; sourceTree = ""; }; DDC2E1A626CEB3400042C5E4 /* LocationHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationHelper.swift; sourceTree = ""; }; DDC2E1AA26DD89EC0042C5E4 /* packets.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = packets.json; sourceTree = ""; }; @@ -255,8 +249,6 @@ isa = PBXGroup; children = ( DDC2E19C26CE27580042C5E4 /* ModelData.swift */, - DDC2E19E26CE27630042C5E4 /* Device.swift */, - DDAF8C6F26ED1DD20058C060 /* Device2.swift */, DD7AA3F226F05C120077AF76 /* NodeInfoModel.swift */, DD47E3DE26F39D9F00029299 /* MyInfoModel.swift */, ); @@ -266,7 +258,6 @@ DDC2E18926CE24F70042C5E4 /* Resources */ = { isa = PBXGroup; children = ( - DDC2E18A26CE25690042C5E4 /* deviceData.json */, DDC2E1AA26DD89EC0042C5E4 /* packets.json */, DDAF8C7126ED2AD80058C060 /* nodeInfo.json */, DD7AA3F426F05D660077AF76 /* nodeInfoModel.json */, @@ -425,7 +416,6 @@ files = ( DDC2E15F26CE248F0042C5E4 /* Preview Assets.xcassets in Resources */, DDC2E15C26CE248F0042C5E4 /* Assets.xcassets in Resources */, - DDC2E1A226CE29AC0042C5E4 /* deviceData.json in Resources */, DDC2E1AB26DD89EC0042C5E4 /* packets.json in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -454,9 +444,7 @@ DDAF8C6E26ED19040058C060 /* Extensions.swift in Sources */, DD47E3CC26F0E51D00029299 /* NodeDetail.swift in Sources */, DDC2E1A726CEB3400042C5E4 /* LocationHelper.swift in Sources */, - DDAF8C7026ED1DD20058C060 /* Device2.swift in Sources */, DD7AA3F326F05C120077AF76 /* NodeInfoModel.swift in Sources */, - DDC2E19F26CE27630042C5E4 /* Device.swift in Sources */, DD47E3D226F1210600029299 /* HelperFunctions.swift in Sources */, DDAF8C5F26ED09B50058C060 /* radioconfig.pb.swift in Sources */, DDAF8C5326EB1DF10058C060 /* BLEManager.swift in Sources */, @@ -650,7 +638,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.04; + MARKETING_VERSION = 1.05; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = NO; @@ -675,7 +663,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.04; + MARKETING_VERSION = 1.05; PRODUCT_BUNDLE_IDENTIFIER = gvh.MeshtasticClient; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = NO; diff --git a/MeshtasticClient/Helpers/BLEManager.swift b/MeshtasticClient/Helpers/BLEManager.swift index aa18b0d6..e0977166 100644 --- a/MeshtasticClient/Helpers/BLEManager.swift +++ b/MeshtasticClient/Helpers/BLEManager.swift @@ -96,11 +96,11 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph //--------------------------------------------------------------------------------------- func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { - //print(peripheral) + print(peripheral) if peripheralArray.contains(peripheral) { print("Duplicate Found.") } else { - print("Adding peripheral: " + peripheral.name!); + print("Adding peripheral: " + ((peripheral.name != nil) ? peripheral.name! : "(null)")); peripheralArray.append(peripheral) rssiArray.append(RSSI) } @@ -117,7 +117,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph } let newPeripheral = Peripheral(id: peripheral.identifier.uuidString, index: peripherals.count, name: peripheralName, rssi: RSSI.intValue) - //print(newPeripheral) + print(newPeripheral) peripherals.append(newPeripheral) } diff --git a/MeshtasticClient/Info.plist b/MeshtasticClient/Info.plist index 126d0802..1dec4fe6 100644 --- a/MeshtasticClient/Info.plist +++ b/MeshtasticClient/Info.plist @@ -20,6 +20,8 @@ $(MARKETING_VERSION) CFBundleVersion 1 + ITSAppUsesNonExemptEncryption + LSApplicationCategoryType public.app-category.utilities LSRequiresIPhoneOS @@ -27,7 +29,7 @@ NSBluetoothAlwaysUsageDescription We use bluetooth to connect to nearby Meshtastic Devices NSBluetoothPeripheralUsageDescription - Bluetooth is used to connect an iPhone to a user's meshtastic device to allow text messaging and location data for the mesh network. + Bluetooth is used to connect an iPhone to a user's meshtastic device to allow text messaging and location data for the mesh network. NSLocationWhenInUseUsageDescription We use your location to center maps of the mesh Privacy – Bluetooth Always Usage Description @@ -51,8 +53,6 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - ITSAppUsesNonExemptEncryption - UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait diff --git a/MeshtasticClient/Model/Device.swift b/MeshtasticClient/Model/Device.swift deleted file mode 100644 index 18295076..00000000 --- a/MeshtasticClient/Model/Device.swift +++ /dev/null @@ -1,37 +0,0 @@ -/* -See LICENSE folder for this app’s licensing information. - -Abstract: -A representation of a single device. -*/ - -import Foundation -import SwiftUI -import CoreLocation - -struct Device: Hashable, Codable, Identifiable { - - var longName: String - var shortName: String - var id: String - var region: String - var hasGPS: Bool - var isRouter: Bool - var firmwareVersion: String - var hardwareModel: String - var lastHeard: Double - var snr: Double - - private var imageName: String - var image: Image { - Image(imageName) - } - - var position: Position - - struct Position: Hashable, Codable { - var latitude: Double - var longitude: Double - var altitude: Int - var batteryLevel: Int } -} diff --git a/MeshtasticClient/Model/Device2.swift b/MeshtasticClient/Model/Device2.swift deleted file mode 100644 index 6980fab6..00000000 --- a/MeshtasticClient/Model/Device2.swift +++ /dev/null @@ -1,45 +0,0 @@ -/* -See LICENSE folder for this app’s licensing information. - -Abstract: -A representation of a single device. -*/ - -import Foundation -import SwiftUI -import CoreLocation - -struct Device2: Hashable, Codable, Identifiable { - - var id: String - var num: Int32 - - struct MyInfo: Hashable, Codable { - - var hasGps: Bool - var numBands: Int32 - var maxChannels: Int32 - var firmwareVersion: String - var rebootCount: Int32 - var messageTimeoutMsec: Int32 - var minAppVersion: Int32 - } - - - struct User: Hashable, Codable { - var id: String - var longName: String - var shortName: String - var macaddr: String - var hwModel: String - } - - struct Position: Hashable, Codable { - var latitude: Int32 - var longitude: Int32 - var altitude: Int32 - var batteryLevel: Int - } - var lastHeard: Int32 - -} diff --git a/MeshtasticClient/Model/ModelData.swift b/MeshtasticClient/Model/ModelData.swift index aac3c578..6578ee42 100644 --- a/MeshtasticClient/Model/ModelData.swift +++ b/MeshtasticClient/Model/ModelData.swift @@ -7,13 +7,9 @@ import Foundation import Combine final class ModelData: ObservableObject { - @Published var devices: [Device] = load("deviceData.json") + // @Published var devices: [Device] = load("deviceData.json") @Published var nodes: [NodeInfoModel] = load("packets.json") - - var nearby: [Device] { - devices - } } func load(_ filename: String) -> T { diff --git a/MeshtasticClient/Resources/deviceData.json b/MeshtasticClient/Resources/deviceData.json deleted file mode 100644 index c6a53913..00000000 --- a/MeshtasticClient/Resources/deviceData.json +++ /dev/null @@ -1,81 +0,0 @@ -[ - { - "longName": "RAK GPS Node", - "shortName": "RGN", - "region": "US", - "id": "!438f02b0", - "firmwareVersion": "1.2.43", - "lastHeard": 1628145597, - "isRouter": true, - "hasGPS": true, - "hardwareModel": "RAK4631", - "macAddress": "MAC STRING", - "snr": 4.75, - "imageName": "rak4631", - "position": { - "longitude": -122.151405, - "latitude": 47.608330, - "batteryLevel": 55, - "altitude": 150 - } - }, - { - "longName": "RAK Solar 1", - "shortName": "RS1", - "region": "US", - "id": "!3ba37b3e", - "firmwareVersion": "1.2.43", - "lastHeard": 1628091161, - "isRouter": false, - "hasGPS": false, - "hardwareModel": "RAK4631", - "macAddress": "MAC STRING", - "snr": 4.75, - "imageName": "rak4631", - "position": { - "longitude": -122.145316, - "latitude": 47.601440, - "batteryLevel": 55, - "altitude": 150 - } - }, - { - "longName": "RAK Solar 2", - "shortName": "RS2", - "region": "US", - "id": "!a66c166f", - "firmwareVersion": "1.2.43", - "lastHeard": 1628094190, - "isRouter": false, - "hasGPS": false, - "hardwareModel": "RAK4631", - "macAddress": "MAC STRING", - "snr": 4.75, - "imageName": "rak4631", - "position": { - "longitude": -122.148599, - "latitude": 47.602106, - "batteryLevel": 77, - "altitude": 150 - } - }, - { - "longName": "Yellow Beam", - "shortName": "YB", - "region": "US", - "id": "!050c2538", - "firmwareVersion": "1.2.43", - "lastHeard": 1628091161, - "isRouter": false, - "hasGPS": true, - "hardwareModel": "TBEAM", - "macAddress": "MAC STRING", - "snr": 4.75, - "imageName": "tbeam", - "position": { - "longitude": -122.154392, - "latitude": 47.598788, - "batteryLevel": 55, - "altitude": 150 - } - }] diff --git a/MeshtasticClient/Views/Devices/DeviceBLE.swift b/MeshtasticClient/Views/Devices/DeviceBLE.swift index 768375de..2d1b7c3d 100644 --- a/MeshtasticClient/Views/Devices/DeviceBLE.swift +++ b/MeshtasticClient/Views/Devices/DeviceBLE.swift @@ -17,11 +17,7 @@ struct DeviceBLE: View { @EnvironmentObject var modelData: ModelData @ObservedObject var bleManager = BLEManager() - - var devices: [Device] { - modelData.devices - } - + var body: some View { NavigationView { @@ -33,7 +29,7 @@ struct DeviceBLE: View { if(bleManager.connectedPeripheral != nil){ HStack{ Image(systemName: "dot.radiowaves.left.and.right").imageScale(.large).foregroundColor(.green) - Text(bleManager.connectedPeripheral.name!).font(.title) + Text((bleManager.connectedPeripheral.name != nil) ? bleManager.connectedPeripheral.name! : "Unknown").font(.title) } } else { diff --git a/MeshtasticClient/Views/Helpers/CircleText.swift b/MeshtasticClient/Views/Helpers/CircleText.swift index 109c1eab..f59d2a00 100644 --- a/MeshtasticClient/Views/Helpers/CircleText.swift +++ b/MeshtasticClient/Views/Helpers/CircleText.swift @@ -14,7 +14,7 @@ struct CircleText: View { Text(text).font(.caption2).foregroundColor(.white) .background(Circle() .fill(color) - .frame(width: 36, height: 36, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)) + .frame(width: 32, height: 32, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)) } } diff --git a/MeshtasticClient/Views/Nodes/NodeDetail.swift b/MeshtasticClient/Views/Nodes/NodeDetail.swift index 7c0533de..e38ff8d0 100644 --- a/MeshtasticClient/Views/Nodes/NodeDetail.swift +++ b/MeshtasticClient/Views/Nodes/NodeDetail.swift @@ -34,7 +34,7 @@ struct NodeDetail: View { let regionBinding = Binding( get: { - MKCoordinateRegion(center: nodeCoordinatePosition, span: MKCoordinateSpan(latitudeDelta: 0.002, longitudeDelta: 0.002)) + MKCoordinateRegion(center: nodeCoordinatePosition, span: MKCoordinateSpan(latitudeDelta: 0.005, longitudeDelta: 0.005)) }, set: { _ in } ) @@ -45,10 +45,7 @@ struct NodeDetail: View { MapAnnotation( coordinate: location.coordinate, content: { - Text(node.user.shortName).font(.subheadline).foregroundColor(.white) - .background(Circle() - .fill(Color.blue) - .frame(width: 36, height: 36)) + CircleText(text: node.user.shortName, color: Color.blue) } ) }.frame(idealWidth: bounds.size.width, minHeight: bounds.size.height / 2)