Skip to content

Commit

Permalink
add network notify function
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Jakymiw <sjakymiw@irobot.com>
  • Loading branch information
Sebastian Jakymiw committed Jan 19, 2023
1 parent 4b84feb commit 28f2bf1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rmw_fastrtps_cpp/include/rmw_fastrtps_cpp/get_participant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ RMW_FASTRTPS_CPP_PUBLIC
eprosima::fastdds::dds::DomainParticipant *
get_domain_participant(rmw_node_t * node);

/**
* This function returns `NULL` when either the node handle is `NULL` or when the
* node handle is from a different rmw implementation.
*
* \return rmw_ret_t non `NULL` value if successful, otherwise `NULL`
*/
rmw_ret_t rmw_notify_participant_dynamic_network_interface(rmw_context_t * context);

} // namespace rmw_fastrtps_cpp

#endif // RMW_FASTRTPS_CPP__GET_PARTICIPANT_HPP_
28 changes: 28 additions & 0 deletions rmw_fastrtps_cpp/src/rmw_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
#include "rmw/ret_types.h"
#include "rmw/rmw.h"

#include "rmw_fastrtps_shared_cpp/custom_participant_info.hpp"
#include "rmw_fastrtps_shared_cpp/init_rmw_context_impl.hpp"
#include "rmw_fastrtps_shared_cpp/rmw_common.hpp"
#include "rmw_fastrtps_shared_cpp/rmw_context_impl.hpp"

#include "rmw_fastrtps_cpp/identifier.hpp"
#include "rmw_fastrtps_cpp/init_rmw_context_impl.hpp"
#include "rmw_fastrtps_cpp/get_participant.hpp"

extern "C"
{
Expand Down Expand Up @@ -121,4 +123,30 @@ rmw_node_get_graph_guard_condition(const rmw_node_t * node)
return rmw_fastrtps_shared_cpp::__rmw_node_get_graph_guard_condition(
node);
}

rmw_ret_t
rmw_notify_participant_dynamic_network_interface(rmw_context_t * context)
{
auto impl = static_cast<CustomParticipantInfo *>(context->impl->participant_info);
eprosima::fastdds::dds::DomainParticipant * participant = impl->participant_;

if (nullptr == participant)
{
return RMW_RET_ERROR;
}

eprosima::fastdds::dds::DomainParticipantQos participant_qos;
if (participant->get_qos(participant_qos) != ReturnCode_t::RETCODE_OK)
{
return RMW_RET_ERROR;
}

ReturnCode_t ret = participant->set_qos(participant_qos);

if (ret != ReturnCode_t::RETCODE_OK)
{
return RMW_RET_ERROR;
}
return RMW_RET_OK;
}
} // extern "C"

0 comments on commit 28f2bf1

Please sign in to comment.