File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -98,14 +98,15 @@ export class DeviceService {
9898 } ) ;
9999 document . dispatchEvent ( event )
100100
101- // Contiuously check the port status every 2 seconds to update the connection status/card
102- setInterval ( ( ) => {
103- console . log ( '[DeviceService]: Checking port status...' ) ;
104- if ( this . port && ! this . port . readable && ! this . port . writable ) {
105- console . log ( '[DeviceService]: Port is not readable or writable, disconnecting...' ) ;
106- this . disconnect ( ) ;
107- }
108- } , 2000 ) ;
101+ // Listen for physical disconnect event
102+ this . port . addEventListener ( 'disconnect' , ( ) => {
103+ console . log ( '[DeviceService]: Serial port physically disconnected.' ) ;
104+ this . isDeviceConnected = false ;
105+ const event = new CustomEvent ( "deviceDisconnected" , {
106+ detail : { msg : "Not connected" }
107+ } ) ;
108+ document . dispatchEvent ( event ) ;
109+ } ) ;
109110 }
110111
111112 async disconnect ( ) : Promise < void > {
You can’t perform that action at this time.
0 commit comments