From 48de377922be20b0d4a11376fbc7847bd733854f Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 23 Apr 2022 12:57:47 -0700 Subject: [PATCH] Update protobufs, clean up qr sharing view --- Meshtastic Client.xcodeproj/project.pbxproj | 4 +- MeshtasticClient/Helpers/BLEManager.swift | 2 +- .../Protobufs/deviceonly.pb.swift | 154 ++++++++++++++++++ .../Protobufs/radioconfig.pb.swift | 20 +++ .../Views/Settings/AppSettings.swift | 2 +- .../Views/Settings/ShareChannel.swift | 4 +- 6 files changed, 180 insertions(+), 6 deletions(-) diff --git a/Meshtastic Client.xcodeproj/project.pbxproj b/Meshtastic Client.xcodeproj/project.pbxproj index bc7af150..d2e228f4 100644 --- a/Meshtastic Client.xcodeproj/project.pbxproj +++ b/Meshtastic Client.xcodeproj/project.pbxproj @@ -735,7 +735,7 @@ CODE_SIGN_ENTITLEMENTS = MeshtasticClient/MeshtasticClient.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 3; DEVELOPMENT_ASSET_PATHS = "\"MeshtasticClient/Preview Content\""; DEVELOPMENT_TEAM = GCH7VS5Y9R; ENABLE_PREVIEWS = YES; @@ -767,7 +767,7 @@ CODE_SIGN_ENTITLEMENTS = MeshtasticClient/MeshtasticClient.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 3; 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 29e471d2..56f17a71 100644 --- a/MeshtasticClient/Helpers/BLEManager.swift +++ b/MeshtasticClient/Helpers/BLEManager.swift @@ -1148,7 +1148,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph context!.rollback() let nsError = error as NSError - print("💥 Unresolved Core Data error in Send Message Function \(nsError)") + print("💥 Unresolved Core Data error in Send Message Function it is likely that your database is corrupted deleting and re-installing the app should clear the corrupted data. Error: \(nsError)") if meshLoggingEnabled { MeshLogger.log("💥 Unresolved Core Data error \(nsError)") } } } diff --git a/MeshtasticClient/Protobufs/deviceonly.pb.swift b/MeshtasticClient/Protobufs/deviceonly.pb.swift index 9311b664..52a31d33 100644 --- a/MeshtasticClient/Protobufs/deviceonly.pb.swift +++ b/MeshtasticClient/Protobufs/deviceonly.pb.swift @@ -20,6 +20,61 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP typealias Version = _2 } +/// +/// TODO: REPLACE +enum ScreenFonts: SwiftProtobuf.Enum { + typealias RawValue = Int + + /// + /// TODO: REPLACE + case fontSmall // = 0 + + /// + /// TODO: REPLACE + case fontMedium // = 1 + + /// + /// TODO: REPLACE + case fontLarge // = 2 + case UNRECOGNIZED(Int) + + init() { + self = .fontSmall + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .fontSmall + case 1: self = .fontMedium + case 2: self = .fontLarge + default: self = .UNRECOGNIZED(rawValue) + } + } + + var rawValue: Int { + switch self { + case .fontSmall: return 0 + case .fontMedium: return 1 + case .fontLarge: return 2 + case .UNRECOGNIZED(let i): return i + } + } + +} + +#if swift(>=4.2) + +extension ScreenFonts: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + static var allCases: [ScreenFonts] = [ + .fontSmall, + .fontMedium, + .fontLarge, + ] +} + +#endif // swift(>=4.2) + /// /// This message is never sent over the wire, but it is used for serializing DB /// state to flash in the device code @@ -127,13 +182,56 @@ struct ChannelFile { init() {} } +/// +/// This can be used for customizing the firmware distribution. If populated, +/// show a secondary bootup screen with cuatom logo and text for 2.5 seconds. +struct OEMStore { + // 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 Logo width in Px + var oemIconWidth: UInt32 = 0 + + /// + /// The Logo height in Px + var oemIconHeight: UInt32 = 0 + + /// + /// The Logo in xbm bytechar format + var oemIconBits: Data = Data() + + /// + /// Use this font for the OEM text. + var oemFont: ScreenFonts = .fontSmall + + /// + /// Use this font for the OEM text. + var oemText: String = String() + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + #if swift(>=5.5) && canImport(_Concurrency) +extension ScreenFonts: @unchecked Sendable {} extension DeviceState: @unchecked Sendable {} extension ChannelFile: @unchecked Sendable {} +extension OEMStore: @unchecked Sendable {} #endif // swift(>=5.5) && canImport(_Concurrency) // MARK: - Code below here is support for the SwiftProtobuf runtime. +extension ScreenFonts: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "FONT_SMALL"), + 1: .same(proto: "FONT_MEDIUM"), + 2: .same(proto: "FONT_LARGE"), + ] +} + extension DeviceState: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = "DeviceState" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ @@ -289,3 +387,59 @@ extension ChannelFile: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementati return true } } + +extension OEMStore: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "OEMStore" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "oem_icon_width"), + 2: .standard(proto: "oem_icon_height"), + 3: .standard(proto: "oem_icon_bits"), + 4: .standard(proto: "oem_font"), + 5: .standard(proto: "oem_text"), + ] + + 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.oemIconWidth) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.oemIconHeight) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self.oemIconBits) }() + case 4: try { try decoder.decodeSingularEnumField(value: &self.oemFont) }() + case 5: try { try decoder.decodeSingularStringField(value: &self.oemText) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.oemIconWidth != 0 { + try visitor.visitSingularUInt32Field(value: self.oemIconWidth, fieldNumber: 1) + } + if self.oemIconHeight != 0 { + try visitor.visitSingularUInt32Field(value: self.oemIconHeight, fieldNumber: 2) + } + if !self.oemIconBits.isEmpty { + try visitor.visitSingularBytesField(value: self.oemIconBits, fieldNumber: 3) + } + if self.oemFont != .fontSmall { + try visitor.visitSingularEnumField(value: self.oemFont, fieldNumber: 4) + } + if !self.oemText.isEmpty { + try visitor.visitSingularStringField(value: self.oemText, fieldNumber: 5) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: OEMStore, rhs: OEMStore) -> Bool { + if lhs.oemIconWidth != rhs.oemIconWidth {return false} + if lhs.oemIconHeight != rhs.oemIconHeight {return false} + if lhs.oemIconBits != rhs.oemIconBits {return false} + if lhs.oemFont != rhs.oemFont {return false} + if lhs.oemText != rhs.oemText {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/MeshtasticClient/Protobufs/radioconfig.pb.swift b/MeshtasticClient/Protobufs/radioconfig.pb.swift index 895a8c90..83453149 100644 --- a/MeshtasticClient/Protobufs/radioconfig.pb.swift +++ b/MeshtasticClient/Protobufs/radioconfig.pb.swift @@ -1362,6 +1362,10 @@ struct RadioConfig { case baud460800 // = 9 case baud576000 // = 10 case baud921600 // = 11 + case baud110 // = 12 + case baud300 // = 13 + case baud600 // = 14 + case baud1200 // = 15 case UNRECOGNIZED(Int) init() { @@ -1382,6 +1386,10 @@ struct RadioConfig { case 9: self = .baud460800 case 10: self = .baud576000 case 11: self = .baud921600 + case 12: self = .baud110 + case 13: self = .baud300 + case 14: self = .baud600 + case 15: self = .baud1200 default: self = .UNRECOGNIZED(rawValue) } } @@ -1400,6 +1408,10 @@ struct RadioConfig { case .baud460800: return 9 case .baud576000: return 10 case .baud921600: return 11 + case .baud110: return 12 + case .baud300: return 13 + case .baud600: return 14 + case .baud1200: return 15 case .UNRECOGNIZED(let i): return i } } @@ -1550,6 +1562,10 @@ extension RadioConfig.UserPreferences.Serial_Baud: CaseIterable { .baud460800, .baud576000, .baud921600, + .baud110, + .baud300, + .baud600, + .baud1200, ] } @@ -2454,6 +2470,10 @@ extension RadioConfig.UserPreferences.Serial_Baud: SwiftProtobuf._ProtoNameProvi 9: .same(proto: "BAUD_460800"), 10: .same(proto: "BAUD_576000"), 11: .same(proto: "BAUD_921600"), + 12: .same(proto: "BAUD_110"), + 13: .same(proto: "BAUD_300"), + 14: .same(proto: "BAUD_600"), + 15: .same(proto: "BAUD_1200"), ] } diff --git a/MeshtasticClient/Views/Settings/AppSettings.swift b/MeshtasticClient/Views/Settings/AppSettings.swift index bc9e9668..769419db 100644 --- a/MeshtasticClient/Views/Settings/AppSettings.swift +++ b/MeshtasticClient/Views/Settings/AppSettings.swift @@ -158,7 +158,7 @@ struct AppSettings: View { GeometryReader { _ in - List { + Form { Section(header: Text("USER DETAILS")) { HStack { diff --git a/MeshtasticClient/Views/Settings/ShareChannel.swift b/MeshtasticClient/Views/Settings/ShareChannel.swift index 352ab6af..2fbab5d3 100644 --- a/MeshtasticClient/Views/Settings/ShareChannel.swift +++ b/MeshtasticClient/Views/Settings/ShareChannel.swift @@ -1,5 +1,5 @@ // -// Channel.swift +// ShareChannel.swift // MeshtasticClient // // Created by Garth Vander Houwen on 4/8/22. @@ -18,7 +18,7 @@ struct QrCodeImage { let filter = CIFilter.qrCodeGenerator() filter.setValue(data, forKey: "inputMessage") - let transform = CGAffineTransform(scaleX: 15, y: 15) + let transform = CGAffineTransform(scaleX: 20, y: 20) if let outputImage = filter.outputImage?.transformed(by: transform) { if let image = context.createCGImage( outputImage,