Meshtastic-Apple/Meshtastic/Enums/RoutingError.swift

86 lines
1.9 KiB
Swift
Raw Normal View History

2022-08-05 15:58:12 -07:00
//
// RoutingError.swift
// Meshtastic
//
// Copyright(c) Garth Vander Houwen 8/4/22.
//
import Foundation
2022-08-05 15:58:12 -07:00
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
2022-08-05 15:58:12 -07:00
case badRequest = 32
case notAuthorized = 33
var id: Int { self.rawValue }
var display: String {
2023-03-06 13:26:04 -08:00
switch self {
2023-03-06 10:33:18 -08:00
2023-03-06 13:26:04 -08:00
case .none:
return "routing.acknowledged".localized
2023-03-06 13:26:04 -08:00
case .noRoute:
return "routing.noroute".localized
2023-03-06 13:26:04 -08:00
case .gotNak:
return "routing.gotnak".localized
2023-03-06 13:26:04 -08:00
case .timeout:
return "routing.timeout".localized
2023-03-06 13:26:04 -08:00
case .noInterface:
return "routing.nointerface".localized
2023-03-06 13:26:04 -08:00
case .maxRetransmit:
return "routing.maxretransmit".localized
2023-03-06 13:26:04 -08:00
case .noChannel:
return "routing.nochannel".localized
2023-03-06 13:26:04 -08:00
case .tooLarge:
return "routing.toolarge".localized
2023-03-06 13:26:04 -08:00
case .noResponse:
return "routing.noresponse".localized
2023-03-06 13:26:04 -08:00
case .dutyCycleLimit:
return "routing.dutycyclelimit".localized
2023-03-06 13:26:04 -08:00
case .badRequest:
return "routing.badRequest".localized
2023-03-06 13:26:04 -08:00
case .notAuthorized:
return "routing.notauthorized".localized
2022-08-05 15:58:12 -07:00
}
}
func protoEnumValue() -> Routing.Error {
2023-03-06 10:33:18 -08:00
2022-08-05 15:58:12 -07:00
switch self {
2023-03-06 10:33:18 -08:00
2022-08-05 15:58:12 -07:00
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
2022-08-05 15:58:12 -07:00
case .badRequest:
return Routing.Error.badRequest
case .notAuthorized:
return Routing.Error.notAuthorized
2023-03-06 10:33:18 -08:00
2022-08-05 15:58:12 -07:00
}
}
}