File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -47,10 +47,15 @@ export class MicrobitRadioBridgeConnection
47
47
private remoteDeviceId : number | undefined ;
48
48
49
49
private delegateStatusListner = ( e : ConnectionStatusEvent ) => {
50
+ const currentStatus = this . status ;
50
51
if ( e . status !== ConnectionStatus . CONNECTED ) {
51
52
this . setStatus ( e . status ) ;
53
+ this . serialSession ?. dispose ( ) ;
52
54
} else {
53
55
this . status = ConnectionStatus . NOT_CONNECTED ;
56
+ if ( currentStatus === ConnectionStatus . NOT_CONNECTED ) {
57
+ this . serialSession ?. connect ( ) ;
58
+ }
54
59
}
55
60
} ;
56
61
@@ -117,7 +122,9 @@ export class MicrobitRadioBridgeConnection
117
122
type : "Serial" ,
118
123
message : "Serial connection lost 1" ,
119
124
} ) ;
120
- this . serialSession ?. dispose ( ) ;
125
+ // This is the point we tell the consumer that we're trying to reconnect
126
+ // in the background.
127
+ // Leave serial connection running in case the remote device comes back.
121
128
} ,
122
129
( ) => {
123
130
// Remote connection... even more lost?
You can’t perform that action at this time.
0 commit comments