@@ -491,30 +491,32 @@ function connectCli() {
491491 $ ( '#tabs .tab_cli a' ) . click ( ) ;
492492}
493493
494- async function onConnect ( ) {
494+ function onConnect ( ) {
495495 if ( $ ( 'div#flashbutton a.flash_state' ) . hasClass ( 'active' ) && $ ( 'div#flashbutton a.flash' ) . hasClass ( 'active' ) ) {
496496 $ ( 'div#flashbutton a.flash_state' ) . removeClass ( 'active' ) ;
497497 $ ( 'div#flashbutton a.flash' ) . removeClass ( 'active' ) ;
498498 }
499+
499500 GUI . timeout_remove ( 'connecting' ) ; // kill connecting timer
501+
500502 $ ( 'div#connectbutton div.connect_state' ) . text ( i18n . getMessage ( 'disconnect' ) ) . addClass ( 'active' ) ;
501503 $ ( 'div#connectbutton a.connect' ) . addClass ( 'active' ) ;
502504
503505 $ ( '#tabs ul.mode-disconnected' ) . hide ( ) ;
504506 $ ( '#tabs ul.mode-connected-cli' ) . show ( ) ;
505507
506-
507508 // show only appropriate tabs
508509 $ ( '#tabs ul.mode-connected li' ) . hide ( ) ;
509510 $ ( '#tabs ul.mode-connected li' ) . filter ( function ( index ) {
510511 const classes = $ ( this ) . attr ( "class" ) . split ( / \s + / ) ;
511512 let found = false ;
513+
512514 $ . each ( GUI . allowedTabs , ( _index , value ) => {
513- const tabName = `tab_${ value } ` ;
514- if ( $ . inArray ( tabName , classes ) >= 0 ) {
515- found = true ;
516- }
517- } ) ;
515+ const tabName = `tab_${ value } ` ;
516+ if ( $ . inArray ( tabName , classes ) >= 0 ) {
517+ found = true ;
518+ }
519+ } ) ;
518520
519521 if ( FC . CONFIG . boardType == 0 ) {
520522 if ( classes . indexOf ( "osd-required" ) >= 0 ) {
@@ -532,13 +534,14 @@ async function onConnect() {
532534
533535 $ ( '#tabs ul.mode-connected' ) . show ( ) ;
534536
535- await MSP . promise ( MSPCodes . MSP_FEATURE_CONFIG ) ;
536- if ( semver . gte ( FC . CONFIG . apiVersion , API_VERSION_1_33 ) ) {
537- await MSP . promise ( MSPCodes . MSP_BATTERY_CONFIG ) ;
538- }
539- await MSP . promise ( semver . gte ( FC . CONFIG . apiVersion , API_VERSION_1_32 ) ? MSPCodes . MSP_STATUS_EX : MSPCodes . MSP_STATUS ) ;
540- await MSP . promise ( MSPCodes . MSP_DATAFLASH_SUMMARY ) ;
541- if ( FC . CONFIG . boardType == 0 || FC . CONFIG . boardType == 2 ) {
537+ MSP . send_message ( MSPCodes . MSP_FEATURE_CONFIG , false , false ) ;
538+ MSP . send_message ( MSPCodes . MSP_BATTERY_CONFIG , false , false ) ;
539+
540+ getStatus ( ) ;
541+
542+ MSP . send_message ( MSPCodes . MSP_DATAFLASH_SUMMARY , false , false ) ;
543+
544+ if ( FC . CONFIG . boardType === 0 || FC . CONFIG . boardType === 2 ) {
542545 startLiveDataRefreshTimer ( ) ;
543546 }
544547 }
@@ -688,8 +691,15 @@ function startLiveDataRefreshTimer() {
688691 GUI . timeout_add ( 'data_refresh' , update_live_status , 100 ) ;
689692}
690693
691- async function update_live_status ( ) {
694+ async function getStatus ( ) {
695+ if ( semver . gte ( FC . CONFIG . apiVersion , API_VERSION_1_32 ) ) {
696+ return MSP . promise ( MSPCodes . MSP_STATUS_EX ) ;
697+ } else {
698+ return MSP . promise ( MSPCodes . MSP_STATUS ) ;
699+ }
700+ }
692701
702+ async function update_live_status ( ) {
693703 const statuswrapper = $ ( '#quad-status_wrapper' ) ;
694704
695705 $ ( ".quad-status-contents" ) . css ( {
@@ -698,7 +708,7 @@ async function update_live_status() {
698708
699709 if ( GUI . active_tab !== 'cli' && GUI . active_tab !== 'presets' ) {
700710 await MSP . promise ( MSPCodes . MSP_BOXNAMES ) ;
701- await MSP . promise ( semver . gte ( FC . CONFIG . apiVersion , API_VERSION_1_32 ) ? MSPCodes . MSP_STATUS_EX : MSPCodes . MSP_STATUS ) ;
711+ await getStatus ( ) ;
702712 await MSP . promise ( MSPCodes . MSP_ANALOG ) ;
703713
704714 const active = ( ( Date . now ( ) - FC . ANALOG . last_received_timestamp ) < 300 ) ;
@@ -828,7 +838,7 @@ function reinitializeConnection(originatorTab, callback) {
828838 if ( connectionTimestamp !== previousTimeStamp && CONFIGURATOR . connectionValid ) {
829839 console . log ( `Serial connection available after ${ attempts / 10 } seconds` ) ;
830840 clearInterval ( reconnect ) ;
831- await MSP . promise ( MSPCodes . MSP_STATUS ) ;
841+ await getStatus ( ) ;
832842 GUI . log ( i18n . getMessage ( 'deviceReady' ) ) ;
833843 originatorTab . initialize ( false , $ ( '#content' ) . scrollTop ( ) ) ;
834844 callback ?. ( ) ;
0 commit comments