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

Add set function to system status #1718

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
9 changes: 9 additions & 0 deletions src/mavsdk/core/include/mavsdk/mavsdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,15 @@ class Mavsdk {
*/
void set_timeout_s(double timeout_s);

/**
* @brief Set system status of this MAVLink entity.
*
* The default system status is MAV_STATE_UNINIT.
*
* @param system_status system status.
*/
void set_system_status(uint8_t system_status);

/**
* @brief Callback type discover and timeout notifications.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/mavsdk/core/mavsdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ void Mavsdk::set_timeout_s(double timeout_s)
_impl->set_timeout_s(timeout_s);
}

void Mavsdk::set_system_status(uint8_t system_status)
{
_impl->set_system_status(system_status);
}

void Mavsdk::subscribe_on_new_system(const NewSystemCallback& callback)
{
_impl->subscribe_on_new_system(callback);
Expand Down
12 changes: 11 additions & 1 deletion src/mavsdk/core/mavsdk_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ void MavsdkImpl::send_heartbeat()
MAV_AUTOPILOT_INVALID,
get_own_component_id() == MAV_COMP_ID_AUTOPILOT1 ? _base_mode.load() : 0,
get_own_component_id() == MAV_COMP_ID_AUTOPILOT1 ? _custom_mode.load() : 0,
0);
get_system_status());
send_message(message);
}

Expand Down Expand Up @@ -683,4 +683,14 @@ uint32_t MavsdkImpl::get_custom_mode() const
return _custom_mode;
}

void MavsdkImpl::set_system_status(uint8_t system_status)
{
_system_status = system_status;
}

uint8_t MavsdkImpl::get_system_status()
{
return _system_status;
}

} // namespace mavsdk
3 changes: 3 additions & 0 deletions src/mavsdk/core/mavsdk_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class MavsdkImpl {
uint8_t get_base_mode() const;
void set_custom_mode(uint32_t custom_mode);
uint32_t get_custom_mode() const;
void set_system_status(uint8_t system_status);
uint8_t get_system_status();

private:
void add_connection(const std::shared_ptr<Connection>&);
Expand Down Expand Up @@ -150,6 +152,7 @@ class MavsdkImpl {

std::atomic<uint8_t> _base_mode = 0;
std::atomic<uint32_t> _custom_mode = 0;
std::atomic<uint8_t> _system_status = 0;
};

} // namespace mavsdk