Meshtastic-Apple/Meshtastic/Extensions/CoreData/MQTTConfigEntityExtension.swift
Blake McAnally 58da532d32 Extract the generated protobufs into its own Swift package
This change modifies the process for generating and integrating the Meshtastic protobufs into the client application.

* The generated Swift code is now in a local SPM package `MeshtasticProtobufs`
* An Xcode Workspace file `Meshtastic.xcworkspace` was created to more easily manage the new build targets.
* The code generation script for the protos was modified to generate the Swift code into the new location.
* The README.md was updated to reflect these changes.

NOTE: After merging this PR, do not open the project file `Meshtastic.xcodeproj`. You must use the workspace `Meshtastic.xcworkspace`

Extracting out the generated protobuf code into its own library enables several opportunities for the project. This is just a first step, but with some more modularization, a standalone Apple Watch app or other targets starts to become a little bit more achievable to implement.

After extracting the protobufs into a Swift package, I validate these changes by building and running the Meshtastic app to an iPhone 15 Pro Max, and tried changing some settings on a local node. I then messaged back and forth using two local nodes connected to two different iOS devices.
2024-06-28 11:11:01 -05:00

38 lines
1.3 KiB
Swift

import CoreData
import MeshtasticProtobufs
extension MQTTConfigEntity {
convenience init(
context: NSManagedObjectContext,
config: ModuleConfig.MQTTConfig
) {
self.init(context: context)
self.enabled = config.enabled
self.proxyToClientEnabled = config.proxyToClientEnabled
self.address = config.address
self.username = config.username
self.password = config.password
self.root = config.root
self.encryptionEnabled = config.encryptionEnabled
self.jsonEnabled = config.jsonEnabled
self.tlsEnabled = config.tlsEnabled
self.mapReportingEnabled = config.mapReportingEnabled
self.mapPositionPrecision = Int32(config.mapReportSettings.positionPrecision)
self.mapPublishIntervalSecs = Int32(config.mapReportSettings.publishIntervalSecs)
}
func update(with config: ModuleConfig.MQTTConfig) {
enabled = config.enabled
proxyToClientEnabled = config.proxyToClientEnabled
address = config.address
username = config.username
password = config.password
root = config.root
encryptionEnabled = config.encryptionEnabled
jsonEnabled = config.jsonEnabled
tlsEnabled = config.tlsEnabled
mapReportingEnabled = config.mapReportingEnabled
mapPositionPrecision = Int32(config.mapReportSettings.positionPrecision)
mapPublishIntervalSecs = Int32(config.mapReportSettings.publishIntervalSecs)
}
}