Meshtastic-Apple/Meshtastic/Enums/RoutingError.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

86 lines
1.9 KiB
Swift

//
// RoutingError.swift
// Meshtastic
//
// Copyright(c) Garth Vander Houwen 8/4/22.
//
import Foundation
import MeshtasticProtobufs
enum RoutingError: Int, CaseIterable, Identifiable {
case none = 0
case noRoute = 1
case gotNak = 2
case timeout = 3
case noInterface = 4
case maxRetransmit = 5
case noChannel = 6
case tooLarge = 7
case noResponse = 8
case dutyCycleLimit = 9
case badRequest = 32
case notAuthorized = 33
var id: Int { self.rawValue }
var display: String {
switch self {
case .none:
return "routing.acknowledged".localized
case .noRoute:
return "routing.noroute".localized
case .gotNak:
return "routing.gotnak".localized
case .timeout:
return "routing.timeout".localized
case .noInterface:
return "routing.nointerface".localized
case .maxRetransmit:
return "routing.maxretransmit".localized
case .noChannel:
return "routing.nochannel".localized
case .tooLarge:
return "routing.toolarge".localized
case .noResponse:
return "routing.noresponse".localized
case .dutyCycleLimit:
return "routing.dutycyclelimit".localized
case .badRequest:
return "routing.badRequest".localized
case .notAuthorized:
return "routing.notauthorized".localized
}
}
func protoEnumValue() -> Routing.Error {
switch self {
case .none:
return Routing.Error.none
case .noRoute:
return Routing.Error.noRoute
case .gotNak:
return Routing.Error.gotNak
case .timeout:
return Routing.Error.timeout
case .noInterface:
return Routing.Error.noInterface
case .maxRetransmit:
return Routing.Error.maxRetransmit
case .noChannel:
return Routing.Error.noChannel
case .tooLarge:
return Routing.Error.tooLarge
case .noResponse:
return Routing.Error.noResponse
case .dutyCycleLimit:
return Routing.Error.dutyCycleLimit
case .badRequest:
return Routing.Error.badRequest
case .notAuthorized:
return Routing.Error.notAuthorized
}
}
}