diff --git a/libraries/AP_Proximity/AP_Proximity.cpp b/libraries/AP_Proximity/AP_Proximity.cpp index 8d09d4abf2..bba180b55b 100644 --- a/libraries/AP_Proximity/AP_Proximity.cpp +++ b/libraries/AP_Proximity/AP_Proximity.cpp @@ -269,7 +269,7 @@ AP_Proximity::Proximity_Status AP_Proximity::get_status() const } // handle mavlink DISTANCE_SENSOR messages -void AP_Proximity::handle_msg(mavlink_message_t *msg) +void AP_Proximity::handle_msg(const mavlink_message_t &msg) { for (uint8_t i=0; imsgid == MAVLINK_MSG_ID_DISTANCE_SENSOR) { + if (msg.msgid == MAVLINK_MSG_ID_DISTANCE_SENSOR) { mavlink_distance_sensor_t packet; - mavlink_msg_distance_sensor_decode(msg, &packet); + mavlink_msg_distance_sensor_decode(&msg, &packet); // store distance to appropriate sector based on orientation field if (packet.orientation <= MAV_SENSOR_ROTATION_YAW_315) { @@ -83,9 +83,9 @@ void AP_Proximity_MAV::handle_msg(mavlink_message_t *msg) return; } - if (msg->msgid == MAVLINK_MSG_ID_OBSTACLE_DISTANCE) { + if (msg.msgid == MAVLINK_MSG_ID_OBSTACLE_DISTANCE) { mavlink_obstacle_distance_t packet; - mavlink_msg_obstacle_distance_decode(msg, &packet); + mavlink_msg_obstacle_distance_decode(&msg, &packet); // check increment (message's sector width) float increment; diff --git a/libraries/AP_Proximity/AP_Proximity_MAV.h b/libraries/AP_Proximity/AP_Proximity_MAV.h index d558bd97d9..26e0f698fa 100644 --- a/libraries/AP_Proximity/AP_Proximity_MAV.h +++ b/libraries/AP_Proximity/AP_Proximity_MAV.h @@ -21,7 +21,7 @@ public: bool get_upward_distance(float &distance) const override; // handle mavlink DISTANCE_SENSOR messages - void handle_msg(mavlink_message_t *msg) override; + void handle_msg(const mavlink_message_t &msg) override; private: