fix(commander): build mag calibration only with CONFIG_SENSORS_VEHICLE_MAGNETOMETER (#28555)

Boards that compile the magnetometer pipeline out still linked 8.6 KB of
calibration that could never run. holybro_kakutef7 is one of them and sits
at 100 % of flash on main. The calibration commands answer UNSUPPORTED
there.
This commit is contained in:
Jacob Dahl authored and GitHub committed 2026-09-04 21:26:50 -06:00
1 parent 29120280ac
commit 6dc89338a8
3 files changed
+33 -6

No files matched your search

+8
View File
@@ -1459,9 +1459,13 @@ Commander::handle_command(const vehicle_command_s &cmd)
} else if ((int)(cmd.param2) == 1) {
/* magnetometer calibration */
#if defined(CONFIG_SENSORS_VEHICLE_MAGNETOMETER)
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED);
_vehicle_status.calibration_enabled = true;
_worker_thread.startTask(WorkerThread::Request::MagCalibration);
#else
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_UNSUPPORTED);
#endif
} else if ((int)(cmd.param3) == 1) {
/* baro calibration */
@@ -1564,6 +1568,7 @@ Commander::handle_command(const vehicle_command_s &cmd)
"Calibration denied: not supported in SIH mode");
} else {
#if defined(CONFIG_SENSORS_VEHICLE_MAGNETOMETER)
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED);
// parameter 1: Heading (degrees)
// parameter 3: Latitude (degrees)
@@ -1586,6 +1591,9 @@ Commander::handle_command(const vehicle_command_s &cmd)
_vehicle_status.calibration_enabled = true;
_worker_thread.setMagQuickData(heading_radians, latitude, longitude);
_worker_thread.startTask(WorkerThread::Request::MagCalibrationQuick);
#else
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_UNSUPPORTED);
#endif
}
return true;