44 * SPDX-License-Identifier: MIT 
55 */ 
66
7- import  {  MicrobitWebUSBConnection  }  from  "./usb.js" ; 
8- import  *  as  protocol  from  "./usb-serial-protocol.js" ; 
9- import  {  Logging ,  NullLogging  }  from  "./logging.js" ; 
10- import  {  TypedEventTarget  }  from  "./events.js" ; 
7+ import  {  AccelerometerDataEvent  }  from  "./accelerometer.js" ; 
8+ import  {  ButtonEvent ,  ButtonState  }  from  "./buttons.js" ; 
119import  { 
1210  BoardVersion , 
1311  ConnectionStatus , 
1412  ConnectionStatusEvent , 
15-   ConnectOptions , 
1613  DeviceConnection , 
1714  DeviceConnectionEventMap , 
1815  SerialDataEvent , 
1916}  from  "./device.js" ; 
17+ import  {  TypedEventTarget  }  from  "./events.js" ; 
18+ import  {  Logging ,  NullLogging  }  from  "./logging.js" ; 
2019import  { 
2120  ServiceConnectionEventMap , 
2221  TypedServiceEventDispatcher , 
2322}  from  "./service-events.js" ; 
24- import  {   AccelerometerDataEvent   }  from  "./accelerometer .js" ; 
25- import  {  ButtonEvent ,   ButtonState   }  from  "./buttons .js" ; 
23+ import  *   as   protocol  from  "./usb-serial-protocol .js" ; 
24+ import  {  MicrobitWebUSBConnection   }  from  "./usb .js" ; 
2625
2726const  connectTimeoutDuration : number  =  10000 ; 
2827
@@ -45,6 +44,7 @@ export class MicrobitRadioBridgeConnection
4544  status : ConnectionStatus ; 
4645  private  logging : Logging ; 
4746  private  serialSession : RadioBridgeSerialSession  |  undefined ; 
47+   private  remoteDeviceId : number  |  undefined ; 
4848
4949  private  delegateStatusListner  =  ( e : ConnectionStatusEvent )  =>  { 
5050    if  ( e . status  !==  ConnectionStatus . CONNECTED )  { 
@@ -56,7 +56,6 @@ export class MicrobitRadioBridgeConnection
5656
5757  constructor ( 
5858    private  delegate : MicrobitWebUSBConnection , 
59-     private  remoteDeviceId : number , 
6059    options ?: MicrobitRadioBridgeConnectionOptions , 
6160  )  { 
6261    super ( ) ; 
@@ -87,10 +86,18 @@ export class MicrobitRadioBridgeConnection
8786    this . delegate . clearDevice ( ) ; 
8887  } 
8988
90-   async  connect ( options : ConnectOptions ) : Promise < ConnectionStatus >  { 
89+   setRemoteDeviceId ( remoteDeviceId : number )  { 
90+     this . remoteDeviceId  =  remoteDeviceId ; 
91+   } 
92+ 
93+   async  connect ( ) : Promise < ConnectionStatus >  { 
9194    // TODO: previously this skipped overlapping connect attempts but that seems awkward 
9295    // can we... just not do that? or wait? 
9396
97+     if  ( this . remoteDeviceId  ===  undefined )  { 
98+       throw  new  BridgeError ( `Missing remote micro:bit ID` ) ; 
99+     } 
100+ 
94101    this . logging . event ( { 
95102      type : "Connect" , 
96103      message : "Serial connect start" , 
0 commit comments