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 function to call through to dds layer to notify about new network interfaces #2086

Draft
wants to merge 2 commits into
base: rolling
Choose a base branch
from
Draft
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
8 changes: 8 additions & 0 deletions rclcpp/include/rclcpp/utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,14 @@ RCLCPP_PUBLIC
std::vector<const char *>
get_c_vector_string(const std::vector<std::string> & strings_in);

/// Notify middleware to refresh available network interfaces.
/**
* \param[in] context is the default ROS context.
*/
RCLCPP_PUBLIC
void
notify_new_networks(Context::SharedPtr context);

} // namespace rclcpp

#endif // RCLCPP__UTILITIES_HPP_
12 changes: 12 additions & 0 deletions rclcpp/src/rclcpp/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "rcl/error_handling.h"
#include "rcl/rcl.h"
#include "rcl/node.h"

namespace rclcpp
{
Expand Down Expand Up @@ -227,4 +228,15 @@ get_c_vector_string(const std::vector<std::string> & strings_in)
return cstrings;
}

void
notify_new_networks(Context::SharedPtr context)
{
rcl_ret_t ret = rcl_notify_participant_dynamic_network_interface(context->get_rcl_context().get());
if (RCL_RET_OK != ret)
{
exceptions::throw_from_rcl_error(
ret, "failed to notify networks");
}
}

} // namespace rclcpp