diff --git a/src/mavsdk/core/mavsdk_impl.cpp b/src/mavsdk/core/mavsdk_impl.cpp index 9e69a6e092..2815963437 100644 --- a/src/mavsdk/core/mavsdk_impl.cpp +++ b/src/mavsdk/core/mavsdk_impl.cpp @@ -532,6 +532,15 @@ ConnectionResult MavsdkImpl::add_serial_connection( if (ret == ConnectionResult::Success) { add_connection(new_conn); } + + auto new_configuration = get_configuration(); + + // PX4 starting with v1.13 does not send heartbeats by default, so we need + // to initiate the MAVLink connection by sending heartbeats. + // Therefore, we override the default here and enable sending heartbeats. + new_configuration.set_always_send_heartbeats(true); + set_configuration(new_configuration); + return ret; } @@ -541,6 +550,11 @@ void MavsdkImpl::add_connection(const std::shared_ptr& new_connectio _connections.push_back(new_connection); } +Mavsdk::Configuration MavsdkImpl::get_configuration() const +{ + return _configuration; +} + void MavsdkImpl::set_configuration(Mavsdk::Configuration new_configuration) { // We just point the default to the newly created component. This means diff --git a/src/mavsdk/core/mavsdk_impl.h b/src/mavsdk/core/mavsdk_impl.h index a6a3e4cc4d..5702f60478 100644 --- a/src/mavsdk/core/mavsdk_impl.h +++ b/src/mavsdk/core/mavsdk_impl.h @@ -68,6 +68,7 @@ class MavsdkImpl { std::vector> systems() const; void set_configuration(Mavsdk::Configuration new_configuration); + Mavsdk::Configuration get_configuration() const; uint8_t get_own_system_id() const; uint8_t get_own_component_id() const;