Skip to content

Commit 24760d4

Browse files
authored
Guard MSP messages not included in build (#4721)
1 parent 41cb8c1 commit 24760d4

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/js/fc.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ const FC = {
813813
serialRxTypes[0] = "NONE";
814814
serialRxTypes.push("SPEKTRUM1024");
815815
}
816-
816+
817817
if (semver.gte(apiVersion, API_VERSION_1_47)) {
818818
serialRxTypes.push("MAVLINK");
819819
}
@@ -873,6 +873,13 @@ const FC = {
873873
return FC.getSerialRxTypes();
874874
},
875875

876+
checkBuildOption(option) {
877+
if (this.CONFIG.buildOptions?.length) {
878+
return this.CONFIG.buildOptions.includes(option);
879+
}
880+
return true; // assume all options are available if build options are not known
881+
},
882+
876883
calculateHardwareName() {
877884
let name;
878885
if (this.CONFIG.targetName) {

src/js/tabs/configuration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ configuration.initialize = function (callback) {
7171
)
7272
.then(() => MSP.promise(MSPCodes.MSP_ADVANCED_CONFIG))
7373
.then(() =>
74-
semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)
74+
semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46) && FC.checkBuildOption("USE_MAG")
7575
? MSP.promise(MSPCodes.MSP_COMPASS_CONFIG)
7676
: Promise.resolve(true),
7777
)

src/js/tabs/failsafe.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ failsafe.initialize = function (callback) {
2929
}
3030

3131
function load_gps_rescue() {
32-
MSP.send_message(MSPCodes.MSP_GPS_RESCUE, false, false, get_box_names);
32+
if (FC.checkBuildOption("USE_GPS")) {
33+
MSP.send_message(MSPCodes.MSP_GPS_RESCUE, false, false, get_box_names);
34+
} else {
35+
get_box_names();
36+
}
3337
}
3438

3539
function get_box_names() {
@@ -65,7 +69,7 @@ failsafe.initialize = function (callback) {
6569
}
6670

6771
function load_compass_config() {
68-
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) {
72+
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46) && FC.checkBuildOption("USE_MAG")) {
6973
MSP.send_message(MSPCodes.MSP_COMPASS_CONFIG, false, false, load_gps_config);
7074
} else {
7175
load_gps_config();

0 commit comments

Comments
 (0)