Skip to content

Commit ffe1754

Browse files
authored
Merge pull request #28 from MaximilianToe/update_to_zenoh_transport
updated to ZenohUTranspoart, updated signature, fixed dependencies and added clang-format.sh
2 parents 42d7a50 + b91e94d commit ffe1754

File tree

12 files changed

+153
-60
lines changed

12 files changed

+153
-60
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ jobs:
2828
uses: actions/checkout@v4
2929
with:
3030
path: up-zenoh-example-cpp
31-
repository: eclipse-uprotocol/up-zenoh-example-cpp
3231

3332
- name: Fetch up-cpp conan recipe
3433
uses: actions/checkout@v4
@@ -39,17 +38,27 @@ jobs:
3938
- name: Build up-core-api conan recipe
4039
shell: bash
4140
run: |
42-
conan create --version 1.6.0 up-conan-recipes/up-core-api/release
41+
conan create --version 1.6.0-alpha4 --build=missing up-conan-recipes/up-core-api/release
4342
4443
- name: Build up-cpp conan recipe
4544
shell: bash
4645
run: |
47-
conan create --version 1.0.1-rc1 --build=missing up-conan-recipes/up-cpp/release
46+
conan create --version 1.0.1-dev --build=missing up-conan-recipes/up-cpp/developer
4847
49-
- name: Build up-transport-socket-cpp recipe
48+
- name: Build zenoh-c recipe
5049
shell: bash
5150
run: |
52-
conan create --version 1.0.0-dev --build=missing up-conan-recipes/up-transport-socket-cpp/developer
51+
conan create --version 1.2.1 up-conan-recipes/zenohc-tmp/prebuilt
52+
53+
- name: Build zenoh-cpp recipe
54+
shell: bash
55+
run: |
56+
conan create --version 1.2.1 up-conan-recipes/zenohcpp-tmp/from-source
57+
58+
- name: Build up-transport-zenoh-cpp recipe
59+
shell: bash
60+
run: |
61+
conan create --version 1.0.0-dev --build=missing up-conan-recipes/up-transport-zenoh-cpp/developer
5362
5463
- name: Build the project
5564
shell: bash

CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ cmake_minimum_required(VERSION 3.20)
2424
project(samples VERSION 0.1.0 LANGUAGES CXX DESCRIPTION "C++ Examples for uProtocol")
2525

2626
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
27-
set(CMAKE_CXX_STANDARD 17)
28-
# place libraries in a lib directory and executables in a bin directory,
29-
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
30-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
31-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
27+
set(CMAKE_CXX_STANDARD 17)
28+
# place libraries in a lib directory and executables in a bin directory,
29+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
30+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
31+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
3232
endif()
3333

3434
add_subdirectory(pubsub)

conanfile.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[requires]
2-
up-cpp/[^1.0.1, include_prerelease]
2+
up-cpp/1.0.1-dev
33
spdlog/[~1.13]
4-
up-core-api/1.6.0
4+
up-core-api/1.6.0-alpha4
55
protobuf/[>=3.21.12]
6-
up-transport-socket-cpp/[>=1.0.0, include_prerelease]
6+
up-transport-zenoh-cpp/1.0.0-dev
7+
zenohcpp/1.2.1
78

89
[test_requires]
910
gtest/[~1.14]

