@@ -24,7 +24,7 @@ import { ArduinoCoreServiceClient } from './cli-protocol/cc/arduino/cli/commands
2424import { firstToUpperCase , firstToLowerCase } from '../common/utils' ;
2525import { Port } from './cli-protocol/cc/arduino/cli/commands/v1/port_pb' ;
2626import { nls } from '@theia/core' ;
27- import { SerialService } from './../common/protocol/serial-service ' ;
27+ import { MonitorManager } from './monitor-manager ' ;
2828
2929@injectable ( )
3030export class CoreServiceImpl extends CoreClientAware implements CoreService {
@@ -34,8 +34,8 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
3434 @inject ( NotificationServiceServer )
3535 protected readonly notificationService : NotificationServiceServer ;
3636
37- @inject ( SerialService )
38- protected readonly serialService : SerialService ;
37+ @inject ( MonitorManager )
38+ protected readonly monitorManager : MonitorManager ;
3939
4040 protected uploading = false ;
4141
@@ -45,7 +45,7 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
4545 compilerWarnings ?: CompilerWarnings ;
4646 }
4747 ) : Promise < void > {
48- const { sketchUri, fqbn , compilerWarnings } = options ;
48+ const { sketchUri, board , compilerWarnings } = options ;
4949 const sketchPath = FileUri . fsPath ( sketchUri ) ;
5050
5151 await this . coreClientProvider . initialized ;
@@ -55,8 +55,8 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
5555 const compileReq = new CompileRequest ( ) ;
5656 compileReq . setInstance ( instance ) ;
5757 compileReq . setSketchPath ( sketchPath ) ;
58- if ( fqbn ) {
59- compileReq . setFqbn ( fqbn ) ;
58+ if ( board ?. fqbn ) {
59+ compileReq . setFqbn ( board . fqbn ) ;
6060 }
6161 if ( compilerWarnings ) {
6262 compileReq . setWarnings ( compilerWarnings . toLowerCase ( ) ) ;
@@ -139,11 +139,9 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
139139 await this . compile ( Object . assign ( options , { exportBinaries : false } ) ) ;
140140
141141 this . uploading = true ;
142- this . serialService . uploadInProgress = true ;
142+ const { sketchUri, board, port, programmer } = options ;
143+ await this . monitorManager . notifyUploadStarted ( board , port ) ;
143144
144- await this . serialService . disconnect ( ) ;
145-
146- const { sketchUri, fqbn, port, programmer } = options ;
147145 const sketchPath = FileUri . fsPath ( sketchUri ) ;
148146
149147 await this . coreClientProvider . initialized ;
@@ -153,8 +151,8 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
153151 const req = requestProvider ( ) ;
154152 req . setInstance ( instance ) ;
155153 req . setSketchPath ( sketchPath ) ;
156- if ( fqbn ) {
157- req . setFqbn ( fqbn ) ;
154+ if ( board ?. fqbn ) {
155+ req . setFqbn ( board . fqbn ) ;
158156 }
159157 const p = new Port ( ) ;
160158 if ( port ) {
@@ -209,23 +207,22 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
209207 throw new Error ( errorMessage ) ;
210208 } finally {
211209 this . uploading = false ;
212- this . serialService . uploadInProgress = false ;
210+ this . monitorManager . notifyUploadFinished ( board , port ) ;
213211 }
214212 }
215213
216214 async burnBootloader ( options : CoreService . Bootloader . Options ) : Promise < void > {
217215 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 ) ;
220218
221219 await this . coreClientProvider . initialized ;
222220 const coreClient = await this . coreClient ( ) ;
223221 const { client, instance } = coreClient ;
224- const { fqbn, port, programmer } = options ;
225222 const burnReq = new BurnBootloaderRequest ( ) ;
226223 burnReq . setInstance ( instance ) ;
227- if ( fqbn ) {
228- burnReq . setFqbn ( fqbn ) ;
224+ if ( board ?. fqbn ) {
225+ burnReq . setFqbn ( board . fqbn ) ;
229226 }
230227 const p = new Port ( ) ;
231228 if ( port ) {
@@ -267,7 +264,7 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
267264 throw new Error ( errorMessage ) ;
268265 } finally {
269266 this . uploading = false ;
270- this . serialService . uploadInProgress = false ;
267+ await this . monitorManager . notifyUploadFinished ( board , port ) ;
271268 }
272269 }
273270
0 commit comments