From 4f3cd0f72bd91f315f344a4c8cd94db4853ed099 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 26 Mar 2024 08:55:38 -0700 Subject: [PATCH] Add TAK tracker, bump db version --- Meshtastic.xcodeproj/project.pbxproj | 4 +- Meshtastic/Enums/DeviceEnums.swift | 10 + .../Meshtastic.xcdatamodeld/.xccurrentversion | 2 +- .../contents | 457 ++++++++++++++++++ .../Protobufs/meshtastic/admin.pb.swift | 125 +++++ .../Protobufs/meshtastic/deviceonly.pb.swift | 72 --- Meshtastic/Protobufs/meshtastic/mesh.pb.swift | 72 +++ protobufs | 2 +- 8 files changed, 669 insertions(+), 75 deletions(-) create mode 100644 Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 31.xcdatamodel/contents diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 5e714267..5cdd8853 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -460,6 +460,7 @@ DDDC22322BA76961002C44F1 /* zh-Hant-TW */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant-TW"; path = "zh-Hant-TW.lproj/Localizable.strings"; sourceTree = ""; }; DDDC22372BA92344002C44F1 /* MeshMapContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshMapContent.swift; sourceTree = ""; }; DDDCD56F2BB26F5C00BE6B60 /* NodeListFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeListFilter.swift; sourceTree = ""; }; + DDDCD5712BB3246500BE6B60 /* MeshtasticDataModelV 31.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "MeshtasticDataModelV 31.xcdatamodel"; sourceTree = ""; }; DDDD527729B5B83F0045BC3C /* MeshtasticDataModelV9.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MeshtasticDataModelV9.xcdatamodel; sourceTree = ""; }; DDDE59F429AF163D00490C6C /* WidgetsExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = WidgetsExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; DDDE59F829AF163D00490C6C /* WidgetsBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetsBundle.swift; sourceTree = ""; }; @@ -1907,6 +1908,7 @@ DD3CC6BA28E366DF00FA9159 /* Meshtastic.xcdatamodeld */ = { isa = XCVersionGroup; children = ( + DDDCD5712BB3246500BE6B60 /* MeshtasticDataModelV 31.xcdatamodel */, DD9A1A912BA2D2D3001E602E /* MeshtasticDataModelV 30.xcdatamodel */, DD398EBD2B93F640002B4C51 /* MeshtasticDataModelV 29.xcdatamodel */, DD0E20FF2B892E1300F2D100 /* MeshtasticDataModelV 28.xcdatamodel */, @@ -1938,7 +1940,7 @@ DD5D0A9A2931AD6B00F7EA61 /* MeshtasticDataModelV2.xcdatamodel */, DD3CC6BB28E366DF00FA9159 /* MeshtasticDataModel.xcdatamodel */, ); - currentVersion = DD9A1A912BA2D2D3001E602E /* MeshtasticDataModelV 30.xcdatamodel */; + currentVersion = DDDCD5712BB3246500BE6B60 /* MeshtasticDataModelV 31.xcdatamodel */; name = Meshtastic.xcdatamodeld; path = Meshtastic/Meshtastic.xcdatamodeld; sourceTree = ""; diff --git a/Meshtastic/Enums/DeviceEnums.swift b/Meshtastic/Enums/DeviceEnums.swift index 8f2bbc7b..dbbc6dc2 100644 --- a/Meshtastic/Enums/DeviceEnums.swift +++ b/Meshtastic/Enums/DeviceEnums.swift @@ -17,6 +17,7 @@ enum DeviceRoles: Int, CaseIterable, Identifiable { case lostAndFound = 9 case sensor = 6 case tak = 7 + case takTracker = 10 case repeater = 4 case router = 2 case routerClient = 3 @@ -40,11 +41,14 @@ enum DeviceRoles: Int, CaseIterable, Identifiable { return "Sensor" case .tak: return "TAK" + case .takTracker: + return "TAK Tracker" case .clientHidden: return "Client Hidden" case .lostAndFound: return "Lost and Found" } + } var description: String { switch self { @@ -64,6 +68,8 @@ enum DeviceRoles: Int, CaseIterable, Identifiable { return "device.role.sensor".localized case .tak: return "device.role.tak".localized + case .takTracker: + return "device.role.taktracker".localized case .clientHidden: return "device.role.clienthidden".localized case .lostAndFound: @@ -87,6 +93,8 @@ enum DeviceRoles: Int, CaseIterable, Identifiable { return "sensor" case .tak: return "shield.checkered" + case .takTracker: + return "dog" case .clientHidden: return "eye.slash" case .lostAndFound: @@ -112,6 +120,8 @@ enum DeviceRoles: Int, CaseIterable, Identifiable { return Config.DeviceConfig.Role.sensor case .tak: return Config.DeviceConfig.Role.tak + case .takTracker: + return Config.DeviceConfig.Role.takTracker case .clientHidden: return Config.DeviceConfig.Role.clientHidden case .lostAndFound: diff --git a/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion b/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion index e8a31698..825d8915 100644 --- a/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion +++ b/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion @@ -3,6 +3,6 @@ _XCCurrentVersionName - MeshtasticDataModelV 30.xcdatamodel + MeshtasticDataModelV 31.xcdatamodel diff --git a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 31.xcdatamodel/contents b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 31.xcdatamodel/contents new file mode 100644 index 00000000..72ba98d4 --- /dev/null +++ b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 31.xcdatamodel/contents @@ -0,0 +1,457 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Meshtastic/Protobufs/meshtastic/admin.pb.swift b/Meshtastic/Protobufs/meshtastic/admin.pb.swift index baa3c742..fa1ac990 100644 --- a/Meshtastic/Protobufs/meshtastic/admin.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/admin.pb.swift @@ -319,6 +319,46 @@ struct AdminMessage { set {payloadVariant = .removeByNodenum(newValue)} } + /// + /// Set specified node-num to be favorited on the NodeDB on the device + var setFavoriteNode: UInt32 { + get { + if case .setFavoriteNode(let v)? = payloadVariant {return v} + return 0 + } + set {payloadVariant = .setFavoriteNode(newValue)} + } + + /// + /// Set specified node-num to be un-favorited on the NodeDB on the device + var removeFavoriteNode: UInt32 { + get { + if case .removeFavoriteNode(let v)? = payloadVariant {return v} + return 0 + } + set {payloadVariant = .removeFavoriteNode(newValue)} + } + + /// + /// Set fixed position data on the node and then set the position.fixed_position = true + var setFixedPosition: Position { + get { + if case .setFixedPosition(let v)? = payloadVariant {return v} + return Position() + } + set {payloadVariant = .setFixedPosition(newValue)} + } + + /// + /// Clear fixed position coordinates and then set position.fixed_position = false + var removeFixedPosition: Bool { + get { + if case .removeFixedPosition(let v)? = payloadVariant {return v} + return false + } + set {payloadVariant = .removeFixedPosition(newValue)} + } + /// /// Begins an edit transaction for config, module config, owner, and channel settings changes /// This will delay the standard *implicit* save to the file system and subsequent reboot behavior until committed (commit_edit_settings) @@ -498,6 +538,18 @@ struct AdminMessage { /// Remove the node by the specified node-num from the NodeDB on the device case removeByNodenum(UInt32) /// + /// Set specified node-num to be favorited on the NodeDB on the device + case setFavoriteNode(UInt32) + /// + /// Set specified node-num to be un-favorited on the NodeDB on the device + case removeFavoriteNode(UInt32) + /// + /// Set fixed position data on the node and then set the position.fixed_position = true + case setFixedPosition(Position) + /// + /// Clear fixed position coordinates and then set position.fixed_position = false + case removeFixedPosition(Bool) + /// /// Begins an edit transaction for config, module config, owner, and channel settings changes /// This will delay the standard *implicit* save to the file system and subsequent reboot behavior until committed (commit_edit_settings) case beginEditSettings(Bool) @@ -643,6 +695,22 @@ struct AdminMessage { guard case .removeByNodenum(let l) = lhs, case .removeByNodenum(let r) = rhs else { preconditionFailure() } return l == r }() + case (.setFavoriteNode, .setFavoriteNode): return { + guard case .setFavoriteNode(let l) = lhs, case .setFavoriteNode(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.removeFavoriteNode, .removeFavoriteNode): return { + guard case .removeFavoriteNode(let l) = lhs, case .removeFavoriteNode(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.setFixedPosition, .setFixedPosition): return { + guard case .setFixedPosition(let l) = lhs, case .setFixedPosition(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.removeFixedPosition, .removeFixedPosition): return { + guard case .removeFixedPosition(let l) = lhs, case .removeFixedPosition(let r) = rhs else { preconditionFailure() } + return l == r + }() case (.beginEditSettings, .beginEditSettings): return { guard case .beginEditSettings(let l) = lhs, case .beginEditSettings(let r) = rhs else { preconditionFailure() } return l == r @@ -978,6 +1046,10 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat 36: .standard(proto: "set_canned_message_module_messages"), 37: .standard(proto: "set_ringtone_message"), 38: .standard(proto: "remove_by_nodenum"), + 39: .standard(proto: "set_favorite_node"), + 40: .standard(proto: "remove_favorite_node"), + 41: .standard(proto: "set_fixed_position"), + 42: .standard(proto: "remove_fixed_position"), 64: .standard(proto: "begin_edit_settings"), 65: .standard(proto: "commit_edit_settings"), 95: .standard(proto: "reboot_ota_seconds"), @@ -1278,6 +1350,43 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat self.payloadVariant = .removeByNodenum(v) } }() + case 39: try { + var v: UInt32? + try decoder.decodeSingularUInt32Field(value: &v) + if let v = v { + if self.payloadVariant != nil {try decoder.handleConflictingOneOf()} + self.payloadVariant = .setFavoriteNode(v) + } + }() + case 40: try { + var v: UInt32? + try decoder.decodeSingularUInt32Field(value: &v) + if let v = v { + if self.payloadVariant != nil {try decoder.handleConflictingOneOf()} + self.payloadVariant = .removeFavoriteNode(v) + } + }() + case 41: try { + var v: Position? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .setFixedPosition(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .setFixedPosition(v) + } + }() + case 42: try { + var v: Bool? + try decoder.decodeSingularBoolField(value: &v) + if let v = v { + if self.payloadVariant != nil {try decoder.handleConflictingOneOf()} + self.payloadVariant = .removeFixedPosition(v) + } + }() case 64: try { var v: Bool? try decoder.decodeSingularBoolField(value: &v) @@ -1465,6 +1574,22 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat guard case .removeByNodenum(let v)? = self.payloadVariant else { preconditionFailure() } try visitor.visitSingularUInt32Field(value: v, fieldNumber: 38) }() + case .setFavoriteNode?: try { + guard case .setFavoriteNode(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 39) + }() + case .removeFavoriteNode?: try { + guard case .removeFavoriteNode(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 40) + }() + case .setFixedPosition?: try { + guard case .setFixedPosition(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 41) + }() + case .removeFixedPosition?: try { + guard case .removeFixedPosition(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularBoolField(value: v, fieldNumber: 42) + }() case .beginEditSettings?: try { guard case .beginEditSettings(let v)? = self.payloadVariant else { preconditionFailure() } try visitor.visitSingularBoolField(value: v, fieldNumber: 64) diff --git a/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift b/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift index f25a5cd1..3080ae9f 100644 --- a/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/deviceonly.pb.swift @@ -405,35 +405,6 @@ struct OEMStore { fileprivate var _oemLocalModuleConfig: LocalModuleConfig? = nil } -/// -/// RemoteHardwarePins associated with a node -struct NodeRemoteHardwarePin { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - /// - /// The node_num exposing the available gpio pin - var nodeNum: UInt32 = 0 - - /// - /// The the available gpio pin for usage with RemoteHardware module - var pin: RemoteHardwarePin { - get {return _pin ?? RemoteHardwarePin()} - set {_pin = newValue} - } - /// Returns true if `pin` has been explicitly set. - var hasPin: Bool {return self._pin != nil} - /// Clears the value of `pin`. Subsequent reads from it will return its default value. - mutating func clearPin() {self._pin = nil} - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} - - fileprivate var _pin: RemoteHardwarePin? = nil -} - #if swift(>=5.5) && canImport(_Concurrency) extension ScreenFonts: @unchecked Sendable {} extension DeviceState: @unchecked Sendable {} @@ -441,7 +412,6 @@ extension NodeInfoLite: @unchecked Sendable {} extension PositionLite: @unchecked Sendable {} extension ChannelFile: @unchecked Sendable {} extension OEMStore: @unchecked Sendable {} -extension NodeRemoteHardwarePin: @unchecked Sendable {} #endif // swift(>=5.5) && canImport(_Concurrency) // MARK: - Code below here is support for the SwiftProtobuf runtime. @@ -907,45 +877,3 @@ extension OEMStore: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB return true } } - -extension NodeRemoteHardwarePin: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".NodeRemoteHardwarePin" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "node_num"), - 2: .same(proto: "pin"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt32Field(value: &self.nodeNum) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._pin) }() - default: break - } - } - } - - func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if self.nodeNum != 0 { - try visitor.visitSingularUInt32Field(value: self.nodeNum, fieldNumber: 1) - } - try { if let v = self._pin { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - try unknownFields.traverse(visitor: &visitor) - } - - static func ==(lhs: NodeRemoteHardwarePin, rhs: NodeRemoteHardwarePin) -> Bool { - if lhs.nodeNum != rhs.nodeNum {return false} - if lhs._pin != rhs._pin {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true - } -} diff --git a/Meshtastic/Protobufs/meshtastic/mesh.pb.swift b/Meshtastic/Protobufs/meshtastic/mesh.pb.swift index 18da455b..1ae038f4 100644 --- a/Meshtastic/Protobufs/meshtastic/mesh.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/mesh.pb.swift @@ -2619,6 +2619,35 @@ struct Heartbeat { init() {} } +/// +/// RemoteHardwarePins associated with a node +struct NodeRemoteHardwarePin { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// + /// The node_num exposing the available gpio pin + var nodeNum: UInt32 = 0 + + /// + /// The the available gpio pin for usage with RemoteHardware module + var pin: RemoteHardwarePin { + get {return _pin ?? RemoteHardwarePin()} + set {_pin = newValue} + } + /// Returns true if `pin` has been explicitly set. + var hasPin: Bool {return self._pin != nil} + /// Clears the value of `pin`. Subsequent reads from it will return its default value. + mutating func clearPin() {self._pin = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _pin: RemoteHardwarePin? = nil +} + #if swift(>=5.5) && canImport(_Concurrency) extension HardwareModel: @unchecked Sendable {} extension Constants: @unchecked Sendable {} @@ -2653,6 +2682,7 @@ extension NeighborInfo: @unchecked Sendable {} extension Neighbor: @unchecked Sendable {} extension DeviceMetadata: @unchecked Sendable {} extension Heartbeat: @unchecked Sendable {} +extension NodeRemoteHardwarePin: @unchecked Sendable {} #endif // swift(>=5.5) && canImport(_Concurrency) // MARK: - Code below here is support for the SwiftProtobuf runtime. @@ -4611,3 +4641,45 @@ extension Heartbeat: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation return true } } + +extension NodeRemoteHardwarePin: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".NodeRemoteHardwarePin" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "node_num"), + 2: .same(proto: "pin"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt32Field(value: &self.nodeNum) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._pin) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if self.nodeNum != 0 { + try visitor.visitSingularUInt32Field(value: self.nodeNum, fieldNumber: 1) + } + try { if let v = self._pin { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: NodeRemoteHardwarePin, rhs: NodeRemoteHardwarePin) -> Bool { + if lhs.nodeNum != rhs.nodeNum {return false} + if lhs._pin != rhs._pin {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/protobufs b/protobufs index bcfb49c4..dea3a82e 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit bcfb49c4988b1539fc35e568a58b9f2f5b60738a +Subproject commit dea3a82ef2accd25112b4ef1c6f8991b579740f4