@@ -116,8 +116,8 @@ export class SerialConnectionManager {
116
116
}
117
117
118
118
/**
119
- * Set the config passing only the properties that has changed. If some has changed and the serial is open,
120
- * we try to reconnect
119
+ * Updated the config in the BE passing only the properties that has changed.
120
+ * BE will create a new connection if needed.
121
121
*
122
122
* @param newConfig the porperties of the config that has changed
123
123
*/
@@ -150,10 +150,6 @@ export class SerialConnectionManager {
150
150
return this . wsPort ;
151
151
}
152
152
153
- isWebSocketConnected ( ) : boolean {
154
- return ! ! this . webSocket ?. url ;
155
- }
156
-
157
153
protected handleWebSocketChanged ( wsPort : number ) : void {
158
154
this . wsPort = wsPort ;
159
155
}
@@ -168,7 +164,7 @@ export class SerialConnectionManager {
168
164
return await this . serialService . isSerialPortOpen ( ) ;
169
165
}
170
166
171
- openSerial ( ) : void {
167
+ openWSToBE ( ) : void {
172
168
if ( ! isSerialConfig ( this . config ) ) {
173
169
this . messageService . error (
174
170
`Please select a board and a port to open the serial connection.`
@@ -189,7 +185,7 @@ export class SerialConnectionManager {
189
185
}
190
186
}
191
187
192
- closeSerial ( ) : void {
188
+ closeWStoBE ( ) : void {
193
189
if ( this . webSocket ) {
194
190
try {
195
191
this . webSocket . close ( ) ;
@@ -297,28 +293,6 @@ export class SerialConnectionManager {
297
293
}
298
294
}
299
295
300
- // async connect(): Promise<Status> {
301
- // if (await this.serialService.isSerialPortOpen())
302
- // return Status.ALREADY_CONNECTED;
303
- // if (!isSerialConfig(this.config)) return Status.NOT_CONNECTED;
304
-
305
- // console.info(
306
- // `>>> Creating serial connection for ${Board.toString(
307
- // this.config.board
308
- // )} on port ${Port.toString(this.config.port)}...`
309
- // );
310
- // const connectStatus = await this.serialService.connect(this.config);
311
- // if (Status.isOK(connectStatus)) {
312
- // console.info(
313
- // `<<< Serial connection created for ${Board.toString(this.config.board, {
314
- // useFqbn: false,
315
- // }) } on port ${Port.toString(this.config.port)}.`
316
- // );
317
- // }
318
-
319
- // return Status.isOK(connectStatus);
320
- // }
321
-
322
296
async reconnectAfterUpload ( ) : Promise < void > {
323
297
try {
324
298
if ( isSerialConfig ( this . config ) ) {
@@ -339,31 +313,6 @@ export class SerialConnectionManager {
339
313
}
340
314
}
341
315
342
- async disconnectSerialPort ( ) : Promise < Status > {
343
- if ( ! ( await this . serialService . isSerialPortOpen ( ) ) ) {
344
- return Status . OK ;
345
- }
346
-
347
- console . log ( '>>> Disposing existing serial connection...' ) ;
348
- const status = await this . serialService . disconnect ( ) ;
349
- if ( Status . isOK ( status ) ) {
350
- console . log (
351
- `<<< Disposed serial connection. Was: ${ Serial . Config . toString (
352
- this . config
353
- ) } `
354
- ) ;
355
- this . wsPort = undefined ;
356
- } else {
357
- console . warn (
358
- `<<< Could not dispose serial connection. Activate connection: ${ Serial . Config . toString (
359
- this . config
360
- ) } `
361
- ) ;
362
- }
363
-
364
- return status ;
365
- }
366
-
367
316
/**
368
317
* Sends the data to the connected serial port.
369
318
* The desired EOL is appended to `data`, you do not have to add it.
@@ -384,7 +333,7 @@ export class SerialConnectionManager {
384
333
return this . onConnectionChangedEmitter . event ;
385
334
}
386
335
387
- get onRead ( ) : Event < { messages : string [ ] } > {
336
+ get onRead ( ) : Event < { messages : any } > {
388
337
return this . onReadEmitter . event ;
389
338
}
390
339
@@ -399,18 +348,6 @@ export class SerialConnectionManager {
399
348
}
400
349
401
350
export namespace Serial {
402
- export enum Type {
403
- Monitor = 'Monitor' ,
404
- Plotter = 'Plotter' ,
405
- }
406
-
407
- /**
408
- * The state represents which types of connections are needed by the client, and it should match whether the Serial Monitor
409
- * or the Serial Plotter are open or not in the GUI. It's an array cause it's possible to have both, none or only one of
410
- * them open
411
- */
412
- export type State = Serial . Type [ ] ;
413
-
414
351
export namespace Config {
415
352
export function toString ( config : Partial < SerialConfig > ) : string {
416
353
if ( ! isSerialConfig ( config ) ) return '' ;
0 commit comments