From f3ba16403c4237fd772dcb3ce22aa98afd1a0d1f Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Fri, 12 Jan 2024 17:45:19 +0900 Subject: [PATCH] GCS_MAVLink: send battery soh as named value --- libraries/GCS_MAVLink/GCS_Common.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index a27eabd1dd71f..17f0e6053e218 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -356,6 +356,14 @@ void GCS_MAVLINK::send_battery_status(const uint8_t instance) const cell_mvolts_ext, // Cell 11..14 voltages 0, // battery mode battery.get_mavlink_fault_bitmask(instance)); // fault_bitmask + + // send state of health percentage if available + uint8_t batt_soh_pct; + if (battery.get_state_of_health_pct(instance, batt_soh_pct)) { + char name[12]; + snprintf(name, sizeof(name), "BATT%u_SOH", instance); + send_named_float(name, batt_soh_pct); + } #else (void)instance; #endif