mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
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.
44 lines
1.5 KiB
Swift
44 lines
1.5 KiB
Swift
import CoreData
|
|
import MeshtasticProtobufs
|
|
|
|
extension ExternalNotificationConfigEntity {
|
|
convenience init(
|
|
context: NSManagedObjectContext,
|
|
config: ModuleConfig.ExternalNotificationConfig
|
|
) {
|
|
self.init(context: context)
|
|
self.enabled = config.enabled
|
|
self.usePWM = config.usePwm
|
|
self.alertBell = config.alertBell
|
|
self.alertBellBuzzer = config.alertBellBuzzer
|
|
self.alertBellVibra = config.alertBellVibra
|
|
self.alertMessage = config.alertMessage
|
|
self.alertMessageBuzzer = config.alertMessageBuzzer
|
|
self.alertMessageVibra = config.alertMessageVibra
|
|
self.active = config.active
|
|
self.output = Int32(config.output)
|
|
self.outputBuzzer = Int32(config.outputBuzzer)
|
|
self.outputVibra = Int32(config.outputVibra)
|
|
self.outputMilliseconds = Int32(config.outputMs)
|
|
self.nagTimeout = Int32(config.nagTimeout)
|
|
self.useI2SAsBuzzer = config.useI2SAsBuzzer
|
|
}
|
|
|
|
func update(with config: ModuleConfig.ExternalNotificationConfig) {
|
|
enabled = config.enabled
|
|
usePWM = config.usePwm
|
|
alertBell = config.alertBell
|
|
alertBellBuzzer = config.alertBellBuzzer
|
|
alertBellVibra = config.alertBellVibra
|
|
alertMessage = config.alertMessage
|
|
alertMessageBuzzer = config.alertMessageBuzzer
|
|
alertMessageVibra = config.alertMessageVibra
|
|
active = config.active
|
|
output = Int32(config.output)
|
|
outputBuzzer = Int32(config.outputBuzzer)
|
|
outputVibra = Int32(config.outputVibra)
|
|
outputMilliseconds = Int32(config.outputMs)
|
|
nagTimeout = Int32(config.nagTimeout)
|
|
useI2SAsBuzzer = config.useI2SAsBuzzer
|
|
}
|
|
}
|