diff --git a/ESPProvision.podspec b/ESPProvision.podspec index 377a9a7..14a1c9c 100644 --- a/ESPProvision.podspec +++ b/ESPProvision.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |spec| spec.name = "ESPProvision" - spec.version = "2.1.2" + spec.version = "3.0.0" spec.summary = "ESP-IDF provisioning in Swift" spec.description = "It provides mechanism to provide network credentials and/or custom data to an ESP32, ESP32-S2 or ESP8266 devices" spec.homepage = "https://github.com/espressif/esp-idf-provisioning-ios" diff --git a/ESPProvision.xcodeproj/project.pbxproj b/ESPProvision.xcodeproj/project.pbxproj index 874b332..80899dc 100644 --- a/ESPProvision.xcodeproj/project.pbxproj +++ b/ESPProvision.xcodeproj/project.pbxproj @@ -3,10 +3,17 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ + 0C2426F62BF4E3D7004BDF49 /* ESPThreadNetwork.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C2426F52BF4E3D7004BDF49 /* ESPThreadNetwork.swift */; }; + 0C2426FA2BF4E429004BDF49 /* ESPThreadManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C2426F92BF4E429004BDF49 /* ESPThreadManager.swift */; }; + 0C5163FC2C22EDDF004EF494 /* constants.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C5163F72C22EDDF004EF494 /* constants.pb.swift */; }; + 0C5163FD2C22EDDF004EF494 /* network_constants.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C5163F92C22EDDF004EF494 /* network_constants.pb.swift */; }; + 0C5163FE2C22EDDF004EF494 /* network_config.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C5163F82C22EDDF004EF494 /* network_config.pb.swift */; }; + 0C5163FF2C22EDDF004EF494 /* network_ctrl.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C5163FA2C22EDDF004EF494 /* network_ctrl.pb.swift */; }; + 0C5164002C22EDDF004EF494 /* network_scan.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C5163FB2C22EDDF004EF494 /* network_scan.pb.swift */; }; E9645E43CF7B1380FC310F19 /* Pods_ESPProvision.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 247B21F19D9AA0FB3A6A6B94 /* Pods_ESPProvision.framework */; }; F151FF03247B1C40006F514E /* ESPProvisionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F151FEF8247B17B3006F514E /* ESPProvisionTests.swift */; }; F15B525828AA1794009852DB /* sec2.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F15B525728AA1794009852DB /* sec2.pb.swift */; }; @@ -42,13 +49,9 @@ F1C34D482451F46400340B04 /* ESPSecurity0.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C34D472451F46400340B04 /* ESPSecurity0.swift */; }; F1C34D4E2457469D00340B04 /* ESPExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C34D4D2457469D00340B04 /* ESPExtensions.swift */; }; F1C34D502457479C00340B04 /* CryptoAES.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C34D4F2457479C00340B04 /* CryptoAES.swift */; }; - F1C34D5D24596C8500340B04 /* constants.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C34D5624596C8500340B04 /* constants.pb.swift */; }; - F1C34D5E24596C8500340B04 /* wifi_config.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C34D5724596C8500340B04 /* wifi_config.pb.swift */; }; F1C34D5F24596C8500340B04 /* sec1.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C34D5824596C8500340B04 /* sec1.pb.swift */; }; - F1C34D6024596C8500340B04 /* wifi_constants.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C34D5924596C8500340B04 /* wifi_constants.pb.swift */; }; F1C34D6124596C8500340B04 /* session.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C34D5A24596C8500340B04 /* session.pb.swift */; }; F1C34D6224596C8500340B04 /* sec0.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C34D5B24596C8500340B04 /* sec0.pb.swift */; }; - F1C34D6324596C8500340B04 /* wifi_scan.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C34D5C24596C8500340B04 /* wifi_scan.pb.swift */; }; F1C34D6624597B8E00340B04 /* HexUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C34D6524597B8E00340B04 /* HexUtils.swift */; }; F1C34D682459B35200340B04 /* ESPWiFiManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C34D672459B35200340B04 /* ESPWiFiManager.swift */; }; F1C34D6A2459B3F200340B04 /* ESPSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C34D692459B3F200340B04 /* ESPSession.swift */; }; @@ -85,6 +88,13 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 0C2426F52BF4E3D7004BDF49 /* ESPThreadNetwork.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ESPThreadNetwork.swift; sourceTree = ""; }; + 0C2426F92BF4E429004BDF49 /* ESPThreadManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ESPThreadManager.swift; sourceTree = ""; }; + 0C5163F72C22EDDF004EF494 /* constants.pb.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = constants.pb.swift; sourceTree = ""; }; + 0C5163F82C22EDDF004EF494 /* network_config.pb.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = network_config.pb.swift; sourceTree = ""; }; + 0C5163F92C22EDDF004EF494 /* network_constants.pb.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = network_constants.pb.swift; sourceTree = ""; }; + 0C5163FA2C22EDDF004EF494 /* network_ctrl.pb.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = network_ctrl.pb.swift; sourceTree = ""; }; + 0C5163FB2C22EDDF004EF494 /* network_scan.pb.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = network_scan.pb.swift; sourceTree = ""; }; 247B21F19D9AA0FB3A6A6B94 /* Pods_ESPProvision.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ESPProvision.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 44F8E73C277B503EAD29F630 /* Pods-ESPProvision-ESPProvisionTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ESPProvision-ESPProvisionTests.release.xcconfig"; path = "Target Support Files/Pods-ESPProvision-ESPProvisionTests/Pods-ESPProvision-ESPProvisionTests.release.xcconfig"; sourceTree = ""; }; 93F6B39AD52298DB1DAAFAAB /* Pods-ESPProvision.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ESPProvision.debug.xcconfig"; path = "Target Support Files/Pods-ESPProvision/Pods-ESPProvision.debug.xcconfig"; sourceTree = ""; }; @@ -128,13 +138,9 @@ F1C34D472451F46400340B04 /* ESPSecurity0.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ESPSecurity0.swift; sourceTree = ""; }; F1C34D4D2457469D00340B04 /* ESPExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ESPExtensions.swift; sourceTree = ""; }; F1C34D4F2457479C00340B04 /* CryptoAES.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CryptoAES.swift; sourceTree = ""; }; - F1C34D5624596C8500340B04 /* constants.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = constants.pb.swift; sourceTree = ""; }; - F1C34D5724596C8500340B04 /* wifi_config.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = wifi_config.pb.swift; sourceTree = ""; }; F1C34D5824596C8500340B04 /* sec1.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = sec1.pb.swift; sourceTree = ""; }; - F1C34D5924596C8500340B04 /* wifi_constants.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = wifi_constants.pb.swift; sourceTree = ""; }; F1C34D5A24596C8500340B04 /* session.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = session.pb.swift; sourceTree = ""; }; F1C34D5B24596C8500340B04 /* sec0.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = sec0.pb.swift; sourceTree = ""; }; - F1C34D5C24596C8500340B04 /* wifi_scan.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = wifi_scan.pb.swift; sourceTree = ""; }; F1C34D6524597B8E00340B04 /* HexUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HexUtils.swift; sourceTree = ""; }; F1C34D672459B35200340B04 /* ESPWiFiManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ESPWiFiManager.swift; sourceTree = ""; }; F1C34D692459B3F200340B04 /* ESPSession.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ESPSession.swift; sourceTree = ""; }; @@ -264,6 +270,7 @@ F1C34D692459B3F200340B04 /* ESPSession.swift */, F1C34D3B245017C900340B04 /* ESPDevice.swift */, F1C34D672459B35200340B04 /* ESPWiFiManager.swift */, + 0C2426F92BF4E429004BDF49 /* ESPThreadManager.swift */, F1C34D77245F17B900340B04 /* ESPProvision.swift */, ); path = ESPProvision; @@ -294,14 +301,15 @@ F1C34D552459696400340B04 /* Proto */ = { isa = PBXGroup; children = ( - F15B525728AA1794009852DB /* sec2.pb.swift */, - F1C34D5624596C8500340B04 /* constants.pb.swift */, + 0C5163F72C22EDDF004EF494 /* constants.pb.swift */, + 0C5163F82C22EDDF004EF494 /* network_config.pb.swift */, + 0C5163F92C22EDDF004EF494 /* network_constants.pb.swift */, + 0C5163FA2C22EDDF004EF494 /* network_ctrl.pb.swift */, + 0C5163FB2C22EDDF004EF494 /* network_scan.pb.swift */, F1C34D5B24596C8500340B04 /* sec0.pb.swift */, F1C34D5824596C8500340B04 /* sec1.pb.swift */, + F15B525728AA1794009852DB /* sec2.pb.swift */, F1C34D5A24596C8500340B04 /* session.pb.swift */, - F1C34D5724596C8500340B04 /* wifi_config.pb.swift */, - F1C34D5924596C8500340B04 /* wifi_constants.pb.swift */, - F1C34D5C24596C8500340B04 /* wifi_scan.pb.swift */, ); path = Proto; sourceTree = ""; @@ -322,6 +330,7 @@ F1C34D7E24618A5800340B04 /* Model */ = { isa = PBXGroup; children = ( + 0C2426F52BF4E3D7004BDF49 /* ESPThreadNetwork.swift */, F1C34D8024618ACC00340B04 /* ESPWifiNetwork.swift */, F17B313B28476DB50052D80F /* ESPScanStatus.swift */, F183F85128C5F41300CB7E86 /* ESPScanResult.swift */, @@ -488,10 +497,9 @@ F183F84928B37D4D00CB7E86 /* Multiplication.swift in Sources */, F1C34D502457479C00340B04 /* CryptoAES.swift in Sources */, F1C34D76245F178E00340B04 /* ESPProvisionManager.swift in Sources */, - F1C34D6024596C8500340B04 /* wifi_constants.pb.swift in Sources */, F183F84A28B37D4D00CB7E86 /* Exponentiation.swift in Sources */, F1C34D702459F60900340B04 /* ESPErrors.swift in Sources */, - F1C34D5D24596C8500340B04 /* constants.pb.swift in Sources */, + 0C2426FA2BF4E429004BDF49 /* ESPThreadManager.swift in Sources */, F1C34D8124618ACC00340B04 /* ESPWifiNetwork.swift in Sources */, F183F7F228B37ADE00CB7E86 /* Client.swift in Sources */, F177859C2A057F4500C3AE73 /* AESDecryptor.swift in Sources */, @@ -499,6 +507,11 @@ F1C34D3C245017C900340B04 /* ESPDevice.swift in Sources */, F183F84E28B37D4D00CB7E86 /* Integer Conversion.swift in Sources */, F183F84528B37D4D00CB7E86 /* Division.swift in Sources */, + 0C5163FC2C22EDDF004EF494 /* constants.pb.swift in Sources */, + 0C5163FD2C22EDDF004EF494 /* network_constants.pb.swift in Sources */, + 0C5163FE2C22EDDF004EF494 /* network_config.pb.swift in Sources */, + 0C5163FF2C22EDDF004EF494 /* network_ctrl.pb.swift in Sources */, + 0C5164002C22EDDF004EF494 /* network_scan.pb.swift in Sources */, F183F85228C5F41500CB7E86 /* ESPScanResult.swift in Sources */, F183F84C28B37D4D00CB7E86 /* Shifts.swift in Sources */, F183F84B28B37D4D00CB7E86 /* Floating Point Conversion.swift in Sources */, @@ -516,6 +529,7 @@ F183F7F028B37ADE00CB7E86 /* SRP.swift in Sources */, F15B525A28AA1915009852DB /* ESPSecurity2.swift in Sources */, F1C34D482451F46400340B04 /* ESPSecurity0.swift in Sources */, + 0C2426F62BF4E3D7004BDF49 /* ESPThreadNetwork.swift in Sources */, F1C34D4224518F3900340B04 /* ESPSoftAPTransport.swift in Sources */, F17B313C28476DB50052D80F /* ESPScanStatus.swift in Sources */, F1C34D462451B33100340B04 /* ESPCodeable.swift in Sources */, @@ -528,9 +542,7 @@ F1C34DEF24673D7300340B04 /* ESPLogging.swift in Sources */, F1C34D6A2459B3F200340B04 /* ESPSession.swift in Sources */, F183F85428C73A8D00CB7E86 /* Bitwise Ops.swift in Sources */, - F1C34D5E24596C8500340B04 /* wifi_config.pb.swift in Sources */, F168F2C928E0B97A00E39433 /* Comparable.swift in Sources */, - F1C34D6324596C8500340B04 /* wifi_scan.pb.swift in Sources */, F1C34D6124596C8500340B04 /* session.pb.swift in Sources */, F183F7EF28B37ADE00CB7E86 /* AuthenticationFailure.swift in Sources */, F1C34D6624597B8E00340B04 /* HexUtils.swift in Sources */, diff --git a/ESPProvision/Crypto/ESPSecurity0.swift b/ESPProvision/Crypto/ESPSecurity0.swift index 86a79d3..86b48df 100644 --- a/ESPProvision/Crypto/ESPSecurity0.swift +++ b/ESPProvision/Crypto/ESPSecurity0.swift @@ -89,10 +89,10 @@ class ESPSecurity0: ESPCodeable { ESPLog.log("Generating Step 0 request data...") var request: Data? - var sessionData = Espressif_SessionData() + var sessionData = SessionData() sessionData.secVer = .secScheme0 do { - try sessionData.sec0.sc.merge(serializedData: Espressif_S0SessionCmd().serializedData()) + try sessionData.sec0.sc.merge(serializedData: S0SessionCmd().serializedData()) request = try? sessionData.serializedData() } catch { ESPLog.log("Serializing Step0 request throws error.") @@ -116,7 +116,7 @@ class ESPSecurity0: ESPCodeable { } ESPLog.log("Serializing Step0 response.") - let sessionData = try Espressif_SessionData(serializedData: response) + let sessionData = try SessionData(serializedData: response) if sessionData.secVer != .secScheme0 { ESPLog.log("Security version mismatch.") throw SecurityError.handshakeError("Security version mismatch") diff --git a/ESPProvision/Crypto/ESPSecurity1.swift b/ESPProvision/Crypto/ESPSecurity1.swift index 990b84a..7aec1f4 100644 --- a/ESPProvision/Crypto/ESPSecurity1.swift +++ b/ESPProvision/Crypto/ESPSecurity1.swift @@ -137,7 +137,7 @@ class ESPSecurity1: ESPCodeable { guard let publicKey = self.publicKey else { throw SecurityError.keygenError("Could not generate keypair") } - var sessionData = Espressif_SessionData() + var sessionData = SessionData() sessionData.secVer = .secScheme1 sessionData.sec1.sc0.clientPubkey = publicKey.rawRepresentation do { @@ -156,7 +156,7 @@ class ESPSecurity1: ESPCodeable { throw SecurityError.keygenError("Could not generate keypair") } - var sessionData = Espressif_SessionData() + var sessionData = SessionData() sessionData.secVer = .secScheme1 sessionData.sec1.msg = .sessionCommand1 sessionData.sec1.sc1.clientVerifyData = verifyData @@ -178,7 +178,7 @@ class ESPSecurity1: ESPCodeable { ESPLog.log("Response 0 is nil.") throw SecurityError.handshakeError("Response 0 is nil") } - let sessionData = try Espressif_SessionData(serializedData: response) + let sessionData = try SessionData(serializedData: response) if sessionData.secVer != .secScheme1 { ESPLog.log("Security version mismatch.") throw SecurityError.handshakeError("Security version mismatch") @@ -220,7 +220,7 @@ class ESPSecurity1: ESPCodeable { ESPLog.log("Response 1 is nil") throw SecurityError.handshakeError("Response 1 is nil") } - let sessionData = try Espressif_SessionData(serializedData: response) + let sessionData = try SessionData(serializedData: response) if sessionData.secVer != .secScheme1 { ESPLog.log("Security version mismatch") throw SecurityError.handshakeError("Security version mismatch") diff --git a/ESPProvision/ESPDevice.swift b/ESPProvision/ESPDevice.swift index 2ff3686..c84be02 100644 --- a/ESPProvision/ESPDevice.swift +++ b/ESPProvision/ESPDevice.swift @@ -103,6 +103,8 @@ open class ESPDevice { var connectionStatus:ESPSessionStatus = .disconnected /// Completion handler for scan Wi-Fi list. var wifiListCompletionHandler: (([ESPWifiNetwork]?,ESPWiFiScanError?) -> Void)? + /// Completion handler for scan Thread list. + var threadListCompletionHandler: (([ESPThreadNetwork]?,ESPThreadScanError?) -> Void)? /// Completion handler for BLE connection status. var bleConnectionStatusHandler: ((ESPSessionStatus) -> Void)? /// Proof of possession @@ -123,6 +125,8 @@ open class ESPDevice { public var bleDelegate: ESPBLEDelegate? /// Store username for sec1 public var username: String? + /// Store network for device + public var network: ESPNetworkType? /// Advertisement data for BLE device /// This property is read-only public private(set) var advertisementData:[String:Any]? @@ -145,12 +149,13 @@ open class ESPDevice { /// - transport: Mode of transport. /// - proofOfPossession: Pop of device. /// - softAPPassword: Password in case SoftAP device. - public init(name: String, security: ESPSecurity, transport: ESPTransport, proofOfPossession:String? = nil, username:String? = nil, softAPPassword:String? = nil, advertisementData: [String:Any]? = nil) { + public init(name: String, security: ESPSecurity, transport: ESPTransport, proofOfPossession:String? = nil, username:String? = nil, network: ESPNetworkType? = nil, softAPPassword:String? = nil, advertisementData: [String:Any]? = nil) { ESPLog.log("Intializing ESPDevice with name:\(name), security:\(security), transport:\(transport), proofOfPossession:\(proofOfPossession ?? "nil") and softAPPassword:\(softAPPassword ?? "nil")") self.deviceName = name self.security = security self.transport = transport self.username = username + self.network = network self.proofOfPossession = proofOfPossession self.softAPPassword = softAPPassword self.advertisementData = advertisementData @@ -322,12 +327,12 @@ open class ESPDevice { /// - passPhrase: Password of home network. /// - completionHandler: The completion handler that is called when provision is completed. /// Parameter of block include status of provision. - public func provision(ssid: String, passPhrase: String = "", completionHandler: @escaping (ESPProvisionStatus) -> Void) { + public func provision(ssid: String?, passPhrase: String? = "", threadOperationalDataset: Data? = nil, completionHandler: @escaping (ESPProvisionStatus) -> Void) { ESPLog.log("Provisioning started.. with ssid:\(ssid) and password:\(passPhrase)") if session == nil || !session.isEstablished { completionHandler(.failure(.sessionError)) } else { - provisionDevice(ssid: ssid, passPhrase: passPhrase, retryOnce: true, completionHandler: completionHandler) + provisionDevice(ssid: ssid, passPhrase: passPhrase, threadOperationalDataset: threadOperationalDataset, retryOnce: true, completionHandler: completionHandler) } } @@ -336,13 +341,48 @@ open class ESPDevice { return self.provision?.wifiConnectedIp4Addr } - private func provisionDevice(ssid: String, passPhrase: String = "", retryOnce: Bool, completionHandler: @escaping (ESPProvisionStatus) -> Void) { + private func provisionDevice(ssid: String?, passPhrase: String? = "", threadOperationalDataset: Data?, retryOnce: Bool, completionHandler: @escaping (ESPProvisionStatus) -> Void) { provision = ESPProvision(session: session) ESPLog.log("Configure wi-fi credentials in device.") - provision.configureWifi(ssid: ssid, passphrase: passPhrase) { status, error in + provision.configureNetwork(ssid: ssid, passphrase: passPhrase, threadOperationalDataset: threadOperationalDataset) { status, error in ESPLog.log("Received configuration response.") switch status { case .success: + if let _ = threadOperationalDataset { + self.provision.applyThreadConfigurations(completionHandler: { _, error in + DispatchQueue.main.async { + guard error == nil else { + completionHandler(.failure(.configurationError(error!))) + return + } + completionHandler(.configApplied) + } + }, threadStatusUpdatedHandler: { threadState, failReason, error in + DispatchQueue.main.async { + if error != nil { + completionHandler(.failure(.threadStatusError(error!))) + return + } else if threadState == ThreadNetworkState.attached { + completionHandler(.success) + return + } else if threadState == ThreadNetworkState.dettached { + completionHandler(.failure(.threadStatusDettached)) + return + } else { + if failReason == ThreadAttachFailedReason.datasetInvalid { + completionHandler(.failure(.threadDatasetInvalid)) + return + } else if failReason == ThreadAttachFailedReason.threadNetworkNotFound { + completionHandler(.failure(.threadStatusNetworkNotFound)) + return + } else { + completionHandler(.failure(.threadStatusUnknownError)) + return + } + } + } + }) + } else { self.provision.applyConfigurations(completionHandler: { _, error in DispatchQueue.main.async { guard error == nil else { @@ -357,17 +397,17 @@ open class ESPDevice { if error != nil { completionHandler(.failure(.wifiStatusError(error!))) return - } else if wifiState == Espressif_WifiStationState.connected { + } else if wifiState == WifiStationState.connected { completionHandler(.success) return - } else if wifiState == Espressif_WifiStationState.disconnected { + } else if wifiState == WifiStationState.disconnected { completionHandler(.failure(.wifiStatusDisconnected)) return } else { - if failReason == Espressif_WifiConnectFailedReason.authError { + if failReason == WifiConnectFailedReason.authError { completionHandler(.failure(.wifiStatusAuthenticationError)) return - } else if failReason == Espressif_WifiConnectFailedReason.networkNotFound { + } else if failReason == WifiConnectFailedReason.wifiNetworkNotFound { completionHandler(.failure(.wifiStatusNetworkNotFound)) return } else { @@ -377,13 +417,14 @@ open class ESPDevice { } } }) + } default: if error != nil, self.isNetworkDisconnected(error: error!) { DispatchQueue.main.async { self.connect { status in switch status { case .connected: - self.provisionDevice(ssid: ssid, passPhrase: passPhrase, retryOnce: false, completionHandler: completionHandler) + self.provisionDevice(ssid: ssid, passPhrase: passPhrase, threadOperationalDataset: threadOperationalDataset, retryOnce: false, completionHandler: completionHandler) return default: completionHandler(.failure(.configurationError(error!))) @@ -413,6 +454,27 @@ open class ESPDevice { } + /// Send command to device for scanning Thread list. + /// + /// - Parameter completionHandler: The completion handler that is called when Thread list is scanned. + /// Parameter of block include list of available Thread network or error in case of failure. + public func scanThreadList(completionHandler: @escaping ([ESPThreadNetwork]?,ESPThreadScanError?) -> Void) { + retryScan = true + scanDeviceForThreadList(completionHandler: completionHandler) + } + + private func scanDeviceForThreadList(completionHandler: @escaping ([ESPThreadNetwork]?,ESPThreadScanError?) -> Void) { + if let capability = self.capabilities, capability.contains(ESPConstants.threadScanCapability) { + self.threadListCompletionHandler = completionHandler + let scanThreadManager: ESPThreadManager = ESPThreadManager(session: self.session!) + scanThreadManager.delegate = self + threadListCompletionHandler = completionHandler + scanThreadManager.startThreadScan() + } else { + completionHandler(nil,.emptyResultCount) + } + } + /// Send command to device for scanning Wi-Fi list. /// /// - Parameter completionHandler: The completion handler that is called when Wi-Fi list is scanned. @@ -638,9 +700,44 @@ extension ESPDevice: ESPScanWifiListProtocol { } else { self.wifiListCompletionHandler?(nil,error) } + } + +} + +extension ESPDevice: ESPScanThreadListProtocol { + func threadScanFinished(threadList: [ESPThreadNetwork]?, error: ESPThreadScanError?) { + if let threadResult = threadList { + threadListCompletionHandler?(threadResult,nil) + return + } + if retryScan { + self.retryScan = false + switch error { + case .scanRequestError(let requestError): + if isNetworkDisconnected(error: requestError) { + DispatchQueue.main.async { + self.connect { status in + switch status { + case .connected: + self.scanDeviceForThreadList(completionHandler: self.threadListCompletionHandler!) + default: + self.threadListCompletionHandler?(nil, error) + } + } + } + } else { + self.threadListCompletionHandler?(nil,error) + } + default: + self.threadListCompletionHandler?(nil,error) + } + } else { + self.threadListCompletionHandler?(nil,error) } } +} + extension ESPDevice: ESPBLEStatusDelegate { func peripheralConnected() { ESPLog.log("Peripheral connected.") @@ -665,5 +762,4 @@ extension ESPDevice: ESPBLEStatusDelegate { } } - } diff --git a/ESPProvision/ESPProvision.swift b/ESPProvision/ESPProvision.swift index 72ea9cf..1f3168e 100644 --- a/ESPProvision/ESPProvision.swift +++ b/ESPProvision/ESPProvision.swift @@ -49,7 +49,7 @@ public class ESPProvision { transportLayer = session.transportLayer securityLayer = session.securityLayer } - + /// Send Configuration information relating to the Home /// Wifi network which the device should use for Internet access @@ -58,28 +58,34 @@ public class ESPProvision { /// - ssid: ssid of the home network /// - passphrase: passphrase /// - completionHandler: handler called when config data is sent - func configureWifi(ssid: String, - passphrase: String, - completionHandler: @escaping (Espressif_Status, Error?) -> Swift.Void) { + func configureNetwork(ssid: String?, + passphrase: String?, + threadOperationalDataset: Data? = nil, + completionHandler: @escaping (Status, Error?) -> Swift.Void) { ESPLog.log("Sending configuration info of home network to device.") if session.isEstablished { do { - let message = try createSetWifiConfigRequest(ssid: ssid, passphrase: passphrase) + let message = try createSetNetworkConfigRequest(ssid: ssid, passphrase: passphrase, threadOperationalDataset: threadOperationalDataset) if let message = message { transportLayer.SendConfigData(path: transportLayer.utility.configPath, data: message) { response, error in guard error == nil, response != nil else { ESPLog.log("Error while sending config data error: \(error.debugDescription)") - completionHandler(Espressif_Status.internalError, error) + completionHandler(Status.internalError, error) return } ESPLog.log("Received response.") - let status = self.processSetWifiConfigResponse(response: response) - completionHandler(status, nil) + if let _ = threadOperationalDataset { + let status = self.processSetThreadConfigResponse(response: response) + completionHandler(status, nil) + } else { + let status = self.processSetWifiConfigResponse(response: response) + completionHandler(status, nil) + } } } } catch { ESPLog.log("Error while creating config request error: \(error.localizedDescription)") - completionHandler(Espressif_Status.internalError, error) + completionHandler(Status.internalError, error) } } } @@ -92,8 +98,8 @@ public class ESPProvision { /// - Parameters: /// - completionHandler: handler to be called when apply config message is sent /// - wifiStatusUpdatedHandler: handler to be called when wifi status is updated on the device - func applyConfigurations(completionHandler: @escaping (Espressif_Status, Error?) -> Void, - wifiStatusUpdatedHandler: @escaping (Espressif_WifiStationState, Espressif_WifiConnectFailedReason, Error?) -> Void) { + func applyConfigurations(completionHandler: @escaping (Status, Error?) -> Void, + wifiStatusUpdatedHandler: @escaping (WifiStationState, WifiConnectFailedReason, Error?) -> Void) { ESPLog.log("Applying Wi-Fi configuration...") if session.isEstablished { do { @@ -102,7 +108,7 @@ public class ESPProvision { transportLayer.SendConfigData(path: transportLayer.utility.configPath, data: message) { response, error in guard error == nil, response != nil else { ESPLog.log("Error while applying Wi-Fi configuration: \(error.debugDescription)") - completionHandler(Espressif_Status.internalError, error) + completionHandler(Status.internalError, error) return } ESPLog.log("Received response.") @@ -115,12 +121,12 @@ public class ESPProvision { } } catch { ESPLog.log("Error while creating configuration request: \(error.localizedDescription)") - completionHandler(Espressif_Status.internalError, error) + completionHandler(Status.internalError, error) } } } - private func pollForWifiConnectionStatus(completionHandler: @escaping (Espressif_WifiStationState, Espressif_WifiConnectFailedReason, Error?) -> Swift.Void) { + private func pollForWifiConnectionStatus(completionHandler: @escaping (WifiStationState, WifiConnectFailedReason, Error?) -> Swift.Void) { do { ESPLog.log("Start polling for Wi-Fi connection status...") let message = try createGetWifiConfigRequest() @@ -129,7 +135,7 @@ public class ESPProvision { data: message) { response, error in guard error == nil, response != nil else { ESPLog.log("Error on polling request: \(error.debugDescription)") - completionHandler(Espressif_WifiStationState.disconnected, Espressif_WifiConnectFailedReason.UNRECOGNIZED(0), error) + completionHandler(WifiStationState.disconnected, WifiConnectFailedReason.UNRECOGNIZED(0), error) return } @@ -139,7 +145,7 @@ public class ESPProvision { self.processGetWifiConfigStatusResponse(response: response) if stationState == .connected { ESPLog.log("Status: connected.") - completionHandler(stationState, Espressif_WifiConnectFailedReason.UNRECOGNIZED(0), nil) + completionHandler(stationState, WifiConnectFailedReason.UNRECOGNIZED(0), nil) } else if stationState == .connecting { ESPLog.log("Status: connecting.") sleep(5) @@ -150,96 +156,249 @@ public class ESPProvision { } } catch { ESPLog.log("Error while processing response: \(error.localizedDescription)") - completionHandler(Espressif_WifiStationState.disconnected, Espressif_WifiConnectFailedReason.UNRECOGNIZED(0), error) + completionHandler(WifiStationState.disconnected, WifiConnectFailedReason.UNRECOGNIZED(0), error) } } } } catch { ESPLog.log("Error while creating polling request: \(error.localizedDescription)") - completionHandler(Espressif_WifiStationState.connectionFailed, Espressif_WifiConnectFailedReason.UNRECOGNIZED(0), error) + completionHandler(WifiStationState.connectionFailed, WifiConnectFailedReason.UNRECOGNIZED(0), error) } } - private func createSetWifiConfigRequest(ssid: String, passphrase: String) throws -> Data? { + private func createSetNetworkConfigRequest(ssid: String?, passphrase: String?, threadOperationalDataset: Data? = nil) throws -> Data? { ESPLog.log("Create set Wi-Fi config request.") - var configData = Espressif_WiFiConfigPayload() - configData.msg = Espressif_WiFiConfigMsgType.typeCmdSetConfig - configData.cmdSetConfig.ssid = Data(ssid.bytes) - configData.cmdSetConfig.passphrase = Data(passphrase.bytes) - + var configData = NetworkConfigPayload() + configData.msg = NetworkConfigMsgType.typeCmdSetWifiConfig + if let ssid = ssid { + configData.cmdSetWifiConfig.ssid = Data(ssid.bytes) + } + if let passphrase = passphrase { + configData.cmdSetWifiConfig.passphrase = Data(passphrase.bytes) + } + if let threadOperationalDataset = threadOperationalDataset { + configData.msg = NetworkConfigMsgType.typeCmdSetThreadConfig + configData.cmdSetThreadConfig.dataset = threadOperationalDataset + } return try securityLayer.encrypt(data: configData.serializedData()) } private func createApplyConfigRequest() throws -> Data? { ESPLog.log("Create apply config request.") - var configData = Espressif_WiFiConfigPayload() - configData.cmdApplyConfig = Espressif_CmdApplyConfig() - configData.msg = Espressif_WiFiConfigMsgType.typeCmdApplyConfig - + var configData = NetworkConfigPayload() + configData.cmdApplyWifiConfig = CmdApplyWifiConfig() + configData.msg = NetworkConfigMsgType.typeCmdApplyWifiConfig return try securityLayer.encrypt(data: configData.serializedData()) } - + private func createGetWifiConfigRequest() throws -> Data? { ESPLog.log("Create get Wi-Fi config request.") - var configData = Espressif_WiFiConfigPayload() - configData.cmdGetStatus = Espressif_CmdGetStatus() - configData.msg = Espressif_WiFiConfigMsgType.typeCmdGetStatus - + var configData = NetworkConfigPayload() + configData.cmdGetWifiStatus = CmdGetWifiStatus() + configData.msg = NetworkConfigMsgType.typeCmdGetWifiStatus return try securityLayer.encrypt(data: configData.serializedData()) } - - private func processSetWifiConfigResponse(response: Data?) -> Espressif_Status { + + private func processSetWifiConfigResponse(response: Data?) -> Status { ESPLog.log("Process set Wi-Fi config response.") guard let response = response else { - return Espressif_Status.invalidArgument + return Status.invalidArgument } let decryptedResponse = securityLayer.decrypt(data: response)! - var responseStatus: Espressif_Status = .invalidArgument + var responseStatus: Status = .invalidArgument do { - let configResponse = try Espressif_WiFiConfigPayload(serializedData: decryptedResponse) - responseStatus = configResponse.respGetStatus.status + let configResponse = try NetworkConfigPayload(serializedData: decryptedResponse) + responseStatus = configResponse.respGetWifiStatus.status } catch { ESPLog.log(error.localizedDescription) } return responseStatus } - private func processApplyConfigResponse(response: Data?) -> Espressif_Status { + private func processApplyConfigResponse(response: Data?) -> Status { ESPLog.log("Process apply Wi-Fi config response.") guard let response = response else { - return Espressif_Status.invalidArgument + return Status.invalidArgument } let decryptedResponse = securityLayer.decrypt(data: response)! - var responseStatus: Espressif_Status = .invalidArgument + var responseStatus: Status = .invalidArgument do { - let configResponse = try Espressif_WiFiConfigPayload(serializedData: decryptedResponse) - responseStatus = configResponse.respApplyConfig.status + let configResponse = try NetworkConfigPayload(serializedData: decryptedResponse) + responseStatus = configResponse.respApplyWifiConfig.status } catch { ESPLog.log(error.localizedDescription) } return responseStatus } - private func processGetWifiConfigStatusResponse(response: Data?) throws -> (Espressif_WifiStationState, Espressif_WifiConnectFailedReason) { + private func processGetWifiConfigStatusResponse(response: Data?) throws -> (WifiStationState, WifiConnectFailedReason) { ESPLog.log("Process get Wi-Fi config status response.") guard let response = response else { - return (Espressif_WifiStationState.disconnected, Espressif_WifiConnectFailedReason.UNRECOGNIZED(-1)) + return (WifiStationState.disconnected, WifiConnectFailedReason.UNRECOGNIZED(-1)) } let decryptedResponse = securityLayer.decrypt(data: response)! - var responseStatus = Espressif_WifiStationState.disconnected - var failReason = Espressif_WifiConnectFailedReason.UNRECOGNIZED(-1) - let configResponse = try Espressif_WiFiConfigPayload(serializedData: decryptedResponse) - responseStatus = configResponse.respGetStatus.staState - failReason = configResponse.respGetStatus.failReason + var responseStatus = WifiStationState.disconnected + var failReason = WifiConnectFailedReason.UNRECOGNIZED(-1) + let configResponse = try NetworkConfigPayload(serializedData: decryptedResponse) + responseStatus = configResponse.respGetWifiStatus.wifiStaState + failReason = configResponse.respGetWifiStatus.wifiFailReason if (responseStatus == .connected){ - self.wifiConnectedIp4Addr = configResponse.respGetStatus.connected.ip4Addr + self.wifiConnectedIp4Addr = configResponse.respGetWifiStatus.wifiConnected.ip4Addr + } + + return (responseStatus, failReason) + } + + //MARK: Thread APIs + private func createGetThreadConfigRequest() throws -> Data? { + ESPLog.log("Create get Wi-Fi config request.") + var configData = NetworkConfigPayload() + configData.cmdGetThreadStatus = CmdGetThreadStatus() + configData.msg = NetworkConfigMsgType.typeCmdGetThreadStatus + + return try securityLayer.encrypt(data: configData.serializedData()) + } + + private func createApplyThreadConfigRequest() throws -> Data? { + ESPLog.log("Create apply config request.") + var configData = NetworkConfigPayload() + configData.cmdApplyThreadConfig = CmdApplyThreadConfig() + configData.msg = NetworkConfigMsgType.typeCmdApplyThreadConfig + return try securityLayer.encrypt(data: configData.serializedData()) + } + + private func processSetThreadConfigResponse(response: Data?) -> Status { + ESPLog.log("Process set Wi-Fi config response.") + guard let response = response else { + return Status.invalidArgument + } + + let decryptedResponse = securityLayer.decrypt(data: response)! + var responseStatus: Status = .invalidArgument + do { + let configResponse = try NetworkConfigPayload(serializedData: decryptedResponse) + responseStatus = configResponse.respGetThreadStatus.status + } catch { + ESPLog.log(error.localizedDescription) + } + return responseStatus + } + + private func pollForThreadConnectionStatus(completionHandler: @escaping (ThreadNetworkState, ThreadAttachFailedReason, Error?) -> Swift.Void) { + do { + ESPLog.log("Start polling for Wi-Fi connection status...") + let message = try createGetThreadConfigRequest() + if let message = message { + transportLayer.SendConfigData(path: transportLayer.utility.configPath, + data: message) { response, error in + guard error == nil, response != nil else { + ESPLog.log("Error on polling request: \(error.debugDescription)") + completionHandler(ThreadNetworkState.dettached, ThreadAttachFailedReason.UNRECOGNIZED(0), error) + return + } + + ESPLog.log("Response received.") + do { + let (stationState, failReason) = try + self.processGetThreadConfigStatusResponse(response: response) + if stationState == .attached { + ESPLog.log("Status: connected.") + completionHandler(stationState, ThreadAttachFailedReason.UNRECOGNIZED(0), nil) + } else if stationState == .attaching { + ESPLog.log("Status: connecting.") + sleep(5) + self.pollForThreadConnectionStatus(completionHandler: completionHandler) + } else { + ESPLog.log("Status: failed.") + completionHandler(stationState, failReason, nil) + } + } catch { + ESPLog.log("Error while processing response: \(error.localizedDescription)") + completionHandler(ThreadNetworkState.dettached, ThreadAttachFailedReason.UNRECOGNIZED(0), error) + } + } + } + } catch { + ESPLog.log("Error while creating polling request: \(error.localizedDescription)") + completionHandler(ThreadNetworkState.attachingFailed, ThreadAttachFailedReason.UNRECOGNIZED(0), error) + } + } + + private func processGetThreadConfigStatusResponse(response: Data?) throws -> (ThreadNetworkState, ThreadAttachFailedReason) { + ESPLog.log("Process get Wi-Fi config status response.") + guard let response = response else { + return (ThreadNetworkState.dettached, ThreadAttachFailedReason.UNRECOGNIZED(-1)) + } + + let decryptedResponse = securityLayer.decrypt(data: response)! + var responseStatus = ThreadNetworkState.dettached + var failReason = ThreadAttachFailedReason.UNRECOGNIZED(-1) + let configResponse = try NetworkConfigPayload(serializedData: decryptedResponse) + responseStatus = configResponse.respGetThreadStatus.threadState + failReason = configResponse.respGetThreadStatus.threadFailReason + + if (responseStatus == .attached){ + self.wifiConnectedIp4Addr = configResponse.respGetThreadStatus.threadAttached.name } return (responseStatus, failReason) } + + private func processApplyThreadConfigResponse(response: Data?) -> Status { + ESPLog.log("Process apply Thread config response.") + guard let response = response else { + return Status.invalidArgument + } + + let decryptedResponse = securityLayer.decrypt(data: response)! + var responseStatus: Status = .invalidArgument + do { + let configResponse = try NetworkConfigPayload(serializedData: decryptedResponse) + responseStatus = configResponse.respApplyThreadConfig.status + } catch { + ESPLog.log(error.localizedDescription) + } + return responseStatus + } + + /// Apply all current configurations on the device. + /// A typical flow will be + /// Initialize session -> Set config (1 or more times) -> Apply config + /// This API call will also start a poll for getting Wifi connection status from the device + /// + /// - Parameters: + /// - completionHandler: handler to be called when apply config message is sent + /// - wifiStatusUpdatedHandler: handler to be called when wifi status is updated on the device + func applyThreadConfigurations(completionHandler: @escaping (Status, Error?) -> Void, + threadStatusUpdatedHandler: @escaping (ThreadNetworkState, ThreadAttachFailedReason, Error?) -> Void) { + ESPLog.log("Applying Wi-Fi configuration...") + if session.isEstablished { + do { + let message = try createApplyThreadConfigRequest() + if let message = message { + transportLayer.SendConfigData(path: transportLayer.utility.configPath, data: message) { response, error in + guard error == nil, response != nil else { + ESPLog.log("Error while applying Wi-Fi configuration: \(error.debugDescription)") + completionHandler(Status.internalError, error) + return + } + ESPLog.log("Received response.") + let status = self.processApplyConfigResponse(response: response) + completionHandler(status, nil) + self.pollForThreadConnectionStatus { threadStatus, failReason, error in + threadStatusUpdatedHandler(threadStatus, failReason, error) + } + } + } + } catch { + ESPLog.log("Error while creating configuration request: \(error.localizedDescription)") + completionHandler(Status.internalError, error) + } + } + } } diff --git a/ESPProvision/ESPProvisionManager.swift b/ESPProvision/ESPProvisionManager.swift index c128ef5..cfb6a14 100644 --- a/ESPProvision/ESPProvisionManager.swift +++ b/ESPProvision/ESPProvisionManager.swift @@ -21,6 +21,21 @@ import UIKit import CoreBluetooth import AVFoundation +public enum ESPNetworkType: String { + /// Communicate over wifi + case wifi + /// Communicate over thread + case thread + + public init?(rawValue: String) { + switch rawValue.lowercased() { + case "wifi": self = .wifi + case "thread": self = .thread + default: return nil + } + } +} + /// Supported mode of communication with device. public enum ESPTransport: String { /// Communicate using bluetooth. @@ -296,9 +311,9 @@ public class ESPProvisionManager: NSObject, AVCaptureMetadataOutputObjectsDelega let decodeResponse = try decoder.decode(ESPScanResult.self, from: jsonData) switch decodeResponse.transport { case .ble: - createESPDevice(deviceName: decodeResponse.name, transport: decodeResponse.transport, security: decodeResponse.security, proofOfPossession: decodeResponse.pop, username: decodeResponse.username, completionHandler: scanCompletionHandler) + createESPDevice(deviceName: decodeResponse.name, transport: decodeResponse.transport, security: decodeResponse.security, proofOfPossession: decodeResponse.pop, username: decodeResponse.username, network: decodeResponse.network, completionHandler: scanCompletionHandler) default: - createESPDevice(deviceName: decodeResponse.name, transport: decodeResponse.transport, security: decodeResponse.security, proofOfPossession: decodeResponse.pop, softAPPassword: decodeResponse.password ?? "", username: decodeResponse.username, completionHandler: scanCompletionHandler) + createESPDevice(deviceName: decodeResponse.name, transport: decodeResponse.transport, security: decodeResponse.security, proofOfPossession: decodeResponse.pop, softAPPassword: decodeResponse.password ?? "", username: decodeResponse.username, network: decodeResponse.network, completionHandler: scanCompletionHandler) } } catch { @@ -318,7 +333,7 @@ public class ESPProvisionManager: NSObject, AVCaptureMetadataOutputObjectsDelega /// - security: Security mode for communication. /// - completionHandler: The completion handler is invoked with parameters containing newly created device object. /// Error in case where method fails to return a device object. - public func createESPDevice(deviceName: String, transport: ESPTransport, security: ESPSecurity = .secure2, proofOfPossession:String? = nil, softAPPassword:String? = nil, username:String? = nil, completionHandler: @escaping (ESPDevice?,ESPDeviceCSSError?) -> Void) { + public func createESPDevice(deviceName: String, transport: ESPTransport, security: ESPSecurity = .secure2, proofOfPossession:String? = nil, softAPPassword:String? = nil, username:String? = nil, network: ESPNetworkType? = nil, completionHandler: @escaping (ESPDevice?,ESPDeviceCSSError?) -> Void) { ESPLog.log("Creating ESPDevice...") @@ -328,11 +343,11 @@ public class ESPProvisionManager: NSObject, AVCaptureMetadataOutputObjectsDelega self.scanCompletionHandler = completionHandler self.security = security self.scanStatusBlock?(.searchingBLE(deviceName)) - espBleTransport = ESPBleTransport(scanTimeout: 5.0, deviceNamePrefix: deviceName, proofOfPossession: proofOfPossession, username: username) + espBleTransport = ESPBleTransport(scanTimeout: 5.0, deviceNamePrefix: deviceName, proofOfPossession: proofOfPossession, username: username, network: network) espBleTransport.scan(delegate: self) default: self.scanStatusBlock?(.joiningSoftAP(deviceName)) - let newDevice = ESPDevice(name: deviceName, security: security, transport: transport, proofOfPossession: proofOfPossession, username:username, softAPPassword: softAPPassword) + let newDevice = ESPDevice(name: deviceName, security: security, transport: transport, proofOfPossession: proofOfPossession, username:username, network: network, softAPPassword: softAPPassword) ESPLog.log("SoftAp device created successfully.") completionHandler(newDevice, nil) } diff --git a/ESPProvision/ESPThreadManager.swift b/ESPProvision/ESPThreadManager.swift new file mode 100644 index 0000000..086dd0c --- /dev/null +++ b/ESPProvision/ESPThreadManager.swift @@ -0,0 +1,194 @@ +// Copyright 2024 Espressif Systems +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ESPThreadManager.swift +// ESPProvision +// + +import Foundation + +/// `ESPScanWifiListProtocol` provides Wi-Fi scan result to conforming class. +protocol ESPScanThreadListProtocol { + func threadScanFinished(threadList: [ESPThreadNetwork]?, error: ESPThreadScanError?) +} + +/// The `ESPWiFiManager` class manages methods related with Wi-Fi scanning and processing. +class ESPThreadManager { + private let transport: ESPCommunicable + private let security: ESPCodeable + private var scanResult: [String: ThreadScanResult] = [:] + + var delegate: ESPScanThreadListProtocol? + + /// Initialise Wi-Fi manager instance. + /// + /// - Parameter session: Session associated with `ESPDevice`. + init(session: ESPSession) { + transport = session.transportLayer + security = session.securityLayer + } + + /// Send command to `ESPDevice` to start scanning for available Wi-Fi networks. + func startThreadScan() { + do { + let payloadData = try createStartScanRequest() + if let data = payloadData { + transport.SendConfigData(path: transport.utility.scanPath, data: data) { response, error in + guard error == nil, response != nil else { + self.delegate?.threadScanFinished(threadList: nil, error: .scanRequestError(error!)) + return + } + self.processStartScan(responseData: response!) + self.getThreadScanStatus() + } + } else { + delegate?.threadScanFinished(threadList: nil, error: .emptyConfigData) + } + } catch { + delegate?.threadScanFinished(threadList: nil, error: .scanRequestError(error)) + } + } + + private func processStartScan(responseData: Data) { + let decryptedResponse = (security.encrypt(data: responseData))! + do { + _ = try NetworkScanPayload(serializedData: decryptedResponse) + } catch { + delegate?.threadScanFinished(threadList: nil, error: .scanRequestError(error)) + } + } + + private func getThreadScanStatus() { + do { + let payloadData = try createThreadScanConfigRequest() + if let data = payloadData { + transport.SendConfigData(path: transport.utility.scanPath, data: data) { response, error in + guard error == nil, response != nil else { + self.delegate?.threadScanFinished(threadList: nil, error: .scanRequestError(error!)) + return + } + let scanCount = self.processGetThreadScanStatus(responseData: response!) + if scanCount > 0 { + self.getScannedThreadListResponse(count: scanCount) + } else { + self.delegate?.threadScanFinished(threadList: nil, error: .emptyResultCount) + } + } + } + } catch { + delegate?.threadScanFinished(threadList: nil, error: .scanRequestError(error)) + } + } + + func processGetThreadScanStatus(responseData: Data) -> UInt32 { + let resultCount: UInt32 = 0 + if let decryptedResponse = security.decrypt(data: responseData) { + do { + let payload = try NetworkScanPayload(serializedData: decryptedResponse) + let response = payload.respScanThreadStatus + return response.resultCount + } catch { + delegate?.threadScanFinished(threadList: nil, error: .scanRequestError(error)) + } + } + return resultCount + } + + func getScannedThreadListResponse(count: UInt32, startIndex: UInt32 = 0) { + do { + var lastFetch = false + var fetchCount: UInt32 = 4 + if startIndex + 4 >= count { + fetchCount = count - startIndex + lastFetch = true + } + let payloadData = try createThreadListConfigRequest(startIndex: startIndex, count: fetchCount) + if let data = payloadData { + transport.SendConfigData(path: transport.utility.scanPath, data: data) { response, error in + guard error == nil, response != nil else { + self.delegate?.threadScanFinished(threadList: nil, error: .scanRequestError(error!)) + return + } + self.getScannedThreadNetworks(response: response!, fetchFinish: lastFetch) + if startIndex + fetchCount < count { + self.getScannedThreadListResponse(count: count, startIndex: startIndex + 4) + } + } + } else { + delegate?.threadScanFinished(threadList: nil, error: .emptyConfigData) + } + } catch { + delegate?.threadScanFinished(threadList: nil, error: .scanRequestError(error)) + } + } + + private func getScannedThreadNetworks(response: Data, fetchFinish: Bool) { + do { + if let decryptedResponse = try security.decrypt(data: response) { + let payload = try NetworkScanPayload(serializedData: decryptedResponse) + let responseList = payload.respScanThreadResult + for index in 0 ... responseList.entries.count - 1 { + let networkName = responseList.entries[index].networkName + scanResult[networkName] = responseList.entries[index] + } + if fetchFinish { + var threadList:[ESPThreadNetwork] = [] + for item in [ThreadScanResult](scanResult.values) { + let threadNetwork = ESPThreadNetwork(panID: item.panID, channel: item.channel, rssi: item.rssi, lqi: item.lqi, extAddr: item.extAddr, networkName: item.networkName, extPanID: item.extPanID) + threadList.append(threadNetwork) + } + if threadList.isEmpty { + delegate?.threadScanFinished(threadList: nil, error: nil) + } else { + delegate?.threadScanFinished(threadList: threadList, error: nil) + } + } + } + } catch { + delegate?.threadScanFinished(threadList: nil, error: .scanRequestError(error)) + } + } + + private func createStartScanRequest() throws -> Data? { + var configRequest = CmdScanThreadStart() + configRequest.blocking = true + configRequest.channelMask = 0 + let msgType = NetworkScanMsgType.typeCmdScanThreadStart + var payload = NetworkScanPayload() + payload.msg = msgType + payload.cmdScanThreadStart = configRequest + return try security.encrypt(data: payload.serializedData()) + } + + private func createThreadScanConfigRequest() throws -> Data? { + let configRequest = CmdScanThreadStatus() + let msgType = NetworkScanMsgType.typeCmdScanThreadStatus + var payload = NetworkScanPayload() + payload.msg = msgType + payload.cmdScanThreadStatus = configRequest + return try security.encrypt(data: payload.serializedData()) + } + + private func createThreadListConfigRequest(startIndex: UInt32, count: UInt32) throws -> Data? { + var configRequest = CmdScanThreadResult() + configRequest.startIndex = startIndex + configRequest.count = count + var payload = NetworkScanPayload() + payload.msg = NetworkScanMsgType.typeCmdScanThreadResult + payload.cmdScanThreadResult = configRequest + return try security.encrypt(data: payload.serializedData()) + } +} + + diff --git a/ESPProvision/ESPWiFiManager.swift b/ESPProvision/ESPWiFiManager.swift index c8bd1ff..1a20953 100644 --- a/ESPProvision/ESPWiFiManager.swift +++ b/ESPProvision/ESPWiFiManager.swift @@ -27,7 +27,7 @@ protocol ESPScanWifiListProtocol { class ESPWiFiManager { private let transport: ESPCommunicable private let security: ESPCodeable - private var scanResult: [String: Espressif_WiFiScanResult] = [:] + private var scanResult: [String: WiFiScanResult] = [:] var delegate: ESPScanWifiListProtocol? @@ -63,7 +63,7 @@ class ESPWiFiManager { private func processStartScan(responseData: Data) { let decryptedResponse = (security.encrypt(data: responseData))! do { - _ = try Espressif_WiFiScanPayload(serializedData: decryptedResponse) + _ = try NetworkScanPayload(serializedData: decryptedResponse) } catch { delegate?.wifiScanFinished(wifiList: nil, error: .scanRequestError(error)) } @@ -95,8 +95,8 @@ class ESPWiFiManager { let resultCount: UInt32 = 0 if let decryptedResponse = security.decrypt(data: responseData) { do { - let payload = try Espressif_WiFiScanPayload(serializedData: decryptedResponse) - let response = payload.respScanStatus + let payload = try NetworkScanPayload(serializedData: decryptedResponse) + let response = payload.respScanWifiStatus return response.resultCount } catch { delegate?.wifiScanFinished(wifiList: nil, error: .scanRequestError(error)) @@ -136,8 +136,8 @@ class ESPWiFiManager { private func getScannedWifiSSIDs(response: Data, fetchFinish: Bool) { do { if let decryptedResponse = try security.decrypt(data: response) { - let payload = try Espressif_WiFiScanPayload(serializedData: decryptedResponse) - let responseList = payload.respScanResult + let payload = try NetworkScanPayload(serializedData: decryptedResponse) + let responseList = payload.respScanWifiResult for index in 0 ... responseList.entries.count - 1 { let ssid = String(decoding: responseList.entries[index].ssid, as: UTF8.self) let rssi = responseList.entries[index].rssi @@ -151,7 +151,7 @@ class ESPWiFiManager { } if fetchFinish { var wifiList:[ESPWifiNetwork] = [] - for item in [Espressif_WiFiScanResult](scanResult.values) { + for item in [WiFiScanResult](scanResult.values) { let wifiNetwork = ESPWifiNetwork(ssid: String(decoding: item.ssid, as: UTF8.self), channel: item.channel, rssi: item.rssi, bssid: item.bssid, auth: item.auth, unknownFields: item.unknownFields) wifiList.append(wifiNetwork) } @@ -168,34 +168,34 @@ class ESPWiFiManager { } private func createStartScanRequest() throws -> Data? { - var configRequest = Espressif_CmdScanStart() + var configRequest = CmdScanWifiStart() configRequest.blocking = true configRequest.passive = false configRequest.groupChannels = 0 configRequest.periodMs = 120 - let msgType = Espressif_WiFiScanMsgType.typeCmdScanStart - var payload = Espressif_WiFiScanPayload() + let msgType = NetworkScanMsgType.typeCmdScanWifiStart + var payload = NetworkScanPayload() payload.msg = msgType - payload.cmdScanStart = configRequest + payload.cmdScanWifiStart = configRequest return try security.encrypt(data: payload.serializedData()) } private func createWifiScanConfigRequest() throws -> Data? { - let configRequest = Espressif_CmdScanStatus() - let msgType = Espressif_WiFiScanMsgType.typeCmdScanStatus - var payload = Espressif_WiFiScanPayload() + var configRequest = CmdScanWifiStatus() + let msgType = NetworkScanMsgType.typeCmdScanWifiStatus + var payload = NetworkScanPayload() payload.msg = msgType - payload.cmdScanStatus = configRequest + payload.cmdScanWifiStatus = configRequest return try security.encrypt(data: payload.serializedData()) } private func createWifiListConfigRequest(startIndex: UInt32, count: UInt32) throws -> Data? { - var configRequest = Espressif_CmdScanResult() + var configRequest = CmdScanWifiResult() configRequest.startIndex = startIndex configRequest.count = count - var payload = Espressif_WiFiScanPayload() - payload.msg = Espressif_WiFiScanMsgType.typeCmdScanResult - payload.cmdScanResult = configRequest + var payload = NetworkScanPayload() + payload.msg = NetworkScanMsgType.typeCmdScanWifiResult + payload.cmdScanWifiResult = configRequest return try security.encrypt(data: payload.serializedData()) } } diff --git a/ESPProvision/Model/ESPScanResult.swift b/ESPProvision/Model/ESPScanResult.swift index 22bed3b..b42e86d 100644 --- a/ESPProvision/Model/ESPScanResult.swift +++ b/ESPProvision/Model/ESPScanResult.swift @@ -29,6 +29,7 @@ struct ESPScanResult: Decodable { var security: ESPSecurity var transport: ESPTransport var password: String? + var network: ESPNetworkType? enum CodingKeys: String, CodingKey { case name @@ -37,6 +38,7 @@ struct ESPScanResult: Decodable { case security case transport case password + case network } init(from decoder: Decoder) throws { @@ -54,5 +56,8 @@ struct ESPScanResult: Decodable { throw ESPScanError.invalidQRCode } password = try container.decodeIfPresent(String.self, forKey: .password) + if let networkType = try? container.decodeIfPresent(String.self, forKey: .network) { + network = ESPNetworkType(rawValue: networkType) + } } } diff --git a/ESPProvision/Model/ESPThreadNetwork.swift b/ESPProvision/Model/ESPThreadNetwork.swift new file mode 100644 index 0000000..85608b1 --- /dev/null +++ b/ESPProvision/Model/ESPThreadNetwork.swift @@ -0,0 +1,40 @@ +// Copyright 2024 Espressif Systems +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ESPThreadNetwork.swift +// ESPProvision +// +// + +import Foundation +import SwiftProtobuf + +/// Type that represent a single Wi-Fi network. +/// Array of this object is returned when scan Wi-Fi command is given to ESPDevice. +public struct ESPThreadNetwork { + + public var panID: UInt32 = 0 + + public var channel: UInt32 = 0 + + public var rssi: Int32 = 0 + + public var lqi: UInt32 = 0 + + public var extAddr: Data = Data() + + public var networkName: String = String() + + public var extPanID: Data = Data() +} diff --git a/ESPProvision/Model/ESPWifiNetwork.swift b/ESPProvision/Model/ESPWifiNetwork.swift index 4132c2c..3fd1dff 100644 --- a/ESPProvision/Model/ESPWifiNetwork.swift +++ b/ESPProvision/Model/ESPWifiNetwork.swift @@ -33,7 +33,7 @@ public struct ESPWifiNetwork { /// The mac address of wireless network. public var bssid: Data = SwiftProtobuf.Internal.emptyData /// The authorisation mode of wireless network. - public var auth: Espressif_WifiAuthMode = .open + public var auth: WifiAuthMode = .open /// Contains uncategorized additional info of wireless network. public var unknownFields = SwiftProtobuf.UnknownStorage() } diff --git a/ESPProvision/Proto/constants.pb.swift b/ESPProvision/Proto/constants.pb.swift index 0bff611..70deaa8 100644 --- a/ESPProvision/Proto/constants.pb.swift +++ b/ESPProvision/Proto/constants.pb.swift @@ -1,4 +1,5 @@ // DO NOT EDIT. +// swift-format-ignore-file // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: constants.proto @@ -6,107 +7,100 @@ // For information on using the generated types, please see the documentation: // https://github.com/apple/swift-protobuf/ -// Copyright 2020 Espressif Systems -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - import Foundation import SwiftProtobuf // If the compiler emits an error on this type, it is because this file // was generated by a version of the `protoc` Swift plug-in that is // incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that your are building against the same version of the API +// Please ensure that you are building against the same version of the API // that was used to generate this file. -private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 } -enum Espressif_Status: SwiftProtobuf.Enum { - typealias RawValue = Int - case success // = 0 - case invalidSecScheme // = 1 - case invalidProto // = 2 - case tooManySessions // = 3 - case invalidArgument // = 4 - case internalError // = 5 - case cryptoError // = 6 - case invalidSession // = 7 - case UNRECOGNIZED(Int) +/// Allowed values for the status +/// of a protocomm instance +enum Status: SwiftProtobuf.Enum { + typealias RawValue = Int + case success // = 0 + case invalidSecScheme // = 1 + case invalidProto // = 2 + case tooManySessions // = 3 + case invalidArgument // = 4 + case internalError // = 5 + case cryptoError // = 6 + case invalidSession // = 7 + case UNRECOGNIZED(Int) - init() { - self = .success - } + init() { + self = .success + } - init?(rawValue: Int) { - switch rawValue { - case 0: self = .success - case 1: self = .invalidSecScheme - case 2: self = .invalidProto - case 3: self = .tooManySessions - case 4: self = .invalidArgument - case 5: self = .internalError - case 6: self = .cryptoError - case 7: self = .invalidSession - default: self = .UNRECOGNIZED(rawValue) - } + init?(rawValue: Int) { + switch rawValue { + case 0: self = .success + case 1: self = .invalidSecScheme + case 2: self = .invalidProto + case 3: self = .tooManySessions + case 4: self = .invalidArgument + case 5: self = .internalError + case 6: self = .cryptoError + case 7: self = .invalidSession + default: self = .UNRECOGNIZED(rawValue) } + } - var rawValue: Int { - switch self { - case .success: return 0 - case .invalidSecScheme: return 1 - case .invalidProto: return 2 - case .tooManySessions: return 3 - case .invalidArgument: return 4 - case .internalError: return 5 - case .cryptoError: return 6 - case .invalidSession: return 7 - case let .UNRECOGNIZED(i): return i - } + var rawValue: Int { + switch self { + case .success: return 0 + case .invalidSecScheme: return 1 + case .invalidProto: return 2 + case .tooManySessions: return 3 + case .invalidArgument: return 4 + case .internalError: return 5 + case .cryptoError: return 6 + case .invalidSession: return 7 + case .UNRECOGNIZED(let i): return i } + } + } #if swift(>=4.2) - extension Espressif_Status: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Espressif_Status] = [ - .success, - .invalidSecScheme, - .invalidProto, - .tooManySessions, - .invalidArgument, - .internalError, - .cryptoError, - .invalidSession, - ] - } +extension Status: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + static let allCases: [Status] = [ + .success, + .invalidSecScheme, + .invalidProto, + .tooManySessions, + .invalidArgument, + .internalError, + .cryptoError, + .invalidSession, + ] +} + +#endif // swift(>=4.2) -#endif // swift(>=4.2) +#if swift(>=5.5) && canImport(_Concurrency) +extension Status: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) // MARK: - Code below here is support for the SwiftProtobuf runtime. -extension Espressif_Status: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "Success"), - 1: .same(proto: "InvalidSecScheme"), - 2: .same(proto: "InvalidProto"), - 3: .same(proto: "TooManySessions"), - 4: .same(proto: "InvalidArgument"), - 5: .same(proto: "InternalError"), - 6: .same(proto: "CryptoError"), - 7: .same(proto: "InvalidSession"), - ] +extension Status: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "Success"), + 1: .same(proto: "InvalidSecScheme"), + 2: .same(proto: "InvalidProto"), + 3: .same(proto: "TooManySessions"), + 4: .same(proto: "InvalidArgument"), + 5: .same(proto: "InternalError"), + 6: .same(proto: "CryptoError"), + 7: .same(proto: "InvalidSession"), + ] } diff --git a/ESPProvision/Proto/network_config.pb.swift b/ESPProvision/Proto/network_config.pb.swift new file mode 100644 index 0000000..00e04f9 --- /dev/null +++ b/ESPProvision/Proto/network_config.pb.swift @@ -0,0 +1,1250 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: network_config.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +enum NetworkConfigMsgType: SwiftProtobuf.Enum { + typealias RawValue = Int + case typeCmdGetWifiStatus // = 0 + case typeRespGetWifiStatus // = 1 + case typeCmdSetWifiConfig // = 2 + case typeRespSetWifiConfig // = 3 + case typeCmdApplyWifiConfig // = 4 + case typeRespApplyWifiConfig // = 5 + case typeCmdGetThreadStatus // = 6 + case typeRespGetThreadStatus // = 7 + case typeCmdSetThreadConfig // = 8 + case typeRespSetThreadConfig // = 9 + case typeCmdApplyThreadConfig // = 10 + case typeRespApplyThreadConfig // = 11 + case UNRECOGNIZED(Int) + + init() { + self = .typeCmdGetWifiStatus + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .typeCmdGetWifiStatus + case 1: self = .typeRespGetWifiStatus + case 2: self = .typeCmdSetWifiConfig + case 3: self = .typeRespSetWifiConfig + case 4: self = .typeCmdApplyWifiConfig + case 5: self = .typeRespApplyWifiConfig + case 6: self = .typeCmdGetThreadStatus + case 7: self = .typeRespGetThreadStatus + case 8: self = .typeCmdSetThreadConfig + case 9: self = .typeRespSetThreadConfig + case 10: self = .typeCmdApplyThreadConfig + case 11: self = .typeRespApplyThreadConfig + default: self = .UNRECOGNIZED(rawValue) + } + } + + var rawValue: Int { + switch self { + case .typeCmdGetWifiStatus: return 0 + case .typeRespGetWifiStatus: return 1 + case .typeCmdSetWifiConfig: return 2 + case .typeRespSetWifiConfig: return 3 + case .typeCmdApplyWifiConfig: return 4 + case .typeRespApplyWifiConfig: return 5 + case .typeCmdGetThreadStatus: return 6 + case .typeRespGetThreadStatus: return 7 + case .typeCmdSetThreadConfig: return 8 + case .typeRespSetThreadConfig: return 9 + case .typeCmdApplyThreadConfig: return 10 + case .typeRespApplyThreadConfig: return 11 + case .UNRECOGNIZED(let i): return i + } + } + +} + +#if swift(>=4.2) + +extension NetworkConfigMsgType: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + static let allCases: [NetworkConfigMsgType] = [ + .typeCmdGetWifiStatus, + .typeRespGetWifiStatus, + .typeCmdSetWifiConfig, + .typeRespSetWifiConfig, + .typeCmdApplyWifiConfig, + .typeRespApplyWifiConfig, + .typeCmdGetThreadStatus, + .typeRespGetThreadStatus, + .typeCmdSetThreadConfig, + .typeRespSetThreadConfig, + .typeCmdApplyThreadConfig, + .typeRespApplyThreadConfig, + ] +} + +#endif // swift(>=4.2) + +struct CmdGetWifiStatus { + // 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. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RespGetWifiStatus { + // 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. + + var status: Status = .success + + var wifiStaState: WifiStationState = .connected + + var state: RespGetWifiStatus.OneOf_State? = nil + + var wifiFailReason: WifiConnectFailedReason { + get { + if case .wifiFailReason(let v)? = state {return v} + return .authError + } + set {state = .wifiFailReason(newValue)} + } + + var wifiConnected: WifiConnectedState { + get { + if case .wifiConnected(let v)? = state {return v} + return WifiConnectedState() + } + set {state = .wifiConnected(newValue)} + } + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum OneOf_State: Equatable { + case wifiFailReason(WifiConnectFailedReason) + case wifiConnected(WifiConnectedState) + + #if !swift(>=4.1) + static func ==(lhs: RespGetWifiStatus.OneOf_State, rhs: RespGetWifiStatus.OneOf_State) -> Bool { + // 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 (lhs, rhs) { + case (.wifiFailReason, .wifiFailReason): return { + guard case .wifiFailReason(let l) = lhs, case .wifiFailReason(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.wifiConnected, .wifiConnected): return { + guard case .wifiConnected(let l) = lhs, case .wifiConnected(let r) = rhs else { preconditionFailure() } + return l == r + }() + default: return false + } + } + #endif + } + + init() {} +} + +struct CmdGetThreadStatus { + // 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. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RespGetThreadStatus { + // 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. + + var status: Status = .success + + var threadState: ThreadNetworkState = .attached + + var state: RespGetThreadStatus.OneOf_State? = nil + + var threadFailReason: ThreadAttachFailedReason { + get { + if case .threadFailReason(let v)? = state {return v} + return .datasetInvalid + } + set {state = .threadFailReason(newValue)} + } + + var threadAttached: ThreadAttachState { + get { + if case .threadAttached(let v)? = state {return v} + return ThreadAttachState() + } + set {state = .threadAttached(newValue)} + } + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum OneOf_State: Equatable { + case threadFailReason(ThreadAttachFailedReason) + case threadAttached(ThreadAttachState) + + #if !swift(>=4.1) + static func ==(lhs: RespGetThreadStatus.OneOf_State, rhs: RespGetThreadStatus.OneOf_State) -> Bool { + // 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 (lhs, rhs) { + case (.threadFailReason, .threadFailReason): return { + guard case .threadFailReason(let l) = lhs, case .threadFailReason(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.threadAttached, .threadAttached): return { + guard case .threadAttached(let l) = lhs, case .threadAttached(let r) = rhs else { preconditionFailure() } + return l == r + }() + default: return false + } + } + #endif + } + + init() {} +} + +struct CmdSetWifiConfig { + // 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. + + var ssid: Data = Data() + + var passphrase: Data = Data() + + var bssid: Data = Data() + + var channel: Int32 = 0 + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct CmdSetThreadConfig { + // 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. + + var dataset: Data = Data() + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RespSetWifiConfig { + // 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. + + var status: Status = .success + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RespSetThreadConfig { + // 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. + + var status: Status = .success + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct CmdApplyWifiConfig { + // 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. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct CmdApplyThreadConfig { + // 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. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RespApplyWifiConfig { + // 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. + + var status: Status = .success + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RespApplyThreadConfig { + // 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. + + var status: Status = .success + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct NetworkConfigPayload { + // 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. + + var msg: NetworkConfigMsgType = .typeCmdGetWifiStatus + + var payload: NetworkConfigPayload.OneOf_Payload? = nil + + var cmdGetWifiStatus: CmdGetWifiStatus { + get { + if case .cmdGetWifiStatus(let v)? = payload {return v} + return CmdGetWifiStatus() + } + set {payload = .cmdGetWifiStatus(newValue)} + } + + var respGetWifiStatus: RespGetWifiStatus { + get { + if case .respGetWifiStatus(let v)? = payload {return v} + return RespGetWifiStatus() + } + set {payload = .respGetWifiStatus(newValue)} + } + + var cmdSetWifiConfig: CmdSetWifiConfig { + get { + if case .cmdSetWifiConfig(let v)? = payload {return v} + return CmdSetWifiConfig() + } + set {payload = .cmdSetWifiConfig(newValue)} + } + + var respSetWifiConfig: RespSetWifiConfig { + get { + if case .respSetWifiConfig(let v)? = payload {return v} + return RespSetWifiConfig() + } + set {payload = .respSetWifiConfig(newValue)} + } + + var cmdApplyWifiConfig: CmdApplyWifiConfig { + get { + if case .cmdApplyWifiConfig(let v)? = payload {return v} + return CmdApplyWifiConfig() + } + set {payload = .cmdApplyWifiConfig(newValue)} + } + + var respApplyWifiConfig: RespApplyWifiConfig { + get { + if case .respApplyWifiConfig(let v)? = payload {return v} + return RespApplyWifiConfig() + } + set {payload = .respApplyWifiConfig(newValue)} + } + + var cmdGetThreadStatus: CmdGetThreadStatus { + get { + if case .cmdGetThreadStatus(let v)? = payload {return v} + return CmdGetThreadStatus() + } + set {payload = .cmdGetThreadStatus(newValue)} + } + + var respGetThreadStatus: RespGetThreadStatus { + get { + if case .respGetThreadStatus(let v)? = payload {return v} + return RespGetThreadStatus() + } + set {payload = .respGetThreadStatus(newValue)} + } + + var cmdSetThreadConfig: CmdSetThreadConfig { + get { + if case .cmdSetThreadConfig(let v)? = payload {return v} + return CmdSetThreadConfig() + } + set {payload = .cmdSetThreadConfig(newValue)} + } + + var respSetThreadConfig: RespSetThreadConfig { + get { + if case .respSetThreadConfig(let v)? = payload {return v} + return RespSetThreadConfig() + } + set {payload = .respSetThreadConfig(newValue)} + } + + var cmdApplyThreadConfig: CmdApplyThreadConfig { + get { + if case .cmdApplyThreadConfig(let v)? = payload {return v} + return CmdApplyThreadConfig() + } + set {payload = .cmdApplyThreadConfig(newValue)} + } + + var respApplyThreadConfig: RespApplyThreadConfig { + get { + if case .respApplyThreadConfig(let v)? = payload {return v} + return RespApplyThreadConfig() + } + set {payload = .respApplyThreadConfig(newValue)} + } + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum OneOf_Payload: Equatable { + case cmdGetWifiStatus(CmdGetWifiStatus) + case respGetWifiStatus(RespGetWifiStatus) + case cmdSetWifiConfig(CmdSetWifiConfig) + case respSetWifiConfig(RespSetWifiConfig) + case cmdApplyWifiConfig(CmdApplyWifiConfig) + case respApplyWifiConfig(RespApplyWifiConfig) + case cmdGetThreadStatus(CmdGetThreadStatus) + case respGetThreadStatus(RespGetThreadStatus) + case cmdSetThreadConfig(CmdSetThreadConfig) + case respSetThreadConfig(RespSetThreadConfig) + case cmdApplyThreadConfig(CmdApplyThreadConfig) + case respApplyThreadConfig(RespApplyThreadConfig) + + #if !swift(>=4.1) + static func ==(lhs: NetworkConfigPayload.OneOf_Payload, rhs: NetworkConfigPayload.OneOf_Payload) -> Bool { + // 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 (lhs, rhs) { + case (.cmdGetWifiStatus, .cmdGetWifiStatus): return { + guard case .cmdGetWifiStatus(let l) = lhs, case .cmdGetWifiStatus(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.respGetWifiStatus, .respGetWifiStatus): return { + guard case .respGetWifiStatus(let l) = lhs, case .respGetWifiStatus(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.cmdSetWifiConfig, .cmdSetWifiConfig): return { + guard case .cmdSetWifiConfig(let l) = lhs, case .cmdSetWifiConfig(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.respSetWifiConfig, .respSetWifiConfig): return { + guard case .respSetWifiConfig(let l) = lhs, case .respSetWifiConfig(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.cmdApplyWifiConfig, .cmdApplyWifiConfig): return { + guard case .cmdApplyWifiConfig(let l) = lhs, case .cmdApplyWifiConfig(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.respApplyWifiConfig, .respApplyWifiConfig): return { + guard case .respApplyWifiConfig(let l) = lhs, case .respApplyWifiConfig(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.cmdGetThreadStatus, .cmdGetThreadStatus): return { + guard case .cmdGetThreadStatus(let l) = lhs, case .cmdGetThreadStatus(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.respGetThreadStatus, .respGetThreadStatus): return { + guard case .respGetThreadStatus(let l) = lhs, case .respGetThreadStatus(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.cmdSetThreadConfig, .cmdSetThreadConfig): return { + guard case .cmdSetThreadConfig(let l) = lhs, case .cmdSetThreadConfig(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.respSetThreadConfig, .respSetThreadConfig): return { + guard case .respSetThreadConfig(let l) = lhs, case .respSetThreadConfig(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.cmdApplyThreadConfig, .cmdApplyThreadConfig): return { + guard case .cmdApplyThreadConfig(let l) = lhs, case .cmdApplyThreadConfig(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.respApplyThreadConfig, .respApplyThreadConfig): return { + guard case .respApplyThreadConfig(let l) = lhs, case .respApplyThreadConfig(let r) = rhs else { preconditionFailure() } + return l == r + }() + default: return false + } + } + #endif + } + + init() {} +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension NetworkConfigMsgType: @unchecked Sendable {} +extension CmdGetWifiStatus: @unchecked Sendable {} +extension RespGetWifiStatus: @unchecked Sendable {} +extension RespGetWifiStatus.OneOf_State: @unchecked Sendable {} +extension CmdGetThreadStatus: @unchecked Sendable {} +extension RespGetThreadStatus: @unchecked Sendable {} +extension RespGetThreadStatus.OneOf_State: @unchecked Sendable {} +extension CmdSetWifiConfig: @unchecked Sendable {} +extension CmdSetThreadConfig: @unchecked Sendable {} +extension RespSetWifiConfig: @unchecked Sendable {} +extension RespSetThreadConfig: @unchecked Sendable {} +extension CmdApplyWifiConfig: @unchecked Sendable {} +extension CmdApplyThreadConfig: @unchecked Sendable {} +extension RespApplyWifiConfig: @unchecked Sendable {} +extension RespApplyThreadConfig: @unchecked Sendable {} +extension NetworkConfigPayload: @unchecked Sendable {} +extension NetworkConfigPayload.OneOf_Payload: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +extension NetworkConfigMsgType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "TypeCmdGetWifiStatus"), + 1: .same(proto: "TypeRespGetWifiStatus"), + 2: .same(proto: "TypeCmdSetWifiConfig"), + 3: .same(proto: "TypeRespSetWifiConfig"), + 4: .same(proto: "TypeCmdApplyWifiConfig"), + 5: .same(proto: "TypeRespApplyWifiConfig"), + 6: .same(proto: "TypeCmdGetThreadStatus"), + 7: .same(proto: "TypeRespGetThreadStatus"), + 8: .same(proto: "TypeCmdSetThreadConfig"), + 9: .same(proto: "TypeRespSetThreadConfig"), + 10: .same(proto: "TypeCmdApplyThreadConfig"), + 11: .same(proto: "TypeRespApplyThreadConfig"), + ] +} + +extension CmdGetWifiStatus: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "CmdGetWifiStatus" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: CmdGetWifiStatus, rhs: CmdGetWifiStatus) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RespGetWifiStatus: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RespGetWifiStatus" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "status"), + 2: .standard(proto: "wifi_sta_state"), + 10: .standard(proto: "wifi_fail_reason"), + 11: .standard(proto: "wifi_connected"), + ] + + 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.decodeSingularEnumField(value: &self.status) }() + case 2: try { try decoder.decodeSingularEnumField(value: &self.wifiStaState) }() + case 10: try { + var v: WifiConnectFailedReason? + try decoder.decodeSingularEnumField(value: &v) + if let v = v { + if self.state != nil {try decoder.handleConflictingOneOf()} + self.state = .wifiFailReason(v) + } + }() + case 11: try { + var v: WifiConnectedState? + var hadOneofValue = false + if let current = self.state { + hadOneofValue = true + if case .wifiConnected(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.state = .wifiConnected(v) + } + }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if self.status != .success { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 1) + } + if self.wifiStaState != .connected { + try visitor.visitSingularEnumField(value: self.wifiStaState, fieldNumber: 2) + } + switch self.state { + case .wifiFailReason?: try { + guard case .wifiFailReason(let v)? = self.state else { preconditionFailure() } + try visitor.visitSingularEnumField(value: v, fieldNumber: 10) + }() + case .wifiConnected?: try { + guard case .wifiConnected(let v)? = self.state else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 11) + }() + case nil: break + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RespGetWifiStatus, rhs: RespGetWifiStatus) -> Bool { + if lhs.status != rhs.status {return false} + if lhs.wifiStaState != rhs.wifiStaState {return false} + if lhs.state != rhs.state {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension CmdGetThreadStatus: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "CmdGetThreadStatus" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: CmdGetThreadStatus, rhs: CmdGetThreadStatus) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RespGetThreadStatus: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RespGetThreadStatus" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "status"), + 2: .standard(proto: "thread_state"), + 10: .standard(proto: "thread_fail_reason"), + 11: .standard(proto: "thread_attached"), + ] + + 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.decodeSingularEnumField(value: &self.status) }() + case 2: try { try decoder.decodeSingularEnumField(value: &self.threadState) }() + case 10: try { + var v: ThreadAttachFailedReason? + try decoder.decodeSingularEnumField(value: &v) + if let v = v { + if self.state != nil {try decoder.handleConflictingOneOf()} + self.state = .threadFailReason(v) + } + }() + case 11: try { + var v: ThreadAttachState? + var hadOneofValue = false + if let current = self.state { + hadOneofValue = true + if case .threadAttached(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.state = .threadAttached(v) + } + }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if self.status != .success { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 1) + } + if self.threadState != .attached { + try visitor.visitSingularEnumField(value: self.threadState, fieldNumber: 2) + } + switch self.state { + case .threadFailReason?: try { + guard case .threadFailReason(let v)? = self.state else { preconditionFailure() } + try visitor.visitSingularEnumField(value: v, fieldNumber: 10) + }() + case .threadAttached?: try { + guard case .threadAttached(let v)? = self.state else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 11) + }() + case nil: break + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RespGetThreadStatus, rhs: RespGetThreadStatus) -> Bool { + if lhs.status != rhs.status {return false} + if lhs.threadState != rhs.threadState {return false} + if lhs.state != rhs.state {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension CmdSetWifiConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "CmdSetWifiConfig" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "ssid"), + 2: .same(proto: "passphrase"), + 3: .same(proto: "bssid"), + 4: .same(proto: "channel"), + ] + + 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.decodeSingularBytesField(value: &self.ssid) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.passphrase) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self.bssid) }() + case 4: try { try decoder.decodeSingularInt32Field(value: &self.channel) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.ssid.isEmpty { + try visitor.visitSingularBytesField(value: self.ssid, fieldNumber: 1) + } + if !self.passphrase.isEmpty { + try visitor.visitSingularBytesField(value: self.passphrase, fieldNumber: 2) + } + if !self.bssid.isEmpty { + try visitor.visitSingularBytesField(value: self.bssid, fieldNumber: 3) + } + if self.channel != 0 { + try visitor.visitSingularInt32Field(value: self.channel, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: CmdSetWifiConfig, rhs: CmdSetWifiConfig) -> Bool { + if lhs.ssid != rhs.ssid {return false} + if lhs.passphrase != rhs.passphrase {return false} + if lhs.bssid != rhs.bssid {return false} + if lhs.channel != rhs.channel {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension CmdSetThreadConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "CmdSetThreadConfig" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "dataset"), + ] + + 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.decodeSingularBytesField(value: &self.dataset) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.dataset.isEmpty { + try visitor.visitSingularBytesField(value: self.dataset, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: CmdSetThreadConfig, rhs: CmdSetThreadConfig) -> Bool { + if lhs.dataset != rhs.dataset {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RespSetWifiConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RespSetWifiConfig" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "status"), + ] + + 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.decodeSingularEnumField(value: &self.status) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.status != .success { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RespSetWifiConfig, rhs: RespSetWifiConfig) -> Bool { + if lhs.status != rhs.status {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RespSetThreadConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RespSetThreadConfig" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "status"), + ] + + 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.decodeSingularEnumField(value: &self.status) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.status != .success { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RespSetThreadConfig, rhs: RespSetThreadConfig) -> Bool { + if lhs.status != rhs.status {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension CmdApplyWifiConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "CmdApplyWifiConfig" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: CmdApplyWifiConfig, rhs: CmdApplyWifiConfig) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension CmdApplyThreadConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "CmdApplyThreadConfig" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: CmdApplyThreadConfig, rhs: CmdApplyThreadConfig) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RespApplyWifiConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RespApplyWifiConfig" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "status"), + ] + + 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.decodeSingularEnumField(value: &self.status) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.status != .success { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RespApplyWifiConfig, rhs: RespApplyWifiConfig) -> Bool { + if lhs.status != rhs.status {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RespApplyThreadConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RespApplyThreadConfig" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "status"), + ] + + 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.decodeSingularEnumField(value: &self.status) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.status != .success { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RespApplyThreadConfig, rhs: RespApplyThreadConfig) -> Bool { + if lhs.status != rhs.status {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension NetworkConfigPayload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "NetworkConfigPayload" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "msg"), + 10: .standard(proto: "cmd_get_wifi_status"), + 11: .standard(proto: "resp_get_wifi_status"), + 12: .standard(proto: "cmd_set_wifi_config"), + 13: .standard(proto: "resp_set_wifi_config"), + 14: .standard(proto: "cmd_apply_wifi_config"), + 15: .standard(proto: "resp_apply_wifi_config"), + 16: .standard(proto: "cmd_get_thread_status"), + 17: .standard(proto: "resp_get_thread_status"), + 18: .standard(proto: "cmd_set_thread_config"), + 19: .standard(proto: "resp_set_thread_config"), + 20: .standard(proto: "cmd_apply_thread_config"), + 21: .standard(proto: "resp_apply_thread_config"), + ] + + 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.decodeSingularEnumField(value: &self.msg) }() + case 10: try { + var v: CmdGetWifiStatus? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .cmdGetWifiStatus(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .cmdGetWifiStatus(v) + } + }() + case 11: try { + var v: RespGetWifiStatus? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .respGetWifiStatus(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .respGetWifiStatus(v) + } + }() + case 12: try { + var v: CmdSetWifiConfig? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .cmdSetWifiConfig(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .cmdSetWifiConfig(v) + } + }() + case 13: try { + var v: RespSetWifiConfig? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .respSetWifiConfig(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .respSetWifiConfig(v) + } + }() + case 14: try { + var v: CmdApplyWifiConfig? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .cmdApplyWifiConfig(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .cmdApplyWifiConfig(v) + } + }() + case 15: try { + var v: RespApplyWifiConfig? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .respApplyWifiConfig(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .respApplyWifiConfig(v) + } + }() + case 16: try { + var v: CmdGetThreadStatus? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .cmdGetThreadStatus(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .cmdGetThreadStatus(v) + } + }() + case 17: try { + var v: RespGetThreadStatus? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .respGetThreadStatus(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .respGetThreadStatus(v) + } + }() + case 18: try { + var v: CmdSetThreadConfig? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .cmdSetThreadConfig(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .cmdSetThreadConfig(v) + } + }() + case 19: try { + var v: RespSetThreadConfig? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .respSetThreadConfig(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .respSetThreadConfig(v) + } + }() + case 20: try { + var v: CmdApplyThreadConfig? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .cmdApplyThreadConfig(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .cmdApplyThreadConfig(v) + } + }() + case 21: try { + var v: RespApplyThreadConfig? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .respApplyThreadConfig(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .respApplyThreadConfig(v) + } + }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if self.msg != .typeCmdGetWifiStatus { + try visitor.visitSingularEnumField(value: self.msg, fieldNumber: 1) + } + switch self.payload { + case .cmdGetWifiStatus?: try { + guard case .cmdGetWifiStatus(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 10) + }() + case .respGetWifiStatus?: try { + guard case .respGetWifiStatus(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 11) + }() + case .cmdSetWifiConfig?: try { + guard case .cmdSetWifiConfig(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 12) + }() + case .respSetWifiConfig?: try { + guard case .respSetWifiConfig(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 13) + }() + case .cmdApplyWifiConfig?: try { + guard case .cmdApplyWifiConfig(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 14) + }() + case .respApplyWifiConfig?: try { + guard case .respApplyWifiConfig(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 15) + }() + case .cmdGetThreadStatus?: try { + guard case .cmdGetThreadStatus(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 16) + }() + case .respGetThreadStatus?: try { + guard case .respGetThreadStatus(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 17) + }() + case .cmdSetThreadConfig?: try { + guard case .cmdSetThreadConfig(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 18) + }() + case .respSetThreadConfig?: try { + guard case .respSetThreadConfig(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 19) + }() + case .cmdApplyThreadConfig?: try { + guard case .cmdApplyThreadConfig(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 20) + }() + case .respApplyThreadConfig?: try { + guard case .respApplyThreadConfig(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 21) + }() + case nil: break + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: NetworkConfigPayload, rhs: NetworkConfigPayload) -> Bool { + if lhs.msg != rhs.msg {return false} + if lhs.payload != rhs.payload {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/ESPProvision/Proto/network_constants.pb.swift b/ESPProvision/Proto/network_constants.pb.swift new file mode 100644 index 0000000..43cd833 --- /dev/null +++ b/ESPProvision/Proto/network_constants.pb.swift @@ -0,0 +1,462 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: network_constants.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +enum WifiStationState: SwiftProtobuf.Enum { + typealias RawValue = Int + case connected // = 0 + case connecting // = 1 + case disconnected // = 2 + case connectionFailed // = 3 + case UNRECOGNIZED(Int) + + init() { + self = .connected + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .connected + case 1: self = .connecting + case 2: self = .disconnected + case 3: self = .connectionFailed + default: self = .UNRECOGNIZED(rawValue) + } + } + + var rawValue: Int { + switch self { + case .connected: return 0 + case .connecting: return 1 + case .disconnected: return 2 + case .connectionFailed: return 3 + case .UNRECOGNIZED(let i): return i + } + } + +} + +#if swift(>=4.2) + +extension WifiStationState: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + static let allCases: [WifiStationState] = [ + .connected, + .connecting, + .disconnected, + .connectionFailed, + ] +} + +#endif // swift(>=4.2) + +enum WifiConnectFailedReason: SwiftProtobuf.Enum { + typealias RawValue = Int + case authError // = 0 + case wifiNetworkNotFound // = 1 + case UNRECOGNIZED(Int) + + init() { + self = .authError + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .authError + case 1: self = .wifiNetworkNotFound + default: self = .UNRECOGNIZED(rawValue) + } + } + + var rawValue: Int { + switch self { + case .authError: return 0 + case .wifiNetworkNotFound: return 1 + case .UNRECOGNIZED(let i): return i + } + } + +} + +#if swift(>=4.2) + +extension WifiConnectFailedReason: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + static let allCases: [WifiConnectFailedReason] = [ + .authError, + .wifiNetworkNotFound, + ] +} + +#endif // swift(>=4.2) + +public enum WifiAuthMode: SwiftProtobuf.Enum { + public typealias RawValue = Int + case `open` // = 0 + case wep // = 1 + case wpaPsk // = 2 + case wpa2Psk // = 3 + case wpaWpa2Psk // = 4 + case wpa2Enterprise // = 5 + case wpa3Psk // = 6 + case wpa2Wpa3Psk // = 7 + case UNRECOGNIZED(Int) + + public init() { + self = .open + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .open + case 1: self = .wep + case 2: self = .wpaPsk + case 3: self = .wpa2Psk + case 4: self = .wpaWpa2Psk + case 5: self = .wpa2Enterprise + case 6: self = .wpa3Psk + case 7: self = .wpa2Wpa3Psk + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .open: return 0 + case .wep: return 1 + case .wpaPsk: return 2 + case .wpa2Psk: return 3 + case .wpaWpa2Psk: return 4 + case .wpa2Enterprise: return 5 + case .wpa3Psk: return 6 + case .wpa2Wpa3Psk: return 7 + case .UNRECOGNIZED(let i): return i + } + } + +} + +#if swift(>=4.2) + +extension WifiAuthMode: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [WifiAuthMode] = [ + .open, + .wep, + .wpaPsk, + .wpa2Psk, + .wpaWpa2Psk, + .wpa2Enterprise, + .wpa3Psk, + .wpa2Wpa3Psk, + ] +} + +#endif // swift(>=4.2) + +enum ThreadNetworkState: SwiftProtobuf.Enum { + typealias RawValue = Int + case attached // = 0 + case attaching // = 1 + case dettached // = 2 + case attachingFailed // = 3 + case UNRECOGNIZED(Int) + + init() { + self = .attached + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .attached + case 1: self = .attaching + case 2: self = .dettached + case 3: self = .attachingFailed + default: self = .UNRECOGNIZED(rawValue) + } + } + + var rawValue: Int { + switch self { + case .attached: return 0 + case .attaching: return 1 + case .dettached: return 2 + case .attachingFailed: return 3 + case .UNRECOGNIZED(let i): return i + } + } + +} + +#if swift(>=4.2) + +extension ThreadNetworkState: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + static let allCases: [ThreadNetworkState] = [ + .attached, + .attaching, + .dettached, + .attachingFailed, + ] +} + +#endif // swift(>=4.2) + +enum ThreadAttachFailedReason: SwiftProtobuf.Enum { + typealias RawValue = Int + case datasetInvalid // = 0 + case threadNetworkNotFound // = 1 + case UNRECOGNIZED(Int) + + init() { + self = .datasetInvalid + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .datasetInvalid + case 1: self = .threadNetworkNotFound + default: self = .UNRECOGNIZED(rawValue) + } + } + + var rawValue: Int { + switch self { + case .datasetInvalid: return 0 + case .threadNetworkNotFound: return 1 + case .UNRECOGNIZED(let i): return i + } + } + +} + +#if swift(>=4.2) + +extension ThreadAttachFailedReason: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + static let allCases: [ThreadAttachFailedReason] = [ + .datasetInvalid, + .threadNetworkNotFound, + ] +} + +#endif // swift(>=4.2) + +struct WifiConnectedState { + // 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. + + var ip4Addr: String = String() + + var authMode: WifiAuthMode = .open + + var ssid: Data = Data() + + var bssid: Data = Data() + + var channel: Int32 = 0 + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct ThreadAttachState { + // 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. + + var panID: UInt32 = 0 + + var extPanID: Data = Data() + + var channel: UInt32 = 0 + + var name: String = String() + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension WifiStationState: @unchecked Sendable {} +extension WifiConnectFailedReason: @unchecked Sendable {} +extension WifiAuthMode: @unchecked Sendable {} +extension ThreadNetworkState: @unchecked Sendable {} +extension ThreadAttachFailedReason: @unchecked Sendable {} +extension WifiConnectedState: @unchecked Sendable {} +extension ThreadAttachState: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +extension WifiStationState: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "Connected"), + 1: .same(proto: "Connecting"), + 2: .same(proto: "Disconnected"), + 3: .same(proto: "ConnectionFailed"), + ] +} + +extension WifiConnectFailedReason: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "AuthError"), + 1: .same(proto: "WifiNetworkNotFound"), + ] +} + +extension WifiAuthMode: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "Open"), + 1: .same(proto: "WEP"), + 2: .same(proto: "WPA_PSK"), + 3: .same(proto: "WPA2_PSK"), + 4: .same(proto: "WPA_WPA2_PSK"), + 5: .same(proto: "WPA2_ENTERPRISE"), + 6: .same(proto: "WPA3_PSK"), + 7: .same(proto: "WPA2_WPA3_PSK"), + ] +} + +extension ThreadNetworkState: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "Attached"), + 1: .same(proto: "Attaching"), + 2: .same(proto: "Dettached"), + 3: .same(proto: "AttachingFailed"), + ] +} + +extension ThreadAttachFailedReason: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "DatasetInvalid"), + 1: .same(proto: "ThreadNetworkNotFound"), + ] +} + +extension WifiConnectedState: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "WifiConnectedState" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "ip4_addr"), + 2: .standard(proto: "auth_mode"), + 3: .same(proto: "ssid"), + 4: .same(proto: "bssid"), + 5: .same(proto: "channel"), + ] + + 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.decodeSingularStringField(value: &self.ip4Addr) }() + case 2: try { try decoder.decodeSingularEnumField(value: &self.authMode) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self.ssid) }() + case 4: try { try decoder.decodeSingularBytesField(value: &self.bssid) }() + case 5: try { try decoder.decodeSingularInt32Field(value: &self.channel) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.ip4Addr.isEmpty { + try visitor.visitSingularStringField(value: self.ip4Addr, fieldNumber: 1) + } + if self.authMode != .open { + try visitor.visitSingularEnumField(value: self.authMode, fieldNumber: 2) + } + if !self.ssid.isEmpty { + try visitor.visitSingularBytesField(value: self.ssid, fieldNumber: 3) + } + if !self.bssid.isEmpty { + try visitor.visitSingularBytesField(value: self.bssid, fieldNumber: 4) + } + if self.channel != 0 { + try visitor.visitSingularInt32Field(value: self.channel, fieldNumber: 5) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: WifiConnectedState, rhs: WifiConnectedState) -> Bool { + if lhs.ip4Addr != rhs.ip4Addr {return false} + if lhs.authMode != rhs.authMode {return false} + if lhs.ssid != rhs.ssid {return false} + if lhs.bssid != rhs.bssid {return false} + if lhs.channel != rhs.channel {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension ThreadAttachState: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "ThreadAttachState" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "pan_id"), + 2: .standard(proto: "ext_pan_id"), + 3: .same(proto: "channel"), + 4: .same(proto: "name"), + ] + + 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.panID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.extPanID) }() + case 3: try { try decoder.decodeSingularUInt32Field(value: &self.channel) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.name) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.panID != 0 { + try visitor.visitSingularUInt32Field(value: self.panID, fieldNumber: 1) + } + if !self.extPanID.isEmpty { + try visitor.visitSingularBytesField(value: self.extPanID, fieldNumber: 2) + } + if self.channel != 0 { + try visitor.visitSingularUInt32Field(value: self.channel, fieldNumber: 3) + } + if !self.name.isEmpty { + try visitor.visitSingularStringField(value: self.name, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: ThreadAttachState, rhs: ThreadAttachState) -> Bool { + if lhs.panID != rhs.panID {return false} + if lhs.extPanID != rhs.extPanID {return false} + if lhs.channel != rhs.channel {return false} + if lhs.name != rhs.name {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/ESPProvision/Proto/network_ctrl.pb.swift b/ESPProvision/Proto/network_ctrl.pb.swift new file mode 100644 index 0000000..d067706 --- /dev/null +++ b/ESPProvision/Proto/network_ctrl.pb.swift @@ -0,0 +1,675 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: network_ctrl.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +enum NetworkCtrlMsgType: SwiftProtobuf.Enum { + typealias RawValue = Int + case typeCtrlReserved // = 0 + case typeCmdCtrlWifiReset // = 1 + case typeRespCtrlWifiReset // = 2 + case typeCmdCtrlWifiReprov // = 3 + case typeRespCtrlWifiReprov // = 4 + case typeCmdCtrlThreadReset // = 5 + case typeRespCtrlThreadReset // = 6 + case typeCmdCtrlThreadReprov // = 7 + case typeRespCtrlThreadReprov // = 8 + case UNRECOGNIZED(Int) + + init() { + self = .typeCtrlReserved + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .typeCtrlReserved + case 1: self = .typeCmdCtrlWifiReset + case 2: self = .typeRespCtrlWifiReset + case 3: self = .typeCmdCtrlWifiReprov + case 4: self = .typeRespCtrlWifiReprov + case 5: self = .typeCmdCtrlThreadReset + case 6: self = .typeRespCtrlThreadReset + case 7: self = .typeCmdCtrlThreadReprov + case 8: self = .typeRespCtrlThreadReprov + default: self = .UNRECOGNIZED(rawValue) + } + } + + var rawValue: Int { + switch self { + case .typeCtrlReserved: return 0 + case .typeCmdCtrlWifiReset: return 1 + case .typeRespCtrlWifiReset: return 2 + case .typeCmdCtrlWifiReprov: return 3 + case .typeRespCtrlWifiReprov: return 4 + case .typeCmdCtrlThreadReset: return 5 + case .typeRespCtrlThreadReset: return 6 + case .typeCmdCtrlThreadReprov: return 7 + case .typeRespCtrlThreadReprov: return 8 + case .UNRECOGNIZED(let i): return i + } + } + +} + +#if swift(>=4.2) + +extension NetworkCtrlMsgType: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + static let allCases: [NetworkCtrlMsgType] = [ + .typeCtrlReserved, + .typeCmdCtrlWifiReset, + .typeRespCtrlWifiReset, + .typeCmdCtrlWifiReprov, + .typeRespCtrlWifiReprov, + .typeCmdCtrlThreadReset, + .typeRespCtrlThreadReset, + .typeCmdCtrlThreadReprov, + .typeRespCtrlThreadReprov, + ] +} + +#endif // swift(>=4.2) + +struct CmdCtrlWifiReset { + // 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. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RespCtrlWifiReset { + // 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. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct CmdCtrlWifiReprov { + // 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. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RespCtrlWifiReprov { + // 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. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct CmdCtrlThreadReset { + // 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. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RespCtrlThreadReset { + // 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. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct CmdCtrlThreadReprov { + // 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. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RespCtrlThreadReprov { + // 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. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct NetworkCtrlPayload { + // 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. + + var msg: NetworkCtrlMsgType = .typeCtrlReserved + + var status: Status = .success + + var payload: NetworkCtrlPayload.OneOf_Payload? = nil + + var cmdCtrlWifiReset: CmdCtrlWifiReset { + get { + if case .cmdCtrlWifiReset(let v)? = payload {return v} + return CmdCtrlWifiReset() + } + set {payload = .cmdCtrlWifiReset(newValue)} + } + + var respCtrlWifiReset: RespCtrlWifiReset { + get { + if case .respCtrlWifiReset(let v)? = payload {return v} + return RespCtrlWifiReset() + } + set {payload = .respCtrlWifiReset(newValue)} + } + + var cmdCtrlWifiReprov: CmdCtrlWifiReprov { + get { + if case .cmdCtrlWifiReprov(let v)? = payload {return v} + return CmdCtrlWifiReprov() + } + set {payload = .cmdCtrlWifiReprov(newValue)} + } + + var respCtrlWifiReprov: RespCtrlWifiReprov { + get { + if case .respCtrlWifiReprov(let v)? = payload {return v} + return RespCtrlWifiReprov() + } + set {payload = .respCtrlWifiReprov(newValue)} + } + + var cmdCtrlThreadReset: CmdCtrlThreadReset { + get { + if case .cmdCtrlThreadReset(let v)? = payload {return v} + return CmdCtrlThreadReset() + } + set {payload = .cmdCtrlThreadReset(newValue)} + } + + var respCtrlThreadReset: RespCtrlThreadReset { + get { + if case .respCtrlThreadReset(let v)? = payload {return v} + return RespCtrlThreadReset() + } + set {payload = .respCtrlThreadReset(newValue)} + } + + var cmdCtrlThreadReprov: CmdCtrlThreadReprov { + get { + if case .cmdCtrlThreadReprov(let v)? = payload {return v} + return CmdCtrlThreadReprov() + } + set {payload = .cmdCtrlThreadReprov(newValue)} + } + + var respCtrlThreadReprov: RespCtrlThreadReprov { + get { + if case .respCtrlThreadReprov(let v)? = payload {return v} + return RespCtrlThreadReprov() + } + set {payload = .respCtrlThreadReprov(newValue)} + } + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum OneOf_Payload: Equatable { + case cmdCtrlWifiReset(CmdCtrlWifiReset) + case respCtrlWifiReset(RespCtrlWifiReset) + case cmdCtrlWifiReprov(CmdCtrlWifiReprov) + case respCtrlWifiReprov(RespCtrlWifiReprov) + case cmdCtrlThreadReset(CmdCtrlThreadReset) + case respCtrlThreadReset(RespCtrlThreadReset) + case cmdCtrlThreadReprov(CmdCtrlThreadReprov) + case respCtrlThreadReprov(RespCtrlThreadReprov) + + #if !swift(>=4.1) + static func ==(lhs: NetworkCtrlPayload.OneOf_Payload, rhs: NetworkCtrlPayload.OneOf_Payload) -> Bool { + // 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 (lhs, rhs) { + case (.cmdCtrlWifiReset, .cmdCtrlWifiReset): return { + guard case .cmdCtrlWifiReset(let l) = lhs, case .cmdCtrlWifiReset(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.respCtrlWifiReset, .respCtrlWifiReset): return { + guard case .respCtrlWifiReset(let l) = lhs, case .respCtrlWifiReset(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.cmdCtrlWifiReprov, .cmdCtrlWifiReprov): return { + guard case .cmdCtrlWifiReprov(let l) = lhs, case .cmdCtrlWifiReprov(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.respCtrlWifiReprov, .respCtrlWifiReprov): return { + guard case .respCtrlWifiReprov(let l) = lhs, case .respCtrlWifiReprov(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.cmdCtrlThreadReset, .cmdCtrlThreadReset): return { + guard case .cmdCtrlThreadReset(let l) = lhs, case .cmdCtrlThreadReset(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.respCtrlThreadReset, .respCtrlThreadReset): return { + guard case .respCtrlThreadReset(let l) = lhs, case .respCtrlThreadReset(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.cmdCtrlThreadReprov, .cmdCtrlThreadReprov): return { + guard case .cmdCtrlThreadReprov(let l) = lhs, case .cmdCtrlThreadReprov(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.respCtrlThreadReprov, .respCtrlThreadReprov): return { + guard case .respCtrlThreadReprov(let l) = lhs, case .respCtrlThreadReprov(let r) = rhs else { preconditionFailure() } + return l == r + }() + default: return false + } + } + #endif + } + + init() {} +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension NetworkCtrlMsgType: @unchecked Sendable {} +extension CmdCtrlWifiReset: @unchecked Sendable {} +extension RespCtrlWifiReset: @unchecked Sendable {} +extension CmdCtrlWifiReprov: @unchecked Sendable {} +extension RespCtrlWifiReprov: @unchecked Sendable {} +extension CmdCtrlThreadReset: @unchecked Sendable {} +extension RespCtrlThreadReset: @unchecked Sendable {} +extension CmdCtrlThreadReprov: @unchecked Sendable {} +extension RespCtrlThreadReprov: @unchecked Sendable {} +extension NetworkCtrlPayload: @unchecked Sendable {} +extension NetworkCtrlPayload.OneOf_Payload: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +extension NetworkCtrlMsgType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "TypeCtrlReserved"), + 1: .same(proto: "TypeCmdCtrlWifiReset"), + 2: .same(proto: "TypeRespCtrlWifiReset"), + 3: .same(proto: "TypeCmdCtrlWifiReprov"), + 4: .same(proto: "TypeRespCtrlWifiReprov"), + 5: .same(proto: "TypeCmdCtrlThreadReset"), + 6: .same(proto: "TypeRespCtrlThreadReset"), + 7: .same(proto: "TypeCmdCtrlThreadReprov"), + 8: .same(proto: "TypeRespCtrlThreadReprov"), + ] +} + +extension CmdCtrlWifiReset: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "CmdCtrlWifiReset" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: CmdCtrlWifiReset, rhs: CmdCtrlWifiReset) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RespCtrlWifiReset: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RespCtrlWifiReset" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RespCtrlWifiReset, rhs: RespCtrlWifiReset) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension CmdCtrlWifiReprov: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "CmdCtrlWifiReprov" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: CmdCtrlWifiReprov, rhs: CmdCtrlWifiReprov) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RespCtrlWifiReprov: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RespCtrlWifiReprov" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RespCtrlWifiReprov, rhs: RespCtrlWifiReprov) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension CmdCtrlThreadReset: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "CmdCtrlThreadReset" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: CmdCtrlThreadReset, rhs: CmdCtrlThreadReset) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RespCtrlThreadReset: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RespCtrlThreadReset" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RespCtrlThreadReset, rhs: RespCtrlThreadReset) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension CmdCtrlThreadReprov: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "CmdCtrlThreadReprov" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: CmdCtrlThreadReprov, rhs: CmdCtrlThreadReprov) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RespCtrlThreadReprov: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RespCtrlThreadReprov" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RespCtrlThreadReprov, rhs: RespCtrlThreadReprov) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension NetworkCtrlPayload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "NetworkCtrlPayload" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "msg"), + 2: .same(proto: "status"), + 11: .standard(proto: "cmd_ctrl_wifi_reset"), + 12: .standard(proto: "resp_ctrl_wifi_reset"), + 13: .standard(proto: "cmd_ctrl_wifi_reprov"), + 14: .standard(proto: "resp_ctrl_wifi_reprov"), + 15: .standard(proto: "cmd_ctrl_thread_reset"), + 16: .standard(proto: "resp_ctrl_thread_reset"), + 17: .standard(proto: "cmd_ctrl_thread_reprov"), + 18: .standard(proto: "resp_ctrl_thread_reprov"), + ] + + 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.decodeSingularEnumField(value: &self.msg) }() + case 2: try { try decoder.decodeSingularEnumField(value: &self.status) }() + case 11: try { + var v: CmdCtrlWifiReset? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .cmdCtrlWifiReset(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .cmdCtrlWifiReset(v) + } + }() + case 12: try { + var v: RespCtrlWifiReset? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .respCtrlWifiReset(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .respCtrlWifiReset(v) + } + }() + case 13: try { + var v: CmdCtrlWifiReprov? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .cmdCtrlWifiReprov(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .cmdCtrlWifiReprov(v) + } + }() + case 14: try { + var v: RespCtrlWifiReprov? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .respCtrlWifiReprov(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .respCtrlWifiReprov(v) + } + }() + case 15: try { + var v: CmdCtrlThreadReset? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .cmdCtrlThreadReset(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .cmdCtrlThreadReset(v) + } + }() + case 16: try { + var v: RespCtrlThreadReset? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .respCtrlThreadReset(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .respCtrlThreadReset(v) + } + }() + case 17: try { + var v: CmdCtrlThreadReprov? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .cmdCtrlThreadReprov(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .cmdCtrlThreadReprov(v) + } + }() + case 18: try { + var v: RespCtrlThreadReprov? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .respCtrlThreadReprov(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .respCtrlThreadReprov(v) + } + }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if self.msg != .typeCtrlReserved { + try visitor.visitSingularEnumField(value: self.msg, fieldNumber: 1) + } + if self.status != .success { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 2) + } + switch self.payload { + case .cmdCtrlWifiReset?: try { + guard case .cmdCtrlWifiReset(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 11) + }() + case .respCtrlWifiReset?: try { + guard case .respCtrlWifiReset(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 12) + }() + case .cmdCtrlWifiReprov?: try { + guard case .cmdCtrlWifiReprov(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 13) + }() + case .respCtrlWifiReprov?: try { + guard case .respCtrlWifiReprov(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 14) + }() + case .cmdCtrlThreadReset?: try { + guard case .cmdCtrlThreadReset(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 15) + }() + case .respCtrlThreadReset?: try { + guard case .respCtrlThreadReset(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 16) + }() + case .cmdCtrlThreadReprov?: try { + guard case .cmdCtrlThreadReprov(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 17) + }() + case .respCtrlThreadReprov?: try { + guard case .respCtrlThreadReprov(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 18) + }() + case nil: break + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: NetworkCtrlPayload, rhs: NetworkCtrlPayload) -> Bool { + if lhs.msg != rhs.msg {return false} + if lhs.status != rhs.status {return false} + if lhs.payload != rhs.payload {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/ESPProvision/Proto/network_scan.pb.swift b/ESPProvision/Proto/network_scan.pb.swift new file mode 100644 index 0000000..188765c --- /dev/null +++ b/ESPProvision/Proto/network_scan.pb.swift @@ -0,0 +1,1288 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: network_scan.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +enum NetworkScanMsgType: SwiftProtobuf.Enum { + typealias RawValue = Int + case typeCmdScanWifiStart // = 0 + case typeRespScanWifiStart // = 1 + case typeCmdScanWifiStatus // = 2 + case typeRespScanWifiStatus // = 3 + case typeCmdScanWifiResult // = 4 + case typeRespScanWifiResult // = 5 + case typeCmdScanThreadStart // = 6 + case typeRespScanThreadStart // = 7 + case typeCmdScanThreadStatus // = 8 + case typeRespScanThreadStatus // = 9 + case typeCmdScanThreadResult // = 10 + case typeRespScanThreadResult // = 11 + case UNRECOGNIZED(Int) + + init() { + self = .typeCmdScanWifiStart + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .typeCmdScanWifiStart + case 1: self = .typeRespScanWifiStart + case 2: self = .typeCmdScanWifiStatus + case 3: self = .typeRespScanWifiStatus + case 4: self = .typeCmdScanWifiResult + case 5: self = .typeRespScanWifiResult + case 6: self = .typeCmdScanThreadStart + case 7: self = .typeRespScanThreadStart + case 8: self = .typeCmdScanThreadStatus + case 9: self = .typeRespScanThreadStatus + case 10: self = .typeCmdScanThreadResult + case 11: self = .typeRespScanThreadResult + default: self = .UNRECOGNIZED(rawValue) + } + } + + var rawValue: Int { + switch self { + case .typeCmdScanWifiStart: return 0 + case .typeRespScanWifiStart: return 1 + case .typeCmdScanWifiStatus: return 2 + case .typeRespScanWifiStatus: return 3 + case .typeCmdScanWifiResult: return 4 + case .typeRespScanWifiResult: return 5 + case .typeCmdScanThreadStart: return 6 + case .typeRespScanThreadStart: return 7 + case .typeCmdScanThreadStatus: return 8 + case .typeRespScanThreadStatus: return 9 + case .typeCmdScanThreadResult: return 10 + case .typeRespScanThreadResult: return 11 + case .UNRECOGNIZED(let i): return i + } + } + +} + +#if swift(>=4.2) + +extension NetworkScanMsgType: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + static let allCases: [NetworkScanMsgType] = [ + .typeCmdScanWifiStart, + .typeRespScanWifiStart, + .typeCmdScanWifiStatus, + .typeRespScanWifiStatus, + .typeCmdScanWifiResult, + .typeRespScanWifiResult, + .typeCmdScanThreadStart, + .typeRespScanThreadStart, + .typeCmdScanThreadStatus, + .typeRespScanThreadStatus, + .typeCmdScanThreadResult, + .typeRespScanThreadResult, + ] +} + +#endif // swift(>=4.2) + +struct CmdScanWifiStart { + // 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. + + var blocking: Bool = false + + var passive: Bool = false + + var groupChannels: UInt32 = 0 + + var periodMs: UInt32 = 0 + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct CmdScanThreadStart { + // 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. + + var blocking: Bool = false + + var channelMask: UInt32 = 0 + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RespScanWifiStart { + // 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. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RespScanThreadStart { + // 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. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct CmdScanWifiStatus { + // 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. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct CmdScanThreadStatus { + // 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. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RespScanWifiStatus { + // 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. + + var scanFinished: Bool = false + + var resultCount: UInt32 = 0 + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RespScanThreadStatus { + // 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. + + var scanFinished: Bool = false + + var resultCount: UInt32 = 0 + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct CmdScanWifiResult { + // 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. + + var startIndex: UInt32 = 0 + + var count: UInt32 = 0 + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct CmdScanThreadResult { + // 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. + + var startIndex: UInt32 = 0 + + var count: UInt32 = 0 + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct WiFiScanResult { + // 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. + + var ssid: Data = Data() + + var channel: UInt32 = 0 + + var rssi: Int32 = 0 + + var bssid: Data = Data() + + var auth: WifiAuthMode = .open + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct ThreadScanResult { + // 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. + + var panID: UInt32 = 0 + + var channel: UInt32 = 0 + + var rssi: Int32 = 0 + + var lqi: UInt32 = 0 + + var extAddr: Data = Data() + + var networkName: String = String() + + var extPanID: Data = Data() + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RespScanWifiResult { + // 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. + + var entries: [WiFiScanResult] = [] + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RespScanThreadResult { + // 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. + + var entries: [ThreadScanResult] = [] + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct NetworkScanPayload { + // 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. + + var msg: NetworkScanMsgType = .typeCmdScanWifiStart + + var status: Status = .success + + var payload: NetworkScanPayload.OneOf_Payload? = nil + + var cmdScanWifiStart: CmdScanWifiStart { + get { + if case .cmdScanWifiStart(let v)? = payload {return v} + return CmdScanWifiStart() + } + set {payload = .cmdScanWifiStart(newValue)} + } + + var respScanWifiStart: RespScanWifiStart { + get { + if case .respScanWifiStart(let v)? = payload {return v} + return RespScanWifiStart() + } + set {payload = .respScanWifiStart(newValue)} + } + + var cmdScanWifiStatus: CmdScanWifiStatus { + get { + if case .cmdScanWifiStatus(let v)? = payload {return v} + return CmdScanWifiStatus() + } + set {payload = .cmdScanWifiStatus(newValue)} + } + + var respScanWifiStatus: RespScanWifiStatus { + get { + if case .respScanWifiStatus(let v)? = payload {return v} + return RespScanWifiStatus() + } + set {payload = .respScanWifiStatus(newValue)} + } + + var cmdScanWifiResult: CmdScanWifiResult { + get { + if case .cmdScanWifiResult(let v)? = payload {return v} + return CmdScanWifiResult() + } + set {payload = .cmdScanWifiResult(newValue)} + } + + var respScanWifiResult: RespScanWifiResult { + get { + if case .respScanWifiResult(let v)? = payload {return v} + return RespScanWifiResult() + } + set {payload = .respScanWifiResult(newValue)} + } + + var cmdScanThreadStart: CmdScanThreadStart { + get { + if case .cmdScanThreadStart(let v)? = payload {return v} + return CmdScanThreadStart() + } + set {payload = .cmdScanThreadStart(newValue)} + } + + var respScanThreadStart: RespScanThreadStart { + get { + if case .respScanThreadStart(let v)? = payload {return v} + return RespScanThreadStart() + } + set {payload = .respScanThreadStart(newValue)} + } + + var cmdScanThreadStatus: CmdScanThreadStatus { + get { + if case .cmdScanThreadStatus(let v)? = payload {return v} + return CmdScanThreadStatus() + } + set {payload = .cmdScanThreadStatus(newValue)} + } + + var respScanThreadStatus: RespScanThreadStatus { + get { + if case .respScanThreadStatus(let v)? = payload {return v} + return RespScanThreadStatus() + } + set {payload = .respScanThreadStatus(newValue)} + } + + var cmdScanThreadResult: CmdScanThreadResult { + get { + if case .cmdScanThreadResult(let v)? = payload {return v} + return CmdScanThreadResult() + } + set {payload = .cmdScanThreadResult(newValue)} + } + + var respScanThreadResult: RespScanThreadResult { + get { + if case .respScanThreadResult(let v)? = payload {return v} + return RespScanThreadResult() + } + set {payload = .respScanThreadResult(newValue)} + } + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum OneOf_Payload: Equatable { + case cmdScanWifiStart(CmdScanWifiStart) + case respScanWifiStart(RespScanWifiStart) + case cmdScanWifiStatus(CmdScanWifiStatus) + case respScanWifiStatus(RespScanWifiStatus) + case cmdScanWifiResult(CmdScanWifiResult) + case respScanWifiResult(RespScanWifiResult) + case cmdScanThreadStart(CmdScanThreadStart) + case respScanThreadStart(RespScanThreadStart) + case cmdScanThreadStatus(CmdScanThreadStatus) + case respScanThreadStatus(RespScanThreadStatus) + case cmdScanThreadResult(CmdScanThreadResult) + case respScanThreadResult(RespScanThreadResult) + + #if !swift(>=4.1) + static func ==(lhs: NetworkScanPayload.OneOf_Payload, rhs: NetworkScanPayload.OneOf_Payload) -> Bool { + // 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 (lhs, rhs) { + case (.cmdScanWifiStart, .cmdScanWifiStart): return { + guard case .cmdScanWifiStart(let l) = lhs, case .cmdScanWifiStart(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.respScanWifiStart, .respScanWifiStart): return { + guard case .respScanWifiStart(let l) = lhs, case .respScanWifiStart(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.cmdScanWifiStatus, .cmdScanWifiStatus): return { + guard case .cmdScanWifiStatus(let l) = lhs, case .cmdScanWifiStatus(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.respScanWifiStatus, .respScanWifiStatus): return { + guard case .respScanWifiStatus(let l) = lhs, case .respScanWifiStatus(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.cmdScanWifiResult, .cmdScanWifiResult): return { + guard case .cmdScanWifiResult(let l) = lhs, case .cmdScanWifiResult(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.respScanWifiResult, .respScanWifiResult): return { + guard case .respScanWifiResult(let l) = lhs, case .respScanWifiResult(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.cmdScanThreadStart, .cmdScanThreadStart): return { + guard case .cmdScanThreadStart(let l) = lhs, case .cmdScanThreadStart(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.respScanThreadStart, .respScanThreadStart): return { + guard case .respScanThreadStart(let l) = lhs, case .respScanThreadStart(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.cmdScanThreadStatus, .cmdScanThreadStatus): return { + guard case .cmdScanThreadStatus(let l) = lhs, case .cmdScanThreadStatus(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.respScanThreadStatus, .respScanThreadStatus): return { + guard case .respScanThreadStatus(let l) = lhs, case .respScanThreadStatus(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.cmdScanThreadResult, .cmdScanThreadResult): return { + guard case .cmdScanThreadResult(let l) = lhs, case .cmdScanThreadResult(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.respScanThreadResult, .respScanThreadResult): return { + guard case .respScanThreadResult(let l) = lhs, case .respScanThreadResult(let r) = rhs else { preconditionFailure() } + return l == r + }() + default: return false + } + } + #endif + } + + init() {} +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension NetworkScanMsgType: @unchecked Sendable {} +extension CmdScanWifiStart: @unchecked Sendable {} +extension CmdScanThreadStart: @unchecked Sendable {} +extension RespScanWifiStart: @unchecked Sendable {} +extension RespScanThreadStart: @unchecked Sendable {} +extension CmdScanWifiStatus: @unchecked Sendable {} +extension CmdScanThreadStatus: @unchecked Sendable {} +extension RespScanWifiStatus: @unchecked Sendable {} +extension RespScanThreadStatus: @unchecked Sendable {} +extension CmdScanWifiResult: @unchecked Sendable {} +extension CmdScanThreadResult: @unchecked Sendable {} +extension WiFiScanResult: @unchecked Sendable {} +extension ThreadScanResult: @unchecked Sendable {} +extension RespScanWifiResult: @unchecked Sendable {} +extension RespScanThreadResult: @unchecked Sendable {} +extension NetworkScanPayload: @unchecked Sendable {} +extension NetworkScanPayload.OneOf_Payload: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +extension NetworkScanMsgType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "TypeCmdScanWifiStart"), + 1: .same(proto: "TypeRespScanWifiStart"), + 2: .same(proto: "TypeCmdScanWifiStatus"), + 3: .same(proto: "TypeRespScanWifiStatus"), + 4: .same(proto: "TypeCmdScanWifiResult"), + 5: .same(proto: "TypeRespScanWifiResult"), + 6: .same(proto: "TypeCmdScanThreadStart"), + 7: .same(proto: "TypeRespScanThreadStart"), + 8: .same(proto: "TypeCmdScanThreadStatus"), + 9: .same(proto: "TypeRespScanThreadStatus"), + 10: .same(proto: "TypeCmdScanThreadResult"), + 11: .same(proto: "TypeRespScanThreadResult"), + ] +} + +extension CmdScanWifiStart: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "CmdScanWifiStart" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "blocking"), + 2: .same(proto: "passive"), + 3: .standard(proto: "group_channels"), + 4: .standard(proto: "period_ms"), + ] + + 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.decodeSingularBoolField(value: &self.blocking) }() + case 2: try { try decoder.decodeSingularBoolField(value: &self.passive) }() + case 3: try { try decoder.decodeSingularUInt32Field(value: &self.groupChannels) }() + case 4: try { try decoder.decodeSingularUInt32Field(value: &self.periodMs) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.blocking != false { + try visitor.visitSingularBoolField(value: self.blocking, fieldNumber: 1) + } + if self.passive != false { + try visitor.visitSingularBoolField(value: self.passive, fieldNumber: 2) + } + if self.groupChannels != 0 { + try visitor.visitSingularUInt32Field(value: self.groupChannels, fieldNumber: 3) + } + if self.periodMs != 0 { + try visitor.visitSingularUInt32Field(value: self.periodMs, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: CmdScanWifiStart, rhs: CmdScanWifiStart) -> Bool { + if lhs.blocking != rhs.blocking {return false} + if lhs.passive != rhs.passive {return false} + if lhs.groupChannels != rhs.groupChannels {return false} + if lhs.periodMs != rhs.periodMs {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension CmdScanThreadStart: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "CmdScanThreadStart" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "blocking"), + 2: .standard(proto: "channel_mask"), + ] + + 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.decodeSingularBoolField(value: &self.blocking) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.channelMask) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.blocking != false { + try visitor.visitSingularBoolField(value: self.blocking, fieldNumber: 1) + } + if self.channelMask != 0 { + try visitor.visitSingularUInt32Field(value: self.channelMask, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: CmdScanThreadStart, rhs: CmdScanThreadStart) -> Bool { + if lhs.blocking != rhs.blocking {return false} + if lhs.channelMask != rhs.channelMask {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RespScanWifiStart: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RespScanWifiStart" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RespScanWifiStart, rhs: RespScanWifiStart) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RespScanThreadStart: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RespScanThreadStart" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RespScanThreadStart, rhs: RespScanThreadStart) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension CmdScanWifiStatus: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "CmdScanWifiStatus" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: CmdScanWifiStatus, rhs: CmdScanWifiStatus) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension CmdScanThreadStatus: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "CmdScanThreadStatus" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: CmdScanThreadStatus, rhs: CmdScanThreadStatus) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RespScanWifiStatus: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RespScanWifiStatus" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "scan_finished"), + 2: .standard(proto: "result_count"), + ] + + 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.decodeSingularBoolField(value: &self.scanFinished) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.resultCount) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.scanFinished != false { + try visitor.visitSingularBoolField(value: self.scanFinished, fieldNumber: 1) + } + if self.resultCount != 0 { + try visitor.visitSingularUInt32Field(value: self.resultCount, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RespScanWifiStatus, rhs: RespScanWifiStatus) -> Bool { + if lhs.scanFinished != rhs.scanFinished {return false} + if lhs.resultCount != rhs.resultCount {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RespScanThreadStatus: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RespScanThreadStatus" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "scan_finished"), + 2: .standard(proto: "result_count"), + ] + + 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.decodeSingularBoolField(value: &self.scanFinished) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.resultCount) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.scanFinished != false { + try visitor.visitSingularBoolField(value: self.scanFinished, fieldNumber: 1) + } + if self.resultCount != 0 { + try visitor.visitSingularUInt32Field(value: self.resultCount, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RespScanThreadStatus, rhs: RespScanThreadStatus) -> Bool { + if lhs.scanFinished != rhs.scanFinished {return false} + if lhs.resultCount != rhs.resultCount {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension CmdScanWifiResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "CmdScanWifiResult" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "start_index"), + 2: .same(proto: "count"), + ] + + 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.startIndex) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.count) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.startIndex != 0 { + try visitor.visitSingularUInt32Field(value: self.startIndex, fieldNumber: 1) + } + if self.count != 0 { + try visitor.visitSingularUInt32Field(value: self.count, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: CmdScanWifiResult, rhs: CmdScanWifiResult) -> Bool { + if lhs.startIndex != rhs.startIndex {return false} + if lhs.count != rhs.count {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension CmdScanThreadResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "CmdScanThreadResult" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "start_index"), + 2: .same(proto: "count"), + ] + + 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.startIndex) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.count) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.startIndex != 0 { + try visitor.visitSingularUInt32Field(value: self.startIndex, fieldNumber: 1) + } + if self.count != 0 { + try visitor.visitSingularUInt32Field(value: self.count, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: CmdScanThreadResult, rhs: CmdScanThreadResult) -> Bool { + if lhs.startIndex != rhs.startIndex {return false} + if lhs.count != rhs.count {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension WiFiScanResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "WiFiScanResult" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "ssid"), + 2: .same(proto: "channel"), + 3: .same(proto: "rssi"), + 4: .same(proto: "bssid"), + 5: .same(proto: "auth"), + ] + + 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.decodeSingularBytesField(value: &self.ssid) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.channel) }() + case 3: try { try decoder.decodeSingularInt32Field(value: &self.rssi) }() + case 4: try { try decoder.decodeSingularBytesField(value: &self.bssid) }() + case 5: try { try decoder.decodeSingularEnumField(value: &self.auth) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.ssid.isEmpty { + try visitor.visitSingularBytesField(value: self.ssid, fieldNumber: 1) + } + if self.channel != 0 { + try visitor.visitSingularUInt32Field(value: self.channel, fieldNumber: 2) + } + if self.rssi != 0 { + try visitor.visitSingularInt32Field(value: self.rssi, fieldNumber: 3) + } + if !self.bssid.isEmpty { + try visitor.visitSingularBytesField(value: self.bssid, fieldNumber: 4) + } + if self.auth != .open { + try visitor.visitSingularEnumField(value: self.auth, fieldNumber: 5) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: WiFiScanResult, rhs: WiFiScanResult) -> Bool { + if lhs.ssid != rhs.ssid {return false} + if lhs.channel != rhs.channel {return false} + if lhs.rssi != rhs.rssi {return false} + if lhs.bssid != rhs.bssid {return false} + if lhs.auth != rhs.auth {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension ThreadScanResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "ThreadScanResult" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "pan_id"), + 2: .same(proto: "channel"), + 3: .same(proto: "rssi"), + 4: .same(proto: "lqi"), + 5: .standard(proto: "ext_addr"), + 6: .standard(proto: "network_name"), + 7: .standard(proto: "ext_pan_id"), + ] + + 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.panID) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.channel) }() + case 3: try { try decoder.decodeSingularInt32Field(value: &self.rssi) }() + case 4: try { try decoder.decodeSingularUInt32Field(value: &self.lqi) }() + case 5: try { try decoder.decodeSingularBytesField(value: &self.extAddr) }() + case 6: try { try decoder.decodeSingularStringField(value: &self.networkName) }() + case 7: try { try decoder.decodeSingularBytesField(value: &self.extPanID) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.panID != 0 { + try visitor.visitSingularUInt32Field(value: self.panID, fieldNumber: 1) + } + if self.channel != 0 { + try visitor.visitSingularUInt32Field(value: self.channel, fieldNumber: 2) + } + if self.rssi != 0 { + try visitor.visitSingularInt32Field(value: self.rssi, fieldNumber: 3) + } + if self.lqi != 0 { + try visitor.visitSingularUInt32Field(value: self.lqi, fieldNumber: 4) + } + if !self.extAddr.isEmpty { + try visitor.visitSingularBytesField(value: self.extAddr, fieldNumber: 5) + } + if !self.networkName.isEmpty { + try visitor.visitSingularStringField(value: self.networkName, fieldNumber: 6) + } + if !self.extPanID.isEmpty { + try visitor.visitSingularBytesField(value: self.extPanID, fieldNumber: 7) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: ThreadScanResult, rhs: ThreadScanResult) -> Bool { + if lhs.panID != rhs.panID {return false} + if lhs.channel != rhs.channel {return false} + if lhs.rssi != rhs.rssi {return false} + if lhs.lqi != rhs.lqi {return false} + if lhs.extAddr != rhs.extAddr {return false} + if lhs.networkName != rhs.networkName {return false} + if lhs.extPanID != rhs.extPanID {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RespScanWifiResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RespScanWifiResult" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "entries"), + ] + + 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.decodeRepeatedMessageField(value: &self.entries) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.entries.isEmpty { + try visitor.visitRepeatedMessageField(value: self.entries, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RespScanWifiResult, rhs: RespScanWifiResult) -> Bool { + if lhs.entries != rhs.entries {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RespScanThreadResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RespScanThreadResult" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "entries"), + ] + + 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.decodeRepeatedMessageField(value: &self.entries) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.entries.isEmpty { + try visitor.visitRepeatedMessageField(value: self.entries, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RespScanThreadResult, rhs: RespScanThreadResult) -> Bool { + if lhs.entries != rhs.entries {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension NetworkScanPayload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "NetworkScanPayload" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "msg"), + 2: .same(proto: "status"), + 10: .standard(proto: "cmd_scan_wifi_start"), + 11: .standard(proto: "resp_scan_wifi_start"), + 12: .standard(proto: "cmd_scan_wifi_status"), + 13: .standard(proto: "resp_scan_wifi_status"), + 14: .standard(proto: "cmd_scan_wifi_result"), + 15: .standard(proto: "resp_scan_wifi_result"), + 16: .standard(proto: "cmd_scan_thread_start"), + 17: .standard(proto: "resp_scan_thread_start"), + 18: .standard(proto: "cmd_scan_thread_status"), + 19: .standard(proto: "resp_scan_thread_status"), + 20: .standard(proto: "cmd_scan_thread_result"), + 21: .standard(proto: "resp_scan_thread_result"), + ] + + 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.decodeSingularEnumField(value: &self.msg) }() + case 2: try { try decoder.decodeSingularEnumField(value: &self.status) }() + case 10: try { + var v: CmdScanWifiStart? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .cmdScanWifiStart(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .cmdScanWifiStart(v) + } + }() + case 11: try { + var v: RespScanWifiStart? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .respScanWifiStart(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .respScanWifiStart(v) + } + }() + case 12: try { + var v: CmdScanWifiStatus? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .cmdScanWifiStatus(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .cmdScanWifiStatus(v) + } + }() + case 13: try { + var v: RespScanWifiStatus? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .respScanWifiStatus(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .respScanWifiStatus(v) + } + }() + case 14: try { + var v: CmdScanWifiResult? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .cmdScanWifiResult(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .cmdScanWifiResult(v) + } + }() + case 15: try { + var v: RespScanWifiResult? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .respScanWifiResult(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .respScanWifiResult(v) + } + }() + case 16: try { + var v: CmdScanThreadStart? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .cmdScanThreadStart(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .cmdScanThreadStart(v) + } + }() + case 17: try { + var v: RespScanThreadStart? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .respScanThreadStart(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .respScanThreadStart(v) + } + }() + case 18: try { + var v: CmdScanThreadStatus? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .cmdScanThreadStatus(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .cmdScanThreadStatus(v) + } + }() + case 19: try { + var v: RespScanThreadStatus? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .respScanThreadStatus(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .respScanThreadStatus(v) + } + }() + case 20: try { + var v: CmdScanThreadResult? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .cmdScanThreadResult(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .cmdScanThreadResult(v) + } + }() + case 21: try { + var v: RespScanThreadResult? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .respScanThreadResult(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .respScanThreadResult(v) + } + }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if self.msg != .typeCmdScanWifiStart { + try visitor.visitSingularEnumField(value: self.msg, fieldNumber: 1) + } + if self.status != .success { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 2) + } + switch self.payload { + case .cmdScanWifiStart?: try { + guard case .cmdScanWifiStart(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 10) + }() + case .respScanWifiStart?: try { + guard case .respScanWifiStart(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 11) + }() + case .cmdScanWifiStatus?: try { + guard case .cmdScanWifiStatus(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 12) + }() + case .respScanWifiStatus?: try { + guard case .respScanWifiStatus(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 13) + }() + case .cmdScanWifiResult?: try { + guard case .cmdScanWifiResult(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 14) + }() + case .respScanWifiResult?: try { + guard case .respScanWifiResult(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 15) + }() + case .cmdScanThreadStart?: try { + guard case .cmdScanThreadStart(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 16) + }() + case .respScanThreadStart?: try { + guard case .respScanThreadStart(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 17) + }() + case .cmdScanThreadStatus?: try { + guard case .cmdScanThreadStatus(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 18) + }() + case .respScanThreadStatus?: try { + guard case .respScanThreadStatus(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 19) + }() + case .cmdScanThreadResult?: try { + guard case .cmdScanThreadResult(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 20) + }() + case .respScanThreadResult?: try { + guard case .respScanThreadResult(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 21) + }() + case nil: break + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: NetworkScanPayload, rhs: NetworkScanPayload) -> Bool { + if lhs.msg != rhs.msg {return false} + if lhs.status != rhs.status {return false} + if lhs.payload != rhs.payload {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/ESPProvision/Proto/sec0.pb.swift b/ESPProvision/Proto/sec0.pb.swift index af1519a..6c94e4c 100644 --- a/ESPProvision/Proto/sec0.pb.swift +++ b/ESPProvision/Proto/sec0.pb.swift @@ -1,4 +1,5 @@ // DO NOT EDIT. +// swift-format-ignore-file // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: sec0.proto @@ -6,290 +7,284 @@ // For information on using the generated types, please see the documentation: // https://github.com/apple/swift-protobuf/ -// Copyright 2020 Espressif Systems -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - import Foundation import SwiftProtobuf // If the compiler emits an error on this type, it is because this file // was generated by a version of the `protoc` Swift plug-in that is // incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that your are building against the same version of the API +// Please ensure that you are building against the same version of the API // that was used to generate this file. -private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 } -enum Espressif_Sec0MsgType: SwiftProtobuf.Enum { - typealias RawValue = Int - case s0SessionCommand // = 0 - case s0SessionResponse // = 1 - case UNRECOGNIZED(Int) - - init() { - self = .s0SessionCommand +/// A message must be of type Cmd or Resp +enum Sec0MsgType: SwiftProtobuf.Enum { + typealias RawValue = Int + case s0SessionCommand // = 0 + case s0SessionResponse // = 1 + case UNRECOGNIZED(Int) + + init() { + self = .s0SessionCommand + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .s0SessionCommand + case 1: self = .s0SessionResponse + default: self = .UNRECOGNIZED(rawValue) } + } - init?(rawValue: Int) { - switch rawValue { - case 0: self = .s0SessionCommand - case 1: self = .s0SessionResponse - default: self = .UNRECOGNIZED(rawValue) - } + var rawValue: Int { + switch self { + case .s0SessionCommand: return 0 + case .s0SessionResponse: return 1 + case .UNRECOGNIZED(let i): return i } + } - var rawValue: Int { - switch self { - case .s0SessionCommand: return 0 - case .s0SessionResponse: return 1 - case let .UNRECOGNIZED(i): return i - } - } } #if swift(>=4.2) - extension Espressif_Sec0MsgType: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Espressif_Sec0MsgType] = [ - .s0SessionCommand, - .s0SessionResponse, - ] - } +extension Sec0MsgType: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + static let allCases: [Sec0MsgType] = [ + .s0SessionCommand, + .s0SessionResponse, + ] +} -#endif // swift(>=4.2) +#endif // swift(>=4.2) -struct Espressif_S0SessionCmd { - // 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. +/// Data structure of Session command/request packet +struct S0SessionCmd { + // 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. - var unknownFields = SwiftProtobuf.UnknownStorage() + var unknownFields = SwiftProtobuf.UnknownStorage() - init() {} + init() {} } -struct Espressif_S0SessionResp { - // 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. +/// Data structure of Session response packet +struct S0SessionResp { + // 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. - var status: Espressif_Status = .success + var status: Status = .success - var unknownFields = SwiftProtobuf.UnknownStorage() + var unknownFields = SwiftProtobuf.UnknownStorage() - init() {} + init() {} } -struct Espressif_Sec0Payload { - // 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. +/// Payload structure of session data +struct Sec0Payload { + // 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. - var msg: Espressif_Sec0MsgType { - get { return _storage._msg } - set { _uniqueStorage()._msg = newValue } - } + ///!< Type of message + var msg: Sec0MsgType = .s0SessionCommand - var payload: OneOf_Payload? { - get { return _storage._payload } - set { _uniqueStorage()._payload = newValue } - } + var payload: Sec0Payload.OneOf_Payload? = nil - var sc: Espressif_S0SessionCmd { - get { - if case let .sc(v)? = _storage._payload { return v } - return Espressif_S0SessionCmd() - } - set { _uniqueStorage()._payload = .sc(newValue) } + ///!< Payload data interpreted as Cmd + var sc: S0SessionCmd { + get { + if case .sc(let v)? = payload {return v} + return S0SessionCmd() } - - var sr: Espressif_S0SessionResp { - get { - if case let .sr(v)? = _storage._payload { return v } - return Espressif_S0SessionResp() - } - set { _uniqueStorage()._payload = .sr(newValue) } + set {payload = .sc(newValue)} + } + + ///!< Payload data interpreted as Resp + var sr: S0SessionResp { + get { + if case .sr(let v)? = payload {return v} + return S0SessionResp() } - - var unknownFields = SwiftProtobuf.UnknownStorage() - - enum OneOf_Payload: Equatable { - case sc(Espressif_S0SessionCmd) - case sr(Espressif_S0SessionResp) - - #if !swift(>=4.1) - static func == (lhs: Espressif_Sec0Payload.OneOf_Payload, rhs: Espressif_Sec0Payload.OneOf_Payload) -> Bool { - switch (lhs, rhs) { - case let (.sc(l), .sc(r)): return l == r - case let (.sr(l), .sr(r)): return l == r - default: return false - } - } - #endif + set {payload = .sr(newValue)} + } + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum OneOf_Payload: Equatable { + ///!< Payload data interpreted as Cmd + case sc(S0SessionCmd) + ///!< Payload data interpreted as Resp + case sr(S0SessionResp) + + #if !swift(>=4.1) + static func ==(lhs: Sec0Payload.OneOf_Payload, rhs: Sec0Payload.OneOf_Payload) -> Bool { + // 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 (lhs, rhs) { + case (.sc, .sc): return { + guard case .sc(let l) = lhs, case .sc(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.sr, .sr): return { + guard case .sr(let l) = lhs, case .sr(let r) = rhs else { preconditionFailure() } + return l == r + }() + default: return false + } } + #endif + } - init() {} - - fileprivate var _storage = _StorageClass.defaultInstance + init() {} } -// MARK: - Code below here is support for the SwiftProtobuf runtime. +#if swift(>=5.5) && canImport(_Concurrency) +extension Sec0MsgType: @unchecked Sendable {} +extension S0SessionCmd: @unchecked Sendable {} +extension S0SessionResp: @unchecked Sendable {} +extension Sec0Payload: @unchecked Sendable {} +extension Sec0Payload.OneOf_Payload: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) -private let _protobuf_package = "espressif" +// MARK: - Code below here is support for the SwiftProtobuf runtime. -extension Espressif_Sec0MsgType: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "S0_Session_Command"), - 1: .same(proto: "S0_Session_Response"), - ] +extension Sec0MsgType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "S0_Session_Command"), + 1: .same(proto: "S0_Session_Response"), + ] } -extension Espressif_S0SessionCmd: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".S0SessionCmd" - static let _protobuf_nameMap = SwiftProtobuf._NameMap() +extension S0SessionCmd: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "S0SessionCmd" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() - mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() {} + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { } + } - func traverse(visitor: inout V) throws { - try unknownFields.traverse(visitor: &visitor) - } + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } - static func == (lhs: Espressif_S0SessionCmd, rhs: Espressif_S0SessionCmd) -> Bool { - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } + static func ==(lhs: S0SessionCmd, rhs: S0SessionCmd) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } } -extension Espressif_S0SessionResp: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".S0SessionResp" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "status"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularEnumField(value: &status) - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if status != .success { - try visitor.visitSingularEnumField(value: status, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) +extension S0SessionResp: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "S0SessionResp" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "status"), + ] + + 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.decodeSingularEnumField(value: &self.status) }() + default: break + } } + } - static func == (lhs: Espressif_S0SessionResp, rhs: Espressif_S0SessionResp) -> Bool { - if lhs.status != rhs.status { return false } - if lhs.unknownFields != rhs.unknownFields { return false } - return true + func traverse(visitor: inout V) throws { + if self.status != .success { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 1) } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: S0SessionResp, rhs: S0SessionResp) -> Bool { + if lhs.status != rhs.status {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } } -extension Espressif_Sec0Payload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".Sec0Payload" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "msg"), - 20: .same(proto: "sc"), - 21: .same(proto: "sr"), - ] - - fileprivate class _StorageClass { - var _msg: Espressif_Sec0MsgType = .s0SessionCommand - var _payload: Espressif_Sec0Payload.OneOf_Payload? - - static let defaultInstance = _StorageClass() - - private init() {} - - init(copying source: _StorageClass) { - _msg = source._msg - _payload = source._payload +extension Sec0Payload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "Sec0Payload" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "msg"), + 20: .same(proto: "sc"), + 21: .same(proto: "sr"), + ] + + 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.decodeSingularEnumField(value: &self.msg) }() + case 20: try { + var v: S0SessionCmd? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .sc(let m) = current {v = m} } - } - - fileprivate mutating func _uniqueStorage() -> _StorageClass { - if !isKnownUniquelyReferenced(&_storage) { - _storage = _StorageClass(copying: _storage) + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .sc(v) } - return _storage - } - - mutating func decodeMessage(decoder: inout D) throws { - _ = _uniqueStorage() - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularEnumField(value: &_storage._msg) - case 20: - var v: Espressif_S0SessionCmd? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .sc(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .sc(v) } - case 21: - var v: Espressif_S0SessionResp? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .sr(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .sr(v) } - default: break - } - } + }() + case 21: try { + var v: S0SessionResp? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .sr(let m) = current {v = m} } - } - - func traverse(visitor: inout V) throws { - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - if _storage._msg != .s0SessionCommand { - try visitor.visitSingularEnumField(value: _storage._msg, fieldNumber: 1) - } - switch _storage._payload { - case let .sc(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 20) - case let .sr(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 21) - case nil: break - } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .sr(v) } - try unknownFields.traverse(visitor: &visitor) + }() + default: break + } } - - static func == (lhs: Espressif_Sec0Payload, rhs: Espressif_Sec0Payload) -> Bool { - if lhs._storage !== rhs._storage { - let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in - let _storage = _args.0 - let rhs_storage = _args.1 - if _storage._msg != rhs_storage._msg { return false } - if _storage._payload != rhs_storage._payload { return false } - return true - } - if !storagesAreEqual { return false } - } - if lhs.unknownFields != rhs.unknownFields { return false } - return true + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if self.msg != .s0SessionCommand { + try visitor.visitSingularEnumField(value: self.msg, fieldNumber: 1) + } + switch self.payload { + case .sc?: try { + guard case .sc(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 20) + }() + case .sr?: try { + guard case .sr(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 21) + }() + case nil: break } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Sec0Payload, rhs: Sec0Payload) -> Bool { + if lhs.msg != rhs.msg {return false} + if lhs.payload != rhs.payload {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } } diff --git a/ESPProvision/Proto/sec1.pb.swift b/ESPProvision/Proto/sec1.pb.swift index 9278b6e..bbcd953 100644 --- a/ESPProvision/Proto/sec1.pb.swift +++ b/ESPProvision/Proto/sec1.pb.swift @@ -1,4 +1,5 @@ // DO NOT EDIT. +// swift-format-ignore-file // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: sec1.proto @@ -6,461 +7,491 @@ // For information on using the generated types, please see the documentation: // https://github.com/apple/swift-protobuf/ -// Copyright 2020 Espressif Systems -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - import Foundation import SwiftProtobuf // If the compiler emits an error on this type, it is because this file // was generated by a version of the `protoc` Swift plug-in that is // incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that your are building against the same version of the API +// Please ensure that you are building against the same version of the API // that was used to generate this file. -private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 } -enum Espressif_Sec1MsgType: SwiftProtobuf.Enum { - typealias RawValue = Int - case sessionCommand0 // = 0 - case sessionResponse0 // = 1 - case sessionCommand1 // = 2 - case sessionResponse1 // = 3 - case UNRECOGNIZED(Int) - - init() { - self = .sessionCommand0 +/// A message must be of type Cmd0 / Cmd1 / Resp0 / Resp1 +enum Sec1MsgType: SwiftProtobuf.Enum { + typealias RawValue = Int + case sessionCommand0 // = 0 + case sessionResponse0 // = 1 + case sessionCommand1 // = 2 + case sessionResponse1 // = 3 + case UNRECOGNIZED(Int) + + init() { + self = .sessionCommand0 + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .sessionCommand0 + case 1: self = .sessionResponse0 + case 2: self = .sessionCommand1 + case 3: self = .sessionResponse1 + default: self = .UNRECOGNIZED(rawValue) } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .sessionCommand0 - case 1: self = .sessionResponse0 - case 2: self = .sessionCommand1 - case 3: self = .sessionResponse1 - default: self = .UNRECOGNIZED(rawValue) - } + } + + var rawValue: Int { + switch self { + case .sessionCommand0: return 0 + case .sessionResponse0: return 1 + case .sessionCommand1: return 2 + case .sessionResponse1: return 3 + case .UNRECOGNIZED(let i): return i } + } - var rawValue: Int { - switch self { - case .sessionCommand0: return 0 - case .sessionResponse0: return 1 - case .sessionCommand1: return 2 - case .sessionResponse1: return 3 - case let .UNRECOGNIZED(i): return i - } - } } #if swift(>=4.2) - extension Espressif_Sec1MsgType: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Espressif_Sec1MsgType] = [ - .sessionCommand0, - .sessionResponse0, - .sessionCommand1, - .sessionResponse1, - ] - } +extension Sec1MsgType: CaseIterable { + // The compiler won't synthesize support with the UNRECOGNIZED case. + static let allCases: [Sec1MsgType] = [ + .sessionCommand0, + .sessionResponse0, + .sessionCommand1, + .sessionResponse1, + ] +} -#endif // swift(>=4.2) +#endif // swift(>=4.2) -struct Espressif_SessionCmd1 { - // 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. +/// Data structure of Session command1 packet +struct SessionCmd1 { + // 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. - var clientVerifyData: Data = SwiftProtobuf.Internal.emptyData + var clientVerifyData: Data = Data() - var unknownFields = SwiftProtobuf.UnknownStorage() + var unknownFields = SwiftProtobuf.UnknownStorage() - init() {} + init() {} } -struct Espressif_SessionResp1 { - // 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. +/// Data structure of Session response1 packet +struct SessionResp1 { + // 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. - var status: Espressif_Status = .success + var status: Status = .success - var deviceVerifyData: Data = SwiftProtobuf.Internal.emptyData + var deviceVerifyData: Data = Data() - var unknownFields = SwiftProtobuf.UnknownStorage() + var unknownFields = SwiftProtobuf.UnknownStorage() - init() {} + init() {} } -struct Espressif_SessionCmd0 { - // 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. +/// Data structure of Session command0 packet +struct SessionCmd0 { + // 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. - var clientPubkey: Data = SwiftProtobuf.Internal.emptyData + var clientPubkey: Data = Data() - var unknownFields = SwiftProtobuf.UnknownStorage() + var unknownFields = SwiftProtobuf.UnknownStorage() - init() {} + init() {} } -struct Espressif_SessionResp0 { - // 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. +/// Data structure of Session response0 packet +struct SessionResp0 { + // 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. - var status: Espressif_Status = .success + var status: Status = .success - var devicePubkey: Data = SwiftProtobuf.Internal.emptyData + var devicePubkey: Data = Data() - var deviceRandom: Data = SwiftProtobuf.Internal.emptyData + var deviceRandom: Data = Data() - var unknownFields = SwiftProtobuf.UnknownStorage() + var unknownFields = SwiftProtobuf.UnknownStorage() - init() {} + init() {} } -struct Espressif_Sec1Payload { - // 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. +/// Payload structure of session data +struct Sec1Payload { + // 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. - var msg: Espressif_Sec1MsgType { - get { return _storage._msg } - set { _uniqueStorage()._msg = newValue } - } + ///!< Type of message + var msg: Sec1MsgType = .sessionCommand0 - var payload: OneOf_Payload? { - get { return _storage._payload } - set { _uniqueStorage()._payload = newValue } - } + var payload: Sec1Payload.OneOf_Payload? = nil - var sc0: Espressif_SessionCmd0 { - get { - if case let .sc0(v)? = _storage._payload { return v } - return Espressif_SessionCmd0() - } - set { _uniqueStorage()._payload = .sc0(newValue) } + ///!< Payload data interpreted as Cmd0 + var sc0: SessionCmd0 { + get { + if case .sc0(let v)? = payload {return v} + return SessionCmd0() } - - var sr0: Espressif_SessionResp0 { - get { - if case let .sr0(v)? = _storage._payload { return v } - return Espressif_SessionResp0() - } - set { _uniqueStorage()._payload = .sr0(newValue) } + set {payload = .sc0(newValue)} + } + + ///!< Payload data interpreted as Resp0 + var sr0: SessionResp0 { + get { + if case .sr0(let v)? = payload {return v} + return SessionResp0() } - - var sc1: Espressif_SessionCmd1 { - get { - if case let .sc1(v)? = _storage._payload { return v } - return Espressif_SessionCmd1() - } - set { _uniqueStorage()._payload = .sc1(newValue) } + set {payload = .sr0(newValue)} + } + + ///!< Payload data interpreted as Cmd1 + var sc1: SessionCmd1 { + get { + if case .sc1(let v)? = payload {return v} + return SessionCmd1() } - - var sr1: Espressif_SessionResp1 { - get { - if case let .sr1(v)? = _storage._payload { return v } - return Espressif_SessionResp1() - } - set { _uniqueStorage()._payload = .sr1(newValue) } + set {payload = .sc1(newValue)} + } + + ///!< Payload data interpreted as Resp1 + var sr1: SessionResp1 { + get { + if case .sr1(let v)? = payload {return v} + return SessionResp1() } - - var unknownFields = SwiftProtobuf.UnknownStorage() - - enum OneOf_Payload: Equatable { - case sc0(Espressif_SessionCmd0) - case sr0(Espressif_SessionResp0) - case sc1(Espressif_SessionCmd1) - case sr1(Espressif_SessionResp1) - - #if !swift(>=4.1) - static func == (lhs: Espressif_Sec1Payload.OneOf_Payload, rhs: Espressif_Sec1Payload.OneOf_Payload) -> Bool { - switch (lhs, rhs) { - case let (.sc0(l), .sc0(r)): return l == r - case let (.sr0(l), .sr0(r)): return l == r - case let (.sc1(l), .sc1(r)): return l == r - case let (.sr1(l), .sr1(r)): return l == r - default: return false - } - } - #endif + set {payload = .sr1(newValue)} + } + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum OneOf_Payload: Equatable { + ///!< Payload data interpreted as Cmd0 + case sc0(SessionCmd0) + ///!< Payload data interpreted as Resp0 + case sr0(SessionResp0) + ///!< Payload data interpreted as Cmd1 + case sc1(SessionCmd1) + ///!< Payload data interpreted as Resp1 + case sr1(SessionResp1) + + #if !swift(>=4.1) + static func ==(lhs: Sec1Payload.OneOf_Payload, rhs: Sec1Payload.OneOf_Payload) -> Bool { + // 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 (lhs, rhs) { + case (.sc0, .sc0): return { + guard case .sc0(let l) = lhs, case .sc0(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.sr0, .sr0): return { + guard case .sr0(let l) = lhs, case .sr0(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.sc1, .sc1): return { + guard case .sc1(let l) = lhs, case .sc1(let r) = rhs else { preconditionFailure() } + return l == r + }() + case (.sr1, .sr1): return { + guard case .sr1(let l) = lhs, case .sr1(let r) = rhs else { preconditionFailure() } + return l == r + }() + default: return false + } } + #endif + } - init() {} - - fileprivate var _storage = _StorageClass.defaultInstance + init() {} } -// MARK: - Code below here is support for the SwiftProtobuf runtime. +#if swift(>=5.5) && canImport(_Concurrency) +extension Sec1MsgType: @unchecked Sendable {} +extension SessionCmd1: @unchecked Sendable {} +extension SessionResp1: @unchecked Sendable {} +extension SessionCmd0: @unchecked Sendable {} +extension SessionResp0: @unchecked Sendable {} +extension Sec1Payload: @unchecked Sendable {} +extension Sec1Payload.OneOf_Payload: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) -private let _protobuf_package = "espressif" +// MARK: - Code below here is support for the SwiftProtobuf runtime. -extension Espressif_Sec1MsgType: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "Session_Command0"), - 1: .same(proto: "Session_Response0"), - 2: .same(proto: "Session_Command1"), - 3: .same(proto: "Session_Response1"), - ] +extension Sec1MsgType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "Session_Command0"), + 1: .same(proto: "Session_Response0"), + 2: .same(proto: "Session_Command1"), + 3: .same(proto: "Session_Response1"), + ] } -extension Espressif_SessionCmd1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".SessionCmd1" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 2: .standard(proto: "client_verify_data"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 2: try decoder.decodeSingularBytesField(value: &clientVerifyData) - default: break - } - } +extension SessionCmd1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "SessionCmd1" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 2: .standard(proto: "client_verify_data"), + ] + + 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 2: try { try decoder.decodeSingularBytesField(value: &self.clientVerifyData) }() + default: break + } } + } - func traverse(visitor: inout V) throws { - if !clientVerifyData.isEmpty { - try visitor.visitSingularBytesField(value: clientVerifyData, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) + func traverse(visitor: inout V) throws { + if !self.clientVerifyData.isEmpty { + try visitor.visitSingularBytesField(value: self.clientVerifyData, fieldNumber: 2) } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: SessionCmd1, rhs: SessionCmd1) -> Bool { + if lhs.clientVerifyData != rhs.clientVerifyData {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} - static func == (lhs: Espressif_SessionCmd1, rhs: Espressif_SessionCmd1) -> Bool { - if lhs.clientVerifyData != rhs.clientVerifyData { return false } - if lhs.unknownFields != rhs.unknownFields { return false } - return true +extension SessionResp1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "SessionResp1" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "status"), + 3: .standard(proto: "device_verify_data"), + ] + + 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.decodeSingularEnumField(value: &self.status) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self.deviceVerifyData) }() + default: break + } } -} + } -extension Espressif_SessionResp1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".SessionResp1" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "status"), - 3: .standard(proto: "device_verify_data"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularEnumField(value: &status) - case 3: try decoder.decodeSingularBytesField(value: &deviceVerifyData) - default: break - } - } + func traverse(visitor: inout V) throws { + if self.status != .success { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 1) } + if !self.deviceVerifyData.isEmpty { + try visitor.visitSingularBytesField(value: self.deviceVerifyData, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: SessionResp1, rhs: SessionResp1) -> Bool { + if lhs.status != rhs.status {return false} + if lhs.deviceVerifyData != rhs.deviceVerifyData {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} - func traverse(visitor: inout V) throws { - if status != .success { - try visitor.visitSingularEnumField(value: status, fieldNumber: 1) - } - if !deviceVerifyData.isEmpty { - try visitor.visitSingularBytesField(value: deviceVerifyData, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) +extension SessionCmd0: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "SessionCmd0" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "client_pubkey"), + ] + + 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.decodeSingularBytesField(value: &self.clientPubkey) }() + default: break + } } + } - static func == (lhs: Espressif_SessionResp1, rhs: Espressif_SessionResp1) -> Bool { - if lhs.status != rhs.status { return false } - if lhs.deviceVerifyData != rhs.deviceVerifyData { return false } - if lhs.unknownFields != rhs.unknownFields { return false } - return true + func traverse(visitor: inout V) throws { + if !self.clientPubkey.isEmpty { + try visitor.visitSingularBytesField(value: self.clientPubkey, fieldNumber: 1) } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: SessionCmd0, rhs: SessionCmd0) -> Bool { + if lhs.clientPubkey != rhs.clientPubkey {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } } -extension Espressif_SessionCmd0: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".SessionCmd0" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "client_pubkey"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularBytesField(value: &clientPubkey) - default: break - } - } +extension SessionResp0: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "SessionResp0" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "status"), + 2: .standard(proto: "device_pubkey"), + 3: .standard(proto: "device_random"), + ] + + 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.decodeSingularEnumField(value: &self.status) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self.devicePubkey) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self.deviceRandom) }() + default: break + } } + } - func traverse(visitor: inout V) throws { - if !clientPubkey.isEmpty { - try visitor.visitSingularBytesField(value: clientPubkey, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) + func traverse(visitor: inout V) throws { + if self.status != .success { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 1) } - - static func == (lhs: Espressif_SessionCmd0, rhs: Espressif_SessionCmd0) -> Bool { - if lhs.clientPubkey != rhs.clientPubkey { return false } - if lhs.unknownFields != rhs.unknownFields { return false } - return true + if !self.devicePubkey.isEmpty { + try visitor.visitSingularBytesField(value: self.devicePubkey, fieldNumber: 2) } + if !self.deviceRandom.isEmpty { + try visitor.visitSingularBytesField(value: self.deviceRandom, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: SessionResp0, rhs: SessionResp0) -> Bool { + if lhs.status != rhs.status {return false} + if lhs.devicePubkey != rhs.devicePubkey {return false} + if lhs.deviceRandom != rhs.deviceRandom {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } } -extension Espressif_SessionResp0: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".SessionResp0" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "status"), - 2: .standard(proto: "device_pubkey"), - 3: .standard(proto: "device_random"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularEnumField(value: &status) - case 2: try decoder.decodeSingularBytesField(value: &devicePubkey) - case 3: try decoder.decodeSingularBytesField(value: &deviceRandom) - default: break - } +extension Sec1Payload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "Sec1Payload" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "msg"), + 20: .same(proto: "sc0"), + 21: .same(proto: "sr0"), + 22: .same(proto: "sc1"), + 23: .same(proto: "sr1"), + ] + + 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.decodeSingularEnumField(value: &self.msg) }() + case 20: try { + var v: SessionCmd0? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .sc0(let m) = current {v = m} } - } - - func traverse(visitor: inout V) throws { - if status != .success { - try visitor.visitSingularEnumField(value: status, fieldNumber: 1) + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .sc0(v) } - if !devicePubkey.isEmpty { - try visitor.visitSingularBytesField(value: devicePubkey, fieldNumber: 2) + }() + case 21: try { + var v: SessionResp0? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .sr0(let m) = current {v = m} } - if !deviceRandom.isEmpty { - try visitor.visitSingularBytesField(value: deviceRandom, fieldNumber: 3) + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .sr0(v) } - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_SessionResp0, rhs: Espressif_SessionResp0) -> Bool { - if lhs.status != rhs.status { return false } - if lhs.devicePubkey != rhs.devicePubkey { return false } - if lhs.deviceRandom != rhs.deviceRandom { return false } - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} - -extension Espressif_Sec1Payload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".Sec1Payload" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "msg"), - 20: .same(proto: "sc0"), - 21: .same(proto: "sr0"), - 22: .same(proto: "sc1"), - 23: .same(proto: "sr1"), - ] - - fileprivate class _StorageClass { - var _msg: Espressif_Sec1MsgType = .sessionCommand0 - var _payload: Espressif_Sec1Payload.OneOf_Payload? - - static let defaultInstance = _StorageClass() - - private init() {} - - init(copying source: _StorageClass) { - _msg = source._msg - _payload = source._payload + }() + case 22: try { + var v: SessionCmd1? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .sc1(let m) = current {v = m} } - } - - fileprivate mutating func _uniqueStorage() -> _StorageClass { - if !isKnownUniquelyReferenced(&_storage) { - _storage = _StorageClass(copying: _storage) + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .sc1(v) } - return _storage - } - - mutating func decodeMessage(decoder: inout D) throws { - _ = _uniqueStorage() - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularEnumField(value: &_storage._msg) - case 20: - var v: Espressif_SessionCmd0? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .sc0(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .sc0(v) } - case 21: - var v: Espressif_SessionResp0? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .sr0(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .sr0(v) } - case 22: - var v: Espressif_SessionCmd1? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .sc1(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .sc1(v) } - case 23: - var v: Espressif_SessionResp1? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .sr1(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .sr1(v) } - default: break - } - } + }() + case 23: try { + var v: SessionResp1? + var hadOneofValue = false + if let current = self.payload { + hadOneofValue = true + if case .sr1(let m) = current {v = m} } - } - - func traverse(visitor: inout V) throws { - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - if _storage._msg != .sessionCommand0 { - try visitor.visitSingularEnumField(value: _storage._msg, fieldNumber: 1) - } - switch _storage._payload { - case let .sc0(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 20) - case let .sr0(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 21) - case let .sc1(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 22) - case let .sr1(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 23) - case nil: break - } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payload = .sr1(v) } - try unknownFields.traverse(visitor: &visitor) + }() + default: break + } } - - static func == (lhs: Espressif_Sec1Payload, rhs: Espressif_Sec1Payload) -> Bool { - if lhs._storage !== rhs._storage { - let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in - let _storage = _args.0 - let rhs_storage = _args.1 - if _storage._msg != rhs_storage._msg { return false } - if _storage._payload != rhs_storage._payload { return false } - return true - } - if !storagesAreEqual { return false } - } - if lhs.unknownFields != rhs.unknownFields { return false } - return true + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if self.msg != .sessionCommand0 { + try visitor.visitSingularEnumField(value: self.msg, fieldNumber: 1) + } + switch self.payload { + case .sc0?: try { + guard case .sc0(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 20) + }() + case .sr0?: try { + guard case .sr0(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 21) + }() + case .sc1?: try { + guard case .sc1(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 22) + }() + case .sr1?: try { + guard case .sr1(let v)? = self.payload else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 23) + }() + case nil: break } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Sec1Payload, rhs: Sec1Payload) -> Bool { + if lhs.msg != rhs.msg {return false} + if lhs.payload != rhs.payload {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } } diff --git a/ESPProvision/Proto/sec2.pb.swift b/ESPProvision/Proto/sec2.pb.swift index ca47ba1..e2024ad 100644 --- a/ESPProvision/Proto/sec2.pb.swift +++ b/ESPProvision/Proto/sec2.pb.swift @@ -6,19 +6,6 @@ // // For information on using the generated types, please see the documentation: // https://github.com/apple/swift-protobuf/ -// Copyright 2022 Espressif Systems -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. import Foundation import SwiftProtobuf @@ -34,7 +21,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP } /// A message must be of type Cmd0 / Cmd1 / Resp0 / Resp1 -enum Espressif_Sec2MsgType: SwiftProtobuf.Enum { +enum Sec2MsgType: SwiftProtobuf.Enum { typealias RawValue = Int case s2SessionCommand0 // = 0 case s2SessionResponse0 // = 1 @@ -70,9 +57,9 @@ enum Espressif_Sec2MsgType: SwiftProtobuf.Enum { #if swift(>=4.2) -extension Espressif_Sec2MsgType: CaseIterable { +extension Sec2MsgType: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Espressif_Sec2MsgType] = [ + static let allCases: [Sec2MsgType] = [ .s2SessionCommand0, .s2SessionResponse0, .s2SessionCommand1, @@ -83,7 +70,7 @@ extension Espressif_Sec2MsgType: CaseIterable { #endif // swift(>=4.2) /// Data structure of Session command0 packet -struct Espressif_S2SessionCmd0 { +struct S2SessionCmd0 { // 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. @@ -98,12 +85,12 @@ struct Espressif_S2SessionCmd0 { } /// Data structure of Session response0 packet -struct Espressif_S2SessionResp0 { +struct S2SessionResp0 { // 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. - var status: Espressif_Status = .success + var status: Status = .success var devicePubkey: Data = Data() @@ -115,7 +102,7 @@ struct Espressif_S2SessionResp0 { } /// Data structure of Session command1 packet -struct Espressif_S2SessionCmd1 { +struct S2SessionCmd1 { // 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. @@ -128,12 +115,12 @@ struct Espressif_S2SessionCmd1 { } /// Data structure of Session response1 packet -struct Espressif_S2SessionResp1 { +struct S2SessionResp1 { // 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. - var status: Espressif_Status = .success + var status: Status = .success var deviceProof: Data = Data() @@ -145,48 +132,48 @@ struct Espressif_S2SessionResp1 { } /// Payload structure of session data -struct Espressif_Sec2Payload { +struct Sec2Payload { // 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. ///!< Type of message - var msg: Espressif_Sec2MsgType = .s2SessionCommand0 + var msg: Sec2MsgType = .s2SessionCommand0 - var payload: Espressif_Sec2Payload.OneOf_Payload? = nil + var payload: Sec2Payload.OneOf_Payload? = nil ///!< Payload data interpreted as Cmd0 - var sc0: Espressif_S2SessionCmd0 { + var sc0: S2SessionCmd0 { get { if case .sc0(let v)? = payload {return v} - return Espressif_S2SessionCmd0() + return S2SessionCmd0() } set {payload = .sc0(newValue)} } ///!< Payload data interpreted as Resp0 - var sr0: Espressif_S2SessionResp0 { + var sr0: S2SessionResp0 { get { if case .sr0(let v)? = payload {return v} - return Espressif_S2SessionResp0() + return S2SessionResp0() } set {payload = .sr0(newValue)} } ///!< Payload data interpreted as Cmd1 - var sc1: Espressif_S2SessionCmd1 { + var sc1: S2SessionCmd1 { get { if case .sc1(let v)? = payload {return v} - return Espressif_S2SessionCmd1() + return S2SessionCmd1() } set {payload = .sc1(newValue)} } ///!< Payload data interpreted as Resp1 - var sr1: Espressif_S2SessionResp1 { + var sr1: S2SessionResp1 { get { if case .sr1(let v)? = payload {return v} - return Espressif_S2SessionResp1() + return S2SessionResp1() } set {payload = .sr1(newValue)} } @@ -195,16 +182,16 @@ struct Espressif_Sec2Payload { enum OneOf_Payload: Equatable { ///!< Payload data interpreted as Cmd0 - case sc0(Espressif_S2SessionCmd0) + case sc0(S2SessionCmd0) ///!< Payload data interpreted as Resp0 - case sr0(Espressif_S2SessionResp0) + case sr0(S2SessionResp0) ///!< Payload data interpreted as Cmd1 - case sc1(Espressif_S2SessionCmd1) + case sc1(S2SessionCmd1) ///!< Payload data interpreted as Resp1 - case sr1(Espressif_S2SessionResp1) + case sr1(S2SessionResp1) #if !swift(>=4.1) - static func ==(lhs: Espressif_Sec2Payload.OneOf_Payload, rhs: Espressif_Sec2Payload.OneOf_Payload) -> Bool { + static func ==(lhs: Sec2Payload.OneOf_Payload, rhs: Sec2Payload.OneOf_Payload) -> Bool { // 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 @@ -235,20 +222,18 @@ struct Espressif_Sec2Payload { } #if swift(>=5.5) && canImport(_Concurrency) -extension Espressif_Sec2MsgType: @unchecked Sendable {} -extension Espressif_S2SessionCmd0: @unchecked Sendable {} -extension Espressif_S2SessionResp0: @unchecked Sendable {} -extension Espressif_S2SessionCmd1: @unchecked Sendable {} -extension Espressif_S2SessionResp1: @unchecked Sendable {} -extension Espressif_Sec2Payload: @unchecked Sendable {} -extension Espressif_Sec2Payload.OneOf_Payload: @unchecked Sendable {} +extension Sec2MsgType: @unchecked Sendable {} +extension S2SessionCmd0: @unchecked Sendable {} +extension S2SessionResp0: @unchecked Sendable {} +extension S2SessionCmd1: @unchecked Sendable {} +extension S2SessionResp1: @unchecked Sendable {} +extension Sec2Payload: @unchecked Sendable {} +extension Sec2Payload.OneOf_Payload: @unchecked Sendable {} #endif // swift(>=5.5) && canImport(_Concurrency) // MARK: - Code below here is support for the SwiftProtobuf runtime. -fileprivate let _protobuf_package = "espressif" - -extension Espressif_Sec2MsgType: SwiftProtobuf._ProtoNameProviding { +extension Sec2MsgType: SwiftProtobuf._ProtoNameProviding { static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 0: .same(proto: "S2Session_Command0"), 1: .same(proto: "S2Session_Response0"), @@ -257,8 +242,8 @@ extension Espressif_Sec2MsgType: SwiftProtobuf._ProtoNameProviding { ] } -extension Espressif_S2SessionCmd0: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".S2SessionCmd0" +extension S2SessionCmd0: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "S2SessionCmd0" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .standard(proto: "client_username"), 2: .standard(proto: "client_pubkey"), @@ -287,7 +272,7 @@ extension Espressif_S2SessionCmd0: SwiftProtobuf.Message, SwiftProtobuf._Message try unknownFields.traverse(visitor: &visitor) } - static func ==(lhs: Espressif_S2SessionCmd0, rhs: Espressif_S2SessionCmd0) -> Bool { + static func ==(lhs: S2SessionCmd0, rhs: S2SessionCmd0) -> Bool { if lhs.clientUsername != rhs.clientUsername {return false} if lhs.clientPubkey != rhs.clientPubkey {return false} if lhs.unknownFields != rhs.unknownFields {return false} @@ -295,8 +280,8 @@ extension Espressif_S2SessionCmd0: SwiftProtobuf.Message, SwiftProtobuf._Message } } -extension Espressif_S2SessionResp0: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".S2SessionResp0" +extension S2SessionResp0: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "S2SessionResp0" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "status"), 2: .standard(proto: "device_pubkey"), @@ -330,7 +315,7 @@ extension Espressif_S2SessionResp0: SwiftProtobuf.Message, SwiftProtobuf._Messag try unknownFields.traverse(visitor: &visitor) } - static func ==(lhs: Espressif_S2SessionResp0, rhs: Espressif_S2SessionResp0) -> Bool { + static func ==(lhs: S2SessionResp0, rhs: S2SessionResp0) -> Bool { if lhs.status != rhs.status {return false} if lhs.devicePubkey != rhs.devicePubkey {return false} if lhs.deviceSalt != rhs.deviceSalt {return false} @@ -339,8 +324,8 @@ extension Espressif_S2SessionResp0: SwiftProtobuf.Message, SwiftProtobuf._Messag } } -extension Espressif_S2SessionCmd1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".S2SessionCmd1" +extension S2SessionCmd1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "S2SessionCmd1" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .standard(proto: "client_proof"), ] @@ -364,15 +349,15 @@ extension Espressif_S2SessionCmd1: SwiftProtobuf.Message, SwiftProtobuf._Message try unknownFields.traverse(visitor: &visitor) } - static func ==(lhs: Espressif_S2SessionCmd1, rhs: Espressif_S2SessionCmd1) -> Bool { + static func ==(lhs: S2SessionCmd1, rhs: S2SessionCmd1) -> Bool { if lhs.clientProof != rhs.clientProof {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } -extension Espressif_S2SessionResp1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".S2SessionResp1" +extension S2SessionResp1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "S2SessionResp1" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "status"), 2: .standard(proto: "device_proof"), @@ -406,7 +391,7 @@ extension Espressif_S2SessionResp1: SwiftProtobuf.Message, SwiftProtobuf._Messag try unknownFields.traverse(visitor: &visitor) } - static func ==(lhs: Espressif_S2SessionResp1, rhs: Espressif_S2SessionResp1) -> Bool { + static func ==(lhs: S2SessionResp1, rhs: S2SessionResp1) -> Bool { if lhs.status != rhs.status {return false} if lhs.deviceProof != rhs.deviceProof {return false} if lhs.deviceNonce != rhs.deviceNonce {return false} @@ -415,8 +400,8 @@ extension Espressif_S2SessionResp1: SwiftProtobuf.Message, SwiftProtobuf._Messag } } -extension Espressif_Sec2Payload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".Sec2Payload" +extension Sec2Payload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "Sec2Payload" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "msg"), 20: .same(proto: "sc0"), @@ -433,7 +418,7 @@ extension Espressif_Sec2Payload: SwiftProtobuf.Message, SwiftProtobuf._MessageIm switch fieldNumber { case 1: try { try decoder.decodeSingularEnumField(value: &self.msg) }() case 20: try { - var v: Espressif_S2SessionCmd0? + var v: S2SessionCmd0? var hadOneofValue = false if let current = self.payload { hadOneofValue = true @@ -446,7 +431,7 @@ extension Espressif_Sec2Payload: SwiftProtobuf.Message, SwiftProtobuf._MessageIm } }() case 21: try { - var v: Espressif_S2SessionResp0? + var v: S2SessionResp0? var hadOneofValue = false if let current = self.payload { hadOneofValue = true @@ -459,7 +444,7 @@ extension Espressif_Sec2Payload: SwiftProtobuf.Message, SwiftProtobuf._MessageIm } }() case 22: try { - var v: Espressif_S2SessionCmd1? + var v: S2SessionCmd1? var hadOneofValue = false if let current = self.payload { hadOneofValue = true @@ -472,7 +457,7 @@ extension Espressif_Sec2Payload: SwiftProtobuf.Message, SwiftProtobuf._MessageIm } }() case 23: try { - var v: Espressif_S2SessionResp1? + var v: S2SessionResp1? var hadOneofValue = false if let current = self.payload { hadOneofValue = true @@ -519,7 +504,7 @@ extension Espressif_Sec2Payload: SwiftProtobuf.Message, SwiftProtobuf._MessageIm try unknownFields.traverse(visitor: &visitor) } - static func ==(lhs: Espressif_Sec2Payload, rhs: Espressif_Sec2Payload) -> Bool { + static func ==(lhs: Sec2Payload, rhs: Sec2Payload) -> Bool { if lhs.msg != rhs.msg {return false} if lhs.payload != rhs.payload {return false} if lhs.unknownFields != rhs.unknownFields {return false} diff --git a/ESPProvision/Proto/session.pb.swift b/ESPProvision/Proto/session.pb.swift index 6a8fbaf..1a808f6 100644 --- a/ESPProvision/Proto/session.pb.swift +++ b/ESPProvision/Proto/session.pb.swift @@ -6,19 +6,6 @@ // // For information on using the generated types, please see the documentation: // https://github.com/apple/swift-protobuf/ -// Copyright 2020 Espressif Systems -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. import Foundation import SwiftProtobuf @@ -35,7 +22,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP /// Allowed values for the type of security /// being used in a protocomm session -enum Espressif_SecSchemeVersion: SwiftProtobuf.Enum { +enum SecSchemeVersion: SwiftProtobuf.Enum { typealias RawValue = Int ///!< Unsecured - plaintext communication @@ -74,9 +61,9 @@ enum Espressif_SecSchemeVersion: SwiftProtobuf.Enum { #if swift(>=4.2) -extension Espressif_SecSchemeVersion: CaseIterable { +extension SecSchemeVersion: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Espressif_SecSchemeVersion] = [ + static let allCases: [SecSchemeVersion] = [ .secScheme0, .secScheme1, .secScheme2, @@ -87,39 +74,39 @@ extension Espressif_SecSchemeVersion: CaseIterable { /// Data structure exchanged when establishing /// secure session between Host and Client -struct Espressif_SessionData { +struct SessionData { // 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. ///!< Type of security - var secVer: Espressif_SecSchemeVersion = .secScheme0 + var secVer: SecSchemeVersion = .secScheme0 - var proto: Espressif_SessionData.OneOf_Proto? = nil + var proto: SessionData.OneOf_Proto? = nil ///!< Payload data in case of security 0 - var sec0: Espressif_Sec0Payload { + var sec0: Sec0Payload { get { if case .sec0(let v)? = proto {return v} - return Espressif_Sec0Payload() + return Sec0Payload() } set {proto = .sec0(newValue)} } ///!< Payload data in case of security 1 - var sec1: Espressif_Sec1Payload { + var sec1: Sec1Payload { get { if case .sec1(let v)? = proto {return v} - return Espressif_Sec1Payload() + return Sec1Payload() } set {proto = .sec1(newValue)} } ///!< Payload data in case of security 2 - var sec2: Espressif_Sec2Payload { + var sec2: Sec2Payload { get { if case .sec2(let v)? = proto {return v} - return Espressif_Sec2Payload() + return Sec2Payload() } set {proto = .sec2(newValue)} } @@ -128,14 +115,14 @@ struct Espressif_SessionData { enum OneOf_Proto: Equatable { ///!< Payload data in case of security 0 - case sec0(Espressif_Sec0Payload) + case sec0(Sec0Payload) ///!< Payload data in case of security 1 - case sec1(Espressif_Sec1Payload) + case sec1(Sec1Payload) ///!< Payload data in case of security 2 - case sec2(Espressif_Sec2Payload) + case sec2(Sec2Payload) #if !swift(>=4.1) - static func ==(lhs: Espressif_SessionData.OneOf_Proto, rhs: Espressif_SessionData.OneOf_Proto) -> Bool { + static func ==(lhs: SessionData.OneOf_Proto, rhs: SessionData.OneOf_Proto) -> Bool { // 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 @@ -162,16 +149,14 @@ struct Espressif_SessionData { } #if swift(>=5.5) && canImport(_Concurrency) -extension Espressif_SecSchemeVersion: @unchecked Sendable {} -extension Espressif_SessionData: @unchecked Sendable {} -extension Espressif_SessionData.OneOf_Proto: @unchecked Sendable {} +extension SecSchemeVersion: @unchecked Sendable {} +extension SessionData: @unchecked Sendable {} +extension SessionData.OneOf_Proto: @unchecked Sendable {} #endif // swift(>=5.5) && canImport(_Concurrency) // MARK: - Code below here is support for the SwiftProtobuf runtime. -fileprivate let _protobuf_package = "espressif" - -extension Espressif_SecSchemeVersion: SwiftProtobuf._ProtoNameProviding { +extension SecSchemeVersion: SwiftProtobuf._ProtoNameProviding { static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 0: .same(proto: "SecScheme0"), 1: .same(proto: "SecScheme1"), @@ -179,8 +164,8 @@ extension Espressif_SecSchemeVersion: SwiftProtobuf._ProtoNameProviding { ] } -extension Espressif_SessionData: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".SessionData" +extension SessionData: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "SessionData" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 2: .standard(proto: "sec_ver"), 10: .same(proto: "sec0"), @@ -196,7 +181,7 @@ extension Espressif_SessionData: SwiftProtobuf.Message, SwiftProtobuf._MessageIm switch fieldNumber { case 2: try { try decoder.decodeSingularEnumField(value: &self.secVer) }() case 10: try { - var v: Espressif_Sec0Payload? + var v: Sec0Payload? var hadOneofValue = false if let current = self.proto { hadOneofValue = true @@ -209,7 +194,7 @@ extension Espressif_SessionData: SwiftProtobuf.Message, SwiftProtobuf._MessageIm } }() case 11: try { - var v: Espressif_Sec1Payload? + var v: Sec1Payload? var hadOneofValue = false if let current = self.proto { hadOneofValue = true @@ -222,7 +207,7 @@ extension Espressif_SessionData: SwiftProtobuf.Message, SwiftProtobuf._MessageIm } }() case 12: try { - var v: Espressif_Sec2Payload? + var v: Sec2Payload? var hadOneofValue = false if let current = self.proto { hadOneofValue = true @@ -265,7 +250,7 @@ extension Espressif_SessionData: SwiftProtobuf.Message, SwiftProtobuf._MessageIm try unknownFields.traverse(visitor: &visitor) } - static func ==(lhs: Espressif_SessionData, rhs: Espressif_SessionData) -> Bool { + static func ==(lhs: SessionData, rhs: SessionData) -> Bool { if lhs.secVer != rhs.secVer {return false} if lhs.proto != rhs.proto {return false} if lhs.unknownFields != rhs.unknownFields {return false} diff --git a/ESPProvision/Proto/wifi_config.pb.swift b/ESPProvision/Proto/wifi_config.pb.swift deleted file mode 100644 index b0c20d1..0000000 --- a/ESPProvision/Proto/wifi_config.pb.swift +++ /dev/null @@ -1,685 +0,0 @@ -// DO NOT EDIT. -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: wifi_config.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -// Copyright 2020 Espressif Systems -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that your are building against the same version of the API -// that was used to generate this file. -private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -enum Espressif_WiFiConfigMsgType: SwiftProtobuf.Enum { - typealias RawValue = Int - case typeCmdGetStatus // = 0 - case typeRespGetStatus // = 1 - case typeCmdSetConfig // = 2 - case typeRespSetConfig // = 3 - case typeCmdApplyConfig // = 4 - case typeRespApplyConfig // = 5 - case UNRECOGNIZED(Int) - - init() { - self = .typeCmdGetStatus - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .typeCmdGetStatus - case 1: self = .typeRespGetStatus - case 2: self = .typeCmdSetConfig - case 3: self = .typeRespSetConfig - case 4: self = .typeCmdApplyConfig - case 5: self = .typeRespApplyConfig - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .typeCmdGetStatus: return 0 - case .typeRespGetStatus: return 1 - case .typeCmdSetConfig: return 2 - case .typeRespSetConfig: return 3 - case .typeCmdApplyConfig: return 4 - case .typeRespApplyConfig: return 5 - case let .UNRECOGNIZED(i): return i - } - } -} - -#if swift(>=4.2) - - extension Espressif_WiFiConfigMsgType: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Espressif_WiFiConfigMsgType] = [ - .typeCmdGetStatus, - .typeRespGetStatus, - .typeCmdSetConfig, - .typeRespSetConfig, - .typeCmdApplyConfig, - .typeRespApplyConfig, - ] - } - -#endif // swift(>=4.2) - -struct Espressif_CmdGetStatus { - // 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. - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -struct Espressif_RespGetStatus { - // 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. - - var status: Espressif_Status { - get { return _storage._status } - set { _uniqueStorage()._status = newValue } - } - - var staState: Espressif_WifiStationState { - get { return _storage._staState } - set { _uniqueStorage()._staState = newValue } - } - - var state: OneOf_State? { - get { return _storage._state } - set { _uniqueStorage()._state = newValue } - } - - var failReason: Espressif_WifiConnectFailedReason { - get { - if case let .failReason(v)? = _storage._state { return v } - return .authError - } - set { _uniqueStorage()._state = .failReason(newValue) } - } - - var connected: Espressif_WifiConnectedState { - get { - if case let .connected(v)? = _storage._state { return v } - return Espressif_WifiConnectedState() - } - set { _uniqueStorage()._state = .connected(newValue) } - } - - var unknownFields = SwiftProtobuf.UnknownStorage() - - enum OneOf_State: Equatable { - case failReason(Espressif_WifiConnectFailedReason) - case connected(Espressif_WifiConnectedState) - - #if !swift(>=4.1) - static func == (lhs: Espressif_RespGetStatus.OneOf_State, rhs: Espressif_RespGetStatus.OneOf_State) -> Bool { - switch (lhs, rhs) { - case let (.failReason(l), .failReason(r)): return l == r - case let (.connected(l), .connected(r)): return l == r - default: return false - } - } - #endif - } - - init() {} - - fileprivate var _storage = _StorageClass.defaultInstance -} - -struct Espressif_CmdSetConfig { - // 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. - - var ssid: Data = SwiftProtobuf.Internal.emptyData - - var passphrase: Data = SwiftProtobuf.Internal.emptyData - - var bssid: Data = SwiftProtobuf.Internal.emptyData - - var channel: Int32 = 0 - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -struct Espressif_RespSetConfig { - // 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. - - var status: Espressif_Status = .success - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -struct Espressif_CmdApplyConfig { - // 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. - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -struct Espressif_RespApplyConfig { - // 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. - - var status: Espressif_Status = .success - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -struct Espressif_WiFiConfigPayload { - // 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. - - var msg: Espressif_WiFiConfigMsgType { - get { return _storage._msg } - set { _uniqueStorage()._msg = newValue } - } - - var payload: OneOf_Payload? { - get { return _storage._payload } - set { _uniqueStorage()._payload = newValue } - } - - var cmdGetStatus: Espressif_CmdGetStatus { - get { - if case let .cmdGetStatus(v)? = _storage._payload { return v } - return Espressif_CmdGetStatus() - } - set { _uniqueStorage()._payload = .cmdGetStatus(newValue) } - } - - var respGetStatus: Espressif_RespGetStatus { - get { - if case let .respGetStatus(v)? = _storage._payload { return v } - return Espressif_RespGetStatus() - } - set { _uniqueStorage()._payload = .respGetStatus(newValue) } - } - - var cmdSetConfig: Espressif_CmdSetConfig { - get { - if case let .cmdSetConfig(v)? = _storage._payload { return v } - return Espressif_CmdSetConfig() - } - set { _uniqueStorage()._payload = .cmdSetConfig(newValue) } - } - - var respSetConfig: Espressif_RespSetConfig { - get { - if case let .respSetConfig(v)? = _storage._payload { return v } - return Espressif_RespSetConfig() - } - set { _uniqueStorage()._payload = .respSetConfig(newValue) } - } - - var cmdApplyConfig: Espressif_CmdApplyConfig { - get { - if case let .cmdApplyConfig(v)? = _storage._payload { return v } - return Espressif_CmdApplyConfig() - } - set { _uniqueStorage()._payload = .cmdApplyConfig(newValue) } - } - - var respApplyConfig: Espressif_RespApplyConfig { - get { - if case let .respApplyConfig(v)? = _storage._payload { return v } - return Espressif_RespApplyConfig() - } - set { _uniqueStorage()._payload = .respApplyConfig(newValue) } - } - - var unknownFields = SwiftProtobuf.UnknownStorage() - - enum OneOf_Payload: Equatable { - case cmdGetStatus(Espressif_CmdGetStatus) - case respGetStatus(Espressif_RespGetStatus) - case cmdSetConfig(Espressif_CmdSetConfig) - case respSetConfig(Espressif_RespSetConfig) - case cmdApplyConfig(Espressif_CmdApplyConfig) - case respApplyConfig(Espressif_RespApplyConfig) - - #if !swift(>=4.1) - static func == (lhs: Espressif_WiFiConfigPayload.OneOf_Payload, rhs: Espressif_WiFiConfigPayload.OneOf_Payload) -> Bool { - switch (lhs, rhs) { - case let (.cmdGetStatus(l), .cmdGetStatus(r)): return l == r - case let (.respGetStatus(l), .respGetStatus(r)): return l == r - case let (.cmdSetConfig(l), .cmdSetConfig(r)): return l == r - case let (.respSetConfig(l), .respSetConfig(r)): return l == r - case let (.cmdApplyConfig(l), .cmdApplyConfig(r)): return l == r - case let (.respApplyConfig(l), .respApplyConfig(r)): return l == r - default: return false - } - } - #endif - } - - init() {} - - fileprivate var _storage = _StorageClass.defaultInstance -} - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -private let _protobuf_package = "espressif" - -extension Espressif_WiFiConfigMsgType: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "TypeCmdGetStatus"), - 1: .same(proto: "TypeRespGetStatus"), - 2: .same(proto: "TypeCmdSetConfig"), - 3: .same(proto: "TypeRespSetConfig"), - 4: .same(proto: "TypeCmdApplyConfig"), - 5: .same(proto: "TypeRespApplyConfig"), - ] -} - -extension Espressif_CmdGetStatus: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CmdGetStatus" - static let _protobuf_nameMap = SwiftProtobuf._NameMap() - - mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() {} - } - - func traverse(visitor: inout V) throws { - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_CmdGetStatus, rhs: Espressif_CmdGetStatus) -> Bool { - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} - -extension Espressif_RespGetStatus: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".RespGetStatus" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "status"), - 2: .standard(proto: "sta_state"), - 10: .standard(proto: "fail_reason"), - 11: .same(proto: "connected"), - ] - - fileprivate class _StorageClass { - var _status: Espressif_Status = .success - var _staState: Espressif_WifiStationState = .connected - var _state: Espressif_RespGetStatus.OneOf_State? - - static let defaultInstance = _StorageClass() - - private init() {} - - init(copying source: _StorageClass) { - _status = source._status - _staState = source._staState - _state = source._state - } - } - - fileprivate mutating func _uniqueStorage() -> _StorageClass { - if !isKnownUniquelyReferenced(&_storage) { - _storage = _StorageClass(copying: _storage) - } - return _storage - } - - mutating func decodeMessage(decoder: inout D) throws { - _ = _uniqueStorage() - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularEnumField(value: &_storage._status) - case 2: try decoder.decodeSingularEnumField(value: &_storage._staState) - case 10: - if _storage._state != nil { try decoder.handleConflictingOneOf() } - var v: Espressif_WifiConnectFailedReason? - try decoder.decodeSingularEnumField(value: &v) - if let v = v { _storage._state = .failReason(v) } - case 11: - var v: Espressif_WifiConnectedState? - if let current = _storage._state { - try decoder.handleConflictingOneOf() - if case let .connected(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._state = .connected(v) } - default: break - } - } - } - } - - func traverse(visitor: inout V) throws { - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - if _storage._status != .success { - try visitor.visitSingularEnumField(value: _storage._status, fieldNumber: 1) - } - if _storage._staState != .connected { - try visitor.visitSingularEnumField(value: _storage._staState, fieldNumber: 2) - } - switch _storage._state { - case let .failReason(v)?: - try visitor.visitSingularEnumField(value: v, fieldNumber: 10) - case let .connected(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 11) - case nil: break - } - } - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_RespGetStatus, rhs: Espressif_RespGetStatus) -> Bool { - if lhs._storage !== rhs._storage { - let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in - let _storage = _args.0 - let rhs_storage = _args.1 - if _storage._status != rhs_storage._status { return false } - if _storage._staState != rhs_storage._staState { return false } - if _storage._state != rhs_storage._state { return false } - return true - } - if !storagesAreEqual { return false } - } - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} - -extension Espressif_CmdSetConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CmdSetConfig" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "ssid"), - 2: .same(proto: "passphrase"), - 3: .same(proto: "bssid"), - 4: .same(proto: "channel"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularBytesField(value: &ssid) - case 2: try decoder.decodeSingularBytesField(value: &passphrase) - case 3: try decoder.decodeSingularBytesField(value: &bssid) - case 4: try decoder.decodeSingularInt32Field(value: &channel) - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !ssid.isEmpty { - try visitor.visitSingularBytesField(value: ssid, fieldNumber: 1) - } - if !passphrase.isEmpty { - try visitor.visitSingularBytesField(value: passphrase, fieldNumber: 2) - } - if !bssid.isEmpty { - try visitor.visitSingularBytesField(value: bssid, fieldNumber: 3) - } - if channel != 0 { - try visitor.visitSingularInt32Field(value: channel, fieldNumber: 4) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_CmdSetConfig, rhs: Espressif_CmdSetConfig) -> Bool { - if lhs.ssid != rhs.ssid { return false } - if lhs.passphrase != rhs.passphrase { return false } - if lhs.bssid != rhs.bssid { return false } - if lhs.channel != rhs.channel { return false } - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} - -extension Espressif_RespSetConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".RespSetConfig" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "status"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularEnumField(value: &status) - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if status != .success { - try visitor.visitSingularEnumField(value: status, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_RespSetConfig, rhs: Espressif_RespSetConfig) -> Bool { - if lhs.status != rhs.status { return false } - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} - -extension Espressif_CmdApplyConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CmdApplyConfig" - static let _protobuf_nameMap = SwiftProtobuf._NameMap() - - mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() {} - } - - func traverse(visitor: inout V) throws { - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_CmdApplyConfig, rhs: Espressif_CmdApplyConfig) -> Bool { - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} - -extension Espressif_RespApplyConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".RespApplyConfig" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "status"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularEnumField(value: &status) - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if status != .success { - try visitor.visitSingularEnumField(value: status, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_RespApplyConfig, rhs: Espressif_RespApplyConfig) -> Bool { - if lhs.status != rhs.status { return false } - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} - -extension Espressif_WiFiConfigPayload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".WiFiConfigPayload" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "msg"), - 10: .standard(proto: "cmd_get_status"), - 11: .standard(proto: "resp_get_status"), - 12: .standard(proto: "cmd_set_config"), - 13: .standard(proto: "resp_set_config"), - 14: .standard(proto: "cmd_apply_config"), - 15: .standard(proto: "resp_apply_config"), - ] - - fileprivate class _StorageClass { - var _msg: Espressif_WiFiConfigMsgType = .typeCmdGetStatus - var _payload: Espressif_WiFiConfigPayload.OneOf_Payload? - - static let defaultInstance = _StorageClass() - - private init() {} - - init(copying source: _StorageClass) { - _msg = source._msg - _payload = source._payload - } - } - - fileprivate mutating func _uniqueStorage() -> _StorageClass { - if !isKnownUniquelyReferenced(&_storage) { - _storage = _StorageClass(copying: _storage) - } - return _storage - } - - mutating func decodeMessage(decoder: inout D) throws { - _ = _uniqueStorage() - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularEnumField(value: &_storage._msg) - case 10: - var v: Espressif_CmdGetStatus? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .cmdGetStatus(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .cmdGetStatus(v) } - case 11: - var v: Espressif_RespGetStatus? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .respGetStatus(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .respGetStatus(v) } - case 12: - var v: Espressif_CmdSetConfig? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .cmdSetConfig(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .cmdSetConfig(v) } - case 13: - var v: Espressif_RespSetConfig? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .respSetConfig(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .respSetConfig(v) } - case 14: - var v: Espressif_CmdApplyConfig? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .cmdApplyConfig(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .cmdApplyConfig(v) } - case 15: - var v: Espressif_RespApplyConfig? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .respApplyConfig(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .respApplyConfig(v) } - default: break - } - } - } - } - - func traverse(visitor: inout V) throws { - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - if _storage._msg != .typeCmdGetStatus { - try visitor.visitSingularEnumField(value: _storage._msg, fieldNumber: 1) - } - switch _storage._payload { - case let .cmdGetStatus(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 10) - case let .respGetStatus(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 11) - case let .cmdSetConfig(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 12) - case let .respSetConfig(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 13) - case let .cmdApplyConfig(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 14) - case let .respApplyConfig(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 15) - case nil: break - } - } - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_WiFiConfigPayload, rhs: Espressif_WiFiConfigPayload) -> Bool { - if lhs._storage !== rhs._storage { - let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in - let _storage = _args.0 - let rhs_storage = _args.1 - if _storage._msg != rhs_storage._msg { return false } - if _storage._payload != rhs_storage._payload { return false } - return true - } - if !storagesAreEqual { return false } - } - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} diff --git a/ESPProvision/Proto/wifi_constants.pb.swift b/ESPProvision/Proto/wifi_constants.pb.swift deleted file mode 100644 index 18109bd..0000000 --- a/ESPProvision/Proto/wifi_constants.pb.swift +++ /dev/null @@ -1,289 +0,0 @@ -// DO NOT EDIT. -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: wifi_constants.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -// Copyright 2020 Espressif Systems -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that your are building against the same version of the API -// that was used to generate this file. -private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -enum Espressif_WifiStationState: SwiftProtobuf.Enum { - typealias RawValue = Int - case connected // = 0 - case connecting // = 1 - case disconnected // = 2 - case connectionFailed // = 3 - case UNRECOGNIZED(Int) - - init() { - self = .connected - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .connected - case 1: self = .connecting - case 2: self = .disconnected - case 3: self = .connectionFailed - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .connected: return 0 - case .connecting: return 1 - case .disconnected: return 2 - case .connectionFailed: return 3 - case let .UNRECOGNIZED(i): return i - } - } -} - -#if swift(>=4.2) - - extension Espressif_WifiStationState: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Espressif_WifiStationState] = [ - .connected, - .connecting, - .disconnected, - .connectionFailed, - ] - } - -#endif // swift(>=4.2) - -enum Espressif_WifiConnectFailedReason: SwiftProtobuf.Enum { - typealias RawValue = Int - case authError // = 0 - case networkNotFound // = 1 - case UNRECOGNIZED(Int) - - init() { - self = .authError - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .authError - case 1: self = .networkNotFound - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .authError: return 0 - case .networkNotFound: return 1 - case let .UNRECOGNIZED(i): return i - } - } -} - -#if swift(>=4.2) - - extension Espressif_WifiConnectFailedReason: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Espressif_WifiConnectFailedReason] = [ - .authError, - .networkNotFound, - ] - } - -#endif // swift(>=4.2) - -public enum Espressif_WifiAuthMode: SwiftProtobuf.Enum { - public typealias RawValue = Int - case open // = 0 - case wep // = 1 - case wpaPsk // = 2 - case wpa2Psk // = 3 - case wpaWpa2Psk // = 4 - case wpa2Enterprise // = 5 - case wpa3Psk // = 6 - case wpa2Wpa3Psk // = 7 - case UNRECOGNIZED(Int) - - public init() { - self = .open - } - - public init?(rawValue: Int) { - switch rawValue { - case 0: self = .open - case 1: self = .wep - case 2: self = .wpaPsk - case 3: self = .wpa2Psk - case 4: self = .wpaWpa2Psk - case 5: self = .wpa2Enterprise - case 6: self = .wpa3Psk - case 7: self = .wpa2Wpa3Psk - default: self = .UNRECOGNIZED(rawValue) - } - } - - public var rawValue: Int { - switch self { - case .open: return 0 - case .wep: return 1 - case .wpaPsk: return 2 - case .wpa2Psk: return 3 - case .wpaWpa2Psk: return 4 - case .wpa2Enterprise: return 5 - case .wpa3Psk: return 6 - case .wpa2Wpa3Psk: return 7 - case let .UNRECOGNIZED(i): return i - } - } -} - -#if swift(>=4.2) - - extension Espressif_WifiAuthMode: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - public static var allCases: [Espressif_WifiAuthMode] = [ - .open, - .wep, - .wpaPsk, - .wpa2Psk, - .wpaWpa2Psk, - .wpa2Enterprise, - .wpa3Psk, - .wpa2Wpa3Psk, - ] - } - -#endif // swift(>=4.2) - -struct Espressif_WifiConnectedState { - // 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. - - var ip4Addr: String = String() - - var authMode: Espressif_WifiAuthMode = .open - - var ssid: Data = SwiftProtobuf.Internal.emptyData - - var bssid: Data = SwiftProtobuf.Internal.emptyData - - var channel: Int32 = 0 - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -private let _protobuf_package = "espressif" - -extension Espressif_WifiStationState: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "Connected"), - 1: .same(proto: "Connecting"), - 2: .same(proto: "Disconnected"), - 3: .same(proto: "ConnectionFailed"), - ] -} - -extension Espressif_WifiConnectFailedReason: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "AuthError"), - 1: .same(proto: "NetworkNotFound"), - ] -} - -extension Espressif_WifiAuthMode: SwiftProtobuf._ProtoNameProviding { - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "Open"), - 1: .same(proto: "WEP"), - 2: .same(proto: "WPA_PSK"), - 3: .same(proto: "WPA2_PSK"), - 4: .same(proto: "WPA_WPA2_PSK"), - 5: .same(proto: "WPA2_ENTERPRISE"), - 6: .same(proto: "WPA3_PSK"), - 7: .same(proto: "WPA2_WPA3_PSK"), - ] -} - -extension Espressif_WifiConnectedState: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".WifiConnectedState" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "ip4_addr"), - 2: .standard(proto: "auth_mode"), - 3: .same(proto: "ssid"), - 4: .same(proto: "bssid"), - 5: .same(proto: "channel"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularStringField(value: &ip4Addr) - case 2: try decoder.decodeSingularEnumField(value: &authMode) - case 3: try decoder.decodeSingularBytesField(value: &ssid) - case 4: try decoder.decodeSingularBytesField(value: &bssid) - case 5: try decoder.decodeSingularInt32Field(value: &channel) - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !ip4Addr.isEmpty { - try visitor.visitSingularStringField(value: ip4Addr, fieldNumber: 1) - } - if authMode != .open { - try visitor.visitSingularEnumField(value: authMode, fieldNumber: 2) - } - if !ssid.isEmpty { - try visitor.visitSingularBytesField(value: ssid, fieldNumber: 3) - } - if !bssid.isEmpty { - try visitor.visitSingularBytesField(value: bssid, fieldNumber: 4) - } - if channel != 0 { - try visitor.visitSingularInt32Field(value: channel, fieldNumber: 5) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_WifiConnectedState, rhs: Espressif_WifiConnectedState) -> Bool { - if lhs.ip4Addr != rhs.ip4Addr { return false } - if lhs.authMode != rhs.authMode { return false } - if lhs.ssid != rhs.ssid { return false } - if lhs.bssid != rhs.bssid { return false } - if lhs.channel != rhs.channel { return false } - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} diff --git a/ESPProvision/Proto/wifi_scan.pb.swift b/ESPProvision/Proto/wifi_scan.pb.swift deleted file mode 100644 index f04c4f6..0000000 --- a/ESPProvision/Proto/wifi_scan.pb.swift +++ /dev/null @@ -1,677 +0,0 @@ -// DO NOT EDIT. -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: wifi_scan.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -// Copyright 2020 Espressif Systems -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -import Foundation -import SwiftProtobuf - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that your are building against the same version of the API -// that was used to generate this file. -private struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -enum Espressif_WiFiScanMsgType: SwiftProtobuf.Enum { - typealias RawValue = Int - case typeCmdScanStart // = 0 - case typeRespScanStart // = 1 - case typeCmdScanStatus // = 2 - case typeRespScanStatus // = 3 - case typeCmdScanResult // = 4 - case typeRespScanResult // = 5 - case UNRECOGNIZED(Int) - - init() { - self = .typeCmdScanStart - } - - init?(rawValue: Int) { - switch rawValue { - case 0: self = .typeCmdScanStart - case 1: self = .typeRespScanStart - case 2: self = .typeCmdScanStatus - case 3: self = .typeRespScanStatus - case 4: self = .typeCmdScanResult - case 5: self = .typeRespScanResult - default: self = .UNRECOGNIZED(rawValue) - } - } - - var rawValue: Int { - switch self { - case .typeCmdScanStart: return 0 - case .typeRespScanStart: return 1 - case .typeCmdScanStatus: return 2 - case .typeRespScanStatus: return 3 - case .typeCmdScanResult: return 4 - case .typeRespScanResult: return 5 - case let .UNRECOGNIZED(i): return i - } - } -} - -#if swift(>=4.2) - - extension Espressif_WiFiScanMsgType: CaseIterable { - // The compiler won't synthesize support with the UNRECOGNIZED case. - static var allCases: [Espressif_WiFiScanMsgType] = [ - .typeCmdScanStart, - .typeRespScanStart, - .typeCmdScanStatus, - .typeRespScanStatus, - .typeCmdScanResult, - .typeRespScanResult, - ] - } - -#endif // swift(>=4.2) - -struct Espressif_CmdScanStart { - // 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. - - var blocking: Bool = false - - var passive: Bool = false - - var groupChannels: UInt32 = 0 - - var periodMs: UInt32 = 0 - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -struct Espressif_RespScanStart { - // 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. - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -struct Espressif_CmdScanStatus { - // 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. - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -struct Espressif_RespScanStatus { - // 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. - - var scanFinished: Bool = false - - var resultCount: UInt32 = 0 - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -struct Espressif_CmdScanResult { - // 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. - - var startIndex: UInt32 = 0 - - var count: UInt32 = 0 - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -struct Espressif_WiFiScanResult { - // 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. - - var ssid: Data = SwiftProtobuf.Internal.emptyData - - var channel: UInt32 = 0 - - var rssi: Int32 = 0 - - var bssid: Data = SwiftProtobuf.Internal.emptyData - - var auth: Espressif_WifiAuthMode = .open - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -struct Espressif_RespScanResult { - // 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. - - var entries: [Espressif_WiFiScanResult] = [] - - var unknownFields = SwiftProtobuf.UnknownStorage() - - init() {} -} - -struct Espressif_WiFiScanPayload { - // 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. - - var msg: Espressif_WiFiScanMsgType { - get { return _storage._msg } - set { _uniqueStorage()._msg = newValue } - } - - var status: Espressif_Status { - get { return _storage._status } - set { _uniqueStorage()._status = newValue } - } - - var payload: OneOf_Payload? { - get { return _storage._payload } - set { _uniqueStorage()._payload = newValue } - } - - var cmdScanStart: Espressif_CmdScanStart { - get { - if case let .cmdScanStart(v)? = _storage._payload { return v } - return Espressif_CmdScanStart() - } - set { _uniqueStorage()._payload = .cmdScanStart(newValue) } - } - - var respScanStart: Espressif_RespScanStart { - get { - if case let .respScanStart(v)? = _storage._payload { return v } - return Espressif_RespScanStart() - } - set { _uniqueStorage()._payload = .respScanStart(newValue) } - } - - var cmdScanStatus: Espressif_CmdScanStatus { - get { - if case let .cmdScanStatus(v)? = _storage._payload { return v } - return Espressif_CmdScanStatus() - } - set { _uniqueStorage()._payload = .cmdScanStatus(newValue) } - } - - var respScanStatus: Espressif_RespScanStatus { - get { - if case let .respScanStatus(v)? = _storage._payload { return v } - return Espressif_RespScanStatus() - } - set { _uniqueStorage()._payload = .respScanStatus(newValue) } - } - - var cmdScanResult: Espressif_CmdScanResult { - get { - if case let .cmdScanResult(v)? = _storage._payload { return v } - return Espressif_CmdScanResult() - } - set { _uniqueStorage()._payload = .cmdScanResult(newValue) } - } - - var respScanResult: Espressif_RespScanResult { - get { - if case let .respScanResult(v)? = _storage._payload { return v } - return Espressif_RespScanResult() - } - set { _uniqueStorage()._payload = .respScanResult(newValue) } - } - - var unknownFields = SwiftProtobuf.UnknownStorage() - - enum OneOf_Payload: Equatable { - case cmdScanStart(Espressif_CmdScanStart) - case respScanStart(Espressif_RespScanStart) - case cmdScanStatus(Espressif_CmdScanStatus) - case respScanStatus(Espressif_RespScanStatus) - case cmdScanResult(Espressif_CmdScanResult) - case respScanResult(Espressif_RespScanResult) - - #if !swift(>=4.1) - static func == (lhs: Espressif_WiFiScanPayload.OneOf_Payload, rhs: Espressif_WiFiScanPayload.OneOf_Payload) -> Bool { - switch (lhs, rhs) { - case let (.cmdScanStart(l), .cmdScanStart(r)): return l == r - case let (.respScanStart(l), .respScanStart(r)): return l == r - case let (.cmdScanStatus(l), .cmdScanStatus(r)): return l == r - case let (.respScanStatus(l), .respScanStatus(r)): return l == r - case let (.cmdScanResult(l), .cmdScanResult(r)): return l == r - case let (.respScanResult(l), .respScanResult(r)): return l == r - default: return false - } - } - #endif - } - - init() {} - - fileprivate var _storage = _StorageClass.defaultInstance -} - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -private let _protobuf_package = "espressif" - -extension Espressif_WiFiScanMsgType: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "TypeCmdScanStart"), - 1: .same(proto: "TypeRespScanStart"), - 2: .same(proto: "TypeCmdScanStatus"), - 3: .same(proto: "TypeRespScanStatus"), - 4: .same(proto: "TypeCmdScanResult"), - 5: .same(proto: "TypeRespScanResult"), - ] -} - -extension Espressif_CmdScanStart: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CmdScanStart" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "blocking"), - 2: .same(proto: "passive"), - 3: .standard(proto: "group_channels"), - 4: .standard(proto: "period_ms"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularBoolField(value: &blocking) - case 2: try decoder.decodeSingularBoolField(value: &passive) - case 3: try decoder.decodeSingularUInt32Field(value: &groupChannels) - case 4: try decoder.decodeSingularUInt32Field(value: &periodMs) - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if blocking != false { - try visitor.visitSingularBoolField(value: blocking, fieldNumber: 1) - } - if passive != false { - try visitor.visitSingularBoolField(value: passive, fieldNumber: 2) - } - if groupChannels != 0 { - try visitor.visitSingularUInt32Field(value: groupChannels, fieldNumber: 3) - } - if periodMs != 0 { - try visitor.visitSingularUInt32Field(value: periodMs, fieldNumber: 4) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_CmdScanStart, rhs: Espressif_CmdScanStart) -> Bool { - if lhs.blocking != rhs.blocking { return false } - if lhs.passive != rhs.passive { return false } - if lhs.groupChannels != rhs.groupChannels { return false } - if lhs.periodMs != rhs.periodMs { return false } - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} - -extension Espressif_RespScanStart: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".RespScanStart" - static let _protobuf_nameMap = SwiftProtobuf._NameMap() - - mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() {} - } - - func traverse(visitor: inout V) throws { - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_RespScanStart, rhs: Espressif_RespScanStart) -> Bool { - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} - -extension Espressif_CmdScanStatus: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CmdScanStatus" - static let _protobuf_nameMap = SwiftProtobuf._NameMap() - - mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() {} - } - - func traverse(visitor: inout V) throws { - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_CmdScanStatus, rhs: Espressif_CmdScanStatus) -> Bool { - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} - -extension Espressif_RespScanStatus: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".RespScanStatus" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "scan_finished"), - 2: .standard(proto: "result_count"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularBoolField(value: &scanFinished) - case 2: try decoder.decodeSingularUInt32Field(value: &resultCount) - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if scanFinished != false { - try visitor.visitSingularBoolField(value: scanFinished, fieldNumber: 1) - } - if resultCount != 0 { - try visitor.visitSingularUInt32Field(value: resultCount, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_RespScanStatus, rhs: Espressif_RespScanStatus) -> Bool { - if lhs.scanFinished != rhs.scanFinished { return false } - if lhs.resultCount != rhs.resultCount { return false } - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} - -extension Espressif_CmdScanResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".CmdScanResult" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "start_index"), - 2: .same(proto: "count"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularUInt32Field(value: &startIndex) - case 2: try decoder.decodeSingularUInt32Field(value: &count) - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if startIndex != 0 { - try visitor.visitSingularUInt32Field(value: startIndex, fieldNumber: 1) - } - if count != 0 { - try visitor.visitSingularUInt32Field(value: count, fieldNumber: 2) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_CmdScanResult, rhs: Espressif_CmdScanResult) -> Bool { - if lhs.startIndex != rhs.startIndex { return false } - if lhs.count != rhs.count { return false } - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} - -extension Espressif_WiFiScanResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".WiFiScanResult" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "ssid"), - 2: .same(proto: "channel"), - 3: .same(proto: "rssi"), - 4: .same(proto: "bssid"), - 5: .same(proto: "auth"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularBytesField(value: &ssid) - case 2: try decoder.decodeSingularUInt32Field(value: &channel) - case 3: try decoder.decodeSingularInt32Field(value: &rssi) - case 4: try decoder.decodeSingularBytesField(value: &bssid) - case 5: try decoder.decodeSingularEnumField(value: &auth) - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !ssid.isEmpty { - try visitor.visitSingularBytesField(value: ssid, fieldNumber: 1) - } - if channel != 0 { - try visitor.visitSingularUInt32Field(value: channel, fieldNumber: 2) - } - if rssi != 0 { - try visitor.visitSingularInt32Field(value: rssi, fieldNumber: 3) - } - if !bssid.isEmpty { - try visitor.visitSingularBytesField(value: bssid, fieldNumber: 4) - } - if auth != .open { - try visitor.visitSingularEnumField(value: auth, fieldNumber: 5) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_WiFiScanResult, rhs: Espressif_WiFiScanResult) -> Bool { - if lhs.ssid != rhs.ssid { return false } - if lhs.channel != rhs.channel { return false } - if lhs.rssi != rhs.rssi { return false } - if lhs.bssid != rhs.bssid { return false } - if lhs.auth != rhs.auth { return false } - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} - -extension Espressif_RespScanResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".RespScanResult" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "entries"), - ] - - mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeRepeatedMessageField(value: &entries) - default: break - } - } - } - - func traverse(visitor: inout V) throws { - if !entries.isEmpty { - try visitor.visitRepeatedMessageField(value: entries, fieldNumber: 1) - } - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_RespScanResult, rhs: Espressif_RespScanResult) -> Bool { - if lhs.entries != rhs.entries { return false } - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} - -extension Espressif_WiFiScanPayload: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".WiFiScanPayload" - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "msg"), - 2: .same(proto: "status"), - 10: .standard(proto: "cmd_scan_start"), - 11: .standard(proto: "resp_scan_start"), - 12: .standard(proto: "cmd_scan_status"), - 13: .standard(proto: "resp_scan_status"), - 14: .standard(proto: "cmd_scan_result"), - 15: .standard(proto: "resp_scan_result"), - ] - - fileprivate class _StorageClass { - var _msg: Espressif_WiFiScanMsgType = .typeCmdScanStart - var _status: Espressif_Status = .success - var _payload: Espressif_WiFiScanPayload.OneOf_Payload? - - static let defaultInstance = _StorageClass() - - private init() {} - - init(copying source: _StorageClass) { - _msg = source._msg - _status = source._status - _payload = source._payload - } - } - - fileprivate mutating func _uniqueStorage() -> _StorageClass { - if !isKnownUniquelyReferenced(&_storage) { - _storage = _StorageClass(copying: _storage) - } - return _storage - } - - mutating func decodeMessage(decoder: inout D) throws { - _ = _uniqueStorage() - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - while let fieldNumber = try decoder.nextFieldNumber() { - switch fieldNumber { - case 1: try decoder.decodeSingularEnumField(value: &_storage._msg) - case 2: try decoder.decodeSingularEnumField(value: &_storage._status) - case 10: - var v: Espressif_CmdScanStart? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .cmdScanStart(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .cmdScanStart(v) } - case 11: - var v: Espressif_RespScanStart? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .respScanStart(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .respScanStart(v) } - case 12: - var v: Espressif_CmdScanStatus? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .cmdScanStatus(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .cmdScanStatus(v) } - case 13: - var v: Espressif_RespScanStatus? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .respScanStatus(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .respScanStatus(v) } - case 14: - var v: Espressif_CmdScanResult? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .cmdScanResult(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .cmdScanResult(v) } - case 15: - var v: Espressif_RespScanResult? - if let current = _storage._payload { - try decoder.handleConflictingOneOf() - if case let .respScanResult(m) = current { v = m } - } - try decoder.decodeSingularMessageField(value: &v) - if let v = v { _storage._payload = .respScanResult(v) } - default: break - } - } - } - } - - func traverse(visitor: inout V) throws { - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - if _storage._msg != .typeCmdScanStart { - try visitor.visitSingularEnumField(value: _storage._msg, fieldNumber: 1) - } - if _storage._status != .success { - try visitor.visitSingularEnumField(value: _storage._status, fieldNumber: 2) - } - switch _storage._payload { - case let .cmdScanStart(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 10) - case let .respScanStart(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 11) - case let .cmdScanStatus(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 12) - case let .respScanStatus(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 13) - case let .cmdScanResult(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 14) - case let .respScanResult(v)?: - try visitor.visitSingularMessageField(value: v, fieldNumber: 15) - case nil: break - } - } - try unknownFields.traverse(visitor: &visitor) - } - - static func == (lhs: Espressif_WiFiScanPayload, rhs: Espressif_WiFiScanPayload) -> Bool { - if lhs._storage !== rhs._storage { - let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in - let _storage = _args.0 - let rhs_storage = _args.1 - if _storage._msg != rhs_storage._msg { return false } - if _storage._status != rhs_storage._status { return false } - if _storage._payload != rhs_storage._payload { return false } - return true - } - if !storagesAreEqual { return false } - } - if lhs.unknownFields != rhs.unknownFields { return false } - return true - } -} diff --git a/ESPProvision/Security2/ESPSecurity2.swift b/ESPProvision/Security2/ESPSecurity2.swift index ac7abef..eee61ad 100644 --- a/ESPProvision/Security2/ESPSecurity2.swift +++ b/ESPProvision/Security2/ESPSecurity2.swift @@ -155,7 +155,7 @@ class ESPSecurity2: ESPCodeable { guard let publicKey = self.publicKey else { throw SecurityError.keygenError("Could not generate keypair") } - var sessionData = Espressif_SessionData() + var sessionData = SessionData() sessionData.secVer = .secScheme2 sessionData.sec2.msg = .s2SessionCommand0 sessionData.sec2.sc0.clientPubkey = publicKey @@ -176,7 +176,7 @@ class ESPSecurity2: ESPCodeable { throw SecurityError.keygenError("Could not generate keypair") } - var sessionData = Espressif_SessionData() + var sessionData = SessionData() sessionData.secVer = .secScheme2 sessionData.sec2.msg = .s2SessionCommand1 sessionData.sec2.sc1.clientProof = verifyData @@ -198,7 +198,7 @@ class ESPSecurity2: ESPCodeable { ESPLog.log("Response 0 is nil.") throw SecurityError.handshakeError("Response 0 is nil") } - let sessionData = try Espressif_SessionData(serializedData: response) + let sessionData = try SessionData(serializedData: response) if sessionData.secVer != .secScheme2 { ESPLog.log("Security version mismatch.") throw SecurityError.handshakeError("Security version mismatch") @@ -224,7 +224,7 @@ class ESPSecurity2: ESPCodeable { ESPLog.log("Response 1 is nil") throw SecurityError.handshakeError("Response 1 is nil") } - let sessionData = try Espressif_SessionData(serializedData: response) + let sessionData = try SessionData(serializedData: response) if sessionData.secVer != .secScheme2 { ESPLog.log("Security version mismatch") throw SecurityError.handshakeError("Security version mismatch") diff --git a/ESPProvision/Transport/ESPBleTransport.swift b/ESPProvision/Transport/ESPBleTransport.swift index 3602f21..f9ce85e 100644 --- a/ESPProvision/Transport/ESPBleTransport.swift +++ b/ESPProvision/Transport/ESPBleTransport.swift @@ -73,6 +73,8 @@ class ESPBleTransport: NSObject, ESPCommunicable { var proofOfPossession:String? /// Store username for device var username:String? + /// Store network for device + var network: ESPNetworkType? var centralManager: CBCentralManager! @@ -96,12 +98,13 @@ class ESPBleTransport: NSObject, ESPCommunicable { /// - Parameters: /// - deviceNamePrefix: Device name prefix. /// - scanTimeout: Timeout in seconds for which BLE scan should happen. - init(scanTimeout: TimeInterval, deviceNamePrefix: String, proofOfPossession:String? = nil, username: String? = nil) { + init(scanTimeout: TimeInterval, deviceNamePrefix: String, proofOfPossession:String? = nil, username: String? = nil, network: ESPNetworkType? = nil) { ESPLog.log("Initalising BLE transport class with scan timeout \(scanTimeout)") self.scanTimeout = scanTimeout self.deviceNamePrefix = deviceNamePrefix self.proofOfPossession = proofOfPossession self.username = username + self.network = network utility = ESPUtility() super.init() centralManager = CBCentralManager(delegate: self, queue: nil) diff --git a/ESPProvision/Utility/ESPConstants.swift b/ESPProvision/Utility/ESPConstants.swift index 06d7f68..c935839 100644 --- a/ESPProvision/Utility/ESPConstants.swift +++ b/ESPProvision/Utility/ESPConstants.swift @@ -53,7 +53,10 @@ struct ESPConstants { static let noSecCapability = "no_sec" /// Key for getting security scheme static let securityScheme = "sec_ver" - + /// Value for thread provisioning + static let threadProv = "thread_prov" + /// Value for thread scan capability + static let threadScanCapability = "thread_scan" } diff --git a/ESPProvision/Utility/ESPErrors.swift b/ESPProvision/Utility/ESPErrors.swift index 5e78784..a0e8bb5 100644 --- a/ESPProvision/Utility/ESPErrors.swift +++ b/ESPProvision/Utility/ESPErrors.swift @@ -61,6 +61,40 @@ public enum ESPWiFiScanError: ESPError { } } +/// 'ESPThreadScanError' consist of error cases that will be generated in the process of fetching available Thread +/// network list from an ESPDevice, +public enum ESPThreadScanError: ESPError { + + /// Unable to generate Thread scan request configuration data. + case emptyConfigData + /// Scan result returned from ESPDevice contains no Thread networks. + case emptyResultCount + /// Consist of errors generated during sending, recieving and parsing of request/response related with Thread scan. + case scanRequestError(Error) + + public var description: String { + switch self { + case .emptyConfigData: + return "Configuration data to request Thread list is empty." + case .emptyResultCount: + return "Number of Thread network scanned result is nil" + case .scanRequestError(let error): + return "Request for returning Wi-Fi network list failed with error: \(error.localizedDescription)" + } + } + + public var code:Int { + switch self { + case .emptyConfigData: + return 1 + case .emptyResultCount: + return 2 + case .scanRequestError(_): + return 3 + } + } +} + /// 'ESPSessionError' covers error cases that are generated throughout the life cycle of ESPDevice session /// right from the beginning of session establishment till termination. public enum ESPSessionError: ESPError { @@ -218,6 +252,16 @@ public enum ESPProvisionError: ESPError { case wifiStatusNetworkNotFound /// Wi-Fi status of ESPDevice is unknown. case wifiStatusUnknownError + /// The attempt to fetch Thread status of ESPDevice failed with underlying error. + case threadStatusError(Error) + /// Unable to apply Thread settings to ESPDevice with status disconnected. + case threadStatusDettached + /// Wrong Thread credentials applied to ESPDevice. + case threadDatasetInvalid + /// Thread network not found. + case threadStatusNetworkNotFound + /// Thread status of ESPDevice is unknown. + case threadStatusUnknownError /// Unkown error case unknownError @@ -237,6 +281,16 @@ public enum ESPProvisionError: ESPError { return "Wi-Fi status: network not found" case .wifiStatusUnknownError: return "Wi-Fi status: unknown error" + case .threadStatusError(let error): + return "Unable to fetch wifi status with error: \(error.localizedDescription)" + case .threadStatusDettached: + return "Thread status: detached" + case .threadDatasetInvalid: + return "Thread status: dataset invalid" + case .threadStatusNetworkNotFound: + return "Thread status: network not found" + case .threadStatusUnknownError: + return "Thread status: unknown error" case .unknownError: return "Unknown error" } @@ -260,6 +314,16 @@ public enum ESPProvisionError: ESPError { return 37 case .unknownError: return 38 + case .threadStatusError: + return 0 + case .threadStatusDettached: + return 1 + case .threadDatasetInvalid: + return 2 + case .threadStatusNetworkNotFound: + return 3 + case .threadStatusUnknownError: + return 4 } } } diff --git a/ESPProvision/Utility/ESPExtensions.swift b/ESPProvision/Utility/ESPExtensions.swift index ff0095b..b6a7cf1 100644 --- a/ESPProvision/Utility/ESPExtensions.swift +++ b/ESPProvision/Utility/ESPExtensions.swift @@ -40,6 +40,10 @@ extension Data { } return Data(hash) } + + public var hexadecimalString: String { + return map { String(format: "%02hhx", $0) }.joined() + } } extension Array { diff --git a/Example/ESPProvisionSPMSample/ESPProvisionSPMSample.xcodeproj/project.pbxproj b/Example/ESPProvisionSPMSample/ESPProvisionSPMSample.xcodeproj/project.pbxproj index 9e97120..10e64e5 100644 --- a/Example/ESPProvisionSPMSample/ESPProvisionSPMSample.xcodeproj/project.pbxproj +++ b/Example/ESPProvisionSPMSample/ESPProvisionSPMSample.xcodeproj/project.pbxproj @@ -7,9 +7,11 @@ objects = { /* Begin PBXBuildFile section */ - 23C230D68A2655CB528BC465 /* Pods_ESPProvisionSPMSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C40C5367131610C57F28675 /* Pods_ESPProvisionSPMSample.framework */; }; - 4126D620BA3B66AE8F605048 /* Pods_ESPProvisionSPMSampleTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F1DEB9BE81150EC2318EAFC8 /* Pods_ESPProvisionSPMSampleTests.framework */; }; - A5A3BC646067DCBBC708147A /* Pods_ESPProvisionSPMSample_ESPProvisionSPMSampleUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1361DAF7A4B6B0AEDCC30409 /* Pods_ESPProvisionSPMSample_ESPProvisionSPMSampleUITests.framework */; }; + 0C44244B2C479F2E006640CE /* ESPProvision in Frameworks */ = {isa = PBXBuildFile; productRef = 0C44244A2C479F2E006640CE /* ESPProvision */; }; + 0C44244E2C479F3B006640CE /* MBProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = 0C44244D2C479F3B006640CE /* MBProgressHUD */; }; + 0C4424522C479F52006640CE /* ThreadNetworkSelectionVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C4424502C479F52006640CE /* ThreadNetworkSelectionVC.swift */; }; + 0C4424532C479F52006640CE /* ThreadCredentialsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C44244F2C479F52006640CE /* ThreadCredentialsManager.swift */; }; + 0C4424542C479F52006640CE /* UIViewController+ThreadUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C4424512C479F52006640CE /* UIViewController+ThreadUtils.swift */; }; F17611872A076D5E004F381D /* ESPProvision in Frameworks */ = {isa = PBXBuildFile; productRef = F17611862A076D5E004F381D /* ESPProvision */; }; F176118A2A077080004F381D /* GitVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = F17611892A077080004F381D /* GitVersion.swift */; }; F17785AA2A058A3700C3AE73 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F17785A92A058A3700C3AE73 /* AppDelegate.swift */; }; @@ -53,15 +55,9 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 036AB4CEA041C085767F4B50 /* Pods-ESPProvisionSPMSampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ESPProvisionSPMSampleTests.release.xcconfig"; path = "Target Support Files/Pods-ESPProvisionSPMSampleTests/Pods-ESPProvisionSPMSampleTests.release.xcconfig"; sourceTree = ""; }; - 08E642D02C6C02218B0CC9D4 /* Pods-ESPProvisionSPMSample-ESPProvisionSPMSampleUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ESPProvisionSPMSample-ESPProvisionSPMSampleUITests.debug.xcconfig"; path = "Target Support Files/Pods-ESPProvisionSPMSample-ESPProvisionSPMSampleUITests/Pods-ESPProvisionSPMSample-ESPProvisionSPMSampleUITests.debug.xcconfig"; sourceTree = ""; }; - 1361DAF7A4B6B0AEDCC30409 /* Pods_ESPProvisionSPMSample_ESPProvisionSPMSampleUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ESPProvisionSPMSample_ESPProvisionSPMSampleUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 47AE925B80391866611B2494 /* Pods-ESPProvisionSPMSampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ESPProvisionSPMSampleTests.debug.xcconfig"; path = "Target Support Files/Pods-ESPProvisionSPMSampleTests/Pods-ESPProvisionSPMSampleTests.debug.xcconfig"; sourceTree = ""; }; - 65AB3C527E92F2C884829ACE /* Pods-ESPProvisionSPMSample-ESPProvisionSPMSampleUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ESPProvisionSPMSample-ESPProvisionSPMSampleUITests.release.xcconfig"; path = "Target Support Files/Pods-ESPProvisionSPMSample-ESPProvisionSPMSampleUITests/Pods-ESPProvisionSPMSample-ESPProvisionSPMSampleUITests.release.xcconfig"; sourceTree = ""; }; - 9C40C5367131610C57F28675 /* Pods_ESPProvisionSPMSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ESPProvisionSPMSample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - B8E795D420B2885052F302B7 /* Pods-ESPProvisionSPMSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ESPProvisionSPMSample.release.xcconfig"; path = "Target Support Files/Pods-ESPProvisionSPMSample/Pods-ESPProvisionSPMSample.release.xcconfig"; sourceTree = ""; }; - E5548CCC2B0EE1C57AF00FE6 /* Pods-ESPProvisionSPMSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ESPProvisionSPMSample.debug.xcconfig"; path = "Target Support Files/Pods-ESPProvisionSPMSample/Pods-ESPProvisionSPMSample.debug.xcconfig"; sourceTree = ""; }; - F17611852A075684004F381D /* esp-idf-provisioning-ios */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "esp-idf-provisioning-ios"; path = ../..; sourceTree = ""; }; + 0C44244F2C479F52006640CE /* ThreadCredentialsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreadCredentialsManager.swift; sourceTree = ""; }; + 0C4424502C479F52006640CE /* ThreadNetworkSelectionVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreadNetworkSelectionVC.swift; sourceTree = ""; }; + 0C4424512C479F52006640CE /* UIViewController+ThreadUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+ThreadUtils.swift"; sourceTree = ""; }; F17611892A077080004F381D /* GitVersion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GitVersion.swift; path = ../../ESPProvisionSample/ESPProvisionSample/GitVersion.swift; sourceTree = ""; }; F176118B2A078542004F381D /* ESPProvisionSPMSample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ESPProvisionSPMSample.entitlements; sourceTree = ""; }; F17785A62A058A3700C3AE73 /* ESPProvisionSPMSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ESPProvisionSPMSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -89,7 +85,6 @@ F17785E92A058A8100C3AE73 /* Utility.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Utility.swift; path = ../../ESPProvisionSample/ESPProvisionSample/Utility.swift; sourceTree = ""; }; F17785F82A058B1F00C3AE73 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = ../../ESPProvisionSample/ESPProvisionSample/Base.lproj/Main.storyboard; sourceTree = ""; }; F17785FC2A058BE800C3AE73 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = ../../ESPProvisionSample/ESPProvisionSample/Assets.xcassets; sourceTree = ""; }; - F1DEB9BE81150EC2318EAFC8 /* Pods_ESPProvisionSPMSampleTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ESPProvisionSPMSampleTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -97,8 +92,9 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 0C44244E2C479F3B006640CE /* MBProgressHUD in Frameworks */, F17611872A076D5E004F381D /* ESPProvision in Frameworks */, - 23C230D68A2655CB528BC465 /* Pods_ESPProvisionSPMSample.framework in Frameworks */, + 0C44244B2C479F2E006640CE /* ESPProvision in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -106,7 +102,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 4126D620BA3B66AE8F605048 /* Pods_ESPProvisionSPMSampleTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -114,54 +109,27 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - A5A3BC646067DCBBC708147A /* Pods_ESPProvisionSPMSample_ESPProvisionSPMSampleUITests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 4CE2E4D81A37A6FFEE54B05A /* Pods */ = { - isa = PBXGroup; - children = ( - E5548CCC2B0EE1C57AF00FE6 /* Pods-ESPProvisionSPMSample.debug.xcconfig */, - B8E795D420B2885052F302B7 /* Pods-ESPProvisionSPMSample.release.xcconfig */, - 08E642D02C6C02218B0CC9D4 /* Pods-ESPProvisionSPMSample-ESPProvisionSPMSampleUITests.debug.xcconfig */, - 65AB3C527E92F2C884829ACE /* Pods-ESPProvisionSPMSample-ESPProvisionSPMSampleUITests.release.xcconfig */, - 47AE925B80391866611B2494 /* Pods-ESPProvisionSPMSampleTests.debug.xcconfig */, - 036AB4CEA041C085767F4B50 /* Pods-ESPProvisionSPMSampleTests.release.xcconfig */, - ); - path = Pods; - sourceTree = ""; - }; F1659D582A0597BE004C393B /* Frameworks */ = { isa = PBXGroup; children = ( - 9C40C5367131610C57F28675 /* Pods_ESPProvisionSPMSample.framework */, - 1361DAF7A4B6B0AEDCC30409 /* Pods_ESPProvisionSPMSample_ESPProvisionSPMSampleUITests.framework */, - F1DEB9BE81150EC2318EAFC8 /* Pods_ESPProvisionSPMSampleTests.framework */, ); name = Frameworks; sourceTree = ""; }; - F17611842A075683004F381D /* Packages */ = { - isa = PBXGroup; - children = ( - F17611852A075684004F381D /* esp-idf-provisioning-ios */, - ); - name = Packages; - sourceTree = ""; - }; F177859D2A058A3700C3AE73 = { isa = PBXGroup; children = ( - F17611842A075683004F381D /* Packages */, F17785A82A058A3700C3AE73 /* ESPProvisionSPMSample */, F17785BF2A058A3D00C3AE73 /* ESPProvisionSPMSampleTests */, F17785C92A058A3D00C3AE73 /* ESPProvisionSPMSampleUITests */, F17785A72A058A3700C3AE73 /* Products */, F1659D582A0597BE004C393B /* Frameworks */, - 4CE2E4D81A37A6FFEE54B05A /* Pods */, ); sourceTree = ""; }; @@ -245,6 +213,9 @@ F17785E22A058A8100C3AE73 /* Provision */ = { isa = PBXGroup; children = ( + 0C44244F2C479F52006640CE /* ThreadCredentialsManager.swift */, + 0C4424502C479F52006640CE /* ThreadNetworkSelectionVC.swift */, + 0C4424512C479F52006640CE /* UIViewController+ThreadUtils.swift */, F17785E32A058A8100C3AE73 /* ConnectViewController.swift */, F17785E42A058A8100C3AE73 /* StatusViewController.swift */, F17785E52A058A8100C3AE73 /* ProvisionViewController.swift */, @@ -263,12 +234,10 @@ isa = PBXNativeTarget; buildConfigurationList = F17785D02A058A3D00C3AE73 /* Build configuration list for PBXNativeTarget "ESPProvisionSPMSample" */; buildPhases = ( - DB4DED6B99DB657F267DF6FB /* [CP] Check Pods Manifest.lock */, F17785A22A058A3700C3AE73 /* Sources */, F17785A32A058A3700C3AE73 /* Frameworks */, F17785A42A058A3700C3AE73 /* Resources */, F17611882A076F4B004F381D /* ShellScript */, - 6F40B16EB8DA327AC110D356 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -277,6 +246,8 @@ name = ESPProvisionSPMSample; packageProductDependencies = ( F17611862A076D5E004F381D /* ESPProvision */, + 0C44244A2C479F2E006640CE /* ESPProvision */, + 0C44244D2C479F3B006640CE /* MBProgressHUD */, ); productName = ESPProvisionSPMSample; productReference = F17785A62A058A3700C3AE73 /* ESPProvisionSPMSample.app */; @@ -353,6 +324,10 @@ Base, ); mainGroup = F177859D2A058A3700C3AE73; + packageReferences = ( + 0C4424492C479F2E006640CE /* XCRemoteSwiftPackageReference "esp-idf-provisioning-ios" */, + 0C44244C2C479F3B006640CE /* XCRemoteSwiftPackageReference "MBProgressHUD" */, + ); productRefGroup = F17785A72A058A3700C3AE73 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -431,23 +406,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 6F40B16EB8DA327AC110D356 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-ESPProvisionSPMSample/Pods-ESPProvisionSPMSample-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-ESPProvisionSPMSample/Pods-ESPProvisionSPMSample-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ESPProvisionSPMSample/Pods-ESPProvisionSPMSample-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; 9B1A2C711B226ECA1B669ED1 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -470,28 +428,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - DB4DED6B99DB657F267DF6FB /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-ESPProvisionSPMSample-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; F17611882A076F4B004F381D /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -527,6 +463,9 @@ F17785F02A058A8100C3AE73 /* ConnectViewController.swift in Sources */, F17785AA2A058A3700C3AE73 /* AppDelegate.swift in Sources */, F17785AC2A058A3700C3AE73 /* SceneDelegate.swift in Sources */, + 0C4424522C479F52006640CE /* ThreadNetworkSelectionVC.swift in Sources */, + 0C4424532C479F52006640CE /* ThreadCredentialsManager.swift in Sources */, + 0C4424542C479F52006640CE /* UIViewController+ThreadUtils.swift in Sources */, F17785F32A058A8100C3AE73 /* WifiListTableViewCell.swift in Sources */, F17785F62A058A8100C3AE73 /* Utility.swift in Sources */, F17785F12A058A8100C3AE73 /* StatusViewController.swift in Sources */, @@ -703,7 +642,6 @@ }; F17785D12A058A3D00C3AE73 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = E5548CCC2B0EE1C57AF00FE6 /* Pods-ESPProvisionSPMSample.debug.xcconfig */; buildSettings = { APP_DISPLAY_NAME = "ESP Prov"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -734,7 +672,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = 3.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.espressif.ESPProvisionSPMSample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -745,7 +683,6 @@ }; F17785D22A058A3D00C3AE73 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = B8E795D420B2885052F302B7 /* Pods-ESPProvisionSPMSample.release.xcconfig */; buildSettings = { APP_DISPLAY_NAME = "ESP Prov"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -776,7 +713,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = 3.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.espressif.ESPProvisionSPMSample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -787,7 +724,6 @@ }; F17785D42A058A3D00C3AE73 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 47AE925B80391866611B2494 /* Pods-ESPProvisionSPMSampleTests.debug.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; @@ -808,7 +744,6 @@ }; F17785D52A058A3D00C3AE73 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 036AB4CEA041C085767F4B50 /* Pods-ESPProvisionSPMSampleTests.release.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; @@ -829,7 +764,6 @@ }; F17785D72A058A3D00C3AE73 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 08E642D02C6C02218B0CC9D4 /* Pods-ESPProvisionSPMSample-ESPProvisionSPMSampleUITests.debug.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; @@ -848,7 +782,6 @@ }; F17785D82A058A3D00C3AE73 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 65AB3C527E92F2C884829ACE /* Pods-ESPProvisionSPMSample-ESPProvisionSPMSampleUITests.release.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; @@ -906,7 +839,36 @@ }; /* End XCConfigurationList section */ +/* Begin XCRemoteSwiftPackageReference section */ + 0C4424492C479F2E006640CE /* XCRemoteSwiftPackageReference "esp-idf-provisioning-ios" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/espressif/esp-idf-provisioning-ios.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 2.1.2; + }; + }; + 0C44244C2C479F3B006640CE /* XCRemoteSwiftPackageReference "MBProgressHUD" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/jdg/MBProgressHUD.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.2.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + /* Begin XCSwiftPackageProductDependency section */ + 0C44244A2C479F2E006640CE /* ESPProvision */ = { + isa = XCSwiftPackageProductDependency; + package = 0C4424492C479F2E006640CE /* XCRemoteSwiftPackageReference "esp-idf-provisioning-ios" */; + productName = ESPProvision; + }; + 0C44244D2C479F3B006640CE /* MBProgressHUD */ = { + isa = XCSwiftPackageProductDependency; + package = 0C44244C2C479F3B006640CE /* XCRemoteSwiftPackageReference "MBProgressHUD" */; + productName = MBProgressHUD; + }; F17611862A076D5E004F381D /* ESPProvision */ = { isa = XCSwiftPackageProductDependency; productName = ESPProvision; diff --git a/Example/ESPProvisionSPMSample/ESPProvisionSPMSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Example/ESPProvisionSPMSample/ESPProvisionSPMSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Example/ESPProvisionSPMSample/ESPProvisionSPMSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Example/ESPProvisionSPMSample/ESPProvisionSPMSample/ESPProvisionSPMSample.entitlements b/Example/ESPProvisionSPMSample/ESPProvisionSPMSample/ESPProvisionSPMSample.entitlements index 7021e63..4bdcd72 100644 --- a/Example/ESPProvisionSPMSample/ESPProvisionSPMSample/ESPProvisionSPMSample.entitlements +++ b/Example/ESPProvisionSPMSample/ESPProvisionSPMSample/ESPProvisionSPMSample.entitlements @@ -4,6 +4,8 @@ com.apple.developer.networking.HotspotConfiguration + com.apple.developer.networking.manage-thread-network-credentials + com.apple.developer.networking.wifi-info diff --git a/Example/ESPProvisionSample/ESPProvisionSample.xcodeproj/project.pbxproj b/Example/ESPProvisionSample/ESPProvisionSample.xcodeproj/project.pbxproj index becceec..8418449 100644 --- a/Example/ESPProvisionSample/ESPProvisionSample.xcodeproj/project.pbxproj +++ b/Example/ESPProvisionSample/ESPProvisionSample.xcodeproj/project.pbxproj @@ -3,10 +3,13 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ + 0CAC43E02C46AC890047B1DB /* ThreadNetworkSelectionVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CAC43DF2C46AC890047B1DB /* ThreadNetworkSelectionVC.swift */; }; + 0CF1218B2C37D0B4008962E7 /* ThreadCredentialsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CF1218A2C37D0AA008962E7 /* ThreadCredentialsManager.swift */; }; + 0CF1218D2C37D6E1008962E7 /* UIViewController+ThreadUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CF1218C2C37D6D8008962E7 /* UIViewController+ThreadUtils.swift */; }; 3ED0C43B27D43AAA5D47EFD6 /* Pods_ESPProvisionSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B95D3CB45501BB92685CB62 /* Pods_ESPProvisionSample.framework */; }; 415DC57E712D9EEF889F4DC6 /* Pods_ESPProvisionSample_ESPProvisionSampleUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0B0EA111F8D65975C74DDBBE /* Pods_ESPProvisionSample_ESPProvisionSampleUITests.framework */; }; 544A5946C8BFDFDD77056E81 /* Pods_ESPProvisionSampleTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28306B0C6FBBC399C5140C2D /* Pods_ESPProvisionSampleTests.framework */; }; @@ -53,6 +56,9 @@ /* Begin PBXFileReference section */ 0B0EA111F8D65975C74DDBBE /* Pods_ESPProvisionSample_ESPProvisionSampleUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ESPProvisionSample_ESPProvisionSampleUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 0CAC43DF2C46AC890047B1DB /* ThreadNetworkSelectionVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreadNetworkSelectionVC.swift; sourceTree = ""; }; + 0CF1218A2C37D0AA008962E7 /* ThreadCredentialsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreadCredentialsManager.swift; sourceTree = ""; }; + 0CF1218C2C37D6D8008962E7 /* UIViewController+ThreadUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+ThreadUtils.swift"; sourceTree = ""; }; 28306B0C6FBBC399C5140C2D /* Pods_ESPProvisionSampleTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ESPProvisionSampleTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 2B56EA7FAACF4B45FD97313D /* Pods-ESPProvisionSampleTests.ble.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ESPProvisionSampleTests.ble.xcconfig"; path = "Target Support Files/Pods-ESPProvisionSampleTests/Pods-ESPProvisionSampleTests.ble.xcconfig"; sourceTree = ""; }; 3097141A9823166E10FF7F9F /* Pods-ESPProvisionSample-ESPProvisionSampleUITests.softap.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ESPProvisionSample-ESPProvisionSampleUITests.softap.xcconfig"; path = "Target Support Files/Pods-ESPProvisionSample-ESPProvisionSampleUITests/Pods-ESPProvisionSample-ESPProvisionSampleUITests.softap.xcconfig"; sourceTree = ""; }; @@ -247,12 +253,15 @@ F1A0A48A24A5DB5900CB347C /* Provision */ = { isa = PBXGroup; children = ( + 0CF1218A2C37D0AA008962E7 /* ThreadCredentialsManager.swift */, + 0CF1218C2C37D6D8008962E7 /* UIViewController+ThreadUtils.swift */, F1A3DBC924A0E934005AF0ED /* ConnectViewController.swift */, F19AEBD8249FD0D50078E5A1 /* WifiListTableViewCell.swift */, F19AEBDA249FD8C10078E5A1 /* DeviceTypeViewController.swift */, F19AEBD2249B926F0078E5A1 /* ScannerViewController.swift */, F19AEBD4249B94540078E5A1 /* ProvisionViewController.swift */, F19AEBD6249BAB4D0078E5A1 /* StatusViewController.swift */, + 0CAC43DF2C46AC890047B1DB /* ThreadNetworkSelectionVC.swift */, ); path = Provision; sourceTree = ""; @@ -522,12 +531,15 @@ F1A0A47A24A29C9900CB347C /* GitVersion.swift in Sources */, F19AEBD3249B92700078E5A1 /* ScannerViewController.swift in Sources */, F19AEBA32498E66A0078E5A1 /* ViewController.swift in Sources */, + 0CF1218D2C37D6E1008962E7 /* UIViewController+ThreadUtils.swift in Sources */, F19AEBDB249FD8C10078E5A1 /* DeviceTypeViewController.swift in Sources */, F19AEBDD249FDBEC0078E5A1 /* BLELandingViewController.swift in Sources */, F19AEB9F2498E66A0078E5A1 /* AppDelegate.swift in Sources */, F19AEBA12498E66A0078E5A1 /* SceneDelegate.swift in Sources */, + 0CF1218B2C37D0B4008962E7 /* ThreadCredentialsManager.swift in Sources */, F19AEBCF2499E3ED0078E5A1 /* SettingsViewController.swift in Sources */, F1A0A47424A27E5000CB347C /* SoftAPLandingViewController.swift in Sources */, + 0CAC43E02C46AC890047B1DB /* ThreadNetworkSelectionVC.swift in Sources */, F19AEBD5249B94540078E5A1 /* ProvisionViewController.swift in Sources */, F19AEBD9249FD0D50078E5A1 /* WifiListTableViewCell.swift in Sources */, ); @@ -714,8 +726,9 @@ DEVELOPMENT_TEAM = QWXF6GB4AV; ESP_ALLOW_PREFIX_SEARCH = YES; ESP_ALLOW_QR_CODE_SCAN = YES; + ESP_DEVICE_THREAD_USERNAME = threadprov; ESP_DEVICE_TYPE = Both; - ESP_DEVICE_USERNAME = wifiprov; + ESP_DEVICE_WIFI_USERNAME = wifiprov; ESP_SECURITY_MODE = Secure; ESP_SETTINGS_ENABLED = YES; INFOPLIST_FILE = ESPProvisionSample/Info.plist; @@ -724,7 +737,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.1.2; + MARKETING_VERSION = 3.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.espressif.provsoftap; PRODUCT_NAME = "ESP PROV Debug"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -747,8 +760,9 @@ DEVELOPMENT_TEAM = QWXF6GB4AV; ESP_ALLOW_PREFIX_SEARCH = YES; ESP_ALLOW_QR_CODE_SCAN = YES; + ESP_DEVICE_THREAD_USERNAME = threadprov; ESP_DEVICE_TYPE = Both; - ESP_DEVICE_USERNAME = wifiprov; + ESP_DEVICE_WIFI_USERNAME = wifiprov; ESP_SECURITY_MODE = Secure; ESP_SETTINGS_ENABLED = YES; INFOPLIST_FILE = ESPProvisionSample/Info.plist; @@ -757,7 +771,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.1.2; + MARKETING_VERSION = 3.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.espressif.provsoftap; PRODUCT_NAME = "ESP PROV Release"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -923,8 +937,9 @@ DEVELOPMENT_TEAM = QWXF6GB4AV; ESP_ALLOW_PREFIX_SEARCH = YES; ESP_ALLOW_QR_CODE_SCAN = YES; + ESP_DEVICE_THREAD_USERNAME = threadprov; ESP_DEVICE_TYPE = BLE; - ESP_DEVICE_USERNAME = wifiprov; + ESP_DEVICE_WIFI_USERNAME = wifiprov; ESP_SECURITY_MODE = Secure; ESP_SETTINGS_ENABLED = YES; INFOPLIST_FILE = ESPProvisionSample/Info.plist; @@ -933,7 +948,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.1.2; + MARKETING_VERSION = 3.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.espressif.provble; PRODUCT_NAME = "ESP BLE Prov"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1055,8 +1070,9 @@ DEVELOPMENT_TEAM = QWXF6GB4AV; ESP_ALLOW_PREFIX_SEARCH = YES; ESP_ALLOW_QR_CODE_SCAN = YES; + ESP_DEVICE_THREAD_USERNAME = threadprov; ESP_DEVICE_TYPE = SoftAP; - ESP_DEVICE_USERNAME = wifiprov; + ESP_DEVICE_WIFI_USERNAME = wifiprov; ESP_SECURITY_MODE = Secure; ESP_SETTINGS_ENABLED = YES; INFOPLIST_FILE = ESPProvisionSample/Info.plist; @@ -1065,7 +1081,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.1.2; + MARKETING_VERSION = 3.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.espressif.provsoftap; PRODUCT_NAME = "ESP SoftAP Prov"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Example/ESPProvisionSample/ESPProvisionSample/BLE/BLELandingViewController.swift b/Example/ESPProvisionSample/ESPProvisionSample/BLE/BLELandingViewController.swift index b5eceed..02bb1ee 100644 --- a/Example/ESPProvisionSample/ESPProvisionSample/BLE/BLELandingViewController.swift +++ b/Example/ESPProvisionSample/ESPProvisionSample/BLE/BLELandingViewController.swift @@ -148,6 +148,15 @@ class BLELandingViewController: UIViewController, UITableViewDelegate, UITableVi } switch status { case .connected: + if let caps = device.capabilities { + if caps.contains(AppConstants.threadScan) { + self.showThreadNetworkSelectionVC(shouldScanThreadNetworks: true, device: device) + return + } else if caps.contains(AppConstants.threadProv) { + self.showThreadNetworkSelectionVC(shouldScanThreadNetworks: false, device: device) + return + } + } DispatchQueue.main.async { self.goToProvision(device: device) } diff --git a/Example/ESPProvisionSample/ESPProvisionSample/Base.lproj/Main.storyboard b/Example/ESPProvisionSample/ESPProvisionSample/Base.lproj/Main.storyboard index a8d0103..3518e57 100644 --- a/Example/ESPProvisionSample/ESPProvisionSample/Base.lproj/Main.storyboard +++ b/Example/ESPProvisionSample/ESPProvisionSample/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -321,6 +321,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +