@@ -116,8 +116,8 @@ export class SerialConnectionManager {
116116 }
117117
118118 /**
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.
121121 *
122122 * @param newConfig the porperties of the config that has changed
123123 */
@@ -150,10 +150,6 @@ export class SerialConnectionManager {
150150 return this . wsPort ;
151151 }
152152
153- isWebSocketConnected ( ) : boolean {
154- return ! ! this . webSocket ?. url ;
155- }
156-
157153 protected handleWebSocketChanged ( wsPort : number ) : void {
158154 this . wsPort = wsPort ;
159155 }
@@ -168,7 +164,7 @@ export class SerialConnectionManager {
168164 return await this . serialService . isSerialPortOpen ( ) ;
169165 }
170166
171- openSerial ( ) : void {
167+ openWSToBE ( ) : void {
172168 if ( ! isSerialConfig ( this . config ) ) {
173169 this . messageService . error (
174170 `Please select a board and a port to open the serial connection.`
@@ -189,7 +185,7 @@ export class SerialConnectionManager {
189185 }
190186 }
191187
192- closeSerial ( ) : void {
188+ closeWStoBE ( ) : void {
193189 if ( this . webSocket ) {
194190 try {
195191 this . webSocket . close ( ) ;
@@ -297,28 +293,6 @@ export class SerialConnectionManager {
297293 }
298294 }
299295
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-
322296 async reconnectAfterUpload ( ) : Promise < void > {
323297 try {
324298 if ( isSerialConfig ( this . config ) ) {
@@ -339,31 +313,6 @@ export class SerialConnectionManager {
339313 }
340314 }
341315
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-
367316 /**
368317 * Sends the data to the connected serial port.
369318 * The desired EOL is appended to `data`, you do not have to add it.
@@ -384,7 +333,7 @@ export class SerialConnectionManager {
384333 return this . onConnectionChangedEmitter . event ;
385334 }
386335
387- get onRead ( ) : Event < { messages : string [ ] } > {
336+ get onRead ( ) : Event < { messages : any } > {
388337 return this . onReadEmitter . event ;
389338 }
390339
@@ -399,18 +348,6 @@ export class SerialConnectionManager {
399348}
400349
401350export 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-
414351 export namespace Config {
415352 export function toString ( config : Partial < SerialConfig > ) : string {
416353 if ( ! isSerialConfig ( config ) ) return '' ;
0 commit comments