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

Feature/zenoh/108 update to 1.2.1 #1

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
344 changes: 319 additions & 25 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions .github/workflows/ci_conan_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=11
os=Linux
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ from [up-cpp][cpp-api-repo].
Using the recipes found in [up-conan-recipes][conan-recipe-repo], build these
Conan packages:

1. [up-core-api][spec-repo] - `conan create --version 1.6.0 --build=missing up-core-api/release`
1. [up-cpp][cpp-api-repo] - `conan create --version 1.0.1-rc1 --build=missing up-cpp/release`
2. [zenoh-c][zenoh-repo] - `conan create --version 0.11.0 zenoh-tmp/from-source`
1. [up-core-api][spec-repo] - `conan create --version 1.6.0-alpha4 --build=missing up-core-api/release`
2. [up-cpp][cpp-api-repo] - `conan create --version 1.0.1 --build=missing up-cpp/release`
3. [zenoh-c][zenoh-repo] - `conan create --version 1.2.1 zenohc-tmp/prebuilt`
4. [zenoh-c][zenoh-repo] - `conan create --version 1.2.1 zenohcpp-tmp/from-source`

**NOTE:** all `conan` commands in this document use Conan 2.x syntax. Please
adjust accordingly when using Conan 1.x.
Expand Down
4 changes: 2 additions & 2 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[requires]
up-cpp/[^1.0.1]
zenohcpp/1.0.0-rc5
zenohc/1.0.0-rc5
zenohcpp/1.2.1
zenohc/1.2.1
spdlog/[~1.13]
up-core-api/[~1.6, include_prerelease]
protobuf/[~3.21]
Expand Down
41 changes: 28 additions & 13 deletions src/ZenohUTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ ZenohUTransport::uattributesToAttachment(const v1::UAttributes& attributes) {

v1::UAttributes ZenohUTransport::attachmentToUAttributes(
const zenoh::Bytes& attachment) {
auto attachment_vec =
attachment
.deserialize<std::vector<std::pair<std::string, std::string>>>();
auto attachment_vec = zenoh::ext::deserialize<
std::vector<std::pair<std::string, std::string>>>(attachment);

if (attachment_vec.size() != 2) {
spdlog::error("attachmentToUAttributes: attachment size != 2");
Expand Down Expand Up @@ -156,20 +155,36 @@ zenoh::Priority ZenohUTransport::mapZenohPriority(v1::UPriority upriority) {

v1::UMessage ZenohUTransport::sampleToUMessage(const zenoh::Sample& sample) {
v1::UMessage message;
*message.mutable_attributes() =
attachmentToUAttributes(sample.get_attachment());
std::string payload(sample.get_payload().deserialize<std::string>());
const auto attachment = sample.get_attachment();
if (attachment.has_value()) {
*message.mutable_attributes() =
attachmentToUAttributes(attachment.value());
} else {
spdlog::error("sampleToUMessage: empty attachment");
// TODO: error report? attachments are optional, attributes are not
}
std::string payload(
zenoh::ext::deserialize<std::string>(sample.get_payload()));
message.set_payload(payload);

return message;
}

v1::UMessage ZenohUTransport::queryToUMessage(const zenoh::Query& query) {
v1::UMessage message;
*message.mutable_attributes() =
attachmentToUAttributes(query.get_attachment());
std::string payload(query.get_payload().deserialize<std::string>());
message.set_payload(payload);
const auto attachment = query.get_attachment();
if (attachment.has_value()) {
*message.mutable_attributes() =
attachmentToUAttributes(attachment.value());
} else {
spdlog::error("sampleToUMessage: empty attachment");
// TODO: report error? attachments are optional, attributes are not
}
if (query.get_payload().has_value()) {
std::string payload(zenoh::ext::deserialize<std::string>(
query.get_payload().value().get()));
message.set_payload(payload);
}

return message;
}
Expand Down Expand Up @@ -218,9 +233,9 @@ v1::UStatus ZenohUTransport::sendPublishNotification_(
zenoh::Session::PutOptions options;
options.priority = priority;
options.encoding = zenoh::Encoding("app/custom");
options.attachment = attachment;
session_.put(zenoh::KeyExpr(zenoh_key),
zenoh::Bytes::serialize(payload), std::move(options));
options.attachment = zenoh::ext::serialize(attachment);
session_.put(zenoh::KeyExpr(zenoh_key), zenoh::ext::serialize(payload),
std::move(options));
} catch (const zenoh::ZException& e) {
return uError(v1::UCode::INTERNAL, e.what());
}
Expand Down
2 changes: 1 addition & 1 deletion test/coverage/ZenohUTransportTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ v1::UUri create_uuri(std::string_view serialized) {
TEST_F(TestZenohUTransport, ConstructDestroy) {
std::cout << ZENOH_CONFIG_FILE << std::endl;

zenoh::init_logger();
zenoh::init_log_from_env_or("error");

auto transport = std::make_shared<transport::ZenohUTransport>(
create_uuri(ENTITY_URI_STR), ZENOH_CONFIG_FILE);
Expand Down
4 changes: 2 additions & 2 deletions test/extra/NotificationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ std::shared_ptr<transport::UTransport> getTransport(
}

TEST_F(NotificationTest, BasicNotificationTestWithPayload) {
zenoh::init_logger();
zenoh::init_log_from_env_or("error");

auto transport = getTransport();
auto source = getUUri(0x8000);
Expand Down Expand Up @@ -103,7 +103,7 @@ TEST_F(NotificationTest, BasicNotificationTestWithPayload) {
}

TEST_F(NotificationTest, BasicNotificationTestWithoutPayload) {
zenoh::init_logger();
zenoh::init_log_from_env_or("error");

auto transport = getTransport();
auto source = getUUri(0x8000);
Expand Down
2 changes: 1 addition & 1 deletion test/extra/PublisherSubscriberTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PublisherSubscriberTest : public testing::Test {

// Run once per execution of the test application.
// Used for setup of all tests. Has access to this instance.
PublisherSubscriberTest() { zenoh::init_logger(); }
PublisherSubscriberTest() { zenoh::init_log_from_env_or("error"); }
~PublisherSubscriberTest() = default;

// Run once per execution of the test application.
Expand Down
Loading