AP_ADSB: tidy sending of SageTech RF mode

Saves 64 bytes on CubeBlack
This commit is contained in:
Peter Barker 2021-09-24 12:49:43 +10:00 committed by Peter Barker
parent e83b598040
commit 0d03cef48b

View File

@ -185,16 +185,12 @@ void AP_ADSB_Sagetech::handle_ack(const Packet_XP &msg)
const uint8_t system_state = msg.payload[2];
transponder_type = (Transponder_Type)msg.payload[6];
const char* rfmode = "RF mode: ";
const uint8_t prev_transponder_mode = last_ack_transponder_mode;
last_ack_transponder_mode = (system_state >> 6) & 0x03;
if (prev_transponder_mode != last_ack_transponder_mode) {
switch (last_ack_transponder_mode) {
case 0: gcs().send_text(MAV_SEVERITY_INFO, "ADSB: %sOFF", rfmode); break;
case 1: gcs().send_text(MAV_SEVERITY_INFO, "ADSB: %sSTBY", rfmode); break;
case 2: gcs().send_text(MAV_SEVERITY_INFO, "ADSB: %sON", rfmode); break;
case 3: gcs().send_text(MAV_SEVERITY_INFO, "ADSB: %sON-ALT",rfmode); break;
default: break;
static const char *mode_names[] = {"OFF", "STBY", "ON", "ON-ALT"};
if (last_ack_transponder_mode < ARRAY_SIZE(mode_names)) {
gcs().send_text(MAV_SEVERITY_INFO, "ADSB: RF Mode: %s", mode_names[last_ack_transponder_mode]);
}
}
}