Skip to content

Commit e0b8f3b

Browse files
Move reconnection location
1 parent 91029c9 commit e0b8f3b

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

kernel/src/services/DeviceService.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)