@@ -12,6 +12,7 @@ import {
12
12
BoardsPackage ,
13
13
AttachedBoardsChangeEvent ,
14
14
BoardWithPackage ,
15
+ BoardUserField ,
15
16
} from '../../common/protocol' ;
16
17
import { BoardsConfig } from './boards-config' ;
17
18
import { naturalCompare } from '../../common/utils' ;
@@ -173,8 +174,8 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
173
174
const selectedAvailableBoard = AvailableBoard . is ( selectedBoard )
174
175
? selectedBoard
175
176
: this . _availableBoards . find ( ( availableBoard ) =>
176
- Board . sameAs ( availableBoard , selectedBoard )
177
- ) ;
177
+ Board . sameAs ( availableBoard , selectedBoard )
178
+ ) ;
178
179
if (
179
180
selectedAvailableBoard &&
180
181
selectedAvailableBoard . selected &&
@@ -264,6 +265,18 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
264
265
return boards ;
265
266
}
266
267
268
+ async selectedBoardUserFields ( ) : Promise < BoardUserField [ ] > {
269
+ if ( ! this . _boardsConfig . selectedBoard || ! this . _boardsConfig . selectedPort ) {
270
+ return [ ] ;
271
+ }
272
+ const fqbn = this . _boardsConfig . selectedBoard . fqbn ;
273
+ if ( ! fqbn ) {
274
+ return [ ] ;
275
+ }
276
+ const protocol = this . _boardsConfig . selectedPort . protocol ;
277
+ return await this . boardsService . getBoardUserFields ( { fqbn, protocol } ) ;
278
+ }
279
+
267
280
/**
268
281
* `true` if the `config.selectedBoard` is defined; hence can compile against the board. Otherwise, `false`.
269
282
*/
@@ -337,14 +350,14 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
337
350
const timeoutTask =
338
351
! ! timeout && timeout > 0
339
352
? new Promise < void > ( ( _ , reject ) =>
340
- setTimeout (
341
- ( ) => reject ( new Error ( `Timeout after ${ timeout } ms.` ) ) ,
342
- timeout
343
- )
353
+ setTimeout (
354
+ ( ) => reject ( new Error ( `Timeout after ${ timeout } ms.` ) ) ,
355
+ timeout
344
356
)
357
+ )
345
358
: new Promise < void > ( ( ) => {
346
- /* never */
347
- } ) ;
359
+ /* never */
360
+ } ) ;
348
361
const waitUntilTask = new Promise < void > ( ( resolve ) => {
349
362
let candidate = find ( what , this . availableBoards ) ;
350
363
if ( candidate ) {
@@ -478,9 +491,8 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
478
491
479
492
protected getLastSelectedBoardOnPortKey ( port : Port | string ) : string {
480
493
// TODO: we lose the port's `protocol` info (`serial`, `network`, etc.) here if the `port` is a `string`.
481
- return `last-selected-board-on-port:${
482
- typeof port === 'string' ? port : Port . toString ( port )
483
- } `;
494
+ return `last-selected-board-on-port:${ typeof port === 'string' ? port : Port . toString ( port )
495
+ } `;
484
496
}
485
497
486
498
protected async loadState ( ) : Promise < void > {
0 commit comments