From 56da04827af16fca343665cf205ac483931d34b2 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 11 Aug 2022 23:34:09 -0700 Subject: [PATCH] New protos and assorted bug fixes --- Meshtastic.xcodeproj/project.pbxproj | 4 + Meshtastic/Helpers/BLEManager.swift | 130 ++++++++++++++---- Meshtastic/Helpers/MeshPackets.swift | 40 +++--- Meshtastic/Protobufs/admin.pb.swift | 95 +++++++++++++ Meshtastic/Protobufs/config.pb.swift | 4 +- Meshtastic/Protobufs/mesh.pb.swift | 20 +++ Meshtastic/Views/Nodes/LocationHistory.swift | 2 +- Meshtastic/Views/Nodes/TelemetryLog.swift | 2 +- .../Views/Settings/Config/DeviceConfig.swift | 2 +- .../Views/Settings/Config/DisplayConfig.swift | 2 +- .../Views/Settings/Config/LoRaConfig.swift | 2 +- .../Config/Module/CannedMessagesConfig.swift | 6 +- .../Module/ExternalNotificationConfig.swift | 2 +- .../Config/Module/RangeTestConfig.swift | 2 +- .../Settings/Config/Module/SerialConfig.swift | 2 +- .../Config/Module/TelemetryConfig.swift | 2 +- .../Settings/Config/PositionConfig.swift | 2 +- .../Views/Settings/Config/WiFiConfig.swift | 2 +- Meshtastic/Views/Settings/UserConfig.swift | 2 +- gen_protos.sh | 2 +- 20 files changed, 256 insertions(+), 69 deletions(-) diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 8844f769..33b13253 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -69,6 +69,7 @@ DDAF8C6926ED0D070058C060 /* deviceonly.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDAF8C6826ED0D070058C060 /* deviceonly.pb.swift */; }; DDAF8C6E26ED19040058C060 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDAF8C6D26ED19040058C060 /* Extensions.swift */; }; DDB2CC6E27F3EB47009C5FCC /* telemetry.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB2CC6D27F3EB47009C5FCC /* telemetry.pb.swift */; }; + DDB3107228A6224100F1DE3D /* device_metadata.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB3107128A6224100F1DE3D /* device_metadata.pb.swift */; }; DDC2E15826CE248E0042C5E4 /* MeshtasticApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDC2E15726CE248E0042C5E4 /* MeshtasticApp.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 */; }; @@ -169,6 +170,7 @@ DDAF8C6D26ED19040058C060 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = ""; }; DDB2CC6D27F3EB47009C5FCC /* telemetry.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = telemetry.pb.swift; sourceTree = ""; }; DDB2CC6F27F3F0AC009C5FCC /* MeshtasticDataModel v 3.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "MeshtasticDataModel v 3.xcdatamodel"; sourceTree = ""; }; + DDB3107128A6224100F1DE3D /* device_metadata.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = device_metadata.pb.swift; sourceTree = ""; }; DDC2E15426CE248E0042C5E4 /* Meshtastic.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Meshtastic.app; sourceTree = BUILT_PRODUCTS_DIR; }; DDC2E15726CE248E0042C5E4 /* MeshtasticApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshtasticApp.swift; sourceTree = ""; }; DDC2E15B26CE248F0042C5E4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = ../Assets.xcassets; sourceTree = ""; }; @@ -326,6 +328,7 @@ DDAF8C5626ED07740058C060 /* Protobufs */ = { isa = PBXGroup; children = ( + DDB3107128A6224100F1DE3D /* device_metadata.pb.swift */, DDCFF600285453A7005FA625 /* localonly.pb.swift */, DD4DED8F27AD2975004BA27E /* cannedmessages.pb.swift */, DDAF8C6126ED0A230058C060 /* admin.pb.swift */, @@ -690,6 +693,7 @@ DDD9E4E4284B208E003777C5 /* UserEntityExtension.swift in Sources */, C9A88B55278B503C00BD810A /* MapViewModule.swift in Sources */, DD2553592855B52700E55709 /* PositionConfig.swift in Sources */, + DDB3107228A6224100F1DE3D /* device_metadata.pb.swift in Sources */, DDAF8C6326ED0A230058C060 /* admin.pb.swift in Sources */, DD86D40C287F401000BAEB7A /* SaveChannelQRCode.swift in Sources */, DD8ED9C8289CE4B900B3B0AB /* RoutingError.swift in Sources */, diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 0962dc11..7564cb3f 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -145,7 +145,10 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph if meshLoggingEnabled { MeshLogger.log(self.lastConnectionError + " 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() + if self.timeoutTimer != nil { + + self.timeoutTimer!.invalidate() + } } else { @@ -171,7 +174,10 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph self.centralManager?.connect(peripheral) // Invalidate any existing timer - self.timeoutTimer?.invalidate() + if self.timeoutTimer != nil { + + self.timeoutTimer!.invalidate() + } // Use a timer to keep track of connecting peripherals, context to pass the radio name with the timer and the RunLoop to prevent // the timer from running on the main UI thread @@ -228,8 +234,11 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph // Invalidate and reset connection timer count, remove any connection errors self.lastConnectionError = "" - self.timeoutTimer!.invalidate() self.timeoutTimerCount = 0 + if self.timeoutTimer != nil { + + self.timeoutTimer!.invalidate() + } // Map the peripheral to the connectedNode and connectedPeripheral ObservedObjects connectedPeripheral = peripherals.filter({ $0.peripheral.identifier == peripheral.identifier }).first @@ -467,7 +476,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph if decodedInfo.myInfo.isInitialized && decodedInfo.myInfo.myNodeNum > 0 { let lastDotIndex = decodedInfo.myInfo.firmwareVersion.lastIndex(of: ".") - var version = decodedInfo.myInfo.firmwareVersion[...(lastDotIndex ?? String.Index(utf16Offset: 6, in: decodedInfo.myInfo.firmwareVersion))] + let version = decodedInfo.myInfo.firmwareVersion[...(lastDotIndex ?? String.Index(utf16Offset: 6, in: decodedInfo.myInfo.firmwareVersion))] nowKnown = true connectedVersion = String(version) @@ -594,6 +603,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph if userSettings?.provideLocation ?? false { if self.positionTimer != nil { + self.positionTimer!.invalidate() } let context = ["name": "@\(peripheral.name ?? "Unknown")"] @@ -744,6 +754,67 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph return success } + public func sendLocation(destNum: Int64) -> Bool { + + var success = false + + let fromNodeNum = connectedPeripheral.num + + if fromNodeNum <= 0 || (LocationHelper.currentLocation.latitude == LocationHelper.DefaultLocation.latitude && LocationHelper.currentLocation.longitude == LocationHelper.DefaultLocation.longitude) { + + return false + } + + //let fetchNode: NSFetchRequest = NSFetchRequest.init(entityName: "NodeInfoEntity") + //fetchNode.predicate = NSPredicate(format: "num == %lld", fromNodeNum) + + //do { + + // let fetchedNode = try context?.fetch(fetchNode) as! [NodeInfoEntity] + + + // if fetchedNode.count == 1 { + + var waypointPacket = Location() + waypointPacket.latitudeI = Int32(LocationHelper.currentLocation.latitude * 1e7) + waypointPacket.longitudeI = Int32(LocationHelper.currentLocation.longitude * 1e7) + waypointPacket.expire = UInt32(LocationHelper.currentTimestamp.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 + meshPacket.wantAck = true + + var dataMessage = DataMessage() + dataMessage.payload = try! waypointPacket.serializedData() + dataMessage.portnum = PortNum.waypointApp + + meshPacket.decoded = dataMessage + + var toRadio: ToRadio! + toRadio = ToRadio() + toRadio.packet = meshPacket + let binaryData: Data = try! toRadio.serializedData() + + if meshLoggingEnabled { MeshLogger.log("📍 Sent a Location Packet from the Apple device GPS to node: \(fromNodeNum)") } + + if connectedPeripheral!.peripheral.state == CBPeripheralState.connected { + + connectedPeripheral.peripheral.writeValue(binaryData, for: TORADIO_characteristic, type: .withResponse) + success = true + + } + // } + + //} catch { + // success = false + //} + + return success + } + public func sendPosition(destNum: Int64, wantResponse: Bool) -> Bool { var success = false @@ -976,7 +1047,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph return false } - public func saveUser(config: User, fromUser: UserEntity, toUser: UserEntity, wantResponse: Bool) -> Int64 { + public func saveUser(config: User, fromUser: UserEntity, toUser: UserEntity, wantAck: Bool) -> Int64 { var adminPacket = AdminMessage() adminPacket.setOwner = config @@ -986,16 +1057,16 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph meshPacket.from = 0 //UInt32(connectedPeripheral.num) meshPacket.id = UInt32.random(in: UInt32(UInt8.max).. Int64 { + public func saveDeviceConfig(config: Config.DeviceConfig, fromUser: UserEntity, toUser: UserEntity, wantAck: Bool) -> Int64 { var adminPacket = AdminMessage() adminPacket.setConfig.device = config @@ -1015,7 +1086,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph meshPacket.from = 0 //UInt32(connectedPeripheral.num) meshPacket.id = UInt32.random(in: UInt32(UInt8.max).. Int64 { + public func saveDisplayConfig(config: Config.DisplayConfig, fromUser: UserEntity, toUser: UserEntity, wantAck: Bool) -> Int64 { var adminPacket = AdminMessage() adminPacket.setConfig.display = config @@ -1044,7 +1115,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph meshPacket.from = 0 //UInt32(connectedPeripheral.num) meshPacket.id = UInt32.random(in: UInt32(UInt8.max).. Int64 { + public func saveLoRaConfig(config: Config.LoRaConfig, fromUser: UserEntity, toUser: UserEntity, wantAck: Bool) -> Int64 { var adminPacket = AdminMessage() adminPacket.setConfig.lora = config @@ -1074,7 +1145,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph meshPacket.id = UInt32.random(in: UInt32(UInt8.max).. Int64 { + public func savePositionConfig(config: Config.PositionConfig, fromUser: UserEntity, toUser: UserEntity, wantAck: Bool) -> Int64 { var adminPacket = AdminMessage() adminPacket.setConfig.position = config @@ -1103,7 +1174,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph meshPacket.from = 0 //UInt32(connectedPeripheral.num) meshPacket.id = UInt32.random(in: UInt32(UInt8.max).. Int64 { + public func saveWiFiConfig(config: Config.WiFiConfig, fromUser: UserEntity, toUser: UserEntity, wantAck: Bool) -> Int64 { var adminPacket = AdminMessage() adminPacket.setConfig.wifi = config @@ -1132,7 +1203,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph meshPacket.from = 0 //UInt32(connectedPeripheral.num) meshPacket.id = UInt32.random(in: UInt32(UInt8.max).. Int64 { + public func saveCannedMessageModuleConfig(config: ModuleConfig.CannedMessageConfig, fromUser: UserEntity, toUser: UserEntity, wantAck: Bool) -> Int64 { var adminPacket = AdminMessage() adminPacket.setModuleConfig.cannedMessage = config @@ -1161,7 +1232,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph meshPacket.from = 0 //UInt32(fromUser.num) meshPacket.id = UInt32.random(in: UInt32(UInt8.max).. Int64 { + public func saveExternalNotificationModuleConfig(config: ModuleConfig.ExternalNotificationConfig, fromUser: UserEntity, toUser: UserEntity) -> Int64 { var adminPacket = AdminMessage() adminPacket.setModuleConfig.externalNotification = config @@ -1267,7 +1339,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph meshPacket.from = 0 //UInt32(fromUser.num) meshPacket.id = UInt32.random(in: UInt32(UInt8.max).. Int64 { + public func saveRangeTestModuleConfig(config: ModuleConfig.RangeTestConfig, fromUser: UserEntity, toUser: UserEntity) -> Int64 { var adminPacket = AdminMessage() adminPacket.setModuleConfig.rangeTest = config @@ -1295,7 +1367,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph meshPacket.from = 0 //UInt32(fromUser.num) meshPacket.id = UInt32.random(in: UInt32(UInt8.max).. Int64 { + public func saveSerialModuleConfig(config: ModuleConfig.SerialConfig, fromUser: UserEntity, toUser: UserEntity) -> Int64 { var adminPacket = AdminMessage() adminPacket.setModuleConfig.serial = config @@ -1323,7 +1395,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph meshPacket.from = 0 //UInt32(connectedPeripheral.num) meshPacket.id = UInt32.random(in: UInt32(UInt8.max).. Int64 { + public func saveTelemetryModuleConfig(config: ModuleConfig.TelemetryConfig, fromUser: UserEntity, toUser: UserEntity) -> Int64 { var adminPacket = AdminMessage() adminPacket.setModuleConfig.telemetry = config @@ -1352,7 +1424,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph meshPacket.from = 0 //UInt32(fromUser.num) meshPacket.id = UInt32.random(in: UInt32(UInt8.max)..=4.1) static func ==(lhs: AdminMessage.OneOf_Variant, rhs: AdminMessage.OneOf_Variant) -> Bool { @@ -522,6 +561,10 @@ struct AdminMessage { guard case .confirmSetModuleConfig(let l) = lhs, case .confirmSetModuleConfig(let r) = rhs else { preconditionFailure() } return l == r }() + case (.getAllChannelRequest, .getAllChannelRequest): return { + guard case .getAllChannelRequest(let l) = lhs, case .getAllChannelRequest(let r) = rhs else { preconditionFailure() } + return l == r + }() case (.confirmSetChannel, .confirmSetChannel): return { guard case .confirmSetChannel(let l) = lhs, case .confirmSetChannel(let r) = rhs else { preconditionFailure() } return l == r @@ -590,6 +633,14 @@ struct AdminMessage { guard case .shutdownSeconds(let l) = lhs, case .shutdownSeconds(let r) = rhs else { preconditionFailure() } return l == r }() + case (.getDeviceMetadataRequest, .getDeviceMetadataRequest): return { + guard case .getDeviceMetadataRequest(let l) = lhs, case .getDeviceMetadataRequest(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.getDeviceMetadataResponse, .getDeviceMetadataResponse): return { + guard case .getDeviceMetadataResponse(let l) = lhs, case .getDeviceMetadataResponse(let r) = rhs else { preconditionFailure() } + return l == r + }() default: return false } } @@ -780,6 +831,7 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat 15: .standard(proto: "get_module_config_response"), 16: .standard(proto: "set_module_config"), 17: .standard(proto: "confirm_set_module_config"), + 18: .standard(proto: "get_all_channel_request"), 32: .standard(proto: "confirm_set_channel"), 33: .standard(proto: "confirm_set_radio"), 34: .standard(proto: "exit_simulator"), @@ -797,6 +849,8 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat 46: .standard(proto: "set_canned_message_module_part3"), 47: .standard(proto: "set_canned_message_module_part4"), 51: .standard(proto: "shutdown_seconds"), + 52: .standard(proto: "get_device_metadata_request"), + 53: .standard(proto: "get_device_metadata_response"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -957,6 +1011,14 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat self.variant = .confirmSetModuleConfig(v) } }() + case 18: try { + var v: Bool? + try decoder.decodeSingularBoolField(value: &v) + if let v = v { + if self.variant != nil {try decoder.handleConflictingOneOf()} + self.variant = .getAllChannelRequest(v) + } + }() case 32: try { var v: Bool? try decoder.decodeSingularBoolField(value: &v) @@ -1093,6 +1155,27 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat self.variant = .shutdownSeconds(v) } }() + case 52: try { + var v: UInt32? + try decoder.decodeSingularUInt32Field(value: &v) + if let v = v { + if self.variant != nil {try decoder.handleConflictingOneOf()} + self.variant = .getDeviceMetadataRequest(v) + } + }() + case 53: try { + var v: DeviceMetadata? + var hadOneofValue = false + if let current = self.variant { + hadOneofValue = true + if case .getDeviceMetadataResponse(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.variant = .getDeviceMetadataResponse(v) + } + }() default: break } } @@ -1160,6 +1243,10 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat guard case .confirmSetModuleConfig(let v)? = self.variant else { preconditionFailure() } try visitor.visitSingularBoolField(value: v, fieldNumber: 17) }() + case .getAllChannelRequest?: try { + guard case .getAllChannelRequest(let v)? = self.variant else { preconditionFailure() } + try visitor.visitSingularBoolField(value: v, fieldNumber: 18) + }() case .confirmSetChannel?: try { guard case .confirmSetChannel(let v)? = self.variant else { preconditionFailure() } try visitor.visitSingularBoolField(value: v, fieldNumber: 32) @@ -1228,6 +1315,14 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat guard case .shutdownSeconds(let v)? = self.variant else { preconditionFailure() } try visitor.visitSingularInt32Field(value: v, fieldNumber: 51) }() + case .getDeviceMetadataRequest?: try { + guard case .getDeviceMetadataRequest(let v)? = self.variant else { preconditionFailure() } + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 52) + }() + case .getDeviceMetadataResponse?: try { + guard case .getDeviceMetadataResponse(let v)? = self.variant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 53) + }() case nil: break } try unknownFields.traverse(visitor: &visitor) diff --git a/Meshtastic/Protobufs/config.pb.swift b/Meshtastic/Protobufs/config.pb.swift index 7d003b01..806ee401 100644 --- a/Meshtastic/Protobufs/config.pb.swift +++ b/Meshtastic/Protobufs/config.pb.swift @@ -359,7 +359,7 @@ struct Config { /// /// Power Config\ - /// See [power management](/docs/software/other/power) for additional power management state machine option details. + /// See [Power Config](/docs/settings/config/power) for additional power config details. struct PowerConfig { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for @@ -573,7 +573,7 @@ struct Config { } /// - /// TODO: REPLACE + /// Display Config struct DisplayConfig { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for diff --git a/Meshtastic/Protobufs/mesh.pb.swift b/Meshtastic/Protobufs/mesh.pb.swift index d528fb7e..ebb8d747 100644 --- a/Meshtastic/Protobufs/mesh.pb.swift +++ b/Meshtastic/Protobufs/mesh.pb.swift @@ -1127,6 +1127,14 @@ struct Location { /// If true, only allow the original sender to update the location. var locked: Bool = false + /// + /// Name of the location - max 30 chars + var name: String = String() + + ///* + /// Description of the location - max 100 chars + var description_p: String = String() + var unknownFields = SwiftProtobuf.UnknownStorage() init() {} @@ -2766,6 +2774,8 @@ extension Location: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB 3: .standard(proto: "longitude_i"), 4: .same(proto: "expire"), 5: .same(proto: "locked"), + 6: .same(proto: "name"), + 7: .same(proto: "description"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -2779,6 +2789,8 @@ extension Location: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB case 3: try { try decoder.decodeSingularSFixed32Field(value: &self.longitudeI) }() case 4: try { try decoder.decodeSingularUInt32Field(value: &self.expire) }() case 5: try { try decoder.decodeSingularBoolField(value: &self.locked) }() + case 6: try { try decoder.decodeSingularStringField(value: &self.name) }() + case 7: try { try decoder.decodeSingularStringField(value: &self.description_p) }() default: break } } @@ -2800,6 +2812,12 @@ extension Location: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB if self.locked != false { try visitor.visitSingularBoolField(value: self.locked, fieldNumber: 5) } + if !self.name.isEmpty { + try visitor.visitSingularStringField(value: self.name, fieldNumber: 6) + } + if !self.description_p.isEmpty { + try visitor.visitSingularStringField(value: self.description_p, fieldNumber: 7) + } try unknownFields.traverse(visitor: &visitor) } @@ -2809,6 +2827,8 @@ extension Location: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB if lhs.longitudeI != rhs.longitudeI {return false} if lhs.expire != rhs.expire {return false} if lhs.locked != rhs.locked {return false} + if lhs.name != rhs.name {return false} + if lhs.description_p != rhs.description_p {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/Meshtastic/Views/Nodes/LocationHistory.swift b/Meshtastic/Views/Nodes/LocationHistory.swift index 692d2827..0d132998 100644 --- a/Meshtastic/Views/Nodes/LocationHistory.swift +++ b/Meshtastic/Views/Nodes/LocationHistory.swift @@ -22,7 +22,7 @@ struct LocationHistory: View { List { - ForEach(node.positions!.array as! [PositionEntity], id: \.self) { (mappin: PositionEntity) in + ForEach(node.positions!.reversed() as! [PositionEntity], id: \.self) { (mappin: PositionEntity) in VStack { diff --git a/Meshtastic/Views/Nodes/TelemetryLog.swift b/Meshtastic/Views/Nodes/TelemetryLog.swift index d60f72c5..43969616 100644 --- a/Meshtastic/Views/Nodes/TelemetryLog.swift +++ b/Meshtastic/Views/Nodes/TelemetryLog.swift @@ -20,7 +20,7 @@ struct TelemetryLog: View { List { - ForEach(node.telemetries!.array as! [TelemetryEntity], id: \.self) { (tel: TelemetryEntity) in + ForEach(node.telemetries!.reversed() as! [TelemetryEntity], id: \.self) { (tel: TelemetryEntity) in VStack (alignment: .leading) { diff --git a/Meshtastic/Views/Settings/Config/DeviceConfig.swift b/Meshtastic/Views/Settings/Config/DeviceConfig.swift index 32d2cff2..b0b137a6 100644 --- a/Meshtastic/Views/Settings/Config/DeviceConfig.swift +++ b/Meshtastic/Views/Settings/Config/DeviceConfig.swift @@ -124,7 +124,7 @@ struct DeviceConfig: View { dc.serialDisabled = !serialEnabled dc.debugLogEnabled = debugLogEnabled - let adminMessageId = bleManager.saveDeviceConfig(config: dc, fromUser: node!.user!, toUser: node!.user!, wantResponse: true) + let adminMessageId = bleManager.saveDeviceConfig(config: dc, fromUser: node!.user!, toUser: node!.user!, wantAck: true) if adminMessageId > 0 { diff --git a/Meshtastic/Views/Settings/Config/DisplayConfig.swift b/Meshtastic/Views/Settings/Config/DisplayConfig.swift index f08c7dbf..6fcb7c35 100644 --- a/Meshtastic/Views/Settings/Config/DisplayConfig.swift +++ b/Meshtastic/Views/Settings/Config/DisplayConfig.swift @@ -213,7 +213,7 @@ struct DisplayConfig: View { dc.autoScreenCarouselSecs = UInt32(screenCarouselInterval) dc.compassNorthTop = compassNorthTop - let adminMessageId = bleManager.saveDisplayConfig(config: dc, fromUser: node!.user!, toUser: node!.user!, wantResponse: true) + let adminMessageId = bleManager.saveDisplayConfig(config: dc, fromUser: node!.user!, toUser: node!.user!, wantAck: true) if adminMessageId > 0 { diff --git a/Meshtastic/Views/Settings/Config/LoRaConfig.swift b/Meshtastic/Views/Settings/Config/LoRaConfig.swift index d3a708e5..d89a0542 100644 --- a/Meshtastic/Views/Settings/Config/LoRaConfig.swift +++ b/Meshtastic/Views/Settings/Config/LoRaConfig.swift @@ -261,7 +261,7 @@ struct LoRaConfig: View { lc.region = RegionCodes(rawValue: region)!.protoEnumValue() lc.modemPreset = ModemPresets(rawValue: modemPreset)!.protoEnumValue() - let adminMessageId = bleManager.saveLoRaConfig(config: lc, fromUser: node!.user!, toUser: node!.user!, wantResponse: true) + let adminMessageId = bleManager.saveLoRaConfig(config: lc, fromUser: node!.user!, toUser: node!.user!, wantAck: true) if adminMessageId > 0 { diff --git a/Meshtastic/Views/Settings/Config/Module/CannedMessagesConfig.swift b/Meshtastic/Views/Settings/Config/Module/CannedMessagesConfig.swift index 950c77de..9534b7dd 100644 --- a/Meshtastic/Views/Settings/Config/Module/CannedMessagesConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/CannedMessagesConfig.swift @@ -320,7 +320,7 @@ struct CannedMessagesConfig: View { cmc.inputbrokerEventCcw = InputEventChars(rawValue: inputbrokerEventCcw)!.protoEnumValue() cmc.inputbrokerEventPress = InputEventChars(rawValue: inputbrokerEventPress)!.protoEnumValue() - let adminMessageId = bleManager.saveCannedMessageModuleConfig(config: cmc, fromUser: node!.user!, toUser: node!.user!, wantResponse: true) + let adminMessageId = bleManager.saveCannedMessageModuleConfig(config: cmc, fromUser: node!.user!, toUser: node!.user!, wantAck: true) if adminMessageId > 0 { // Should show a saved successfully alert once I know that to be true @@ -391,8 +391,8 @@ struct CannedMessagesConfig: View { inputbrokerPinA = 25 inputbrokerPinB = 39 inputbrokerPinPress = 36 - inputbrokerEventCw = InputEventChars.keyLeft.rawValue - inputbrokerEventCcw = InputEventChars.keyRight.rawValue + inputbrokerEventCw = InputEventChars.keyUp.rawValue + inputbrokerEventCcw = InputEventChars.keyDown.rawValue inputbrokerEventPress = InputEventChars.keySelect.rawValue } diff --git a/Meshtastic/Views/Settings/Config/Module/ExternalNotificationConfig.swift b/Meshtastic/Views/Settings/Config/Module/ExternalNotificationConfig.swift index 3769d4f6..7ef699ed 100644 --- a/Meshtastic/Views/Settings/Config/Module/ExternalNotificationConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/ExternalNotificationConfig.swift @@ -159,7 +159,7 @@ struct ExternalNotificationConfig: View { enc.output = UInt32(output) enc.outputMs = UInt32(outputMilliseconds) - let adminMessageId = bleManager.saveExternalNotificationModuleConfig(config: enc, fromUser: node!.user!, toUser: node!.user!, wantResponse: true) + let adminMessageId = bleManager.saveExternalNotificationModuleConfig(config: enc, fromUser: node!.user!, toUser: node!.user!) if adminMessageId > 0{ diff --git a/Meshtastic/Views/Settings/Config/Module/RangeTestConfig.swift b/Meshtastic/Views/Settings/Config/Module/RangeTestConfig.swift index 077b4d14..642a12ec 100644 --- a/Meshtastic/Views/Settings/Config/Module/RangeTestConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/RangeTestConfig.swift @@ -113,7 +113,7 @@ struct RangeTestConfig: View { rtc.save = save rtc.sender = UInt32(sender) - let adminMessageId = bleManager.saveRangeTestModuleConfig(config: rtc, fromUser: node!.user!, toUser: node!.user!, wantResponse: true) + let adminMessageId = bleManager.saveRangeTestModuleConfig(config: rtc, fromUser: node!.user!, toUser: node!.user!) if adminMessageId > 0 { diff --git a/Meshtastic/Views/Settings/Config/Module/SerialConfig.swift b/Meshtastic/Views/Settings/Config/Module/SerialConfig.swift index b4432798..99f183cf 100644 --- a/Meshtastic/Views/Settings/Config/Module/SerialConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/SerialConfig.swift @@ -303,7 +303,7 @@ struct SerialConfig: View { sc.timeout = UInt32(timeout) sc.mode = SerialModeTypes(rawValue: mode)!.protoEnumValue() - let adminMessageId = bleManager.saveSerialModuleConfig(config: sc, fromUser: node!.user!, toUser: node!.user!, wantResponse: true) + let adminMessageId = bleManager.saveSerialModuleConfig(config: sc, fromUser: node!.user!, toUser: node!.user!) if adminMessageId > 0 { diff --git a/Meshtastic/Views/Settings/Config/Module/TelemetryConfig.swift b/Meshtastic/Views/Settings/Config/Module/TelemetryConfig.swift index 14123fac..275a70b0 100644 --- a/Meshtastic/Views/Settings/Config/Module/TelemetryConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/TelemetryConfig.swift @@ -203,7 +203,7 @@ struct TelemetryConfig: View { tc.environmentScreenEnabled = environmentScreenEnabled tc.environmentDisplayFahrenheit = environmentDisplayFahrenheit - let adminMessageId = bleManager.saveTelemetryModuleConfig(config: tc, fromUser: node!.user!, toUser: node!.user!, wantResponse: true) + let adminMessageId = bleManager.saveTelemetryModuleConfig(config: tc, fromUser: node!.user!, toUser: node!.user!) if adminMessageId > 0 { diff --git a/Meshtastic/Views/Settings/Config/PositionConfig.swift b/Meshtastic/Views/Settings/Config/PositionConfig.swift index ff5ece92..42ca784d 100644 --- a/Meshtastic/Views/Settings/Config/PositionConfig.swift +++ b/Meshtastic/Views/Settings/Config/PositionConfig.swift @@ -323,7 +323,7 @@ struct PositionConfig: View { pc.gpsAttemptTime = UInt32(gpsAttemptTime) pc.positionBroadcastSecs = UInt32(positionBroadcastSeconds) - let adminMessageId = bleManager.savePositionConfig(config: pc, fromUser: node!.user!, toUser: node!.user!, wantResponse: true) + let adminMessageId = bleManager.savePositionConfig(config: pc, fromUser: node!.user!, toUser: node!.user!, wantAck: true) if adminMessageId > 0{ diff --git a/Meshtastic/Views/Settings/Config/WiFiConfig.swift b/Meshtastic/Views/Settings/Config/WiFiConfig.swift index 1da29f14..e7cfb5eb 100644 --- a/Meshtastic/Views/Settings/Config/WiFiConfig.swift +++ b/Meshtastic/Views/Settings/Config/WiFiConfig.swift @@ -167,7 +167,7 @@ struct WiFiConfig: View { wifi.psk = self.password wifi.mode = WiFiModes(rawValue: self.mode)?.protoEnumValue() ?? WiFiModes.client.protoEnumValue() - let adminMessageId = bleManager.saveWiFiConfig(config: wifi, fromUser: node!.user!, toUser: node!.user!, wantResponse: true) + let adminMessageId = bleManager.saveWiFiConfig(config: wifi, fromUser: node!.user!, toUser: node!.user!, wantAck: true) if adminMessageId > 0 { diff --git a/Meshtastic/Views/Settings/UserConfig.swift b/Meshtastic/Views/Settings/UserConfig.swift index 6d9d304d..accc224b 100644 --- a/Meshtastic/Views/Settings/UserConfig.swift +++ b/Meshtastic/Views/Settings/UserConfig.swift @@ -113,7 +113,7 @@ struct UserConfig: View { u.shortName = shortName u.longName = longName - let adminMessageId = bleManager.saveUser(config: u, fromUser: node!.user!, toUser: node!.user!, wantResponse: true) + let adminMessageId = bleManager.saveUser(config: u, fromUser: node!.user!, toUser: node!.user!, wantAck: true) if adminMessageId > 0 { diff --git a/gen_protos.sh b/gen_protos.sh index 968e1e39..94c685c2 100755 --- a/gen_protos.sh +++ b/gen_protos.sh @@ -15,7 +15,7 @@ fi pdir=$(realpath "../Meshtastic-protobufs") sdir=$(realpath "./Meshtastic/Protobufs") echo "pdir:$pdir sdir:$sdir" -pfiles="admin.proto apponly.proto cannedmessages.proto channel.proto config.proto deviceonly.proto localonly.proto mesh.proto module_config.proto mqtt.proto portnums.proto remote_hardware.proto +pfiles="admin.proto apponly.proto cannedmessages.proto channel.proto config.proto device_metadata.proto deviceonly.proto localonly.proto mesh.proto module_config.proto mqtt.proto portnums.proto remote_hardware.proto storeforward.proto telemetry.proto" for pf in $pfiles do