@@ -58,7 +58,7 @@ export class MonitorManager extends CoreClientAware {
58
58
* combination specified, false in all other cases.
59
59
*/
60
60
isStarted ( board : Board , port : Port ) : boolean {
61
- const monitorID = this . monitorID ( board , port ) ;
61
+ const monitorID = this . monitorID ( board . fqbn , port ) ;
62
62
const monitor = this . monitorServices . get ( monitorID ) ;
63
63
if ( monitor ) {
64
64
return monitor . isStarted ( ) ;
@@ -106,7 +106,7 @@ export class MonitorManager extends CoreClientAware {
106
106
port : Port ,
107
107
connectToClient : ( status : Status ) => void
108
108
) : Promise < void > {
109
- const monitorID = this . monitorID ( board , port ) ;
109
+ const monitorID = this . monitorID ( board . fqbn , port ) ;
110
110
111
111
let monitor = this . monitorServices . get ( monitorID ) ;
112
112
if ( ! monitor ) {
@@ -138,7 +138,7 @@ export class MonitorManager extends CoreClientAware {
138
138
* @param port port monitored
139
139
*/
140
140
async stopMonitor ( board : Board , port : Port ) : Promise < void > {
141
- const monitorID = this . monitorID ( board , port ) ;
141
+ const monitorID = this . monitorID ( board . fqbn , port ) ;
142
142
const monitor = this . monitorServices . get ( monitorID ) ;
143
143
if ( ! monitor ) {
144
144
// There's no monitor to stop, bail
@@ -155,7 +155,7 @@ export class MonitorManager extends CoreClientAware {
155
155
* @returns port of the MonitorService's WebSocket
156
156
*/
157
157
getWebsocketAddressPort ( board : Board , port : Port ) : number {
158
- const monitorID = this . monitorID ( board , port ) ;
158
+ const monitorID = this . monitorID ( board . fqbn , port ) ;
159
159
const monitor = this . monitorServices . get ( monitorID ) ;
160
160
if ( ! monitor ) {
161
161
return - 1 ;
@@ -168,17 +168,17 @@ export class MonitorManager extends CoreClientAware {
168
168
* that an upload process started on that exact board/port combination.
169
169
* This must be done so that we can stop the monitor for the time being
170
170
* until the upload process finished.
171
- * @param board board connected to port
171
+ * @param fqbn the FQBN of the board connected to port
172
172
* @param port port to monitor
173
173
*/
174
- async notifyUploadStarted ( board ?: Board , port ?: Port ) : Promise < void > {
175
- if ( ! board || ! port ) {
174
+ async notifyUploadStarted ( fqbn ?: string , port ?: Port ) : Promise < void > {
175
+ if ( ! fqbn || ! port ) {
176
176
// We have no way of knowing which monitor
177
177
// to retrieve if we don't have this information.
178
178
return ;
179
179
}
180
180
181
- const monitorID = this . monitorID ( board , port ) ;
181
+ const monitorID = this . monitorID ( fqbn , port ) ;
182
182
this . addToMonitorIDsByUploadState ( 'uploadInProgress' , monitorID ) ;
183
183
184
184
const monitor = this . monitorServices . get ( monitorID ) ;
@@ -194,19 +194,22 @@ export class MonitorManager extends CoreClientAware {
194
194
/**
195
195
* Notifies the monitor service of that board/port combination
196
196
* that an upload process started on that exact board/port combination.
197
- * @param board board connected to port
197
+ * @param fqbn the FQBN of the board connected to port
198
198
* @param port port to monitor
199
199
* @returns a Status object to know if the process has been
200
200
* started or if there have been errors.
201
201
*/
202
- async notifyUploadFinished ( board ?: Board , port ?: Port ) : Promise < Status > {
202
+ async notifyUploadFinished (
203
+ fqbn ?: string | undefined ,
204
+ port ?: Port
205
+ ) : Promise < Status > {
203
206
let status : Status = Status . NOT_CONNECTED ;
204
207
let portDidChangeOnUpload = false ;
205
208
206
209
// We have no way of knowing which monitor
207
210
// to retrieve if we don't have this information.
208
- if ( board && port ) {
209
- const monitorID = this . monitorID ( board , port ) ;
211
+ if ( fqbn && port ) {
212
+ const monitorID = this . monitorID ( fqbn , port ) ;
210
213
this . removeFromMonitorIDsByUploadState ( 'uploadInProgress' , monitorID ) ;
211
214
212
215
const monitor = this . monitorServices . get ( monitorID ) ;
@@ -277,7 +280,7 @@ export class MonitorManager extends CoreClientAware {
277
280
port : Port ,
278
281
settings : PluggableMonitorSettings
279
282
) {
280
- const monitorID = this . monitorID ( board , port ) ;
283
+ const monitorID = this . monitorID ( board . fqbn , port ) ;
281
284
let monitor = this . monitorServices . get ( monitorID ) ;
282
285
if ( ! monitor ) {
283
286
monitor = this . createMonitor ( board , port ) ;
@@ -296,7 +299,7 @@ export class MonitorManager extends CoreClientAware {
296
299
board : Board ,
297
300
port : Port
298
301
) : Promise < MonitorSettings > {
299
- const monitorID = this . monitorID ( board , port ) ;
302
+ const monitorID = this . monitorID ( board . fqbn , port ) ;
300
303
const monitor = this . monitorServices . get ( monitorID ) ;
301
304
if ( ! monitor ) {
302
305
return { } ;
@@ -312,7 +315,7 @@ export class MonitorManager extends CoreClientAware {
312
315
* @returns a new instance of MonitorService ready to use.
313
316
*/
314
317
private createMonitor ( board : Board , port : Port ) : MonitorService {
315
- const monitorID = this . monitorID ( board , port ) ;
318
+ const monitorID = this . monitorID ( board . fqbn , port ) ;
316
319
const monitor = this . monitorServiceFactory ( {
317
320
board,
318
321
port,
@@ -341,12 +344,12 @@ export class MonitorManager extends CoreClientAware {
341
344
342
345
/**
343
346
* Utility function to create a unique ID for a monitor service.
344
- * @param board
347
+ * @param fqbn
345
348
* @param port
346
349
* @returns a unique monitor ID
347
350
*/
348
- private monitorID ( board : Board , port : Port ) : MonitorID {
349
- const splitFqbn = board ?. fqbn ?. split ( ':' ) || [ ] ;
351
+ private monitorID ( fqbn : string | undefined , port : Port ) : MonitorID {
352
+ const splitFqbn = fqbn ?. split ( ':' ) || [ ] ;
350
353
const shortenedFqbn = splitFqbn . slice ( 0 , 3 ) . join ( ':' ) || '' ;
351
354
return `${ shortenedFqbn } -${ port . address } -${ port . protocol } ` ;
352
355
}
0 commit comments