lint/clang-format.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# SPDX-FileCopyrightText: 2025 Contributors to the Eclipse Foundation
2+
#
3+
# See the NOTICE file(s) distributed with this work for additional
4+
# information regarding copyright ownership.
5+
#
6+
# This program and the accompanying materials are made available under the
7+
# terms of the Apache License Version 2.0 which is available at
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# SPDX-License-Identifier: Apache-2.0
11+
#!/bin/bash
12+
13+
PROJECT_ROOT="$(realpath "$(dirname "$0")/../")"
14+
15+
if [ -n "$(which clang-format-13)" ]; then
16+
# NOTE: Using clang-format-13 in CI system, too
17+
FORMATTER=clang-format-13
18+
elif [ -n "$(which clang-format)" ]; then
19+
echo "Did not find clang-format-13. Trying clang-format. Results may not"
20+
echo "match formatting in GitHub CI process."
21+
FORMATTER=clang-format
22+
else
23+
echo "Could not find clang-format. Please make sure it is installed" 1>&2
24+
exit 2
25+
fi
26+
27+
echo "Running $FORMATTER on all files in '$PROJECT_ROOT'"
28+
shopt -s globstar
29+
30+
pushd "$PROJECT_ROOT" > /dev/null
31+
for f in **/*.h **/*.cpp; do
32+
if [[ ! ("$f" =~ "build/") ]]; then
33+
echo
34+
echo "Checking file '$f'"
35+
$FORMATTER -i "$f"
36+
fi
37+
done
38+
popd > /dev/null

pubsub/CMakeLists.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,28 @@ project(pubsub VERSION 0.1.0 LANGUAGES CXX)
2525

2626
find_package(spdlog REQUIRED)
2727
find_package(up-cpp REQUIRED)
28+
find_package(up-transport-zenoh-cpp REQUIRED)
2829

2930
add_definitions(-DSPDLOG_FMT_EXTERNAL)
3031

3132
# sub
3233
add_executable(sub src/main_sub.cpp src/UTransportDomainSockets.cpp)
3334
target_link_libraries(sub
34-
PUBLIC
35-
spdlog::spdlog
36-
up-cpp::up-cpp
37-
up-core-api::up-core-api)
35+
PUBLIC
36+
spdlog::spdlog
37+
up-cpp::up-cpp
38+
up-core-api::up-core-api)
3839
target_include_directories(sub
3940
PRIVATE
4041
include)
4142

4243
# pub
4344
add_executable(pub src/main_pub.cpp src/UTransportDomainSockets.cpp)
4445
target_link_libraries(pub
45-
PUBLIC
46-
spdlog::spdlog
47-
up-cpp::up-cpp
48-
up-core-api::up-core-api)
46+
PUBLIC
47+
spdlog::spdlog
48+
up-cpp::up-cpp
49+
up-core-api::up-core-api)
4950
target_include_directories(pub
50-
PRIVATE
51-
include)
51+
PRIVATE
52+
include)

pubsub/include/common.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ uprotocol::v1::UUri getUUri(int const resource_id) {
3535
}
3636

3737
uprotocol::v1::UUri const& getTimeUUri() {
38-
static auto uuri = getUUri(0x8001);
39-
return uuri;
38+
static auto uuri = getUUri(0x8001);
39+
return uuri;
4040
}
4141

4242
uprotocol::v1::UUri const& getRandomUUri() {
43-
static auto uuri = getUUri(0x8002);
44-
return uuri;
43+
static auto uuri = getUUri(0x8002);
44+
return uuri;
4545
}
4646

4747
uprotocol::v1::UUri const& getCounterUUri() {
48-
static auto uuri = getUUri(0x8003);
49-
return uuri;
48+
static auto uuri = getUUri(0x8003);
49+
return uuri;
5050
}
5151

52-
#endif // PUBSUB_COMMON_H
52+
#endif // PUBSUB_COMMON_H

pubsub/src/UTransportDomainSockets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class UTransportDomainSockets : public transport::UTransport {
4242

4343
void notifyListener(const v1::UMessage& message);
4444
void listenThread(); // listen for incoming messages (thread)
45-
void cleanupListener(CallableConn listener) override {}
45+
void cleanupListener(const CallableConn& listener) override {}
4646
}; // class UTransportDomainSockets
4747

4848
#endif // UTRANSPORT_DOMAIN_SOCKETS_H

rpc/CMakeLists.txt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,30 @@ project(rpc VERSION 0.1.0 LANGUAGES CXX)
2525

