File tree 2 files changed +16
-6
lines changed 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ const dataAddr = 0x20002000;
6
6
const stackAddr = 0x20001000 ;
7
7
const FULL_FLASH_TIMEOUT = 100000 ; // 100s
8
8
const PARTIAL_FLASH_TIMEOUT = 60000 ; // 60s
9
+ const CONNECTION_CHECK_TIMEOUT = 2000 ; // 2s
9
10
const RETRY_DAP_CMD_TIMEOUT = 50 ; // .05s
10
11
11
12
const flashPageBIN = new Uint32Array ( [
@@ -351,12 +352,20 @@ class DAPWrapper implements pxt.packetio.PacketIOWrapper {
351
352
}
352
353
353
354
private async clearCommandsAsync ( ) {
354
- // before calling into dapjs, push through a few commands to make sure the responses
355
- // to commands from previous sessions (if any) are flushed. Count of 5 is arbitrary.
356
- for ( let i = 0 ; i < 5 ; i ++ ) {
357
- try {
358
- await this . getDaplinkVersionAsync ( ) ;
359
- } catch ( e ) { }
355
+ try {
356
+ await pxt . Util . promiseTimeout ( CONNECTION_CHECK_TIMEOUT , ( async ( ) => {
357
+ // before calling into dapjs, push through a few commands to make sure the responses
358
+ // to commands from previous sessions (if any) are flushed. Count of 5 is arbitrary.
359
+ for ( let i = 0 ; i < 5 ; i ++ ) {
360
+ try {
361
+ await this . getDaplinkVersionAsync ( ) ;
362
+ } catch ( e ) { }
363
+ }
364
+ } ) ( ) ) ;
365
+ } catch ( e ) {
366
+ const errOut = new Error ( e ) ;
367
+ ( errOut as any ) . type = "inittimeout" ;
368
+ throw errOut ;
360
369
}
361
370
}
362
371
Original file line number Diff line number Diff line change 590
590
591
591
"dragFileImage" : " /static/download/transfer.png" ,
592
592
"connectDeviceImage" : " /static/download/connect-microbit.gif" ,
593
+ "disconnectDeviceImage" : " /static/download/device-forgotten.gif" ,
593
594
"selectDeviceImage" : " /static/download/selecting-microbit.gif" ,
594
595
"connectionSuccessImage" : " /static/download/successfully-paired.png" ,
595
596
"incompatibleHardwareImage" : " /static/download/incompatible.png" ,
You can’t perform that action at this time.
0 commit comments