diff --git a/libraries/GCS_MAVLink/GCS.h b/libraries/GCS_MAVLink/GCS.h index 4552e97c35..a339d2a85c 100644 --- a/libraries/GCS_MAVLink/GCS.h +++ b/libraries/GCS_MAVLink/GCS.h @@ -158,6 +158,9 @@ public: void data_stream_send(void); void queued_param_send(); void queued_waypoint_send(); + void set_snoop(void (*_msg_snoop)(const mavlink_message_t* msg)) { + msg_snoop = _msg_snoop; + } static const struct AP_Param::GroupInfo var_info[]; @@ -190,9 +193,6 @@ public: // last time we got a non-zero RSSI from RADIO_STATUS static uint32_t last_radio_status_remrssi_ms; - // mavlink routing object - static MAVLink_routing routing; - // common send functions void send_meminfo(void); void send_power_status(void); @@ -318,6 +318,12 @@ private: // bitmask of what mavlink channels are active static uint8_t mavlink_active; + // mavlink routing object + static MAVLink_routing routing; + + // a vehicle can optionally snoop on messages for other systems + static void (*msg_snoop)(const mavlink_message_t* msg); + // vehicle specific message send function bool try_send_message(enum ap_message id); diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index 7ec29aa386..3e787d9ca4 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -853,7 +853,11 @@ GCS_MAVLINK::update(void (*run_cli)(AP_HAL::UARTDriver *)) // we exclude radio packets to make it possible to use the // CLI over the radio if (msg.msgid != MAVLINK_MSG_ID_RADIO && msg.msgid != MAVLINK_MSG_ID_RADIO_STATUS) { - mavlink_active |= (1U<= MAVLINK_NUM_NON_PAYLOAD_BYTES + MAVLINK_MSG_ID_STATUSTEXT_LEN) { char msg2[50]; strncpy_P(msg2, msg, sizeof(msg2)); diff --git a/libraries/GCS_MAVLink/GCS_MAVLink.cpp b/libraries/GCS_MAVLink/GCS_MAVLink.cpp index 62f73a1ff6..9cbb19cc2f 100644 --- a/libraries/GCS_MAVLink/GCS_MAVLink.cpp +++ b/libraries/GCS_MAVLink/GCS_MAVLink.cpp @@ -46,6 +46,10 @@ static uint8_t mavlink_locked_mask; // routing table MAVLink_routing GCS_MAVLINK::routing; +// snoop function for vehicle types that want to see messages for +// other targets +void (*GCS_MAVLINK::msg_snoop)(const mavlink_message_t* msg) = NULL; + /* lock a channel, preventing use by MAVLink */