@@ -24,7 +24,7 @@ import { ArduinoCoreServiceClient } from './cli-protocol/cc/arduino/cli/commands
24
24
import { firstToUpperCase , firstToLowerCase } from '../common/utils' ;
25
25
import { Port } from './cli-protocol/cc/arduino/cli/commands/v1/port_pb' ;
26
26
import { nls } from '@theia/core' ;
27
- import { SerialService } from './../common/protocol/serial-service ' ;
27
+ import { MonitorManager } from './monitor-manager ' ;
28
28
29
29
@injectable ( )
30
30
export class CoreServiceImpl extends CoreClientAware implements CoreService {
@@ -34,8 +34,8 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
34
34
@inject ( NotificationServiceServer )
35
35
protected readonly notificationService : NotificationServiceServer ;
36
36
37
- @inject ( SerialService )
38
- protected readonly serialService : SerialService ;
37
+ @inject ( MonitorManager )
38
+ protected readonly monitorManager : MonitorManager ;
39
39
40
40
protected uploading = false ;
41
41
@@ -45,7 +45,7 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
45
45
compilerWarnings ?: CompilerWarnings ;
46
46
}
47
47
) : Promise < void > {
48
- const { sketchUri, fqbn , compilerWarnings } = options ;
48
+ const { sketchUri, board , compilerWarnings } = options ;
49
49
const sketchPath = FileUri . fsPath ( sketchUri ) ;
50
50
51
51
await this . coreClientProvider . initialized ;
@@ -55,8 +55,8 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
55
55
const compileReq = new CompileRequest ( ) ;
56
56
compileReq . setInstance ( instance ) ;
57
57
compileReq . setSketchPath ( sketchPath ) ;
58
- if ( fqbn ) {
59
- compileReq . setFqbn ( fqbn ) ;
58
+ if ( board ?. fqbn ) {
59
+ compileReq . setFqbn ( board . fqbn ) ;
60
60
}
61
61
if ( compilerWarnings ) {
62
62
compileReq . setWarnings ( compilerWarnings . toLowerCase ( ) ) ;
@@ -139,11 +139,9 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
139
139
await this . compile ( Object . assign ( options , { exportBinaries : false } ) ) ;
140
140
141
141
this . uploading = true ;
142
- this . serialService . uploadInProgress = true ;
142
+ const { sketchUri, board, port, programmer } = options ;
143
+ await this . monitorManager . notifyUploadStarted ( board , port ) ;
143
144
144
- await this . serialService . disconnect ( ) ;
145
-
146
- const { sketchUri, fqbn, port, programmer } = options ;
147
145
const sketchPath = FileUri . fsPath ( sketchUri ) ;
148
146
149
147
await this . coreClientProvider . initialized ;
@@ -153,8 +151,8 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
153
151
const req = requestProvider ( ) ;
154
152
req . setInstance ( instance ) ;
155
153
req . setSketchPath ( sketchPath ) ;
156
- if ( fqbn ) {
157
- req . setFqbn ( fqbn ) ;
154
+ if ( board ?. fqbn ) {
155
+ req . setFqbn ( board . fqbn ) ;
158
156
}
159
157
const p = new Port ( ) ;
160
158
if ( port ) {
@@ -209,23 +207,22 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
209
207
throw new Error ( errorMessage ) ;
210
208
} finally {
211
209
this . uploading = false ;
212
- this . serialService . uploadInProgress = false ;
210
+ this . monitorManager . notifyUploadFinished ( board , port ) ;
213
211
}
214
212
}
215
213
216
214
async burnBootloader ( options : CoreService . Bootloader . Options ) : Promise < void > {
217
215
this . uploading = true ;
218
- this . serialService . uploadInProgress = true ;
219
- await this . serialService . disconnect ( ) ;
216
+ const { board , port , programmer } = options ;
217
+ await this . monitorManager . notifyUploadStarted ( board , port ) ;
220
218
221
219
await this . coreClientProvider . initialized ;
222
220
const coreClient = await this . coreClient ( ) ;
223
221
const { client, instance } = coreClient ;
224
- const { fqbn, port, programmer } = options ;
225
222
const burnReq = new BurnBootloaderRequest ( ) ;
226
223
burnReq . setInstance ( instance ) ;
227
- if ( fqbn ) {
228
- burnReq . setFqbn ( fqbn ) ;
224
+ if ( board ?. fqbn ) {
225
+ burnReq . setFqbn ( board . fqbn ) ;
229
226
}
230
227
const p = new Port ( ) ;
231
228
if ( port ) {
@@ -267,7 +264,7 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
267
264
throw new Error ( errorMessage ) ;
268
265
} finally {
269
266
this . uploading = false ;
270
- this . serialService . uploadInProgress = false ;
267
+ await this . monitorManager . notifyUploadFinished ( board , port ) ;
271
268
}
272
269
}
273
270
0 commit comments