19
19
20
20
import Foundation
21
21
import ESPProvision
22
+ import OSLog
22
23
23
24
struct DeviceInfo {
24
25
let deviceId : String
@@ -33,6 +34,11 @@ enum BackendConnectionStatus {
33
34
}
34
35
35
36
struct ORConfigChannel {
37
+ private static let logger = Logger (
38
+ subsystem: Bundle . main. bundleIdentifier!,
39
+ category: String ( describing: ORConfigChannel . self)
40
+ )
41
+
36
42
let device : ORESPDevice
37
43
38
44
var messageId = 0
@@ -103,12 +109,15 @@ struct ORConfigChannel {
103
109
var request = Request ( )
104
110
request. body = . exitProvisioning( Request . ExitProvisioning ( ) )
105
111
112
+ Self . logger. info ( " Sending exitProvisioning request " )
106
113
_ = try await sendRequest ( request)
114
+ Self . logger. info ( " ExitProvisioning request sent " )
107
115
}
108
116
109
117
private mutating func sendRequest( _ request: Request ) async throws -> Response {
110
118
var request = request
111
119
request. id = String ( messageId)
120
+ Self . logger. info ( " Send request with messageId: \( request. id) " )
112
121
messageId += 1
113
122
114
123
do {
@@ -118,9 +127,10 @@ struct ORConfigChannel {
118
127
}
119
128
return try await withCheckedThrowingContinuation { continuation in
120
129
device. sendData ( path: " or-cfg " , data: requestData) { responseData, error in
130
+ Self . logger. info ( " Received a response " )
121
131
if let error {
122
- // TODO:
123
- print ( " Error: \( error. localizedDescription) " )
132
+ // TODO: anything better to do with error ?
133
+ Self . logger . error ( " Error sending request : \( error. localizedDescription) " )
124
134
continuation. resume ( throwing: ORConfigChannelError . genericError)
125
135
} else if let responseData {
126
136
do {
0 commit comments