Skip to content

Commit bf092c6

Browse files
authored
Wait firmware response to exit provisioning before communicating back to webapp (#13)
1 parent ef528da commit bf092c6

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

ORLib/ConsoleProviders/ESPProvision/DeviceConnection.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,14 @@ class DeviceConnection {
122122
bleStatus == .connected && device != nil && configChannel != nil
123123
}
124124

125-
func exitProvisioning() throws {
125+
func exitProvisioning() async throws {
126126
if !isConnected {
127127
throw ESPProviderError(errorCode: .notConnected, errorMessage: "No connection established to device")
128128
}
129-
Task {
130-
do {
131-
try await configChannel!.exitProvisioning()
132-
} catch {
133-
throw ESPProviderError(errorCode: .communicationError, errorMessage: error.localizedDescription)
134-
}
129+
do {
130+
try await configChannel!.exitProvisioning()
131+
} catch {
132+
throw ESPProviderError(errorCode: .communicationError, errorMessage: error.localizedDescription)
135133
}
136134
}
137135

ORLib/ConsoleProviders/ESPProvision/ESPProvisionProvider.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,15 @@ class ESPProvisionProvider: NSObject {
152152
sendExitProvisioningError(.notConnected, errorMessage: "No connection established to device")
153153
return
154154
}
155-
do {
156-
try deviceConnection!.exitProvisioning()
157-
callbackChannel?.sendMessage(action: Actions.exitProvisioning, data: ["exit": true])
158-
} catch let error as ESPProviderError {
159-
sendExitProvisioningError(error.errorCode, errorMessage: error.errorMessage)
160-
} catch {
161-
sendExitProvisioningError(.genericError, errorMessage: error.localizedDescription)
155+
Task {
156+
do {
157+
try await deviceConnection!.exitProvisioning()
158+
callbackChannel?.sendMessage(action: Actions.exitProvisioning, data: ["exit": true])
159+
} catch let error as ESPProviderError {
160+
sendExitProvisioningError(error.errorCode, errorMessage: error.errorMessage)
161+
} catch {
162+
sendExitProvisioningError(.genericError, errorMessage: error.localizedDescription)
163+
}
162164
}
163165
}
164166

0 commit comments

Comments
 (0)