Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: always send heartbeat on serial connections #1968

Merged
merged 1 commit into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/mavsdk/core/mavsdk_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -541,6 +550,11 @@ void MavsdkImpl::add_connection(const std::shared_ptr<Connection>& 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
Expand Down
1 change: 1 addition & 0 deletions src/mavsdk/core/mavsdk_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class MavsdkImpl {
std::vector<std::shared_ptr<System>> 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;
Expand Down