diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index 6b33a5f2..c1342509 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -2338,6 +2338,39 @@ rmw_ret_t rmw_publisher_assert_liveliness(const rmw_publisher_t * publisher) return RMW_RET_OK; } +rmw_ret_t rmw_publisher_wait_for_all_acked( + const rmw_publisher_t * publisher, + rmw_time_t wait_timeout) +{ + RMW_CHECK_ARGUMENT_FOR_NULL(publisher, RMW_RET_INVALID_ARGUMENT); + RMW_CHECK_TYPE_IDENTIFIERS_MATCH( + publisher, + publisher->implementation_identifier, + eclipse_cyclonedds_identifier, + return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); + + auto pub = static_cast(publisher->data); + if (pub == nullptr) { + RMW_SET_ERROR_MSG("The publisher is not a valid publisher."); + return RMW_RET_INVALID_ARGUMENT; + } + + dds_duration_t timeout = rmw_duration_to_dds(wait_timeout); + switch (dds_wait_for_acks(pub->enth, timeout)) { + case DDS_RETCODE_OK: + return RMW_RET_OK; + case DDS_RETCODE_BAD_PARAMETER: + RMW_SET_ERROR_MSG("The publisher is not a valid publisher."); + return RMW_RET_INVALID_ARGUMENT; + case DDS_RETCODE_TIMEOUT: + return RMW_RET_TIMEOUT; + case DDS_RETCODE_UNSUPPORTED: + return RMW_RET_UNSUPPORTED; + default: + return RMW_RET_ERROR; + } +} + rmw_ret_t rmw_publisher_get_actual_qos(const rmw_publisher_t * publisher, rmw_qos_profile_t * qos) { RMW_CHECK_ARGUMENT_FOR_NULL(publisher, RMW_RET_INVALID_ARGUMENT);