Skip to content

Commit

Permalink
GCS_MAVLink: Add AP_MAVLINK_MSG_FLIGHT_INFORMATION_ENABLED guard
Browse files Browse the repository at this point in the history
  • Loading branch information
nexton-winjeel committed Aug 4, 2024
1 parent cbce03d commit 3447e4f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libraries/GCS_MAVLink/GCS.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,14 @@ class GCS_MAVLINK
void send_uavionix_adsb_out_status() const;
void send_autopilot_state_for_gimbal_device() const;

#if AP_MAVLINK_MSG_FLIGHT_INFORMATION_ENABLED
struct {
MAV_LANDED_STATE last_landed_state;
uint64_t takeoff_time_us;
} flight_info;

void send_flight_information();
#endif

// lock a channel, preventing use by MAVLink
void lock(bool _lock) {
Expand Down
4 changes: 4 additions & 0 deletions libraries/GCS_MAVLink/GCS_Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5964,6 +5964,7 @@ void GCS_MAVLINK::send_autopilot_state_for_gimbal_device() const
#endif // AP_AHRS_ENABLED
}

#if AP_MAVLINK_MSG_FLIGHT_INFORMATION_ENABLED
void GCS_MAVLINK::send_flight_information()
{
const uint32_t time_boot_us = AP_HAL::millis64();
Expand Down Expand Up @@ -6013,6 +6014,7 @@ void GCS_MAVLINK::send_flight_information()
flight_number
);
}
#endif // AP_MAVLINK_MSG_FLIGHT_INFORMATION_ENABLED

void GCS_MAVLINK::send_received_message_deprecation_warning(const char * message)
{
Expand Down Expand Up @@ -6445,10 +6447,12 @@ bool GCS_MAVLINK::try_send_message(const enum ap_message id)
break;
#endif

#if AP_MAVLINK_MSG_FLIGHT_INFORMATION_ENABLED
case MSG_FLIGHT_INFORMATION:
CHECK_PAYLOAD_SIZE(FLIGHT_INFORMATION);
send_flight_information();
break;
#endif

default:
// try_send_message must always at some stage return true for
Expand Down
4 changes: 4 additions & 0 deletions libraries/GCS_MAVLink/GCS_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,7 @@
#ifndef AP_MAVLINK_MAV_CMD_SET_HAGL_ENABLED
#define AP_MAVLINK_MAV_CMD_SET_HAGL_ENABLED (BOARD_FLASH_SIZE > 1024)
#endif

#ifndef AP_MAVLINK_MSG_FLIGHT_INFORMATION_ENABLED
#define AP_MAVLINK_MSG_FLIGHT_INFORMATION_ENABLED 1
#endif
2 changes: 2 additions & 0 deletions libraries/GCS_MAVLink/ap_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ enum ap_message : uint8_t {
#if AP_MAVLINK_MSG_HIGHRES_IMU_ENABLED
MSG_HIGHRES_IMU,
#endif
#if AP_MAVLINK_MSG_FLIGHT_INFORMATION_ENABLED
MSG_FLIGHT_INFORMATION,
#endif
MSG_LAST // MSG_LAST must be the last entry in this enum
};

0 comments on commit 3447e4f

Please sign in to comment.