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 {
124
124
}
125
125
126
126
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
+
127
136
if ( ! this . transport || ! this . transport . device . writable ) {
128
137
return false ;
129
138
}
@@ -138,16 +147,6 @@ export class DeviceService {
138
147
139
148
await writer . write ( ctrl_e ) ;
140
149
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
-
151
150
152
151
const data = encoder . encode ( code + "######START REQUEST######" ) ;
153
152
await writer . write ( data ) ;
You can’t perform that action at this time.
0 commit comments