File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,15 @@ export class DeviceService {
124124 }
125125
126126 async sendCommand ( code : string ) : Promise < boolean > {
127+ if ( code . includes ( reconnectString ) ) {
128+ // Reconnect the device or connect for the first time
129+ console . log ( 'Reconnect command detected, reconnecting device...' ) ;
130+ await this . disconnect ( ) ;
131+ console . log ( 'Device disconnected' ) ;
132+ await this . connect ( ) ;
133+ console . log ( 'Device connected' ) ;
134+ }
135+
127136 if ( ! this . transport || ! this . transport . device . writable ) {
128137 return false ;
129138 }
@@ -138,16 +147,6 @@ export class DeviceService {
138147
139148 await writer . write ( ctrl_e ) ;
140149 await writer . write ( new_line ) ;
141-
142- if ( code . includes ( reconnectString ) ) {
143- // Reconnect the device or connect for the first time
144- console . log ( 'Reconnect command detected, reconnecting device...' ) ;
145- await this . disconnect ( ) ;
146- await this . connect ( ) ;
147- console . log ( 'Device reconnected' ) ;
148- this . isDeviceConnected = true ;
149- }
150-
151150
152151 const data = encoder . encode ( code + "######START REQUEST######" ) ;
153152 await writer . write ( data ) ;
You can’t perform that action at this time.
0 commit comments