@@ -12,7 +12,7 @@ import FC from '../fc';
1212import MSP from '../msp' ;
1313import MSPCodes from '../msp/MSPCodes' ;
1414import PortHandler , { usbDevices } from '../port_handler' ;
15- import { API_VERSION_1_39 , API_VERSION_1_45 , API_VERSION_1_47 } from '../data_storage' ;
15+ import { API_VERSION_1_39 , API_VERSION_1_45 , API_VERSION_1_46 } from '../data_storage' ;
1616import serial from '../serial' ;
1717import STM32DFU from '../protocols/stm32usbdfu' ;
1818import { gui_log } from '../gui_log' ;
@@ -1305,7 +1305,7 @@ firmware_flasher.verifyBoard = function() {
13051305
13061306 function getBoardInfo ( ) {
13071307 MSP . send_message ( MSPCodes . MSP_BOARD_INFO , false , false , function ( ) {
1308- if ( semver . gte ( FC . CONFIG . apiVersion , API_VERSION_1_47 ) ) {
1308+ if ( semver . gte ( FC . CONFIG . apiVersion , API_VERSION_1_46 ) ) {
13091309 FC . processBuildOptions ( ) ;
13101310 self . cloudBuildOptions = FC . CONFIG . buildOptions ;
13111311 }
@@ -1320,20 +1320,24 @@ firmware_flasher.verifyBoard = function() {
13201320 getBoardInfo ( ) ;
13211321 }
13221322
1323- function getBuildInfo ( ) {
1323+ async function getBuildInfo ( ) {
13241324 if ( semver . gte ( FC . CONFIG . apiVersion , API_VERSION_1_45 ) && FC . CONFIG . flightControllerIdentifier === 'BTFL' ) {
1325- MSP . send_message ( MSPCodes . MSP2_GET_TEXT , mspHelper . crunch ( MSPCodes . MSP2_GET_TEXT , MSPCodes . BUILD_KEY ) , false , ( ) => {
1326- MSP . send_message ( MSPCodes . MSP2_GET_TEXT , mspHelper . crunch ( MSPCodes . MSP2_GET_TEXT , MSPCodes . CRAFT_NAME ) , false , ( ) => {
1327- // store FC.CONFIG.buildKey as the object gets destroyed after disconnect
1328- self . cloudBuildKey = FC . CONFIG . buildKey ;
1325+ await MSP . promise ( MSPCodes . MSP2_GET_TEXT , mspHelper . crunch ( MSPCodes . MSP2_GET_TEXT , MSPCodes . BUILD_KEY ) ) ;
1326+ await MSP . promise ( MSPCodes . MSP2_GET_TEXT , mspHelper . crunch ( MSPCodes . MSP2_GET_TEXT , MSPCodes . CRAFT_NAME ) ) ;
1327+ await MSP . promise ( MSPCodes . MSP_BUILD_INFO ) ;
13291328
1330- if ( self . validateBuildKey ( ) && semver . lt ( FC . CONFIG . apiVersion , API_VERSION_1_47 ) ) {
1331- self . buildApi . requestBuildOptions ( self . cloudBuildKey , getCloudBuildOptions , getBoardInfo ) ;
1332- } else {
1333- getBoardInfo ( ) ;
1334- }
1335- } ) ;
1336- } ) ;
1329+ // store FC.CONFIG.buildKey as the object gets destroyed after disconnect
1330+ self . cloudBuildKey = FC . CONFIG . buildKey ;
1331+
1332+ // 3/21/2024 is the date when the build key was introduced
1333+ const supportedDate = new Date ( '3/21/2024' ) ;
1334+ const buildDate = new Date ( FC . CONFIG . buildInfo ) ;
1335+
1336+ if ( self . validateBuildKey ( ) && ( semver . lt ( FC . CONFIG . apiVersion , API_VERSION_1_46 ) || buildDate < supportedDate ) ) {
1337+ self . buildApi . requestBuildOptions ( self . cloudBuildKey , getCloudBuildOptions , getBoardInfo ) ;
1338+ } else {
1339+ getBoardInfo ( ) ;
1340+ }
13371341 } else {
13381342 getBoardInfo ( ) ;
13391343 }
0 commit comments