2626
find_package(spdlog REQUIRED)
2727
find_package(up-cpp REQUIRED)
28-
find_package(up-transport-socket-cpp REQUIRED)
28+
find_package(up-transport-zenoh-cpp REQUIRED)
2929

3030
add_definitions(-DSPDLOG_FMT_EXTERNAL)
3131

3232
# rpc client
3333
add_executable(rpc_client src/main_rpc_client.cpp)
3434
target_link_libraries(rpc_client
35-
PUBLIC
36-
spdlog::spdlog
37-
up-cpp::up-cpp
38-
up-core-api::up-core-api
39-
up-transport-socket-cpp::up-transport-socket-cpp)
35+
PUBLIC
36+
spdlog::spdlog
37+
up-cpp::up-cpp
38+
up-core-api::up-core-api
39+
up-transport-zenoh-cpp::up-transport-zenoh-cpp)
4040
target_include_directories(rpc_client
41-
PRIVATE
42-
include)
41+
PRIVATE
42+
include)
4343

4444
# rpc server
4545
add_executable(rpc_server src/main_rpc_server.cpp)
4646
target_link_libraries(rpc_server
47-
PUBLIC
48-
spdlog::spdlog
49-
up-cpp::up-cpp
50-
up-core-api::up-core-api
51-
up-transport-socket-cpp::up-transport-socket-cpp)
47+
PUBLIC
48+
spdlog::spdlog
49+
up-cpp::up-cpp
50+
up-core-api::up-core-api
51+
up-transport-zenoh-cpp::up-transport-zenoh-cpp)
5252
target_include_directories(rpc_server
53-
PRIVATE
54-
include)
53+
PRIVATE
54+
include)

rpc/include/common.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
#include <uprotocol/v1/uri.pb.h>
2727

2828
uprotocol::v1::UUri getRpcUUri(const int resource_id) {
29-
uprotocol::v1::UUri uuri;
30-
uuri.set_authority_name("test_rpc.app");
31-
uuri.set_ue_id(0x10001);
32-
uuri.set_ue_version_major(1);
33-
uuri.set_resource_id(resource_id);
34-
return uuri;
29+
uprotocol::v1::UUri uuri;
30+
uuri.set_authority_name("test_rpc.app");
31+
uuri.set_ue_id(0x10001);
32+
uuri.set_ue_version_major(1);
33+
uuri.set_resource_id(resource_id);
34+
return uuri;
3535
}
3636

37-
#endif // RPC_COMMON_H
37+
#endif // RPC_COMMON_H

rpc/resources/DEFAULT_CONFIG.json5

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SPDX-FileCopyrightText: 2025 Contributors to the Eclipse Foundation
2+
//
3+
// See the NOTICE file(s) distributed with this work for additional
4+
// information regarding copyright ownership.
5+
//
6+
// This program and the accompanying materials are made available under the
7+
// terms of the Apache License Version 2.0 which is available at
8+
// https://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// SPDX-License-Identifier: Apache-2.0
11+
12+
/// This file attempts to list and document available configuration elements.
13+
/// For a more complete view of the configuration's structure, check out `zenoh/src/config.rs`'s `Config` structure.
14+
/// Note that the values here are correctly typed, but may not be sensible, so copying this file to change only the parts that matter to you is not good practice.
15+
{
16+
/// The identifier (as unsigned 128bit integer in hexadecimal lowercase - leading zeros are not accepted)
17+
/// that zenoh runtime will use.
18+
/// If not set, a random unsigned 128bit integer will be used.
19+
/// WARNING: this id must be unique in your zenoh network.
20+
// id: "1234567890abcdef",
21+
22+
/// The node's mode (router, peer or client)
23+
mode: "peer",
24+
25+
connect: {
26+
timeout_ms: { router: -1, peer: -1, client: -1 },
27+
endpoints: [
28+
// "<proto>/<address>"
29+
],
30+
},
31+
queries_default_timeout: 10000
32+
}

0 commit comments

Comments
 (0)