diff --git a/rmw_zenoh_cpp/CMakeLists.txt b/rmw_zenoh_cpp/CMakeLists.txt index 31d541ad..3f6f7fa3 100644 --- a/rmw_zenoh_cpp/CMakeLists.txt +++ b/rmw_zenoh_cpp/CMakeLists.txt @@ -45,7 +45,6 @@ add_library(rmw_zenoh_cpp SHARED src/detail/type_support.cpp src/detail/type_support_common.cpp src/detail/zenoh_config.cpp - src/detail/zenoh_router_check.cpp src/detail/zenoh_utils.cpp src/rmw_event.cpp src/rmw_get_network_flow_endpoints.cpp diff --git a/rmw_zenoh_cpp/src/detail/rmw_context_impl_s.cpp b/rmw_zenoh_cpp/src/detail/rmw_context_impl_s.cpp index 4f145968..5a24d659 100644 --- a/rmw_zenoh_cpp/src/detail/rmw_context_impl_s.cpp +++ b/rmw_zenoh_cpp/src/detail/rmw_context_impl_s.cpp @@ -32,7 +32,6 @@ #include "logging_macros.hpp" #include "rmw_node_data.hpp" #include "zenoh_config.hpp" -#include "zenoh_router_check.hpp" #include "rcpputils/scope_exit.hpp" #include "rmw/error_handling.h" diff --git a/rmw_zenoh_cpp/src/detail/zenoh_router_check.cpp b/rmw_zenoh_cpp/src/detail/zenoh_router_check.cpp deleted file mode 100644 index 150cf111..00000000 --- a/rmw_zenoh_cpp/src/detail/zenoh_router_check.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 Open Source Robotics Foundation, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "zenoh_router_check.hpp" - -#include - -#include - -#include "logging_macros.hpp" -#include "liveliness_utils.hpp" - -namespace rmw_zenoh_cpp -{ -///============================================================================= -rmw_ret_t zenoh_router_check(const z_loaned_session_t * session) -{ - // Initialize context for callback - int context = 0; - - // Define callback - auto callback = [](const struct z_id_t * id, void * ctx) { - const std::string id_str = liveliness::zid_to_str(*id); - RMW_ZENOH_LOG_INFO_NAMED( - "rmw_zenoh_cpp", - "Successfully connected to a Zenoh router with id %s.", id_str.c_str()); - // Note: Callback is guaranteed to never be called - // concurrently according to z_info_routers_zid docstring - (*(static_cast(ctx)))++; - }; - - rmw_ret_t ret = RMW_RET_OK; - z_owned_closure_zid_t router_callback; - z_closure(&router_callback, callback, NULL, &context); - if (z_info_routers_zid(session, z_move(router_callback)) != Z_OK) { - RMW_ZENOH_LOG_ERROR_NAMED( - "rmw_zenoh_cpp", - "Failed to evaluate if Zenoh routers are connected to the session."); - ret = RMW_RET_ERROR; - } else { - if (context == 0) { - RMW_ZENOH_LOG_ERROR_NAMED( - "rmw_zenoh_cpp", - "Unable to connect to a Zenoh router. " - "Have you started a router with `ros2 run rmw_zenoh_cpp rmw_zenohd`?"); - ret = RMW_RET_ERROR; - } - } - - return ret; -} -} // namespace rmw_zenoh_cpp diff --git a/rmw_zenoh_cpp/src/detail/zenoh_router_check.hpp b/rmw_zenoh_cpp/src/detail/zenoh_router_check.hpp deleted file mode 100644 index 1db74a4c..00000000 --- a/rmw_zenoh_cpp/src/detail/zenoh_router_check.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2023 Open Source Robotics Foundation, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef DETAIL__ZENOH_ROUTER_CHECK_HPP_ -#define DETAIL__ZENOH_ROUTER_CHECK_HPP_ - -#include - -#include "rmw/ret_types.h" - -namespace rmw_zenoh_cpp -{ -/// Check if a Zenoh router is connected to the session. -/// @param session Zenoh session to check. -/// @return RMW_RET_OK if a Zenoh router is connected to the session. -rmw_ret_t zenoh_router_check(const z_loaned_session_t * session); -} // namespace rmw_zenoh_cpp - -#endif // DETAIL__ZENOH_ROUTER_CHECK_HPP_