Skip to content

Commit 2c95e7f

Browse files
silvanocerzaAlberto Iannaccone
authored and
Alberto Iannaccone
committedMay 9, 2022
Changed upload settings
1 parent 116b3d5 commit 2c95e7f

File tree

4 files changed

+35
-27
lines changed

4 files changed

+35
-27
lines changed
 

‎arduino-ide-extension/src/browser/contributions/burn-bootloader.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,15 @@ export class BurnBootloader extends SketchContribution {
6060
this.preferences.get('arduino.upload.verify'),
6161
this.preferences.get('arduino.upload.verbose'),
6262
]);
63+
64+
const board = {
65+
...boardsConfig.selectedBoard,
66+
name: boardsConfig.selectedBoard?.name || '',
67+
fqbn,
68+
}
6369
this.outputChannelManager.getChannel('Arduino').clear();
6470
await this.coreService.burnBootloader({
65-
fqbn,
71+
board,
6672
programmer,
6773
port,
6874
verify,

‎arduino-ide-extension/src/browser/contributions/upload-sketch.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ export class UploadSketch extends SketchContribution {
226226
this.sourceOverride(),
227227
]);
228228

229+
const board = {
230+
...boardsConfig.selectedBoard,
231+
name: boardsConfig.selectedBoard?.name || '',
232+
fqbn,
233+
}
229234
let options: CoreService.Upload.Options | undefined = undefined;
230235
const sketchUri = sketch.uri;
231236
const optimizeForDebug = this.editorMode.compileForDebug;
@@ -247,7 +252,7 @@ export class UploadSketch extends SketchContribution {
247252
const programmer = selectedProgrammer;
248253
options = {
249254
sketchUri,
250-
fqbn,
255+
board,
251256
optimizeForDebug,
252257
programmer,
253258
port,
@@ -259,7 +264,7 @@ export class UploadSketch extends SketchContribution {
259264
} else {
260265
options = {
261266
sketchUri,
262-
fqbn,
267+
board,
263268
optimizeForDebug,
264269
port,
265270
verbose,

‎arduino-ide-extension/src/common/protocol/core-service.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BoardUserField } from '.';
2-
import { Port } from '../../common/protocol/boards-service';
2+
import { Board, Port } from '../../common/protocol/boards-service';
33
import { Programmer } from './boards-service';
44

55
export const CompilerWarningLiterals = [
@@ -33,7 +33,7 @@ export namespace CoreService {
3333
* `file` URI to the sketch folder.
3434
*/
3535
readonly sketchUri: string;
36-
readonly fqbn?: string | undefined;
36+
readonly board?: Board;
3737
readonly optimizeForDebug: boolean;
3838
readonly verbose: boolean;
3939
readonly sourceOverride: Record<string, string>;
@@ -42,7 +42,7 @@ export namespace CoreService {
4242

4343
export namespace Upload {
4444
export interface Options extends Compile.Options {
45-
readonly port?: Port | undefined;
45+
readonly port?: Port;
4646
readonly programmer?: Programmer | undefined;
4747
readonly verify: boolean;
4848
readonly userFields: BoardUserField[];
@@ -51,8 +51,8 @@ export namespace CoreService {
5151

5252
export namespace Bootloader {
5353
export interface Options {
54-
readonly fqbn?: string | undefined;
55-
readonly port?: Port | undefined;
54+
readonly board?: Board;
55+
readonly port?: Port;
5656
readonly programmer?: Programmer | undefined;
5757
readonly verbose: boolean;
5858
readonly verify: boolean;

‎arduino-ide-extension/src/node/core-service-impl.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { ArduinoCoreServiceClient } from './cli-protocol/cc/arduino/cli/commands
2424
import { firstToUpperCase, firstToLowerCase } from '../common/utils';
2525
import { Port } from './cli-protocol/cc/arduino/cli/commands/v1/port_pb';
2626
import { nls } from '@theia/core';
27-
import { SerialService } from './../common/protocol/serial-service';
27+
import { MonitorManager } from './monitor-manager';
2828

2929
@injectable()
3030
export 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

Comments
 (0)
Please sign in to comment.