From 2241f4c052872c9b820b1da048c5e9bb30036ba1 Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Wed, 6 Nov 2019 14:14:01 +0300 Subject: [PATCH 01/20] CustomParticipantListener show addition data --- FastRTPSBridge/CustomParticipantListener.cpp | 31 ++++++++++++++++++-- FastRTPSBridge/CustomParticipantListener.h | 1 + 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/FastRTPSBridge/CustomParticipantListener.cpp b/FastRTPSBridge/CustomParticipantListener.cpp index 4625d61..6f76894 100644 --- a/FastRTPSBridge/CustomParticipantListener.cpp +++ b/FastRTPSBridge/CustomParticipantListener.cpp @@ -8,6 +8,8 @@ #include #include "CustomParticipantListener.h" +#include +#include using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; @@ -17,7 +19,8 @@ void CustomParticipantListener::onReaderDiscovery(RTPSParticipant *participant, (void)participant; switch(info.status) { case ReaderDiscoveryInfo::DISCOVERED_READER: - logWarning(PARTICIPANT_LISTENER, "Reader for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' discovered") + std::cout << "Reader for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' discovered" << std::endl; + DumpLocators(info.info.remote_locators().unicast); break; case ReaderDiscoveryInfo::CHANGED_QOS_READER: break; @@ -32,7 +35,8 @@ void CustomParticipantListener::onWriterDiscovery(RTPSParticipant *participant, (void)participant; switch(info.status) { case WriterDiscoveryInfo::DISCOVERED_WRITER: - logWarning(PARTICIPANT_LISTENER, "Writer for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' discovered") + std::cout << "Writer for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' discovered" << std::endl; + DumpLocators(info.info.remote_locators().unicast); break; case WriterDiscoveryInfo::CHANGED_QOS_WRITER: break; @@ -42,12 +46,35 @@ void CustomParticipantListener::onWriterDiscovery(RTPSParticipant *participant, } } +void CustomParticipantListener::DumpLocators(ResourceLimitedVector locators) +{ + char addrString[INET6_ADDRSTRLEN+1]; + + for (auto locator = locators.cbegin(); locator != locators.cend(); locator++) { + switch (locator->kind) { + case LOCATOR_KIND_UDPv4: + std::cout << inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)) << ":" << locator->port << std::endl; + break; + case LOCATOR_KIND_UDPv6: + std::cout << inet_ntop(AF_INET6, locator->address, addrString, sizeof(addrString)) << ":" << locator->port << std::endl; + break; + default: + break; + } + } +} + void CustomParticipantListener::onParticipantDiscovery(RTPSParticipant *participant, ParticipantDiscoveryInfo &&info) { (void)participant; + auto properties = info.info.m_properties.properties; switch(info.status) { case ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT: logWarning(PARTICIPANT_LISTENER, "Participant '" << info.info.m_participantName << "' discovered") + for (auto prop = properties.cbegin(); prop != properties.cend(); prop++) { + std::cout << prop->first << ":" << prop->second << std::endl; + } + DumpLocators(info.info.default_locators.unicast); break; case ParticipantDiscoveryInfo::DROPPED_PARTICIPANT: logWarning(PARTICIPANT_LISTENER, "Participant '" << info.info.m_participantName << "' dropped") diff --git a/FastRTPSBridge/CustomParticipantListener.h b/FastRTPSBridge/CustomParticipantListener.h index 498a1b4..0141056 100644 --- a/FastRTPSBridge/CustomParticipantListener.h +++ b/FastRTPSBridge/CustomParticipantListener.h @@ -21,6 +21,7 @@ class CustomParticipantListener: public eprosima::fastrtps::rtps::RTPSParticipan void onParticipantDiscovery(RTPSParticipant *participant, ParticipantDiscoveryInfo &&info) override; void onReaderDiscovery(RTPSParticipant *participant, ReaderDiscoveryInfo &&info) override; void onWriterDiscovery(RTPSParticipant *participant, WriterDiscoveryInfo &&info) override; + void DumpLocators(ResourceLimitedVector locators); }; #endif /* CustomParticipantListener_h */ From 949b3e9c6646b031f9040968507cdd57872f4a96 Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Wed, 6 Nov 2019 20:34:44 +0300 Subject: [PATCH 02/20] macOS monolith build --- FastRTPSBridge.xcodeproj/project.pbxproj | 39 +++++++++--------------- fastrtps_build_osx.sh | 7 ++--- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/FastRTPSBridge.xcodeproj/project.pbxproj b/FastRTPSBridge.xcodeproj/project.pbxproj index 0a50ffc..bb7b305 100644 --- a/FastRTPSBridge.xcodeproj/project.pbxproj +++ b/FastRTPSBridge.xcodeproj/project.pbxproj @@ -7,6 +7,9 @@ objects = { /* Begin PBXBuildFile section */ + 0A2735AC2373389100A877B0 /* libfastrtps.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A2735AB2373385E00A877B0 /* libfastrtps.a */; }; + 0A2735AE237338A900A877B0 /* libfastcdr.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A2735AD237338A900A877B0 /* libfastcdr.a */; }; + 0A2735B0237338BD00A877B0 /* libfoonathan_memory-0.6.2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A2735AF237338BD00A877B0 /* libfoonathan_memory-0.6.2.a */; }; 0A71307A2363503500817593 /* FastRTPSBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130782363503500817593 /* FastRTPSBridge.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0A7130882363514900817593 /* CustomParticipantListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130812363514900817593 /* CustomParticipantListener.cpp */; }; 0A7130892363514900817593 /* CustomLogConsumer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130822363514900817593 /* CustomLogConsumer.cpp */; }; @@ -39,10 +42,6 @@ 0A8A37F12366DC51008E8DC1 /* CustomParticipantListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130842363514900817593 /* CustomParticipantListener.h */; }; 0A969815236EEF0100FF958F /* CDRCodable in Frameworks */ = {isa = PBXBuildFile; productRef = 0A969814236EEF0100FF958F /* CDRCodable */; }; 0A969817236EEF0B00FF958F /* CDRCodable in Frameworks */ = {isa = PBXBuildFile; productRef = 0A969816236EEF0B00FF958F /* CDRCodable */; }; - 0A9F4FAE23664DC800C1917C /* libfastcdr.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A9F4FAC23664DC800C1917C /* libfastcdr.1.dylib */; }; - 0A9F4FAF23664DC800C1917C /* libfastcdr.1.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 0A9F4FAC23664DC800C1917C /* libfastcdr.1.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; - 0A9F4FB023664DC800C1917C /* libfastrtps.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A9F4FAD23664DC800C1917C /* libfastrtps.1.dylib */; }; - 0A9F4FB123664DC800C1917C /* libfastrtps.1.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 0A9F4FAD23664DC800C1917C /* libfastrtps.1.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 0AD993862366F76300D037A3 /* libfastcdr.1.0.10.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AD993842366F76300D037A3 /* libfastcdr.1.0.10.dylib */; }; 0AD993872366F76300D037A3 /* libfastcdr.1.0.10.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 0AD993842366F76300D037A3 /* libfastcdr.1.0.10.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 0AD993882366F76300D037A3 /* libfastrtps.1.9.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AD993852366F76300D037A3 /* libfastrtps.1.9.1.dylib */; }; @@ -67,18 +66,6 @@ /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ - 0A9F4FA62365FF0C00C1917C /* Embed Libraries */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - 0A9F4FB123664DC800C1917C /* libfastrtps.1.dylib in Embed Libraries */, - 0A9F4FAF23664DC800C1917C /* libfastcdr.1.dylib in Embed Libraries */, - ); - name = "Embed Libraries"; - runOnlyForDeploymentPostprocessing = 0; - }; 0AD9938A2366F76300D037A3 /* Embed Libraries */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -94,6 +81,9 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 0A2735AB2373385E00A877B0 /* libfastrtps.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfastrtps.a; path = build/osx/lib/libfastrtps.a; sourceTree = ""; }; + 0A2735AD237338A900A877B0 /* libfastcdr.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfastcdr.a; path = build/osx/lib/libfastcdr.a; sourceTree = ""; }; + 0A2735AF237338BD00A877B0 /* libfoonathan_memory-0.6.2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libfoonathan_memory-0.6.2.a"; path = "build/osx/lib/libfoonathan_memory-0.6.2.a"; sourceTree = ""; }; 0A5B3F252364E63400BE5707 /* fastrtps_build_osx.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = fastrtps_build_osx.sh; sourceTree = ""; }; 0A7130752363503500817593 /* FastRTPSBridge.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FastRTPSBridge.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 0A7130782363503500817593 /* FastRTPSBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FastRTPSBridge.h; sourceTree = ""; }; @@ -114,8 +104,6 @@ 0A7130952363516700817593 /* RovParticipant.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RovParticipant.mm; sourceTree = ""; }; 0A8A37CF2366D469008E8DC1 /* fastrtps_build_ios.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = fastrtps_build_ios.sh; sourceTree = ""; }; 0A8A37DB2366DB1B008E8DC1 /* FastRTPSBridge.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FastRTPSBridge.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 0A9F4FAC23664DC800C1917C /* libfastcdr.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfastcdr.1.dylib; path = Framework/libfastcdr.1.dylib; sourceTree = ""; }; - 0A9F4FAD23664DC800C1917C /* libfastrtps.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfastrtps.1.dylib; path = Framework/libfastrtps.1.dylib; sourceTree = ""; }; 0AD993842366F76300D037A3 /* libfastcdr.1.0.10.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfastcdr.1.0.10.dylib; path = build/ios/lib/libfastcdr.1.0.10.dylib; sourceTree = ""; }; 0AD993852366F76300D037A3 /* libfastrtps.1.9.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfastrtps.1.9.1.dylib; path = build/ios/lib/libfastrtps.1.9.1.dylib; sourceTree = ""; }; /* End PBXFileReference section */ @@ -125,8 +113,9 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 0A9F4FAE23664DC800C1917C /* libfastcdr.1.dylib in Frameworks */, - 0A9F4FB023664DC800C1917C /* libfastrtps.1.dylib in Frameworks */, + 0A2735B0237338BD00A877B0 /* libfoonathan_memory-0.6.2.a in Frameworks */, + 0A2735AE237338A900A877B0 /* libfastcdr.a in Frameworks */, + 0A2735AC2373389100A877B0 /* libfastrtps.a in Frameworks */, 0A969815236EEF0100FF958F /* CDRCodable in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -190,10 +179,11 @@ 0A7130A32363650B00817593 /* Frameworks */ = { isa = PBXGroup; children = ( + 0A2735AF237338BD00A877B0 /* libfoonathan_memory-0.6.2.a */, + 0A2735AD237338A900A877B0 /* libfastcdr.a */, + 0A2735AB2373385E00A877B0 /* libfastrtps.a */, 0AD993842366F76300D037A3 /* libfastcdr.1.0.10.dylib */, 0AD993852366F76300D037A3 /* libfastrtps.1.9.1.dylib */, - 0A9F4FAC23664DC800C1917C /* libfastcdr.1.dylib */, - 0A9F4FAD23664DC800C1917C /* libfastrtps.1.dylib */, ); name = Frameworks; sourceTree = ""; @@ -271,7 +261,6 @@ 0A7130712363503500817593 /* Sources */, 0A7130722363503500817593 /* Frameworks */, 0A7130732363503500817593 /* Resources */, - 0A9F4FA62365FF0C00C1917C /* Embed Libraries */, ); buildRules = ( ); @@ -606,7 +595,7 @@ "@executable_path/../Frameworks", "@loader_path/Frameworks", ); - LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/Framework"; + LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/build/osx/lib"; MACOSX_DEPLOYMENT_TARGET = 10.13; MARKETING_VERSION = 1.0.0; PRODUCT_BUNDLE_IDENTIFIER = in.ioshack.FastRTPSBridge; @@ -642,7 +631,7 @@ "@executable_path/../Frameworks", "@loader_path/Frameworks", ); - LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/Framework"; + LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/build/osx/lib"; MACOSX_DEPLOYMENT_TARGET = 10.13; MARKETING_VERSION = 1.0.0; PRODUCT_BUNDLE_IDENTIFIER = in.ioshack.FastRTPSBridge; diff --git a/fastrtps_build_osx.sh b/fastrtps_build_osx.sh index 3ddf0c8..a757ee6 100755 --- a/fastrtps_build_osx.sh +++ b/fastrtps_build_osx.sh @@ -2,7 +2,7 @@ set -e set -x echo "$1" # Build type -if [ ! -f "Framework/libfastrtps.1.dylib" ]; then +if [ ! -f "build/osx/lib/libfastrtps.a" ]; then if [ ! -d memory ]; then git clone --quiet --recurse-submodules -b ios $Foonathan_memory_repo memory fi @@ -24,10 +24,7 @@ cmake -SFast-RTPS -B"$PROJECT_TEMP_DIR/Fast-RTPS" \ -DCMAKE_INSTALL_PREFIX=build/osx \ -Dfoonathan_memory_DIR=build/osx/share/foonathan_memory/cmake \ -DTHIRDPARTY=ON \ --DCMAKE_SKIP_RPATH=ON \ +-DBUILD_SHARED_LIBS=OFF \ -DCMAKE_BUILD_TYPE="$1" cmake --build "$PROJECT_TEMP_DIR/Fast-RTPS" --target install -mkdir Framework || true -cp build/osx/lib/libfastrtps.1.dylib Framework/ -cp build/osx/lib/libfastcdr.1.dylib Framework/ fi From a8749feac6be3374545304a93360f352878b8c51 Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Thu, 7 Nov 2019 22:52:35 +0300 Subject: [PATCH 03/20] Format file headers --- FastRTPSBridge/CustomLogConsumer.cpp | 5 +++++ FastRTPSBridge/CustomLogConsumer.h | 5 +++++ FastRTPSBridge/CustomParticipantListener.cpp | 9 +++------ FastRTPSBridge/CustomParticipantListener.h | 9 +++------ FastRTPSBridge/DDSType.swift | 9 +++------ FastRTPSBridge/FastRTPSBridge-Bridging-Header.h | 5 +++-- FastRTPSBridge/FastRTPSBridge.h | 9 +++------ FastRTPSBridge/FastRTPSBridge.mm | 9 +++------ FastRTPSBridge/PayloadDecoder.swift | 9 +++------ FastRTPSBridge/RovParticipant.h | 9 +++------ FastRTPSBridge/RovParticipant.mm | 9 +++------ FastRTPSBridge/RovTopicListener.h | 9 +++------ FastRTPSBridge/RovTopicListener.mm | 9 +++------ FastRTPSBridge/RovWriterListener.cpp | 9 +++------ FastRTPSBridge/RovWriterListener.h | 9 +++------ fastrtps_build_ios.sh | 4 ++++ fastrtps_build_osx.sh | 4 ++++ 17 files changed, 57 insertions(+), 74 deletions(-) diff --git a/FastRTPSBridge/CustomLogConsumer.cpp b/FastRTPSBridge/CustomLogConsumer.cpp index d12d106..16bfebb 100644 --- a/FastRTPSBridge/CustomLogConsumer.cpp +++ b/FastRTPSBridge/CustomLogConsumer.cpp @@ -1,3 +1,8 @@ +///// +//// CustomLogConsumer.cpp +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +// + #include "CustomLogConsumer.h" #include #include diff --git a/FastRTPSBridge/CustomLogConsumer.h b/FastRTPSBridge/CustomLogConsumer.h index 9b15583..a0a6cc3 100644 --- a/FastRTPSBridge/CustomLogConsumer.h +++ b/FastRTPSBridge/CustomLogConsumer.h @@ -1,3 +1,8 @@ +///// +//// CustomLogConsumer.h +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +// + #ifndef CUSTOMLOG_CONSUMER_H #define CUSTOMLOG_CONSUMER_H diff --git a/FastRTPSBridge/CustomParticipantListener.cpp b/FastRTPSBridge/CustomParticipantListener.cpp index 6f76894..dcc4399 100644 --- a/FastRTPSBridge/CustomParticipantListener.cpp +++ b/FastRTPSBridge/CustomParticipantListener.cpp @@ -1,9 +1,6 @@ -// -// CustomParticipantListener.cpp -// TestFastRTPS -// -// Created by Dmitriy Borovikov on 29/07/2019. -// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +///// +//// CustomParticipantListener.cpp +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // #include diff --git a/FastRTPSBridge/CustomParticipantListener.h b/FastRTPSBridge/CustomParticipantListener.h index 0141056..6610549 100644 --- a/FastRTPSBridge/CustomParticipantListener.h +++ b/FastRTPSBridge/CustomParticipantListener.h @@ -1,9 +1,6 @@ -// -// CustomParticipantListener.h -// TestFastRTPS -// -// Created by Dmitriy Borovikov on 29/07/2019. -// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +///// +//// CustomParticipantListener.h +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // #ifndef CustomParticipantListener_h diff --git a/FastRTPSBridge/DDSType.swift b/FastRTPSBridge/DDSType.swift index fbe4f7c..2c5b6cb 100644 --- a/FastRTPSBridge/DDSType.swift +++ b/FastRTPSBridge/DDSType.swift @@ -1,9 +1,6 @@ -// -// DDSType.swift -// TridentVideoViewer -// -// Created by Dmitriy Borovikov on 31/08/2019. -// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +///// +//// DDSType.swift +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // import Foundation diff --git a/FastRTPSBridge/FastRTPSBridge-Bridging-Header.h b/FastRTPSBridge/FastRTPSBridge-Bridging-Header.h index 8473b2f..32f29a9 100644 --- a/FastRTPSBridge/FastRTPSBridge-Bridging-Header.h +++ b/FastRTPSBridge/FastRTPSBridge-Bridging-Header.h @@ -1,5 +1,6 @@ -// -// Use this file to import your target's public headers that you would like to expose to Swift. +///// +//// FastRTPSBridge-Bridging-Header.h +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // #import "FastRTPSBridge.h" diff --git a/FastRTPSBridge/FastRTPSBridge.h b/FastRTPSBridge/FastRTPSBridge.h index 2c9d3fd..d32faa1 100644 --- a/FastRTPSBridge/FastRTPSBridge.h +++ b/FastRTPSBridge/FastRTPSBridge.h @@ -1,9 +1,6 @@ -// -// FastRTPSBridge.h -// FastRTPSBridge -// -// Created by Dmitriy Borovikov on 25.10.2019. -// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +///// +//// FastRTPSBridge.h +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // #import diff --git a/FastRTPSBridge/FastRTPSBridge.mm b/FastRTPSBridge/FastRTPSBridge.mm index 26c2998..75821a6 100644 --- a/FastRTPSBridge/FastRTPSBridge.mm +++ b/FastRTPSBridge/FastRTPSBridge.mm @@ -1,9 +1,6 @@ -// -// FastRTPSBridge.mm -// TridentVideoViewer -// -// Created by Dmitriy Borovikov on 04/09/2019. -// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +///// +//// FastRTPSBridge.mm +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // #import "FastRTPSBridge.h" diff --git a/FastRTPSBridge/PayloadDecoder.swift b/FastRTPSBridge/PayloadDecoder.swift index e026f6a..0a33322 100644 --- a/FastRTPSBridge/PayloadDecoder.swift +++ b/FastRTPSBridge/PayloadDecoder.swift @@ -1,9 +1,6 @@ -// -// PayloadDecoder.swift -// TestIntegration -// -// Created by Dmitriy Borovikov on 14/08/2019. -// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +///// +//// PayloadDecoder.swift +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // import Foundation diff --git a/FastRTPSBridge/RovParticipant.h b/FastRTPSBridge/RovParticipant.h index b33fb3b..d2f3f8f 100644 --- a/FastRTPSBridge/RovParticipant.h +++ b/FastRTPSBridge/RovParticipant.h @@ -1,9 +1,6 @@ -// -// RovParticipant.h -// TridentVideoViewer -// -// Created by Dmitriy Borovikov on 06/09/2019. -// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +///// +//// RovParticipant.h +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // #pragma once diff --git a/FastRTPSBridge/RovParticipant.mm b/FastRTPSBridge/RovParticipant.mm index 0af3da0..bda9cc9 100644 --- a/FastRTPSBridge/RovParticipant.mm +++ b/FastRTPSBridge/RovParticipant.mm @@ -1,9 +1,6 @@ -// -// RovParticipant.mm -// TridentVideoViewer -// -// Created by Dmitriy Borovikov on 06/09/2019. -// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +///// +//// RovParticipant.mm +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // #include "RovParticipant.h" diff --git a/FastRTPSBridge/RovTopicListener.h b/FastRTPSBridge/RovTopicListener.h index 2fdde2c..1912f5a 100644 --- a/FastRTPSBridge/RovTopicListener.h +++ b/FastRTPSBridge/RovTopicListener.h @@ -1,9 +1,6 @@ -// -// RovTopicListener.h -// TestIntegration -// -// Created by Dmitriy Borovikov on 21/08/2019. -// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +///// +//// RovTopicListener.h +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // #ifndef ORovTopicListener_h diff --git a/FastRTPSBridge/RovTopicListener.mm b/FastRTPSBridge/RovTopicListener.mm index 678b09e..21bc4d6 100644 --- a/FastRTPSBridge/RovTopicListener.mm +++ b/FastRTPSBridge/RovTopicListener.mm @@ -1,9 +1,6 @@ -// -// RovTopicListener.cpp -// TestIntegration -// -// Created by Dmitriy Borovikov on 21/08/2019. -// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +///// +//// RovTopicListener.cpp +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // #include "RovTopicListener.h" diff --git a/FastRTPSBridge/RovWriterListener.cpp b/FastRTPSBridge/RovWriterListener.cpp index b6f5ad6..e9e85a1 100644 --- a/FastRTPSBridge/RovWriterListener.cpp +++ b/FastRTPSBridge/RovWriterListener.cpp @@ -1,9 +1,6 @@ -// -// RovWriterListener.cpp -// TridentVideoViewer -// -// Created by Dmitriy Borovikov on 13.09.2019. -// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +///// +//// RovWriterListener.cpp +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // #include diff --git a/FastRTPSBridge/RovWriterListener.h b/FastRTPSBridge/RovWriterListener.h index 79ab1ad..3ad9bbc 100644 --- a/FastRTPSBridge/RovWriterListener.h +++ b/FastRTPSBridge/RovWriterListener.h @@ -1,9 +1,6 @@ -// -// RovWriterListener.h -// TridentVideoViewer -// -// Created by Dmitriy Borovikov on 13.09.2019. -// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +///// +//// RovWriterListener.h +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // #ifndef RovWriterListener_h diff --git a/fastrtps_build_ios.sh b/fastrtps_build_ios.sh index cacb563..351d39d 100755 --- a/fastrtps_build_ios.sh +++ b/fastrtps_build_ios.sh @@ -1,4 +1,8 @@ #!/bin/bash +# +# fastrtps_build_ios.sh +# Copyright © 2019 Dmitriy Borovikov. All rights reserved. +# export PATH=$HOME/Developer/tools/polly/bin:$PATH set -e echo "$1" # Build type diff --git a/fastrtps_build_osx.sh b/fastrtps_build_osx.sh index a757ee6..9b149b3 100755 --- a/fastrtps_build_osx.sh +++ b/fastrtps_build_osx.sh @@ -1,4 +1,8 @@ #!/bin/bash +# +# fastrtps_build_osx.sh +# Copyright © 2019 Dmitriy Borovikov. All rights reserved. +# set -e set -x echo "$1" # Build type From 9e39f823fabf2e491bc4610f9083b4a9510c6e54 Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Fri, 8 Nov 2019 16:08:21 +0300 Subject: [PATCH 04/20] Refactoring - rename. --- FastRTPSBridge.xcodeproj/project.pbxproj | 98 +++++++++---------- ...{RovParticipant.h => BridgedParticipant.h} | 20 ++-- ...ovParticipant.mm => BridgedParticipant.mm} | 34 +++---- ...istener.h => BridgedParticipantListener.h} | 9 +- ...ener.cpp => BridgedParticipantListener.mm} | 12 +-- ...istener.h => BridgedReaderTopicListener.h} | 13 +-- ...tener.mm => BridgedReaderTopicListener.mm} | 18 ++-- ...iterListener.h => BridgedWriterListener.h} | 13 +-- ...rListener.cpp => BridgedWriterListener.mm} | 16 +-- FastRTPSBridge/CustomLogConsumer.h | 5 +- FastRTPSBridge/FastRTPSBridge.mm | 6 +- 11 files changed, 116 insertions(+), 128 deletions(-) rename FastRTPSBridge/{RovParticipant.h => BridgedParticipant.h} (82%) rename FastRTPSBridge/{RovParticipant.mm => BridgedParticipant.mm} (90%) rename FastRTPSBridge/{CustomParticipantListener.h => BridgedParticipantListener.h} (74%) rename FastRTPSBridge/{CustomParticipantListener.cpp => BridgedParticipantListener.mm} (85%) rename FastRTPSBridge/{RovTopicListener.h => BridgedReaderTopicListener.h} (73%) rename FastRTPSBridge/{RovTopicListener.mm => BridgedReaderTopicListener.mm} (59%) rename FastRTPSBridge/{RovWriterListener.h => BridgedWriterListener.h} (66%) rename FastRTPSBridge/{RovWriterListener.cpp => BridgedWriterListener.mm} (58%) diff --git a/FastRTPSBridge.xcodeproj/project.pbxproj b/FastRTPSBridge.xcodeproj/project.pbxproj index bb7b305..6805d91 100644 --- a/FastRTPSBridge.xcodeproj/project.pbxproj +++ b/FastRTPSBridge.xcodeproj/project.pbxproj @@ -11,35 +11,35 @@ 0A2735AE237338A900A877B0 /* libfastcdr.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A2735AD237338A900A877B0 /* libfastcdr.a */; }; 0A2735B0237338BD00A877B0 /* libfoonathan_memory-0.6.2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A2735AF237338BD00A877B0 /* libfoonathan_memory-0.6.2.a */; }; 0A71307A2363503500817593 /* FastRTPSBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130782363503500817593 /* FastRTPSBridge.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 0A7130882363514900817593 /* CustomParticipantListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130812363514900817593 /* CustomParticipantListener.cpp */; }; + 0A7130882363514900817593 /* BridgedParticipantListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130812363514900817593 /* BridgedParticipantListener.mm */; }; 0A7130892363514900817593 /* CustomLogConsumer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130822363514900817593 /* CustomLogConsumer.cpp */; }; 0A71308A2363514900817593 /* CustomLogConsumer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130832363514900817593 /* CustomLogConsumer.h */; }; - 0A71308B2363514900817593 /* CustomParticipantListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130842363514900817593 /* CustomParticipantListener.h */; }; + 0A71308B2363514900817593 /* BridgedParticipantListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130842363514900817593 /* BridgedParticipantListener.h */; }; 0A71308C2363514900817593 /* FastRTPSBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130852363514900817593 /* FastRTPSBridge.mm */; }; 0A71308D2363514900817593 /* DDSType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130862363514900817593 /* DDSType.swift */; }; - 0A7130962363516700817593 /* RovWriterListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0A71308E2363516700817593 /* RovWriterListener.cpp */; }; - 0A7130972363516700817593 /* RovWriterListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A71308F2363516700817593 /* RovWriterListener.h */; }; - 0A7130982363516700817593 /* RovTopicListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130902363516700817593 /* RovTopicListener.h */; }; + 0A7130962363516700817593 /* BridgedWriterListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A71308E2363516700817593 /* BridgedWriterListener.mm */; }; + 0A7130972363516700817593 /* BridgedWriterListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A71308F2363516700817593 /* BridgedWriterListener.h */; }; + 0A7130982363516700817593 /* BridgedReaderTopicListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130902363516700817593 /* BridgedReaderTopicListener.h */; }; 0A7130992363516700817593 /* PayloadDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130912363516700817593 /* PayloadDecoder.swift */; }; - 0A71309A2363516700817593 /* RovParticipant.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130922363516700817593 /* RovParticipant.h */; }; - 0A71309B2363516700817593 /* RovTopicListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130932363516700817593 /* RovTopicListener.mm */; }; + 0A71309A2363516700817593 /* BridgedParticipant.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130922363516700817593 /* BridgedParticipant.h */; }; + 0A71309B2363516700817593 /* BridgedReaderTopicListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130932363516700817593 /* BridgedReaderTopicListener.mm */; }; 0A71309C2363516700817593 /* FastRTPSBridge-Bridging-Header.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130942363516700817593 /* FastRTPSBridge-Bridging-Header.h */; }; - 0A71309D2363516700817593 /* RovParticipant.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130952363516700817593 /* RovParticipant.mm */; }; + 0A71309D2363516700817593 /* BridgedParticipant.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130952363516700817593 /* BridgedParticipant.mm */; }; 0A8A37E32366DC51008E8DC1 /* DDSType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130862363514900817593 /* DDSType.swift */; }; 0A8A37E42366DC51008E8DC1 /* PayloadDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130912363516700817593 /* PayloadDecoder.swift */; }; 0A8A37E52366DC51008E8DC1 /* FastRTPSBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130852363514900817593 /* FastRTPSBridge.mm */; }; 0A8A37E62366DC51008E8DC1 /* FastRTPSBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130782363503500817593 /* FastRTPSBridge.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 0A8A37E72366DC51008E8DC1 /* RovParticipant.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130922363516700817593 /* RovParticipant.h */; }; - 0A8A37E82366DC51008E8DC1 /* RovParticipant.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130952363516700817593 /* RovParticipant.mm */; }; - 0A8A37E92366DC51008E8DC1 /* RovTopicListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130902363516700817593 /* RovTopicListener.h */; }; - 0A8A37EA2366DC51008E8DC1 /* RovTopicListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130932363516700817593 /* RovTopicListener.mm */; }; - 0A8A37EB2366DC51008E8DC1 /* RovWriterListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0A71308E2363516700817593 /* RovWriterListener.cpp */; }; - 0A8A37EC2366DC51008E8DC1 /* RovWriterListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A71308F2363516700817593 /* RovWriterListener.h */; }; + 0A8A37E72366DC51008E8DC1 /* BridgedParticipant.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130922363516700817593 /* BridgedParticipant.h */; }; + 0A8A37E82366DC51008E8DC1 /* BridgedParticipant.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130952363516700817593 /* BridgedParticipant.mm */; }; + 0A8A37E92366DC51008E8DC1 /* BridgedReaderTopicListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130902363516700817593 /* BridgedReaderTopicListener.h */; }; + 0A8A37EA2366DC51008E8DC1 /* BridgedReaderTopicListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130932363516700817593 /* BridgedReaderTopicListener.mm */; }; + 0A8A37EB2366DC51008E8DC1 /* BridgedWriterListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A71308E2363516700817593 /* BridgedWriterListener.mm */; }; + 0A8A37EC2366DC51008E8DC1 /* BridgedWriterListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A71308F2363516700817593 /* BridgedWriterListener.h */; }; 0A8A37ED2366DC51008E8DC1 /* FastRTPSBridge-Bridging-Header.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130942363516700817593 /* FastRTPSBridge-Bridging-Header.h */; }; 0A8A37EE2366DC51008E8DC1 /* CustomLogConsumer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130822363514900817593 /* CustomLogConsumer.cpp */; }; 0A8A37EF2366DC51008E8DC1 /* CustomLogConsumer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130832363514900817593 /* CustomLogConsumer.h */; }; - 0A8A37F02366DC51008E8DC1 /* CustomParticipantListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130812363514900817593 /* CustomParticipantListener.cpp */; }; - 0A8A37F12366DC51008E8DC1 /* CustomParticipantListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130842363514900817593 /* CustomParticipantListener.h */; }; + 0A8A37F02366DC51008E8DC1 /* BridgedParticipantListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130812363514900817593 /* BridgedParticipantListener.mm */; }; + 0A8A37F12366DC51008E8DC1 /* BridgedParticipantListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130842363514900817593 /* BridgedParticipantListener.h */; }; 0A969815236EEF0100FF958F /* CDRCodable in Frameworks */ = {isa = PBXBuildFile; productRef = 0A969814236EEF0100FF958F /* CDRCodable */; }; 0A969817236EEF0B00FF958F /* CDRCodable in Frameworks */ = {isa = PBXBuildFile; productRef = 0A969816236EEF0B00FF958F /* CDRCodable */; }; 0AD993862366F76300D037A3 /* libfastcdr.1.0.10.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AD993842366F76300D037A3 /* libfastcdr.1.0.10.dylib */; }; @@ -88,20 +88,20 @@ 0A7130752363503500817593 /* FastRTPSBridge.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FastRTPSBridge.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 0A7130782363503500817593 /* FastRTPSBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FastRTPSBridge.h; sourceTree = ""; }; 0A7130792363503500817593 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 0A7130812363514900817593 /* CustomParticipantListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomParticipantListener.cpp; sourceTree = ""; }; + 0A7130812363514900817593 /* BridgedParticipantListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BridgedParticipantListener.mm; sourceTree = ""; }; 0A7130822363514900817593 /* CustomLogConsumer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomLogConsumer.cpp; sourceTree = ""; }; 0A7130832363514900817593 /* CustomLogConsumer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomLogConsumer.h; sourceTree = ""; }; - 0A7130842363514900817593 /* CustomParticipantListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomParticipantListener.h; sourceTree = ""; }; + 0A7130842363514900817593 /* BridgedParticipantListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgedParticipantListener.h; sourceTree = ""; }; 0A7130852363514900817593 /* FastRTPSBridge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FastRTPSBridge.mm; sourceTree = ""; }; 0A7130862363514900817593 /* DDSType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DDSType.swift; sourceTree = ""; }; - 0A71308E2363516700817593 /* RovWriterListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RovWriterListener.cpp; sourceTree = ""; }; - 0A71308F2363516700817593 /* RovWriterListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RovWriterListener.h; sourceTree = ""; }; - 0A7130902363516700817593 /* RovTopicListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RovTopicListener.h; sourceTree = ""; }; + 0A71308E2363516700817593 /* BridgedWriterListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BridgedWriterListener.mm; sourceTree = ""; }; + 0A71308F2363516700817593 /* BridgedWriterListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgedWriterListener.h; sourceTree = ""; }; + 0A7130902363516700817593 /* BridgedReaderTopicListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgedReaderTopicListener.h; sourceTree = ""; }; 0A7130912363516700817593 /* PayloadDecoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PayloadDecoder.swift; sourceTree = ""; }; - 0A7130922363516700817593 /* RovParticipant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RovParticipant.h; sourceTree = ""; }; - 0A7130932363516700817593 /* RovTopicListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RovTopicListener.mm; sourceTree = ""; }; + 0A7130922363516700817593 /* BridgedParticipant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgedParticipant.h; sourceTree = ""; }; + 0A7130932363516700817593 /* BridgedReaderTopicListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BridgedReaderTopicListener.mm; sourceTree = ""; }; 0A7130942363516700817593 /* FastRTPSBridge-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "FastRTPSBridge-Bridging-Header.h"; sourceTree = ""; }; - 0A7130952363516700817593 /* RovParticipant.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RovParticipant.mm; sourceTree = ""; }; + 0A7130952363516700817593 /* BridgedParticipant.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BridgedParticipant.mm; sourceTree = ""; }; 0A8A37CF2366D469008E8DC1 /* fastrtps_build_ios.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = fastrtps_build_ios.sh; sourceTree = ""; }; 0A8A37DB2366DB1B008E8DC1 /* FastRTPSBridge.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FastRTPSBridge.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 0AD993842366F76300D037A3 /* libfastcdr.1.0.10.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfastcdr.1.0.10.dylib; path = build/ios/lib/libfastcdr.1.0.10.dylib; sourceTree = ""; }; @@ -160,17 +160,17 @@ 0A7130912363516700817593 /* PayloadDecoder.swift */, 0A7130852363514900817593 /* FastRTPSBridge.mm */, 0A7130782363503500817593 /* FastRTPSBridge.h */, - 0A7130922363516700817593 /* RovParticipant.h */, - 0A7130952363516700817593 /* RovParticipant.mm */, - 0A7130902363516700817593 /* RovTopicListener.h */, - 0A7130932363516700817593 /* RovTopicListener.mm */, - 0A71308E2363516700817593 /* RovWriterListener.cpp */, - 0A71308F2363516700817593 /* RovWriterListener.h */, - 0A7130942363516700817593 /* FastRTPSBridge-Bridging-Header.h */, + 0A7130952363516700817593 /* BridgedParticipant.mm */, + 0A7130922363516700817593 /* BridgedParticipant.h */, + 0A7130932363516700817593 /* BridgedReaderTopicListener.mm */, + 0A7130902363516700817593 /* BridgedReaderTopicListener.h */, + 0A71308E2363516700817593 /* BridgedWriterListener.mm */, + 0A71308F2363516700817593 /* BridgedWriterListener.h */, + 0A7130812363514900817593 /* BridgedParticipantListener.mm */, + 0A7130842363514900817593 /* BridgedParticipantListener.h */, 0A7130822363514900817593 /* CustomLogConsumer.cpp */, 0A7130832363514900817593 /* CustomLogConsumer.h */, - 0A7130812363514900817593 /* CustomParticipantListener.cpp */, - 0A7130842363514900817593 /* CustomParticipantListener.h */, + 0A7130942363516700817593 /* FastRTPSBridge-Bridging-Header.h */, 0A7130792363503500817593 /* Info.plist */, ); path = FastRTPSBridge; @@ -196,12 +196,12 @@ buildActionMask = 2147483647; files = ( 0A71309C2363516700817593 /* FastRTPSBridge-Bridging-Header.h in Headers */, - 0A71309A2363516700817593 /* RovParticipant.h in Headers */, + 0A71309A2363516700817593 /* BridgedParticipant.h in Headers */, 0A71308A2363514900817593 /* CustomLogConsumer.h in Headers */, - 0A71308B2363514900817593 /* CustomParticipantListener.h in Headers */, + 0A71308B2363514900817593 /* BridgedParticipantListener.h in Headers */, 0A71307A2363503500817593 /* FastRTPSBridge.h in Headers */, - 0A7130972363516700817593 /* RovWriterListener.h in Headers */, - 0A7130982363516700817593 /* RovTopicListener.h in Headers */, + 0A7130972363516700817593 /* BridgedWriterListener.h in Headers */, + 0A7130982363516700817593 /* BridgedReaderTopicListener.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -211,10 +211,10 @@ files = ( 0A8A37E62366DC51008E8DC1 /* FastRTPSBridge.h in Headers */, 0A8A37ED2366DC51008E8DC1 /* FastRTPSBridge-Bridging-Header.h in Headers */, - 0A8A37F12366DC51008E8DC1 /* CustomParticipantListener.h in Headers */, - 0A8A37E92366DC51008E8DC1 /* RovTopicListener.h in Headers */, - 0A8A37E72366DC51008E8DC1 /* RovParticipant.h in Headers */, - 0A8A37EC2366DC51008E8DC1 /* RovWriterListener.h in Headers */, + 0A8A37F12366DC51008E8DC1 /* BridgedParticipantListener.h in Headers */, + 0A8A37E92366DC51008E8DC1 /* BridgedReaderTopicListener.h in Headers */, + 0A8A37E72366DC51008E8DC1 /* BridgedParticipant.h in Headers */, + 0A8A37EC2366DC51008E8DC1 /* BridgedWriterListener.h in Headers */, 0A8A37EF2366DC51008E8DC1 /* CustomLogConsumer.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -368,14 +368,14 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 0A7130882363514900817593 /* CustomParticipantListener.cpp in Sources */, + 0A7130882363514900817593 /* BridgedParticipantListener.mm in Sources */, 0A71308D2363514900817593 /* DDSType.swift in Sources */, - 0A7130962363516700817593 /* RovWriterListener.cpp in Sources */, + 0A7130962363516700817593 /* BridgedWriterListener.mm in Sources */, 0A71308C2363514900817593 /* FastRTPSBridge.mm in Sources */, 0A7130992363516700817593 /* PayloadDecoder.swift in Sources */, 0A7130892363514900817593 /* CustomLogConsumer.cpp in Sources */, - 0A71309B2363516700817593 /* RovTopicListener.mm in Sources */, - 0A71309D2363516700817593 /* RovParticipant.mm in Sources */, + 0A71309B2363516700817593 /* BridgedReaderTopicListener.mm in Sources */, + 0A71309D2363516700817593 /* BridgedParticipant.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -383,14 +383,14 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 0A8A37EA2366DC51008E8DC1 /* RovTopicListener.mm in Sources */, + 0A8A37EA2366DC51008E8DC1 /* BridgedReaderTopicListener.mm in Sources */, 0A8A37E52366DC51008E8DC1 /* FastRTPSBridge.mm in Sources */, - 0A8A37EB2366DC51008E8DC1 /* RovWriterListener.cpp in Sources */, + 0A8A37EB2366DC51008E8DC1 /* BridgedWriterListener.mm in Sources */, 0A8A37EE2366DC51008E8DC1 /* CustomLogConsumer.cpp in Sources */, 0A8A37E32366DC51008E8DC1 /* DDSType.swift in Sources */, 0A8A37E42366DC51008E8DC1 /* PayloadDecoder.swift in Sources */, - 0A8A37F02366DC51008E8DC1 /* CustomParticipantListener.cpp in Sources */, - 0A8A37E82366DC51008E8DC1 /* RovParticipant.mm in Sources */, + 0A8A37F02366DC51008E8DC1 /* BridgedParticipantListener.mm in Sources */, + 0A8A37E82366DC51008E8DC1 /* BridgedParticipant.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/FastRTPSBridge/RovParticipant.h b/FastRTPSBridge/BridgedParticipant.h similarity index 82% rename from FastRTPSBridge/RovParticipant.h rename to FastRTPSBridge/BridgedParticipant.h index d2f3f8f..c5fc318 100644 --- a/FastRTPSBridge/RovParticipant.h +++ b/FastRTPSBridge/BridgedParticipant.h @@ -1,5 +1,5 @@ ///// -//// RovParticipant.h +//// BridgedParticipant.h /// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // @@ -14,16 +14,16 @@ #include "fastrtps/rtps/history/WriterHistory.h" #include #include -#import "RovTopicListener.h" -#import "RovWriterListener.h" +#import "BridgedReaderTopicListener.h" +#import "BridgedWriterListener.h" -class CustomParticipantListener; -class RovParticipant +class BridgedParticipantListener; +class BridgedParticipant { struct ReaderInfo { eprosima::fastrtps::rtps::RTPSReader* reader; eprosima::fastrtps::rtps::ReaderHistory* history; - RovTopicListener* listener; + BridgedReaderTopicListener* listener; ~ReaderInfo() { delete history; delete listener; @@ -33,17 +33,17 @@ class RovParticipant struct WriterInfo { eprosima::fastrtps::rtps::RTPSWriter* writer; eprosima::fastrtps::rtps::WriterHistory* history; - RovWriterListener* listener; + BridgedWriterListener* listener; ~WriterInfo() { delete history; delete listener; } }; public: - RovParticipant(); - virtual ~RovParticipant(); + BridgedParticipant(); + virtual ~BridgedParticipant(); eprosima::fastrtps::rtps::RTPSParticipant* mp_participant; - CustomParticipantListener* mp_listener; + BridgedParticipantListener* mp_listener; std::map readerList; std::map writerList; diff --git a/FastRTPSBridge/RovParticipant.mm b/FastRTPSBridge/BridgedParticipant.mm similarity index 90% rename from FastRTPSBridge/RovParticipant.mm rename to FastRTPSBridge/BridgedParticipant.mm index bda9cc9..c5af435 100644 --- a/FastRTPSBridge/RovParticipant.mm +++ b/FastRTPSBridge/BridgedParticipant.mm @@ -1,12 +1,12 @@ ///// -//// RovParticipant.mm +//// BridgedParticipant.mm /// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // -#include "RovParticipant.h" -#include "RovTopicListener.h" -#include "RovWriterListener.h" -#include "CustomParticipantListener.h" +#include "BridgedParticipant.h" +#include "BridgedReaderTopicListener.h" +#include "BridgedWriterListener.h" +#include "BridgedParticipantListener.h" #include #include @@ -24,13 +24,13 @@ using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; -RovParticipant::RovParticipant(): +BridgedParticipant::BridgedParticipant(): mp_participant(nullptr), mp_listener(nullptr) { } -RovParticipant::~RovParticipant() +BridgedParticipant::~BridgedParticipant() { mp_participant->stopRTPSParticipantAnnouncement(); logInfo(ROV_PARTICIPANT, "Delete participant") @@ -40,7 +40,7 @@ // RTPSDomain::stopAll(); } -void RovParticipant::resignAll() { +void BridgedParticipant::resignAll() { for(auto it = readerList.begin(); it != readerList.end(); it++) { logInfo(ROV_PARTICIPANT, "Remove reader: " << it->first) @@ -60,7 +60,7 @@ writerList.clear(); } -bool RovParticipant::startRTPS() +bool BridgedParticipant::startRTPS() { //CREATE PARTICIPANT RTPSParticipantAttributes PParam; @@ -73,7 +73,7 @@ PParam.builtin.domainId = 0; PParam.setName("TridentVideoViewer"); - mp_listener = new CustomParticipantListener(); + mp_listener = new BridgedParticipantListener(); mp_participant = RTPSDomain::createParticipant(PParam, mp_listener); if (mp_participant == nullptr) return false; @@ -81,7 +81,7 @@ return true; } -bool RovParticipant::addReader(const char* name, +bool BridgedParticipant::addReader(const char* name, const char* dataType, const bool keyed, NSObject* payloadDecoder) @@ -95,7 +95,7 @@ //CREATE READER ReaderAttributes readerAttributes; readerAttributes.endpoint.topicKind = tKind; - auto listener = new RovTopicListener(name, payloadDecoder); + auto listener = new BridgedReaderTopicListener(name, payloadDecoder); //CREATE READERHISTORY HistoryAttributes hatt; hatt.payloadMaxSize = 10000; @@ -129,7 +129,7 @@ return true; } -bool RovParticipant::removeReader(const char* name) +bool BridgedParticipant::removeReader(const char* name) { logInfo(ROV_PARTICIPANT, "Remove reader: " << name) auto topicName = std::string(name); @@ -144,7 +144,7 @@ return true; } -bool RovParticipant::addWriter(const char* name, +bool BridgedParticipant::addWriter(const char* name, const char* dataType, const bool keyed) { @@ -158,7 +158,7 @@ WriterAttributes watt; watt.endpoint.reliabilityKind = BEST_EFFORT; watt.endpoint.topicKind = tKind; - auto listener = new RovWriterListener(name); + auto listener = new BridgedWriterListener(name); //CREATE WRITERHISTORY HistoryAttributes hatt; // hatt.payloadMaxSize = 10000; @@ -193,7 +193,7 @@ return true; } -bool RovParticipant::removeWriter(const char* name) +bool BridgedParticipant::removeWriter(const char* name) { logInfo(ROV_PARTICIPANT, "Remove writer: " << name) auto topicName = std::string(name); @@ -208,7 +208,7 @@ return true; } -bool RovParticipant::send(const char* name, const uint8_t* data, uint32_t length, const void* key, uint32_t keyLength) +bool BridgedParticipant::send(const char* name, const uint8_t* data, uint32_t length, const void* key, uint32_t keyLength) { static const octet header[] = {0, 1, 0, 0}; auto topicName = std::string(name); diff --git a/FastRTPSBridge/CustomParticipantListener.h b/FastRTPSBridge/BridgedParticipantListener.h similarity index 74% rename from FastRTPSBridge/CustomParticipantListener.h rename to FastRTPSBridge/BridgedParticipantListener.h index 6610549..2db0106 100644 --- a/FastRTPSBridge/CustomParticipantListener.h +++ b/FastRTPSBridge/BridgedParticipantListener.h @@ -1,10 +1,9 @@ ///// -//// CustomParticipantListener.h +//// BridgedParticipantListener.h /// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // -#ifndef CustomParticipantListener_h -#define CustomParticipantListener_h +#pragma once #include #include @@ -13,12 +12,10 @@ using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; -class CustomParticipantListener: public eprosima::fastrtps::rtps::RTPSParticipantListener +class BridgedParticipantListener: public eprosima::fastrtps::rtps::RTPSParticipantListener { void onParticipantDiscovery(RTPSParticipant *participant, ParticipantDiscoveryInfo &&info) override; void onReaderDiscovery(RTPSParticipant *participant, ReaderDiscoveryInfo &&info) override; void onWriterDiscovery(RTPSParticipant *participant, WriterDiscoveryInfo &&info) override; void DumpLocators(ResourceLimitedVector locators); }; - -#endif /* CustomParticipantListener_h */ diff --git a/FastRTPSBridge/CustomParticipantListener.cpp b/FastRTPSBridge/BridgedParticipantListener.mm similarity index 85% rename from FastRTPSBridge/CustomParticipantListener.cpp rename to FastRTPSBridge/BridgedParticipantListener.mm index dcc4399..ce0c445 100644 --- a/FastRTPSBridge/CustomParticipantListener.cpp +++ b/FastRTPSBridge/BridgedParticipantListener.mm @@ -1,17 +1,17 @@ ///// -//// CustomParticipantListener.cpp +//// BridgedParticipantListener.cpp /// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // #include -#include "CustomParticipantListener.h" +#include "BridgedParticipantListener.h" #include #include using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; -void CustomParticipantListener::onReaderDiscovery(RTPSParticipant *participant, ReaderDiscoveryInfo &&info) +void BridgedParticipantListener::onReaderDiscovery(RTPSParticipant *participant, ReaderDiscoveryInfo &&info) { (void)participant; switch(info.status) { @@ -27,7 +27,7 @@ void CustomParticipantListener::onReaderDiscovery(RTPSParticipant *participant, } } -void CustomParticipantListener::onWriterDiscovery(RTPSParticipant *participant, WriterDiscoveryInfo &&info) +void BridgedParticipantListener::onWriterDiscovery(RTPSParticipant *participant, WriterDiscoveryInfo &&info) { (void)participant; switch(info.status) { @@ -43,7 +43,7 @@ void CustomParticipantListener::onWriterDiscovery(RTPSParticipant *participant, } } -void CustomParticipantListener::DumpLocators(ResourceLimitedVector locators) +void BridgedParticipantListener::DumpLocators(ResourceLimitedVector locators) { char addrString[INET6_ADDRSTRLEN+1]; @@ -61,7 +61,7 @@ void CustomParticipantListener::DumpLocators(ResourceLimitedVector #include "fastrtps/rtps/rtps_fwd.h" @@ -12,11 +11,11 @@ #import "FastRTPSBridge/FastRTPSBridge-Swift.h" -class RovTopicListener:public eprosima::fastrtps::rtps::ReaderListener +class BridgedReaderTopicListener:public eprosima::fastrtps::rtps::ReaderListener { public: - RovTopicListener(const char* topicName, NSObject* payloadDecoder); - ~RovTopicListener(); + BridgedReaderTopicListener(const char* topicName, NSObject* payloadDecoder); + ~BridgedReaderTopicListener(); void onNewCacheChangeAdded(eprosima::fastrtps::rtps::RTPSReader* reader, const eprosima::fastrtps::rtps::CacheChange_t* const change) override; void onReaderMatched(eprosima::fastrtps::rtps::RTPSReader*, @@ -28,5 +27,3 @@ class RovTopicListener:public eprosima::fastrtps::rtps::ReaderListener uint32_t n_matched; std::string topicName; }; - -#endif /* ORovTopicListener_h */ diff --git a/FastRTPSBridge/RovTopicListener.mm b/FastRTPSBridge/BridgedReaderTopicListener.mm similarity index 59% rename from FastRTPSBridge/RovTopicListener.mm rename to FastRTPSBridge/BridgedReaderTopicListener.mm index 21bc4d6..42ff302 100644 --- a/FastRTPSBridge/RovTopicListener.mm +++ b/FastRTPSBridge/BridgedReaderTopicListener.mm @@ -1,9 +1,9 @@ ///// -//// RovTopicListener.cpp +//// BridgedReaderTopicListener.cpp /// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // -#include "RovTopicListener.h" +#include "BridgedReaderTopicListener.h" #include #include @@ -12,17 +12,17 @@ using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; -RovTopicListener::RovTopicListener(const char* topicName, NSObject* payloadDecoder): n_matched(0) +BridgedReaderTopicListener::BridgedReaderTopicListener(const char* topicName, NSObject* payloadDecoder): n_matched(0) { - RovTopicListener::topicName = std::string(topicName); - RovTopicListener::payloadDecoder = payloadDecoder; + BridgedReaderTopicListener::topicName = std::string(topicName); + BridgedReaderTopicListener::payloadDecoder = payloadDecoder; } -RovTopicListener::~RovTopicListener() +BridgedReaderTopicListener::~BridgedReaderTopicListener() { } -void RovTopicListener::onNewCacheChangeAdded(RTPSReader* reader, const CacheChange_t * const change) +void BridgedReaderTopicListener::onNewCacheChangeAdded(RTPSReader* reader, const CacheChange_t * const change) { [payloadDecoder decodeWithSequence:change->sequenceNumber.to64long() payloadSize:change->serializedPayload.length @@ -30,12 +30,12 @@ reader->getHistory()->remove_change((CacheChange_t*)change); } -void RovTopicListener::on_liveliness_changed(RTPSReader *reader, const LivelinessChangedStatus &status) +void BridgedReaderTopicListener::on_liveliness_changed(RTPSReader *reader, const LivelinessChangedStatus &status) { logWarning(READER_LISTENER, "Liveliness: " << status.alive_count_change) } -void RovTopicListener::onReaderMatched(RTPSReader* reader, MatchingInfo& info) +void BridgedReaderTopicListener::onReaderMatched(RTPSReader* reader, MatchingInfo& info) { switch (info.status) { diff --git a/FastRTPSBridge/RovWriterListener.h b/FastRTPSBridge/BridgedWriterListener.h similarity index 66% rename from FastRTPSBridge/RovWriterListener.h rename to FastRTPSBridge/BridgedWriterListener.h index 3ad9bbc..3c58eed 100644 --- a/FastRTPSBridge/RovWriterListener.h +++ b/FastRTPSBridge/BridgedWriterListener.h @@ -1,24 +1,21 @@ ///// -//// RovWriterListener.h +//// BridgedWriterListener.h /// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // -#ifndef RovWriterListener_h -#define RovWriterListener_h +#pragma once #include #include #include -class RovWriterListener :public eprosima::fastrtps::rtps::WriterListener +class BridgedWriterListener :public eprosima::fastrtps::rtps::WriterListener { public: - RovWriterListener(const char* topicName); - ~RovWriterListener(); + BridgedWriterListener(const char* topicName); + ~BridgedWriterListener(); void onWriterMatched(eprosima::fastrtps::rtps::RTPSWriter*, eprosima::fastrtps::rtps::MatchingInfo& info); void on_liveliness_lost(eprosima::fastrtps::rtps::RTPSWriter* writer, const eprosima::fastrtps::LivelinessLostStatus& status); int n_matched; std::string topicName; }; - -#endif /* RovWriterListener_h */ diff --git a/FastRTPSBridge/RovWriterListener.cpp b/FastRTPSBridge/BridgedWriterListener.mm similarity index 58% rename from FastRTPSBridge/RovWriterListener.cpp rename to FastRTPSBridge/BridgedWriterListener.mm index e9e85a1..8be61db 100644 --- a/FastRTPSBridge/RovWriterListener.cpp +++ b/FastRTPSBridge/BridgedWriterListener.mm @@ -1,30 +1,30 @@ ///// -//// RovWriterListener.cpp +//// BridgedWriterListener.cpp /// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // #include -#include "RovWriterListener.h" +#include "BridgedWriterListener.h" using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; -RovWriterListener::RovWriterListener(const char* topicName) +BridgedWriterListener::BridgedWriterListener(const char* topicName) { - RovWriterListener::n_matched = 0; - RovWriterListener::topicName = std::string(topicName); + BridgedWriterListener::n_matched = 0; + BridgedWriterListener::topicName = std::string(topicName); } -RovWriterListener::~RovWriterListener() +BridgedWriterListener::~BridgedWriterListener() { } -void RovWriterListener::on_liveliness_lost(RTPSWriter* writer, const LivelinessLostStatus& status) +void BridgedWriterListener::on_liveliness_lost(RTPSWriter* writer, const LivelinessLostStatus& status) { logWarning(WRITER_LISTENER, "Writer liveliness lost:" << status.total_count); } -void RovWriterListener::onWriterMatched(RTPSWriter* writer, MatchingInfo& info) +void BridgedWriterListener::onWriterMatched(RTPSWriter* writer, MatchingInfo& info) { switch (info.status) { diff --git a/FastRTPSBridge/CustomLogConsumer.h b/FastRTPSBridge/CustomLogConsumer.h index a0a6cc3..eb53412 100644 --- a/FastRTPSBridge/CustomLogConsumer.h +++ b/FastRTPSBridge/CustomLogConsumer.h @@ -3,8 +3,7 @@ /// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // -#ifndef CUSTOMLOG_CONSUMER_H -#define CUSTOMLOG_CONSUMER_H +#pragma once #include @@ -23,5 +22,3 @@ class CustomLogConsumer: public LogConsumer { } // namespace fastrtps } // namespace eprosima - -#endif diff --git a/FastRTPSBridge/FastRTPSBridge.mm b/FastRTPSBridge/FastRTPSBridge.mm index 75821a6..7baf7ca 100644 --- a/FastRTPSBridge/FastRTPSBridge.mm +++ b/FastRTPSBridge/FastRTPSBridge.mm @@ -4,7 +4,7 @@ // #import "FastRTPSBridge.h" -#import "RovParticipant.h" +#import "BridgedParticipant.h" #include #include "CustomLogConsumer.h" @@ -15,7 +15,7 @@ @interface FastRTPSBridge() { - RovParticipant* participant; + BridgedParticipant* participant; } @end @@ -41,7 +41,7 @@ - (id)initWithLogLevel:(LogLevel)logLevel { } Log::ReportFilenames(false); - participant = new RovParticipant(); + participant = new BridgedParticipant(); return self; } From 461573c52e9774de17ae0ba1bc14a30b66939e4d Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Fri, 8 Nov 2019 16:11:36 +0300 Subject: [PATCH 05/20] Add IDETemplateMacros --- .../xcshareddata/IDETemplateMacros.plist | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 FastRTPSBridge.xcodeproj/xcshareddata/IDETemplateMacros.plist diff --git a/FastRTPSBridge.xcodeproj/xcshareddata/IDETemplateMacros.plist b/FastRTPSBridge.xcodeproj/xcshareddata/IDETemplateMacros.plist new file mode 100644 index 0000000..e4f161d --- /dev/null +++ b/FastRTPSBridge.xcodeproj/xcshareddata/IDETemplateMacros.plist @@ -0,0 +1,12 @@ + + + + + FILEHEADER + + + From 5c9cb1eea540a267d17526d70f54481721ec9373 Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Fri, 8 Nov 2019 22:01:56 +0300 Subject: [PATCH 06/20] FastRTPSNotifications --- FastRTPSBridge.xcodeproj/project.pbxproj | 30 +++++---- FastRTPSBridge/BridgedParticipant.h | 10 +-- FastRTPSBridge/BridgedParticipant.mm | 6 +- FastRTPSBridge/BridgedParticipantListener.h | 3 +- FastRTPSBridge/BridgedParticipantListener.mm | 59 +++++++++++++++--- ...opicListener.h => BridgedReaderListener.h} | 9 ++- FastRTPSBridge/BridgedReaderListener.mm | 61 +++++++++++++++++++ FastRTPSBridge/BridgedReaderTopicListener.mm | 51 ---------------- FastRTPSBridge/BridgedWriterListener.h | 1 + FastRTPSBridge/BridgedWriterListener.mm | 12 +++- FastRTPSBridge/FastRTPSBridge.h | 5 +- FastRTPSBridge/FastRTPSBridge.mm | 4 +- FastRTPSBridge/FastRTPSNotifications.swift | 36 +++++++++++ 13 files changed, 198 insertions(+), 89 deletions(-) rename FastRTPSBridge/{BridgedReaderTopicListener.h => BridgedReaderListener.h} (77%) create mode 100644 FastRTPSBridge/BridgedReaderListener.mm delete mode 100644 FastRTPSBridge/BridgedReaderTopicListener.mm create mode 100644 FastRTPSBridge/FastRTPSNotifications.swift diff --git a/FastRTPSBridge.xcodeproj/project.pbxproj b/FastRTPSBridge.xcodeproj/project.pbxproj index 6805d91..00274f4 100644 --- a/FastRTPSBridge.xcodeproj/project.pbxproj +++ b/FastRTPSBridge.xcodeproj/project.pbxproj @@ -10,6 +10,8 @@ 0A2735AC2373389100A877B0 /* libfastrtps.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A2735AB2373385E00A877B0 /* libfastrtps.a */; }; 0A2735AE237338A900A877B0 /* libfastcdr.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A2735AD237338A900A877B0 /* libfastcdr.a */; }; 0A2735B0237338BD00A877B0 /* libfoonathan_memory-0.6.2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A2735AF237338BD00A877B0 /* libfoonathan_memory-0.6.2.a */; }; + 0A70B3212375A147007E05B6 /* FastRTPSNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A70B3202375A147007E05B6 /* FastRTPSNotifications.swift */; }; + 0A70B3222375A147007E05B6 /* FastRTPSNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A70B3202375A147007E05B6 /* FastRTPSNotifications.swift */; }; 0A71307A2363503500817593 /* FastRTPSBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130782363503500817593 /* FastRTPSBridge.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0A7130882363514900817593 /* BridgedParticipantListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130812363514900817593 /* BridgedParticipantListener.mm */; }; 0A7130892363514900817593 /* CustomLogConsumer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130822363514900817593 /* CustomLogConsumer.cpp */; }; @@ -19,10 +21,10 @@ 0A71308D2363514900817593 /* DDSType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130862363514900817593 /* DDSType.swift */; }; 0A7130962363516700817593 /* BridgedWriterListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A71308E2363516700817593 /* BridgedWriterListener.mm */; }; 0A7130972363516700817593 /* BridgedWriterListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A71308F2363516700817593 /* BridgedWriterListener.h */; }; - 0A7130982363516700817593 /* BridgedReaderTopicListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130902363516700817593 /* BridgedReaderTopicListener.h */; }; + 0A7130982363516700817593 /* BridgedReaderListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130902363516700817593 /* BridgedReaderListener.h */; }; 0A7130992363516700817593 /* PayloadDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130912363516700817593 /* PayloadDecoder.swift */; }; 0A71309A2363516700817593 /* BridgedParticipant.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130922363516700817593 /* BridgedParticipant.h */; }; - 0A71309B2363516700817593 /* BridgedReaderTopicListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130932363516700817593 /* BridgedReaderTopicListener.mm */; }; + 0A71309B2363516700817593 /* BridgedReaderListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130932363516700817593 /* BridgedReaderListener.mm */; }; 0A71309C2363516700817593 /* FastRTPSBridge-Bridging-Header.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130942363516700817593 /* FastRTPSBridge-Bridging-Header.h */; }; 0A71309D2363516700817593 /* BridgedParticipant.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130952363516700817593 /* BridgedParticipant.mm */; }; 0A8A37E32366DC51008E8DC1 /* DDSType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130862363514900817593 /* DDSType.swift */; }; @@ -31,8 +33,8 @@ 0A8A37E62366DC51008E8DC1 /* FastRTPSBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130782363503500817593 /* FastRTPSBridge.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0A8A37E72366DC51008E8DC1 /* BridgedParticipant.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130922363516700817593 /* BridgedParticipant.h */; }; 0A8A37E82366DC51008E8DC1 /* BridgedParticipant.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130952363516700817593 /* BridgedParticipant.mm */; }; - 0A8A37E92366DC51008E8DC1 /* BridgedReaderTopicListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130902363516700817593 /* BridgedReaderTopicListener.h */; }; - 0A8A37EA2366DC51008E8DC1 /* BridgedReaderTopicListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130932363516700817593 /* BridgedReaderTopicListener.mm */; }; + 0A8A37E92366DC51008E8DC1 /* BridgedReaderListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130902363516700817593 /* BridgedReaderListener.h */; }; + 0A8A37EA2366DC51008E8DC1 /* BridgedReaderListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130932363516700817593 /* BridgedReaderListener.mm */; }; 0A8A37EB2366DC51008E8DC1 /* BridgedWriterListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A71308E2363516700817593 /* BridgedWriterListener.mm */; }; 0A8A37EC2366DC51008E8DC1 /* BridgedWriterListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A71308F2363516700817593 /* BridgedWriterListener.h */; }; 0A8A37ED2366DC51008E8DC1 /* FastRTPSBridge-Bridging-Header.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130942363516700817593 /* FastRTPSBridge-Bridging-Header.h */; }; @@ -85,6 +87,7 @@ 0A2735AD237338A900A877B0 /* libfastcdr.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfastcdr.a; path = build/osx/lib/libfastcdr.a; sourceTree = ""; }; 0A2735AF237338BD00A877B0 /* libfoonathan_memory-0.6.2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libfoonathan_memory-0.6.2.a"; path = "build/osx/lib/libfoonathan_memory-0.6.2.a"; sourceTree = ""; }; 0A5B3F252364E63400BE5707 /* fastrtps_build_osx.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = fastrtps_build_osx.sh; sourceTree = ""; }; + 0A70B3202375A147007E05B6 /* FastRTPSNotifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FastRTPSNotifications.swift; sourceTree = ""; }; 0A7130752363503500817593 /* FastRTPSBridge.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FastRTPSBridge.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 0A7130782363503500817593 /* FastRTPSBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FastRTPSBridge.h; sourceTree = ""; }; 0A7130792363503500817593 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -96,10 +99,10 @@ 0A7130862363514900817593 /* DDSType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DDSType.swift; sourceTree = ""; }; 0A71308E2363516700817593 /* BridgedWriterListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BridgedWriterListener.mm; sourceTree = ""; }; 0A71308F2363516700817593 /* BridgedWriterListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgedWriterListener.h; sourceTree = ""; }; - 0A7130902363516700817593 /* BridgedReaderTopicListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgedReaderTopicListener.h; sourceTree = ""; }; + 0A7130902363516700817593 /* BridgedReaderListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgedReaderListener.h; sourceTree = ""; }; 0A7130912363516700817593 /* PayloadDecoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PayloadDecoder.swift; sourceTree = ""; }; 0A7130922363516700817593 /* BridgedParticipant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgedParticipant.h; sourceTree = ""; }; - 0A7130932363516700817593 /* BridgedReaderTopicListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BridgedReaderTopicListener.mm; sourceTree = ""; }; + 0A7130932363516700817593 /* BridgedReaderListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BridgedReaderListener.mm; sourceTree = ""; }; 0A7130942363516700817593 /* FastRTPSBridge-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "FastRTPSBridge-Bridging-Header.h"; sourceTree = ""; }; 0A7130952363516700817593 /* BridgedParticipant.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BridgedParticipant.mm; sourceTree = ""; }; 0A8A37CF2366D469008E8DC1 /* fastrtps_build_ios.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = fastrtps_build_ios.sh; sourceTree = ""; }; @@ -158,12 +161,13 @@ children = ( 0A7130862363514900817593 /* DDSType.swift */, 0A7130912363516700817593 /* PayloadDecoder.swift */, + 0A70B3202375A147007E05B6 /* FastRTPSNotifications.swift */, 0A7130852363514900817593 /* FastRTPSBridge.mm */, 0A7130782363503500817593 /* FastRTPSBridge.h */, 0A7130952363516700817593 /* BridgedParticipant.mm */, 0A7130922363516700817593 /* BridgedParticipant.h */, - 0A7130932363516700817593 /* BridgedReaderTopicListener.mm */, - 0A7130902363516700817593 /* BridgedReaderTopicListener.h */, + 0A7130932363516700817593 /* BridgedReaderListener.mm */, + 0A7130902363516700817593 /* BridgedReaderListener.h */, 0A71308E2363516700817593 /* BridgedWriterListener.mm */, 0A71308F2363516700817593 /* BridgedWriterListener.h */, 0A7130812363514900817593 /* BridgedParticipantListener.mm */, @@ -201,7 +205,7 @@ 0A71308B2363514900817593 /* BridgedParticipantListener.h in Headers */, 0A71307A2363503500817593 /* FastRTPSBridge.h in Headers */, 0A7130972363516700817593 /* BridgedWriterListener.h in Headers */, - 0A7130982363516700817593 /* BridgedReaderTopicListener.h in Headers */, + 0A7130982363516700817593 /* BridgedReaderListener.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -212,7 +216,7 @@ 0A8A37E62366DC51008E8DC1 /* FastRTPSBridge.h in Headers */, 0A8A37ED2366DC51008E8DC1 /* FastRTPSBridge-Bridging-Header.h in Headers */, 0A8A37F12366DC51008E8DC1 /* BridgedParticipantListener.h in Headers */, - 0A8A37E92366DC51008E8DC1 /* BridgedReaderTopicListener.h in Headers */, + 0A8A37E92366DC51008E8DC1 /* BridgedReaderListener.h in Headers */, 0A8A37E72366DC51008E8DC1 /* BridgedParticipant.h in Headers */, 0A8A37EC2366DC51008E8DC1 /* BridgedWriterListener.h in Headers */, 0A8A37EF2366DC51008E8DC1 /* CustomLogConsumer.h in Headers */, @@ -374,8 +378,9 @@ 0A71308C2363514900817593 /* FastRTPSBridge.mm in Sources */, 0A7130992363516700817593 /* PayloadDecoder.swift in Sources */, 0A7130892363514900817593 /* CustomLogConsumer.cpp in Sources */, - 0A71309B2363516700817593 /* BridgedReaderTopicListener.mm in Sources */, + 0A71309B2363516700817593 /* BridgedReaderListener.mm in Sources */, 0A71309D2363516700817593 /* BridgedParticipant.mm in Sources */, + 0A70B3212375A147007E05B6 /* FastRTPSNotifications.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -383,7 +388,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 0A8A37EA2366DC51008E8DC1 /* BridgedReaderTopicListener.mm in Sources */, + 0A8A37EA2366DC51008E8DC1 /* BridgedReaderListener.mm in Sources */, 0A8A37E52366DC51008E8DC1 /* FastRTPSBridge.mm in Sources */, 0A8A37EB2366DC51008E8DC1 /* BridgedWriterListener.mm in Sources */, 0A8A37EE2366DC51008E8DC1 /* CustomLogConsumer.cpp in Sources */, @@ -391,6 +396,7 @@ 0A8A37E42366DC51008E8DC1 /* PayloadDecoder.swift in Sources */, 0A8A37F02366DC51008E8DC1 /* BridgedParticipantListener.mm in Sources */, 0A8A37E82366DC51008E8DC1 /* BridgedParticipant.mm in Sources */, + 0A70B3222375A147007E05B6 /* FastRTPSNotifications.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/FastRTPSBridge/BridgedParticipant.h b/FastRTPSBridge/BridgedParticipant.h index c5fc318..33809fb 100644 --- a/FastRTPSBridge/BridgedParticipant.h +++ b/FastRTPSBridge/BridgedParticipant.h @@ -9,12 +9,12 @@ #include #include #include -#include "fastrtps/rtps/writer/RTPSWriter.h" +#include #include -#include "fastrtps/rtps/history/WriterHistory.h" +#include #include #include -#import "BridgedReaderTopicListener.h" +#import "BridgedReaderListener.h" #import "BridgedWriterListener.h" class BridgedParticipantListener; @@ -23,7 +23,7 @@ class BridgedParticipant struct ReaderInfo { eprosima::fastrtps::rtps::RTPSReader* reader; eprosima::fastrtps::rtps::ReaderHistory* history; - BridgedReaderTopicListener* listener; + BridgedReaderListener* listener; ~ReaderInfo() { delete history; delete listener; @@ -48,7 +48,7 @@ class BridgedParticipant std::map readerList; std::map writerList; - bool startRTPS(); //Initialization + bool startRTPS(const char* name); bool addReader(const char* name, const char* dataType, const bool keyed, diff --git a/FastRTPSBridge/BridgedParticipant.mm b/FastRTPSBridge/BridgedParticipant.mm index c5af435..5194c14 100644 --- a/FastRTPSBridge/BridgedParticipant.mm +++ b/FastRTPSBridge/BridgedParticipant.mm @@ -4,7 +4,7 @@ // #include "BridgedParticipant.h" -#include "BridgedReaderTopicListener.h" +#include "BridgedReaderListener.h" #include "BridgedWriterListener.h" #include "BridgedParticipantListener.h" @@ -60,7 +60,7 @@ writerList.clear(); } -bool BridgedParticipant::startRTPS() +bool BridgedParticipant::startRTPS(const char* name) { //CREATE PARTICIPANT RTPSParticipantAttributes PParam; @@ -95,7 +95,7 @@ //CREATE READER ReaderAttributes readerAttributes; readerAttributes.endpoint.topicKind = tKind; - auto listener = new BridgedReaderTopicListener(name, payloadDecoder); + auto listener = new BridgedReaderListener(name, payloadDecoder); //CREATE READERHISTORY HistoryAttributes hatt; hatt.payloadMaxSize = 10000; diff --git a/FastRTPSBridge/BridgedParticipantListener.h b/FastRTPSBridge/BridgedParticipantListener.h index 2db0106..51cdb89 100644 --- a/FastRTPSBridge/BridgedParticipantListener.h +++ b/FastRTPSBridge/BridgedParticipantListener.h @@ -8,6 +8,7 @@ #include #include #include +#import "FastRTPSBridge.h" using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; @@ -17,5 +18,5 @@ class BridgedParticipantListener: public eprosima::fastrtps::rtps::RTPSParticipa void onParticipantDiscovery(RTPSParticipant *participant, ParticipantDiscoveryInfo &&info) override; void onReaderDiscovery(RTPSParticipant *participant, ReaderDiscoveryInfo &&info) override; void onWriterDiscovery(RTPSParticipant *participant, WriterDiscoveryInfo &&info) override; - void DumpLocators(ResourceLimitedVector locators); + NSSet* DumpLocators(ResourceLimitedVector locators); }; diff --git a/FastRTPSBridge/BridgedParticipantListener.mm b/FastRTPSBridge/BridgedParticipantListener.mm index ce0c445..103eade 100644 --- a/FastRTPSBridge/BridgedParticipantListener.mm +++ b/FastRTPSBridge/BridgedParticipantListener.mm @@ -7,6 +7,7 @@ #include "BridgedParticipantListener.h" #include #include +#import "FastRTPSBridge/FastRTPSBridge-Swift.h" using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; @@ -14,72 +15,114 @@ void BridgedParticipantListener::onReaderDiscovery(RTPSParticipant *participant, ReaderDiscoveryInfo &&info) { (void)participant; + NSMutableDictionary *notificationDictionary = [[NSMutableDictionary alloc] init]; + notificationDictionary[@"topic"] = [[NSString alloc] initWithCString:info.info.topicName() encoding:NSUTF8StringEncoding]; + notificationDictionary[@"typeName"] = [[NSString alloc] initWithCString:info.info.typeName() encoding:NSUTF8StringEncoding]; + switch(info.status) { case ReaderDiscoveryInfo::DISCOVERED_READER: std::cout << "Reader for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' discovered" << std::endl; - DumpLocators(info.info.remote_locators().unicast); + notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeDiscoveredReader); + notificationDictionary[@"locators"] = DumpLocators(info.info.remote_locators().unicast); break; case ReaderDiscoveryInfo::CHANGED_QOS_READER: + notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeChangedQosReader); break; case ReaderDiscoveryInfo::REMOVED_READER: logWarning(PARTICIPANT_LISTENER, "Reader for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' left the domain.") + notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeRemovedReader); break; } + + [NSNotificationCenter.defaultCenter postNotificationName:RTPSParticipantNotificationName object:NULL userInfo:notificationDictionary]; } void BridgedParticipantListener::onWriterDiscovery(RTPSParticipant *participant, WriterDiscoveryInfo &&info) { (void)participant; + NSMutableDictionary *notificationDictionary = [[NSMutableDictionary alloc] init]; + notificationDictionary[@"topic"] = [[NSString alloc] initWithCString:info.info.topicName() encoding:NSUTF8StringEncoding]; + notificationDictionary[@"typeName"] = [[NSString alloc] initWithCString:info.info.typeName() encoding:NSUTF8StringEncoding]; + switch(info.status) { case WriterDiscoveryInfo::DISCOVERED_WRITER: std::cout << "Writer for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' discovered" << std::endl; - DumpLocators(info.info.remote_locators().unicast); + notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeDiscoveredWriter); + notificationDictionary[@"locators"] = DumpLocators(info.info.remote_locators().unicast); break; case WriterDiscoveryInfo::CHANGED_QOS_WRITER: + notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeChangedQosWriter); break; case WriterDiscoveryInfo::REMOVED_WRITER: logWarning(PARTICIPANT_LISTENER, "Writer for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' left the domain.") + notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeRemovedWriter); break; } + + [NSNotificationCenter.defaultCenter postNotificationName:RTPSParticipantNotificationName object:NULL userInfo:notificationDictionary]; } -void BridgedParticipantListener::DumpLocators(ResourceLimitedVector locators) +NSSet* BridgedParticipantListener::DumpLocators(ResourceLimitedVector locators) { char addrString[INET6_ADDRSTRLEN+1]; - + NSMutableSet *set = [[NSMutableSet alloc] init]; + NSString *locatorString; + for (auto locator = locators.cbegin(); locator != locators.cend(); locator++) { switch (locator->kind) { case LOCATOR_KIND_UDPv4: - std::cout << inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)) << ":" << locator->port << std::endl; + locatorString = [NSString stringWithFormat:@"%s:%d", inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)), locator->port]; + [set addObject:locatorString]; +// std::cout << inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)) << ":" << locator->port << std::endl; break; case LOCATOR_KIND_UDPv6: - std::cout << inet_ntop(AF_INET6, locator->address, addrString, sizeof(addrString)) << ":" << locator->port << std::endl; + locatorString = [NSString stringWithFormat:@"%s:%d", inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)), locator->port]; + [set addObject:locatorString]; +// std::cout << inet_ntop(AF_INET6, locator->address, addrString, sizeof(addrString)) << ":" << locator->port << std::endl; break; default: break; } } + return set; } void BridgedParticipantListener::onParticipantDiscovery(RTPSParticipant *participant, ParticipantDiscoveryInfo &&info) { (void)participant; auto properties = info.info.m_properties.properties; + NSMutableDictionary *notificationDictionary = [[NSMutableDictionary alloc] init]; + notificationDictionary[@"participant"] = [[NSString alloc] initWithCString:info.info.m_participantName encoding:NSUTF8StringEncoding]; + NSString* key; + NSString* value; + NSMutableDictionary *propDict; + switch(info.status) { case ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT: logWarning(PARTICIPANT_LISTENER, "Participant '" << info.info.m_participantName << "' discovered") + propDict = [[NSMutableDictionary alloc] init]; for (auto prop = properties.cbegin(); prop != properties.cend(); prop++) { - std::cout << prop->first << ":" << prop->second << std::endl; + key = [[NSString alloc] initWithCString:prop->first.c_str() encoding:NSUTF8StringEncoding]; + value = [[NSString alloc] initWithCString:prop->second.c_str() encoding:NSUTF8StringEncoding]; + propDict[key] = value; +// std::cout << prop->first << ":" << prop->second << std::endl; } - DumpLocators(info.info.default_locators.unicast); + notificationDictionary[@"properties"] = propDict; + notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeDiscoveredParticipant); + notificationDictionary[@"locators"] = DumpLocators(info.info.default_locators.unicast); break; case ParticipantDiscoveryInfo::DROPPED_PARTICIPANT: logWarning(PARTICIPANT_LISTENER, "Participant '" << info.info.m_participantName << "' dropped") + notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeDroppedParticipant); break; case ParticipantDiscoveryInfo::REMOVED_PARTICIPANT: logWarning(PARTICIPANT_LISTENER, "Participant '" << info.info.m_participantName << "' removed") + notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeRemovedParticipant); break; case ParticipantDiscoveryInfo::CHANGED_QOS_PARTICIPANT: + notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeChangedQosParticipant); break; } + + [NSNotificationCenter.defaultCenter postNotificationName:RTPSParticipantNotificationName object:NULL userInfo:notificationDictionary]; } diff --git a/FastRTPSBridge/BridgedReaderTopicListener.h b/FastRTPSBridge/BridgedReaderListener.h similarity index 77% rename from FastRTPSBridge/BridgedReaderTopicListener.h rename to FastRTPSBridge/BridgedReaderListener.h index 69bf132..d7a1a90 100644 --- a/FastRTPSBridge/BridgedReaderTopicListener.h +++ b/FastRTPSBridge/BridgedReaderListener.h @@ -1,5 +1,5 @@ ///// -//// BridgedReaderTopicListener.h +//// BridgedReaderListener.h /// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // @@ -10,12 +10,11 @@ #include "fastrtps/rtps/reader/ReaderListener.h" #import "FastRTPSBridge/FastRTPSBridge-Swift.h" - -class BridgedReaderTopicListener:public eprosima::fastrtps::rtps::ReaderListener +class BridgedReaderListener:public eprosima::fastrtps::rtps::ReaderListener { public: - BridgedReaderTopicListener(const char* topicName, NSObject* payloadDecoder); - ~BridgedReaderTopicListener(); + BridgedReaderListener(const char* topicName, NSObject* payloadDecoder); + ~BridgedReaderListener(); void onNewCacheChangeAdded(eprosima::fastrtps::rtps::RTPSReader* reader, const eprosima::fastrtps::rtps::CacheChange_t* const change) override; void onReaderMatched(eprosima::fastrtps::rtps::RTPSReader*, diff --git a/FastRTPSBridge/BridgedReaderListener.mm b/FastRTPSBridge/BridgedReaderListener.mm new file mode 100644 index 0000000..7f6124e --- /dev/null +++ b/FastRTPSBridge/BridgedReaderListener.mm @@ -0,0 +1,61 @@ +///// +//// BridgedReaderListener.cpp +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +// + +#include "BridgedReaderListener.h" + +#include +#include +#include +#import "FastRTPSBridge.h" + +using namespace eprosima::fastrtps; +using namespace eprosima::fastrtps::rtps; + +BridgedReaderListener::BridgedReaderListener(const char* topicName, NSObject* payloadDecoder): n_matched(0) +{ + BridgedReaderListener::topicName = std::string(topicName); + BridgedReaderListener::payloadDecoder = payloadDecoder; +} + +BridgedReaderListener::~BridgedReaderListener() +{ +} + +void BridgedReaderListener::onNewCacheChangeAdded(RTPSReader* reader, const CacheChange_t * const change) +{ + [payloadDecoder decodeWithSequence:change->sequenceNumber.to64long() + payloadSize:change->serializedPayload.length + payload:change->serializedPayload.data]; + reader->getHistory()->remove_change((CacheChange_t*)change); +} + +void BridgedReaderListener::on_liveliness_changed(RTPSReader *reader, const LivelinessChangedStatus &status) +{ + NSMutableDictionary *notificationDictionary = [[NSMutableDictionary alloc] init]; + notificationDictionary[@"topic"] = [[NSString alloc] initWithCString:topicName.c_str() encoding:NSUTF8StringEncoding]; + notificationDictionary[@"type"] = @(RTPSReaderWriterNotificationTypeReaderLivelinessLost); + [NSNotificationCenter.defaultCenter postNotificationName:RTPSReaderWriterNotificationName object:NULL userInfo:notificationDictionary]; + logWarning(READER_LISTENER, "Liveliness: " << status.alive_count_change) +} + +void BridgedReaderListener::onReaderMatched(RTPSReader* reader, MatchingInfo& info) +{ + NSMutableDictionary *notificationDictionary = [[NSMutableDictionary alloc] init]; + notificationDictionary[@"topic"] = [[NSString alloc] initWithCString:topicName.c_str() encoding:NSUTF8StringEncoding]; + switch (info.status) + { + case MATCHED_MATCHING: + n_matched++; + notificationDictionary[@"type"] = @(RTPSReaderWriterNotificationTypeReaderMatchedMatching); + logWarning(READER_LISTENER, "\tReader matched:" << topicName << " count: " << n_matched) + break; + case REMOVED_MATCHING: + n_matched--; + notificationDictionary[@"type"] = @(RTPSReaderWriterNotificationTypeReaderRemovedMatching); + logWarning(READER_LISTENER, "\tReader remove matched:" << topicName << " count: " << n_matched) + break; + } + [NSNotificationCenter.defaultCenter postNotificationName:RTPSReaderWriterNotificationName object:NULL userInfo:notificationDictionary]; +} diff --git a/FastRTPSBridge/BridgedReaderTopicListener.mm b/FastRTPSBridge/BridgedReaderTopicListener.mm deleted file mode 100644 index 42ff302..0000000 --- a/FastRTPSBridge/BridgedReaderTopicListener.mm +++ /dev/null @@ -1,51 +0,0 @@ -///// -//// BridgedReaderTopicListener.cpp -/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. -// - -#include "BridgedReaderTopicListener.h" - -#include -#include -#include - -using namespace eprosima::fastrtps; -using namespace eprosima::fastrtps::rtps; - -BridgedReaderTopicListener::BridgedReaderTopicListener(const char* topicName, NSObject* payloadDecoder): n_matched(0) -{ - BridgedReaderTopicListener::topicName = std::string(topicName); - BridgedReaderTopicListener::payloadDecoder = payloadDecoder; -} - -BridgedReaderTopicListener::~BridgedReaderTopicListener() -{ -} - -void BridgedReaderTopicListener::onNewCacheChangeAdded(RTPSReader* reader, const CacheChange_t * const change) -{ - [payloadDecoder decodeWithSequence:change->sequenceNumber.to64long() - payloadSize:change->serializedPayload.length - payload:change->serializedPayload.data]; - reader->getHistory()->remove_change((CacheChange_t*)change); -} - -void BridgedReaderTopicListener::on_liveliness_changed(RTPSReader *reader, const LivelinessChangedStatus &status) -{ - logWarning(READER_LISTENER, "Liveliness: " << status.alive_count_change) -} - -void BridgedReaderTopicListener::onReaderMatched(RTPSReader* reader, MatchingInfo& info) -{ - switch (info.status) - { - case MATCHED_MATCHING: - n_matched++; - logWarning(READER_LISTENER, "\tReader matched:" << topicName << " count: " << n_matched) - break; - case REMOVED_MATCHING: - n_matched--; - logWarning(READER_LISTENER, "\tReader remove matched:" << topicName << " count: " << n_matched) - break; - } -} diff --git a/FastRTPSBridge/BridgedWriterListener.h b/FastRTPSBridge/BridgedWriterListener.h index 3c58eed..db20efe 100644 --- a/FastRTPSBridge/BridgedWriterListener.h +++ b/FastRTPSBridge/BridgedWriterListener.h @@ -8,6 +8,7 @@ #include #include #include +#import "FastRTPSBridge/FastRTPSBridge-Swift.h" class BridgedWriterListener :public eprosima::fastrtps::rtps::WriterListener { diff --git a/FastRTPSBridge/BridgedWriterListener.mm b/FastRTPSBridge/BridgedWriterListener.mm index 8be61db..1375f2b 100644 --- a/FastRTPSBridge/BridgedWriterListener.mm +++ b/FastRTPSBridge/BridgedWriterListener.mm @@ -3,8 +3,9 @@ /// Copyright © 2019 Dmitriy Borovikov. All rights reserved. // -#include #include "BridgedWriterListener.h" +#include +#import "FastRTPSBridge.h" using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; @@ -21,20 +22,29 @@ void BridgedWriterListener::on_liveliness_lost(RTPSWriter* writer, const LivelinessLostStatus& status) { + NSMutableDictionary *notificationDictionary = [[NSMutableDictionary alloc] init]; + notificationDictionary[@"topic"] = [[NSString alloc] initWithCString:topicName.c_str() encoding:NSUTF8StringEncoding]; + notificationDictionary[@"type"] = @(RTPSReaderWriterNotificationTypeWriterLivelinessLost); + [NSNotificationCenter.defaultCenter postNotificationName:RTPSReaderWriterNotificationName object:NULL userInfo:notificationDictionary]; logWarning(WRITER_LISTENER, "Writer liveliness lost:" << status.total_count); } void BridgedWriterListener::onWriterMatched(RTPSWriter* writer, MatchingInfo& info) { + NSMutableDictionary *notificationDictionary = [[NSMutableDictionary alloc] init]; + notificationDictionary[@"topic"] = [[NSString alloc] initWithCString:topicName.c_str() encoding:NSUTF8StringEncoding]; switch (info.status) { case MATCHED_MATCHING: n_matched++; + notificationDictionary[@"type"] = @(RTPSReaderWriterNotificationTypeWriterMatchedMatching); logWarning(WRITER_LISTENER, "\tWriter matched:" << topicName << " count: " << n_matched) break; case REMOVED_MATCHING: n_matched--; + notificationDictionary[@"type"] = @(RTPSReaderWriterNotificationTypeWriterRemovedMatching); logWarning(WRITER_LISTENER, "\tWriter remove matched:" << topicName << " count: " << n_matched) break; } + [NSNotificationCenter.defaultCenter postNotificationName:RTPSReaderWriterNotificationName object:NULL userInfo:notificationDictionary]; } diff --git a/FastRTPSBridge/FastRTPSBridge.h b/FastRTPSBridge/FastRTPSBridge.h index d32faa1..16592b8 100644 --- a/FastRTPSBridge/FastRTPSBridge.h +++ b/FastRTPSBridge/FastRTPSBridge.h @@ -13,6 +13,9 @@ FOUNDATION_EXPORT const unsigned char FastRTPSBridgeVersionString[]; NS_ASSUME_NONNULL_BEGIN +NSString *const RTPSParticipantNotificationName = @"RTPSParticipantNotification"; +NSString *const RTPSReaderWriterNotificationName = @"RTPSReaderWriterNotification"; + @protocol PayloadDecoderInterface; @interface FastRTPSBridge : NSObject typedef NS_CLOSED_ENUM(NSInteger, LogLevel) { @@ -26,7 +29,7 @@ typedef NS_CLOSED_ENUM(NSInteger, LogLevel) { - (bool)removeWriterWithTopicName:(NSString *)topicName; - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data key: (NSData*) key; - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data; -- (bool)startRTPS; +- (bool)createRTPSParticipantWithName:(NSString *)name; - (void)stopRTPS; - (void)resignAll; diff --git a/FastRTPSBridge/FastRTPSBridge.mm b/FastRTPSBridge/FastRTPSBridge.mm index 7baf7ca..88efd8b 100644 --- a/FastRTPSBridge/FastRTPSBridge.mm +++ b/FastRTPSBridge/FastRTPSBridge.mm @@ -82,8 +82,8 @@ - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data key: (NSData static_cast(key.length)); } -- (bool)startRTPS { - return participant->startRTPS(); +- (bool)createRTPSParticipantWithName:(NSString *)name { + return participant->startRTPS([name cStringUsingEncoding:NSUTF8StringEncoding]); } - (void)stopRTPS { diff --git a/FastRTPSBridge/FastRTPSNotifications.swift b/FastRTPSBridge/FastRTPSNotifications.swift new file mode 100644 index 0000000..e062510 --- /dev/null +++ b/FastRTPSBridge/FastRTPSNotifications.swift @@ -0,0 +1,36 @@ +///// +//// FastRTPSNotifications.swift +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +// + + +import Foundation + +extension Notification.Name { + public static let RTPSParticipantNotification = Notification.Name(RTPSParticipantNotificationName) + public static let RTPSReaderWriterNotification = Notification.Name(RTPSReaderWriterNotificationName) +} + +@objc +public enum RTPSParticipantNotificationType: Int { + case discoveredReader + case changedQosReader + case removedReader + case discoveredWriter + case changedQosWriter + case removedWriter + case discoveredParticipant + case changedQosParticipant + case removedParticipant + case droppedParticipant +} + +@objc +public enum RTPSReaderWriterNotificationType: Int { + case readerMatchedMatching + case readerRemovedMatching + case readerLivelinessLost + case writerMatchedMatching + case writerRemovedMatching + case writerLivelinessLost +} From 5e145baf5207587e04419be72518adf7556d0f9d Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Fri, 8 Nov 2019 22:16:59 +0300 Subject: [PATCH 07/20] Fix bugs with duplicate symbols --- FastRTPSBridge.xcodeproj/project.pbxproj | 6 ++++++ FastRTPSBridge/FastRTPSBridge.h | 4 ++-- FastRTPSBridge/FastRTPSNotifications.mm | 11 +++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 FastRTPSBridge/FastRTPSNotifications.mm diff --git a/FastRTPSBridge.xcodeproj/project.pbxproj b/FastRTPSBridge.xcodeproj/project.pbxproj index 00274f4..cf93eea 100644 --- a/FastRTPSBridge.xcodeproj/project.pbxproj +++ b/FastRTPSBridge.xcodeproj/project.pbxproj @@ -44,6 +44,8 @@ 0A8A37F12366DC51008E8DC1 /* BridgedParticipantListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130842363514900817593 /* BridgedParticipantListener.h */; }; 0A969815236EEF0100FF958F /* CDRCodable in Frameworks */ = {isa = PBXBuildFile; productRef = 0A969814236EEF0100FF958F /* CDRCodable */; }; 0A969817236EEF0B00FF958F /* CDRCodable in Frameworks */ = {isa = PBXBuildFile; productRef = 0A969816236EEF0B00FF958F /* CDRCodable */; }; + 0AC08A802375F61900A80C2E /* FastRTPSNotifications.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0AC08A7F2375F61900A80C2E /* FastRTPSNotifications.mm */; }; + 0AC08A812375F61900A80C2E /* FastRTPSNotifications.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0AC08A7F2375F61900A80C2E /* FastRTPSNotifications.mm */; }; 0AD993862366F76300D037A3 /* libfastcdr.1.0.10.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AD993842366F76300D037A3 /* libfastcdr.1.0.10.dylib */; }; 0AD993872366F76300D037A3 /* libfastcdr.1.0.10.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 0AD993842366F76300D037A3 /* libfastcdr.1.0.10.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 0AD993882366F76300D037A3 /* libfastrtps.1.9.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AD993852366F76300D037A3 /* libfastrtps.1.9.1.dylib */; }; @@ -107,6 +109,7 @@ 0A7130952363516700817593 /* BridgedParticipant.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BridgedParticipant.mm; sourceTree = ""; }; 0A8A37CF2366D469008E8DC1 /* fastrtps_build_ios.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = fastrtps_build_ios.sh; sourceTree = ""; }; 0A8A37DB2366DB1B008E8DC1 /* FastRTPSBridge.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FastRTPSBridge.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 0AC08A7F2375F61900A80C2E /* FastRTPSNotifications.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FastRTPSNotifications.mm; sourceTree = ""; }; 0AD993842366F76300D037A3 /* libfastcdr.1.0.10.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfastcdr.1.0.10.dylib; path = build/ios/lib/libfastcdr.1.0.10.dylib; sourceTree = ""; }; 0AD993852366F76300D037A3 /* libfastrtps.1.9.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfastrtps.1.9.1.dylib; path = build/ios/lib/libfastrtps.1.9.1.dylib; sourceTree = ""; }; /* End PBXFileReference section */ @@ -162,6 +165,7 @@ 0A7130862363514900817593 /* DDSType.swift */, 0A7130912363516700817593 /* PayloadDecoder.swift */, 0A70B3202375A147007E05B6 /* FastRTPSNotifications.swift */, + 0AC08A7F2375F61900A80C2E /* FastRTPSNotifications.mm */, 0A7130852363514900817593 /* FastRTPSBridge.mm */, 0A7130782363503500817593 /* FastRTPSBridge.h */, 0A7130952363516700817593 /* BridgedParticipant.mm */, @@ -373,6 +377,7 @@ buildActionMask = 2147483647; files = ( 0A7130882363514900817593 /* BridgedParticipantListener.mm in Sources */, + 0AC08A802375F61900A80C2E /* FastRTPSNotifications.mm in Sources */, 0A71308D2363514900817593 /* DDSType.swift in Sources */, 0A7130962363516700817593 /* BridgedWriterListener.mm in Sources */, 0A71308C2363514900817593 /* FastRTPSBridge.mm in Sources */, @@ -389,6 +394,7 @@ buildActionMask = 2147483647; files = ( 0A8A37EA2366DC51008E8DC1 /* BridgedReaderListener.mm in Sources */, + 0AC08A812375F61900A80C2E /* FastRTPSNotifications.mm in Sources */, 0A8A37E52366DC51008E8DC1 /* FastRTPSBridge.mm in Sources */, 0A8A37EB2366DC51008E8DC1 /* BridgedWriterListener.mm in Sources */, 0A8A37EE2366DC51008E8DC1 /* CustomLogConsumer.cpp in Sources */, diff --git a/FastRTPSBridge/FastRTPSBridge.h b/FastRTPSBridge/FastRTPSBridge.h index 16592b8..4a4d0df 100644 --- a/FastRTPSBridge/FastRTPSBridge.h +++ b/FastRTPSBridge/FastRTPSBridge.h @@ -13,8 +13,8 @@ FOUNDATION_EXPORT const unsigned char FastRTPSBridgeVersionString[]; NS_ASSUME_NONNULL_BEGIN -NSString *const RTPSParticipantNotificationName = @"RTPSParticipantNotification"; -NSString *const RTPSReaderWriterNotificationName = @"RTPSReaderWriterNotification"; +FOUNDATION_EXPORT NSString *const RTPSParticipantNotificationName; +FOUNDATION_EXPORT NSString *const RTPSReaderWriterNotificationName; @protocol PayloadDecoderInterface; @interface FastRTPSBridge : NSObject diff --git a/FastRTPSBridge/FastRTPSNotifications.mm b/FastRTPSBridge/FastRTPSNotifications.mm new file mode 100644 index 0000000..3402b64 --- /dev/null +++ b/FastRTPSBridge/FastRTPSNotifications.mm @@ -0,0 +1,11 @@ +///// +//// FastRTPSNotifications.mm +/// Copyright © 2019 Dmitriy Borovikov. All rights reserved. +// + + +#import +#import "FastRTPSBridge.h" + +NSString *const RTPSParticipantNotificationName = @"RTPSParticipantNotification"; +NSString *const RTPSReaderWriterNotificationName = @"RTPSReaderWriterNotification"; From bda781b0d0af144c310717abd79d68f753f563c6 Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Sat, 9 Nov 2019 01:48:36 +0300 Subject: [PATCH 08/20] Refactoring - rename --- FastRTPSBridge/BridgedParticipantListener.mm | 40 ++++++++++---------- FastRTPSBridge/BridgedReaderListener.mm | 6 +-- FastRTPSBridge/BridgedWriterListener.mm | 6 +-- FastRTPSBridge/FastRTPSNotifications.swift | 11 +++--- 4 files changed, 32 insertions(+), 31 deletions(-) diff --git a/FastRTPSBridge/BridgedParticipantListener.mm b/FastRTPSBridge/BridgedParticipantListener.mm index 103eade..ac6660f 100644 --- a/FastRTPSBridge/BridgedParticipantListener.mm +++ b/FastRTPSBridge/BridgedParticipantListener.mm @@ -21,16 +21,16 @@ switch(info.status) { case ReaderDiscoveryInfo::DISCOVERED_READER: - std::cout << "Reader for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' discovered" << std::endl; - notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeDiscoveredReader); + logInfo(PARTICIPANT_LISTENER, "Reader for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' discovered"); + notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonDiscoveredReader); notificationDictionary[@"locators"] = DumpLocators(info.info.remote_locators().unicast); break; case ReaderDiscoveryInfo::CHANGED_QOS_READER: - notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeChangedQosReader); + notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonChangedQosReader); break; case ReaderDiscoveryInfo::REMOVED_READER: - logWarning(PARTICIPANT_LISTENER, "Reader for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' left the domain.") - notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeRemovedReader); + logInfo(PARTICIPANT_LISTENER, "Reader for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' left the domain.") + notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonRemovedReader); break; } @@ -46,16 +46,16 @@ switch(info.status) { case WriterDiscoveryInfo::DISCOVERED_WRITER: - std::cout << "Writer for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' discovered" << std::endl; - notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeDiscoveredWriter); + logInfo(PARTICIPANT_LISTENER, "Writer for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' discovered"); + notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonDiscoveredWriter); notificationDictionary[@"locators"] = DumpLocators(info.info.remote_locators().unicast); break; case WriterDiscoveryInfo::CHANGED_QOS_WRITER: - notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeChangedQosWriter); + notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonChangedQosWriter); break; case WriterDiscoveryInfo::REMOVED_WRITER: - logWarning(PARTICIPANT_LISTENER, "Writer for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' left the domain.") - notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeRemovedWriter); + logInfo(PARTICIPANT_LISTENER, "Writer for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' left the domain.") + notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonRemovedWriter); break; } @@ -73,12 +73,12 @@ case LOCATOR_KIND_UDPv4: locatorString = [NSString stringWithFormat:@"%s:%d", inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)), locator->port]; [set addObject:locatorString]; -// std::cout << inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)) << ":" << locator->port << std::endl; + logInfo(PARTICIPANT_LISTENER, inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)) << ":" << locator->port); break; case LOCATOR_KIND_UDPv6: locatorString = [NSString stringWithFormat:@"%s:%d", inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)), locator->port]; [set addObject:locatorString]; -// std::cout << inet_ntop(AF_INET6, locator->address, addrString, sizeof(addrString)) << ":" << locator->port << std::endl; + logInfo(PARTICIPANT_LISTENER, inet_ntop(AF_INET6, locator->address, addrString, sizeof(addrString)) << ":" << locator->port); break; default: break; @@ -99,28 +99,28 @@ switch(info.status) { case ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT: - logWarning(PARTICIPANT_LISTENER, "Participant '" << info.info.m_participantName << "' discovered") + logInfo(PARTICIPANT_LISTENER, "Participant '" << info.info.m_participantName << "' discovered") propDict = [[NSMutableDictionary alloc] init]; for (auto prop = properties.cbegin(); prop != properties.cend(); prop++) { key = [[NSString alloc] initWithCString:prop->first.c_str() encoding:NSUTF8StringEncoding]; value = [[NSString alloc] initWithCString:prop->second.c_str() encoding:NSUTF8StringEncoding]; propDict[key] = value; -// std::cout << prop->first << ":" << prop->second << std::endl; + logInfo(PARTICIPANT_LISTENER, prop->first << ":" << prop->second); } notificationDictionary[@"properties"] = propDict; - notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeDiscoveredParticipant); + notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonDiscoveredParticipant); notificationDictionary[@"locators"] = DumpLocators(info.info.default_locators.unicast); break; case ParticipantDiscoveryInfo::DROPPED_PARTICIPANT: - logWarning(PARTICIPANT_LISTENER, "Participant '" << info.info.m_participantName << "' dropped") - notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeDroppedParticipant); + logInfo(PARTICIPANT_LISTENER, "Participant '" << info.info.m_participantName << "' dropped") + notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonDroppedParticipant); break; case ParticipantDiscoveryInfo::REMOVED_PARTICIPANT: - logWarning(PARTICIPANT_LISTENER, "Participant '" << info.info.m_participantName << "' removed") - notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeRemovedParticipant); + logInfo(PARTICIPANT_LISTENER, "Participant '" << info.info.m_participantName << "' removed") + notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonRemovedParticipant); break; case ParticipantDiscoveryInfo::CHANGED_QOS_PARTICIPANT: - notificationDictionary[@"type"] = @(RTPSParticipantNotificationTypeChangedQosParticipant); + notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonChangedQosParticipant); break; } diff --git a/FastRTPSBridge/BridgedReaderListener.mm b/FastRTPSBridge/BridgedReaderListener.mm index 7f6124e..d76480d 100644 --- a/FastRTPSBridge/BridgedReaderListener.mm +++ b/FastRTPSBridge/BridgedReaderListener.mm @@ -35,7 +35,7 @@ { NSMutableDictionary *notificationDictionary = [[NSMutableDictionary alloc] init]; notificationDictionary[@"topic"] = [[NSString alloc] initWithCString:topicName.c_str() encoding:NSUTF8StringEncoding]; - notificationDictionary[@"type"] = @(RTPSReaderWriterNotificationTypeReaderLivelinessLost); + notificationDictionary[@"reason"] = @(RTPSReaderWriterNotificationReasonReaderLivelinessLost); [NSNotificationCenter.defaultCenter postNotificationName:RTPSReaderWriterNotificationName object:NULL userInfo:notificationDictionary]; logWarning(READER_LISTENER, "Liveliness: " << status.alive_count_change) } @@ -48,12 +48,12 @@ { case MATCHED_MATCHING: n_matched++; - notificationDictionary[@"type"] = @(RTPSReaderWriterNotificationTypeReaderMatchedMatching); + notificationDictionary[@"reason"] = @(RTPSReaderWriterNotificationReasonReaderMatchedMatching); logWarning(READER_LISTENER, "\tReader matched:" << topicName << " count: " << n_matched) break; case REMOVED_MATCHING: n_matched--; - notificationDictionary[@"type"] = @(RTPSReaderWriterNotificationTypeReaderRemovedMatching); + notificationDictionary[@"reason"] = @(RTPSReaderWriterNotificationReasonReaderRemovedMatching); logWarning(READER_LISTENER, "\tReader remove matched:" << topicName << " count: " << n_matched) break; } diff --git a/FastRTPSBridge/BridgedWriterListener.mm b/FastRTPSBridge/BridgedWriterListener.mm index 1375f2b..3567510 100644 --- a/FastRTPSBridge/BridgedWriterListener.mm +++ b/FastRTPSBridge/BridgedWriterListener.mm @@ -24,7 +24,7 @@ { NSMutableDictionary *notificationDictionary = [[NSMutableDictionary alloc] init]; notificationDictionary[@"topic"] = [[NSString alloc] initWithCString:topicName.c_str() encoding:NSUTF8StringEncoding]; - notificationDictionary[@"type"] = @(RTPSReaderWriterNotificationTypeWriterLivelinessLost); + notificationDictionary[@"reason"] = @(RTPSReaderWriterNotificationReasonWriterLivelinessLost); [NSNotificationCenter.defaultCenter postNotificationName:RTPSReaderWriterNotificationName object:NULL userInfo:notificationDictionary]; logWarning(WRITER_LISTENER, "Writer liveliness lost:" << status.total_count); } @@ -37,12 +37,12 @@ { case MATCHED_MATCHING: n_matched++; - notificationDictionary[@"type"] = @(RTPSReaderWriterNotificationTypeWriterMatchedMatching); + notificationDictionary[@"reason"] = @(RTPSReaderWriterNotificationReasonWriterMatchedMatching); logWarning(WRITER_LISTENER, "\tWriter matched:" << topicName << " count: " << n_matched) break; case REMOVED_MATCHING: n_matched--; - notificationDictionary[@"type"] = @(RTPSReaderWriterNotificationTypeWriterRemovedMatching); + notificationDictionary[@"reason"] = @(RTPSReaderWriterNotificationReasonWriterRemovedMatching); logWarning(WRITER_LISTENER, "\tWriter remove matched:" << topicName << " count: " << n_matched) break; } diff --git a/FastRTPSBridge/FastRTPSNotifications.swift b/FastRTPSBridge/FastRTPSNotifications.swift index e062510..634a8e6 100644 --- a/FastRTPSBridge/FastRTPSNotifications.swift +++ b/FastRTPSBridge/FastRTPSNotifications.swift @@ -6,13 +6,13 @@ import Foundation -extension Notification.Name { - public static let RTPSParticipantNotification = Notification.Name(RTPSParticipantNotificationName) - public static let RTPSReaderWriterNotification = Notification.Name(RTPSReaderWriterNotificationName) +public extension Notification.Name { + static let RTPSParticipantNotification = Notification.Name(RTPSParticipantNotificationName) + static let RTPSReaderWriterNotification = Notification.Name(RTPSReaderWriterNotificationName) } @objc -public enum RTPSParticipantNotificationType: Int { +public enum RTPSParticipantNotificationReason: Int { case discoveredReader case changedQosReader case removedReader @@ -26,7 +26,7 @@ public enum RTPSParticipantNotificationType: Int { } @objc -public enum RTPSReaderWriterNotificationType: Int { +public enum RTPSReaderWriterNotificationReason: Int { case readerMatchedMatching case readerRemovedMatching case readerLivelinessLost @@ -34,3 +34,4 @@ public enum RTPSReaderWriterNotificationType: Int { case writerRemovedMatching case writerLivelinessLost } + From c46eaba0c1f4214fc52615a7cd1e0c53c0787260 Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Sat, 9 Nov 2019 10:55:08 +0300 Subject: [PATCH 09/20] Refactoring - use enum for userInfo dictionary. Set diag messages info log level --- FastRTPSBridge/BridgedParticipant.mm | 4 +-- FastRTPSBridge/BridgedParticipantListener.mm | 38 ++++++++++---------- FastRTPSBridge/BridgedReaderListener.mm | 16 ++++----- FastRTPSBridge/BridgedWriterListener.mm | 16 ++++----- FastRTPSBridge/FastRTPSNotifications.swift | 9 +++++ 5 files changed, 46 insertions(+), 37 deletions(-) diff --git a/FastRTPSBridge/BridgedParticipant.mm b/FastRTPSBridge/BridgedParticipant.mm index 5194c14..32bd6e2 100644 --- a/FastRTPSBridge/BridgedParticipant.mm +++ b/FastRTPSBridge/BridgedParticipant.mm @@ -228,14 +228,14 @@ memcpy(instanceHandle.value, key, len); change = writer->new_change([length]() -> uint32_t { return length+sizeof(header);}, ALIVE, instanceHandle); if (!change) { // In the case history is full, remove some old changes - logWarning(ROV_PARTICIPANT, "cleaning history...") + logInfo(ROV_PARTICIPANT, "cleaning history...") writer->remove_older_changes(2); change = writer->new_change([length]() -> uint32_t { return length+sizeof(header);}, ALIVE, instanceHandle); } } else { change = writer->new_change([length]() -> uint32_t { return length+sizeof(header);}, ALIVE); if (!change) { // In the case history is full, remove some old changes - logWarning(ROV_PARTICIPANT, "cleaning history...") + logInfo(ROV_PARTICIPANT, "cleaning history...") writer->remove_older_changes(2); change = writer->new_change([length]() -> uint32_t { return length+sizeof(header);}, ALIVE); } diff --git a/FastRTPSBridge/BridgedParticipantListener.mm b/FastRTPSBridge/BridgedParticipantListener.mm index ac6660f..d0c1e50 100644 --- a/FastRTPSBridge/BridgedParticipantListener.mm +++ b/FastRTPSBridge/BridgedParticipantListener.mm @@ -16,21 +16,21 @@ { (void)participant; NSMutableDictionary *notificationDictionary = [[NSMutableDictionary alloc] init]; - notificationDictionary[@"topic"] = [[NSString alloc] initWithCString:info.info.topicName() encoding:NSUTF8StringEncoding]; - notificationDictionary[@"typeName"] = [[NSString alloc] initWithCString:info.info.typeName() encoding:NSUTF8StringEncoding]; + notificationDictionary[@(RTPSNotificationUserInfoTopic)] = [[NSString alloc] initWithCString:info.info.topicName() encoding:NSUTF8StringEncoding]; + notificationDictionary[@(RTPSNotificationUserInfoTypeName)] = [[NSString alloc] initWithCString:info.info.typeName() encoding:NSUTF8StringEncoding]; switch(info.status) { case ReaderDiscoveryInfo::DISCOVERED_READER: logInfo(PARTICIPANT_LISTENER, "Reader for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' discovered"); - notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonDiscoveredReader); - notificationDictionary[@"locators"] = DumpLocators(info.info.remote_locators().unicast); + notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonDiscoveredReader); + notificationDictionary[@(RTPSNotificationUserInfoLocators)] = DumpLocators(info.info.remote_locators().unicast); break; case ReaderDiscoveryInfo::CHANGED_QOS_READER: - notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonChangedQosReader); + notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonChangedQosReader); break; case ReaderDiscoveryInfo::REMOVED_READER: logInfo(PARTICIPANT_LISTENER, "Reader for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' left the domain.") - notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonRemovedReader); + notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonRemovedReader); break; } @@ -41,21 +41,21 @@ { (void)participant; NSMutableDictionary *notificationDictionary = [[NSMutableDictionary alloc] init]; - notificationDictionary[@"topic"] = [[NSString alloc] initWithCString:info.info.topicName() encoding:NSUTF8StringEncoding]; - notificationDictionary[@"typeName"] = [[NSString alloc] initWithCString:info.info.typeName() encoding:NSUTF8StringEncoding]; + notificationDictionary[@(RTPSNotificationUserInfoTopic)] = [[NSString alloc] initWithCString:info.info.topicName() encoding:NSUTF8StringEncoding]; + notificationDictionary[@(RTPSNotificationUserInfoTypeName)] = [[NSString alloc] initWithCString:info.info.typeName() encoding:NSUTF8StringEncoding]; switch(info.status) { case WriterDiscoveryInfo::DISCOVERED_WRITER: logInfo(PARTICIPANT_LISTENER, "Writer for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' discovered"); - notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonDiscoveredWriter); - notificationDictionary[@"locators"] = DumpLocators(info.info.remote_locators().unicast); + notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonDiscoveredWriter); + notificationDictionary[@(RTPSNotificationUserInfoLocators)] = DumpLocators(info.info.remote_locators().unicast); break; case WriterDiscoveryInfo::CHANGED_QOS_WRITER: - notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonChangedQosWriter); + notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonChangedQosWriter); break; case WriterDiscoveryInfo::REMOVED_WRITER: logInfo(PARTICIPANT_LISTENER, "Writer for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' left the domain.") - notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonRemovedWriter); + notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonRemovedWriter); break; } @@ -92,7 +92,7 @@ (void)participant; auto properties = info.info.m_properties.properties; NSMutableDictionary *notificationDictionary = [[NSMutableDictionary alloc] init]; - notificationDictionary[@"participant"] = [[NSString alloc] initWithCString:info.info.m_participantName encoding:NSUTF8StringEncoding]; + notificationDictionary[@(RTPSNotificationUserInfoParticipant)] = [[NSString alloc] initWithCString:info.info.m_participantName encoding:NSUTF8StringEncoding]; NSString* key; NSString* value; NSMutableDictionary *propDict; @@ -107,20 +107,20 @@ propDict[key] = value; logInfo(PARTICIPANT_LISTENER, prop->first << ":" << prop->second); } - notificationDictionary[@"properties"] = propDict; - notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonDiscoveredParticipant); - notificationDictionary[@"locators"] = DumpLocators(info.info.default_locators.unicast); + notificationDictionary[@(RTPSNotificationUserInfoProperties)] = propDict; + notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonDiscoveredParticipant); + notificationDictionary[@(RTPSNotificationUserInfoLocators)] = DumpLocators(info.info.default_locators.unicast); break; case ParticipantDiscoveryInfo::DROPPED_PARTICIPANT: logInfo(PARTICIPANT_LISTENER, "Participant '" << info.info.m_participantName << "' dropped") - notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonDroppedParticipant); + notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonDroppedParticipant); break; case ParticipantDiscoveryInfo::REMOVED_PARTICIPANT: logInfo(PARTICIPANT_LISTENER, "Participant '" << info.info.m_participantName << "' removed") - notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonRemovedParticipant); + notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonRemovedParticipant); break; case ParticipantDiscoveryInfo::CHANGED_QOS_PARTICIPANT: - notificationDictionary[@"reason"] = @(RTPSParticipantNotificationReasonChangedQosParticipant); + notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonChangedQosParticipant); break; } diff --git a/FastRTPSBridge/BridgedReaderListener.mm b/FastRTPSBridge/BridgedReaderListener.mm index d76480d..64775bc 100644 --- a/FastRTPSBridge/BridgedReaderListener.mm +++ b/FastRTPSBridge/BridgedReaderListener.mm @@ -34,27 +34,27 @@ void BridgedReaderListener::on_liveliness_changed(RTPSReader *reader, const LivelinessChangedStatus &status) { NSMutableDictionary *notificationDictionary = [[NSMutableDictionary alloc] init]; - notificationDictionary[@"topic"] = [[NSString alloc] initWithCString:topicName.c_str() encoding:NSUTF8StringEncoding]; - notificationDictionary[@"reason"] = @(RTPSReaderWriterNotificationReasonReaderLivelinessLost); + notificationDictionary[@(RTPSNotificationUserInfoTopic)] = [[NSString alloc] initWithCString:topicName.c_str() encoding:NSUTF8StringEncoding]; + notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSReaderWriterNotificationReasonReaderLivelinessLost); [NSNotificationCenter.defaultCenter postNotificationName:RTPSReaderWriterNotificationName object:NULL userInfo:notificationDictionary]; - logWarning(READER_LISTENER, "Liveliness: " << status.alive_count_change) + logInfo(READER_LISTENER, "Liveliness: " << status.alive_count_change) } void BridgedReaderListener::onReaderMatched(RTPSReader* reader, MatchingInfo& info) { NSMutableDictionary *notificationDictionary = [[NSMutableDictionary alloc] init]; - notificationDictionary[@"topic"] = [[NSString alloc] initWithCString:topicName.c_str() encoding:NSUTF8StringEncoding]; + notificationDictionary[@(RTPSNotificationUserInfoTopic)] = [[NSString alloc] initWithCString:topicName.c_str() encoding:NSUTF8StringEncoding]; switch (info.status) { case MATCHED_MATCHING: n_matched++; - notificationDictionary[@"reason"] = @(RTPSReaderWriterNotificationReasonReaderMatchedMatching); - logWarning(READER_LISTENER, "\tReader matched:" << topicName << " count: " << n_matched) + notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSReaderWriterNotificationReasonReaderMatchedMatching); + logInfo(READER_LISTENER, "\tReader matched:" << topicName << " count: " << n_matched) break; case REMOVED_MATCHING: n_matched--; - notificationDictionary[@"reason"] = @(RTPSReaderWriterNotificationReasonReaderRemovedMatching); - logWarning(READER_LISTENER, "\tReader remove matched:" << topicName << " count: " << n_matched) + notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSReaderWriterNotificationReasonReaderRemovedMatching); + logInfo(READER_LISTENER, "\tReader remove matched:" << topicName << " count: " << n_matched) break; } [NSNotificationCenter.defaultCenter postNotificationName:RTPSReaderWriterNotificationName object:NULL userInfo:notificationDictionary]; diff --git a/FastRTPSBridge/BridgedWriterListener.mm b/FastRTPSBridge/BridgedWriterListener.mm index 3567510..79a02e0 100644 --- a/FastRTPSBridge/BridgedWriterListener.mm +++ b/FastRTPSBridge/BridgedWriterListener.mm @@ -23,27 +23,27 @@ void BridgedWriterListener::on_liveliness_lost(RTPSWriter* writer, const LivelinessLostStatus& status) { NSMutableDictionary *notificationDictionary = [[NSMutableDictionary alloc] init]; - notificationDictionary[@"topic"] = [[NSString alloc] initWithCString:topicName.c_str() encoding:NSUTF8StringEncoding]; - notificationDictionary[@"reason"] = @(RTPSReaderWriterNotificationReasonWriterLivelinessLost); + notificationDictionary[@(RTPSNotificationUserInfoTopic)] = [[NSString alloc] initWithCString:topicName.c_str() encoding:NSUTF8StringEncoding]; + notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSReaderWriterNotificationReasonWriterLivelinessLost); [NSNotificationCenter.defaultCenter postNotificationName:RTPSReaderWriterNotificationName object:NULL userInfo:notificationDictionary]; - logWarning(WRITER_LISTENER, "Writer liveliness lost:" << status.total_count); + logInfo(WRITER_LISTENER, "Writer liveliness lost:" << status.total_count); } void BridgedWriterListener::onWriterMatched(RTPSWriter* writer, MatchingInfo& info) { NSMutableDictionary *notificationDictionary = [[NSMutableDictionary alloc] init]; - notificationDictionary[@"topic"] = [[NSString alloc] initWithCString:topicName.c_str() encoding:NSUTF8StringEncoding]; + notificationDictionary[@(RTPSNotificationUserInfoTopic)] = [[NSString alloc] initWithCString:topicName.c_str() encoding:NSUTF8StringEncoding]; switch (info.status) { case MATCHED_MATCHING: n_matched++; - notificationDictionary[@"reason"] = @(RTPSReaderWriterNotificationReasonWriterMatchedMatching); - logWarning(WRITER_LISTENER, "\tWriter matched:" << topicName << " count: " << n_matched) + notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSReaderWriterNotificationReasonWriterMatchedMatching); + logInfo(WRITER_LISTENER, "\tWriter matched:" << topicName << " count: " << n_matched) break; case REMOVED_MATCHING: n_matched--; - notificationDictionary[@"reason"] = @(RTPSReaderWriterNotificationReasonWriterRemovedMatching); - logWarning(WRITER_LISTENER, "\tWriter remove matched:" << topicName << " count: " << n_matched) + notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSReaderWriterNotificationReasonWriterRemovedMatching); + logInfo(WRITER_LISTENER, "\tWriter remove matched:" << topicName << " count: " << n_matched) break; } [NSNotificationCenter.defaultCenter postNotificationName:RTPSReaderWriterNotificationName object:NULL userInfo:notificationDictionary]; diff --git a/FastRTPSBridge/FastRTPSNotifications.swift b/FastRTPSBridge/FastRTPSNotifications.swift index 634a8e6..f905db2 100644 --- a/FastRTPSBridge/FastRTPSNotifications.swift +++ b/FastRTPSBridge/FastRTPSNotifications.swift @@ -35,3 +35,12 @@ public enum RTPSReaderWriterNotificationReason: Int { case writerLivelinessLost } +@objc +public enum RTPSNotificationUserInfo: Int { + case participant + case reason + case topic + case locators + case properties + case typeName +} From b883a7388bbeb7684a64a65cda54664277450aa8 Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Sun, 10 Nov 2019 22:22:06 +0300 Subject: [PATCH 10/20] Refactoring BridgedParticipant createRTPSParticipant: add ipv4 address, setPartition addReader, addWriteer: initialReservedCaches = 5, set partition name --- FastRTPSBridge/BridgedParticipant.h | 4 +++- FastRTPSBridge/BridgedParticipant.mm | 32 +++++++++++++++++----------- FastRTPSBridge/FastRTPSBridge.h | 3 ++- FastRTPSBridge/FastRTPSBridge.mm | 9 ++++++-- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/FastRTPSBridge/BridgedParticipant.h b/FastRTPSBridge/BridgedParticipant.h index 33809fb..a490b0f 100644 --- a/FastRTPSBridge/BridgedParticipant.h +++ b/FastRTPSBridge/BridgedParticipant.h @@ -44,11 +44,13 @@ class BridgedParticipant virtual ~BridgedParticipant(); eprosima::fastrtps::rtps::RTPSParticipant* mp_participant; BridgedParticipantListener* mp_listener; + std::string partitionName; std::map readerList; std::map writerList; - bool startRTPS(const char* name); + bool createParticipant(const char* name, const char *ipv4); + void setPartition(const char* name) { partitionName = std::string(name); } bool addReader(const char* name, const char* dataType, const bool keyed, diff --git a/FastRTPSBridge/BridgedParticipant.mm b/FastRTPSBridge/BridgedParticipant.mm index 32bd6e2..2c61008 100644 --- a/FastRTPSBridge/BridgedParticipant.mm +++ b/FastRTPSBridge/BridgedParticipant.mm @@ -26,14 +26,15 @@ BridgedParticipant::BridgedParticipant(): mp_participant(nullptr), -mp_listener(nullptr) +mp_listener(nullptr), +partitionName("*") { } BridgedParticipant::~BridgedParticipant() { - mp_participant->stopRTPSParticipantAnnouncement(); logInfo(ROV_PARTICIPANT, "Delete participant") + mp_participant->stopRTPSParticipantAnnouncement(); resignAll(); RTPSDomain::removeRTPSParticipant(mp_participant); delete mp_listener; @@ -60,9 +61,8 @@ writerList.clear(); } -bool BridgedParticipant::startRTPS(const char* name) +bool BridgedParticipant::createParticipant(const char* name, const char *ipv4) { - //CREATE PARTICIPANT RTPSParticipantAttributes PParam; PParam.builtin.use_WriterLivelinessProtocol = true; PParam.builtin.discovery_config.discoveryProtocol = eprosima::fastrtps::rtps::DiscoveryProtocol::SIMPLE; @@ -71,8 +71,14 @@ PParam.builtin.readerHistoryMemoryPolicy = PREALLOCATED_WITH_REALLOC_MEMORY_MODE; PParam.builtin.writerHistoryMemoryPolicy = PREALLOCATED_WITH_REALLOC_MEMORY_MODE; PParam.builtin.domainId = 0; - PParam.setName("TridentVideoViewer"); - + PParam.setName(name); + + if (ipv4 != nullptr) { + Locator_t locator; + IPLocator::setIPv4(locator, ipv4); + PParam.builtin.initialPeersList.push_back(locator); + } + mp_listener = new BridgedParticipantListener(); mp_participant = RTPSDomain::createParticipant(PParam, mp_listener); if (mp_participant == nullptr) @@ -92,14 +98,14 @@ // aready registered return false; } - //CREATE READER ReaderAttributes readerAttributes; readerAttributes.endpoint.topicKind = tKind; auto listener = new BridgedReaderListener(name, payloadDecoder); - //CREATE READERHISTORY + HistoryAttributes hatt; - hatt.payloadMaxSize = 10000; hatt.memoryPolicy = DYNAMIC_RESERVE_MEMORY_MODE; + hatt.payloadMaxSize = 1000; + hatt.initialReservedCaches = 5; hatt.maximumReservedCaches = 0; auto history = new ReaderHistory(hatt); auto reader = RTPSDomain::createRTPSReader(mp_participant, readerAttributes, history, listener); @@ -117,7 +123,7 @@ TopicAttributes Tatt(name, dataType, tKind); ReaderQos Rqos; - Rqos.m_partition.push_back("*"); + Rqos.m_partition.push_back(partitionName.c_str()); auto rezult = mp_participant->registerReader(reader, Tatt, Rqos); if (!rezult) { RTPSDomain::removeRTPSReader(reader); @@ -159,10 +165,10 @@ watt.endpoint.reliabilityKind = BEST_EFFORT; watt.endpoint.topicKind = tKind; auto listener = new BridgedWriterListener(name); - //CREATE WRITERHISTORY HistoryAttributes hatt; -// hatt.payloadMaxSize = 10000; hatt.memoryPolicy = DYNAMIC_RESERVE_MEMORY_MODE; + hatt.payloadMaxSize = 1000; + hatt.initialReservedCaches = 5; hatt.maximumReservedCaches = 0; auto history = new WriterHistory(hatt); auto writer = RTPSDomain::createRTPSWriter(mp_participant, watt, history, listener); @@ -180,7 +186,7 @@ TopicAttributes Tatt(name, dataType, tKind); WriterQos Wqos; - Wqos.m_partition.push_back("*"); + Wqos.m_partition.push_back(partitionName.c_str()); Wqos.m_disablePositiveACKs.enabled = true; auto rezult = mp_participant->registerWriter(writer, Tatt, Wqos); if (!rezult) { diff --git a/FastRTPSBridge/FastRTPSBridge.h b/FastRTPSBridge/FastRTPSBridge.h index 4a4d0df..b8b385d 100644 --- a/FastRTPSBridge/FastRTPSBridge.h +++ b/FastRTPSBridge/FastRTPSBridge.h @@ -29,7 +29,8 @@ typedef NS_CLOSED_ENUM(NSInteger, LogLevel) { - (bool)removeWriterWithTopicName:(NSString *)topicName; - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data key: (NSData*) key; - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data; -- (bool)createRTPSParticipantWithName:(NSString *)name; +- (bool)createRTPSParticipantWithName:(NSString *)name ipv4:(NSString *) ipv4; +- (void)setPartition:(NSString *)name; - (void)stopRTPS; - (void)resignAll; diff --git a/FastRTPSBridge/FastRTPSBridge.mm b/FastRTPSBridge/FastRTPSBridge.mm index 88efd8b..9ccbfdb 100644 --- a/FastRTPSBridge/FastRTPSBridge.mm +++ b/FastRTPSBridge/FastRTPSBridge.mm @@ -82,8 +82,13 @@ - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data key: (NSData static_cast(key.length)); } -- (bool)createRTPSParticipantWithName:(NSString *)name { - return participant->startRTPS([name cStringUsingEncoding:NSUTF8StringEncoding]); +- (bool)createRTPSParticipantWithName:(NSString *)name ipv4: (NSString *) ipv4 { + return participant->createParticipant([name cStringUsingEncoding:NSUTF8StringEncoding], + [ipv4 cStringUsingEncoding:NSUTF8StringEncoding]); +} + +- (void)setPartition:(NSString *) name { + participant->setPartition([name cStringUsingEncoding:NSUTF8StringEncoding]); } - (void)stopRTPS { From b71be9f204af4aeed771580ed2fd87349a9e0335 Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Sun, 10 Nov 2019 22:44:04 +0300 Subject: [PATCH 11/20] createRTPSParticipantWithName: make ipv4 param nullable --- FastRTPSBridge/FastRTPSBridge.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FastRTPSBridge/FastRTPSBridge.h b/FastRTPSBridge/FastRTPSBridge.h index b8b385d..24707b5 100644 --- a/FastRTPSBridge/FastRTPSBridge.h +++ b/FastRTPSBridge/FastRTPSBridge.h @@ -29,7 +29,7 @@ typedef NS_CLOSED_ENUM(NSInteger, LogLevel) { - (bool)removeWriterWithTopicName:(NSString *)topicName; - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data key: (NSData*) key; - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data; -- (bool)createRTPSParticipantWithName:(NSString *)name ipv4:(NSString *) ipv4; +- (bool)createRTPSParticipantWithName:(NSString *)name ipv4:(NSString* _Nullable) ipv4; - (void)setPartition:(NSString *)name; - (void)stopRTPS; - (void)resignAll; From 5b17c4e069e049a8cdb968ccd5d9b3bfb9961b7e Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Sun, 10 Nov 2019 22:47:35 +0300 Subject: [PATCH 12/20] Remove debug printing --- FastRTPSBridge/BridgedParticipantListener.mm | 10 ---------- FastRTPSBridge/BridgedReaderListener.mm | 3 --- FastRTPSBridge/BridgedWriterListener.mm | 3 --- 3 files changed, 16 deletions(-) diff --git a/FastRTPSBridge/BridgedParticipantListener.mm b/FastRTPSBridge/BridgedParticipantListener.mm index d0c1e50..7ab68fb 100644 --- a/FastRTPSBridge/BridgedParticipantListener.mm +++ b/FastRTPSBridge/BridgedParticipantListener.mm @@ -21,7 +21,6 @@ switch(info.status) { case ReaderDiscoveryInfo::DISCOVERED_READER: - logInfo(PARTICIPANT_LISTENER, "Reader for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' discovered"); notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonDiscoveredReader); notificationDictionary[@(RTPSNotificationUserInfoLocators)] = DumpLocators(info.info.remote_locators().unicast); break; @@ -29,7 +28,6 @@ notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonChangedQosReader); break; case ReaderDiscoveryInfo::REMOVED_READER: - logInfo(PARTICIPANT_LISTENER, "Reader for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' left the domain.") notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonRemovedReader); break; } @@ -46,7 +44,6 @@ switch(info.status) { case WriterDiscoveryInfo::DISCOVERED_WRITER: - logInfo(PARTICIPANT_LISTENER, "Writer for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' discovered"); notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonDiscoveredWriter); notificationDictionary[@(RTPSNotificationUserInfoLocators)] = DumpLocators(info.info.remote_locators().unicast); break; @@ -54,7 +51,6 @@ notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonChangedQosWriter); break; case WriterDiscoveryInfo::REMOVED_WRITER: - logInfo(PARTICIPANT_LISTENER, "Writer for topic '" << info.info.topicName() << "' type '" << info.info.typeName() << "' left the domain.") notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonRemovedWriter); break; } @@ -73,12 +69,10 @@ case LOCATOR_KIND_UDPv4: locatorString = [NSString stringWithFormat:@"%s:%d", inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)), locator->port]; [set addObject:locatorString]; - logInfo(PARTICIPANT_LISTENER, inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)) << ":" << locator->port); break; case LOCATOR_KIND_UDPv6: locatorString = [NSString stringWithFormat:@"%s:%d", inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)), locator->port]; [set addObject:locatorString]; - logInfo(PARTICIPANT_LISTENER, inet_ntop(AF_INET6, locator->address, addrString, sizeof(addrString)) << ":" << locator->port); break; default: break; @@ -99,24 +93,20 @@ switch(info.status) { case ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT: - logInfo(PARTICIPANT_LISTENER, "Participant '" << info.info.m_participantName << "' discovered") propDict = [[NSMutableDictionary alloc] init]; for (auto prop = properties.cbegin(); prop != properties.cend(); prop++) { key = [[NSString alloc] initWithCString:prop->first.c_str() encoding:NSUTF8StringEncoding]; value = [[NSString alloc] initWithCString:prop->second.c_str() encoding:NSUTF8StringEncoding]; propDict[key] = value; - logInfo(PARTICIPANT_LISTENER, prop->first << ":" << prop->second); } notificationDictionary[@(RTPSNotificationUserInfoProperties)] = propDict; notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonDiscoveredParticipant); notificationDictionary[@(RTPSNotificationUserInfoLocators)] = DumpLocators(info.info.default_locators.unicast); break; case ParticipantDiscoveryInfo::DROPPED_PARTICIPANT: - logInfo(PARTICIPANT_LISTENER, "Participant '" << info.info.m_participantName << "' dropped") notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonDroppedParticipant); break; case ParticipantDiscoveryInfo::REMOVED_PARTICIPANT: - logInfo(PARTICIPANT_LISTENER, "Participant '" << info.info.m_participantName << "' removed") notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonRemovedParticipant); break; case ParticipantDiscoveryInfo::CHANGED_QOS_PARTICIPANT: diff --git a/FastRTPSBridge/BridgedReaderListener.mm b/FastRTPSBridge/BridgedReaderListener.mm index 64775bc..abec6d8 100644 --- a/FastRTPSBridge/BridgedReaderListener.mm +++ b/FastRTPSBridge/BridgedReaderListener.mm @@ -37,7 +37,6 @@ notificationDictionary[@(RTPSNotificationUserInfoTopic)] = [[NSString alloc] initWithCString:topicName.c_str() encoding:NSUTF8StringEncoding]; notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSReaderWriterNotificationReasonReaderLivelinessLost); [NSNotificationCenter.defaultCenter postNotificationName:RTPSReaderWriterNotificationName object:NULL userInfo:notificationDictionary]; - logInfo(READER_LISTENER, "Liveliness: " << status.alive_count_change) } void BridgedReaderListener::onReaderMatched(RTPSReader* reader, MatchingInfo& info) @@ -49,12 +48,10 @@ case MATCHED_MATCHING: n_matched++; notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSReaderWriterNotificationReasonReaderMatchedMatching); - logInfo(READER_LISTENER, "\tReader matched:" << topicName << " count: " << n_matched) break; case REMOVED_MATCHING: n_matched--; notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSReaderWriterNotificationReasonReaderRemovedMatching); - logInfo(READER_LISTENER, "\tReader remove matched:" << topicName << " count: " << n_matched) break; } [NSNotificationCenter.defaultCenter postNotificationName:RTPSReaderWriterNotificationName object:NULL userInfo:notificationDictionary]; diff --git a/FastRTPSBridge/BridgedWriterListener.mm b/FastRTPSBridge/BridgedWriterListener.mm index 79a02e0..6ab9207 100644 --- a/FastRTPSBridge/BridgedWriterListener.mm +++ b/FastRTPSBridge/BridgedWriterListener.mm @@ -26,7 +26,6 @@ notificationDictionary[@(RTPSNotificationUserInfoTopic)] = [[NSString alloc] initWithCString:topicName.c_str() encoding:NSUTF8StringEncoding]; notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSReaderWriterNotificationReasonWriterLivelinessLost); [NSNotificationCenter.defaultCenter postNotificationName:RTPSReaderWriterNotificationName object:NULL userInfo:notificationDictionary]; - logInfo(WRITER_LISTENER, "Writer liveliness lost:" << status.total_count); } void BridgedWriterListener::onWriterMatched(RTPSWriter* writer, MatchingInfo& info) @@ -38,12 +37,10 @@ case MATCHED_MATCHING: n_matched++; notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSReaderWriterNotificationReasonWriterMatchedMatching); - logInfo(WRITER_LISTENER, "\tWriter matched:" << topicName << " count: " << n_matched) break; case REMOVED_MATCHING: n_matched--; notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSReaderWriterNotificationReasonWriterRemovedMatching); - logInfo(WRITER_LISTENER, "\tWriter remove matched:" << topicName << " count: " << n_matched) break; } [NSNotificationCenter.defaultCenter postNotificationName:RTPSReaderWriterNotificationName object:NULL userInfo:notificationDictionary]; From 49cad71ed5a4f7f9b1365396667139667449d190 Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Wed, 13 Nov 2019 00:37:14 +0300 Subject: [PATCH 13/20] Improve iOS build: Use standard polly version. Use static libs. --- FastRTPSBridge.xcodeproj/project.pbxproj | 38 ++++++++---------------- fastrtps_build_ios.sh | 16 +++++----- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/FastRTPSBridge.xcodeproj/project.pbxproj b/FastRTPSBridge.xcodeproj/project.pbxproj index cf93eea..7b33507 100644 --- a/FastRTPSBridge.xcodeproj/project.pbxproj +++ b/FastRTPSBridge.xcodeproj/project.pbxproj @@ -27,6 +27,9 @@ 0A71309B2363516700817593 /* BridgedReaderListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130932363516700817593 /* BridgedReaderListener.mm */; }; 0A71309C2363516700817593 /* FastRTPSBridge-Bridging-Header.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A7130942363516700817593 /* FastRTPSBridge-Bridging-Header.h */; }; 0A71309D2363516700817593 /* BridgedParticipant.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130952363516700817593 /* BridgedParticipant.mm */; }; + 0A84F9D2237B3D40009BBAD4 /* libfastcdr.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A84F9CF237B3D20009BBAD4 /* libfastcdr.a */; }; + 0A84F9D3237B3D4E009BBAD4 /* libfastrtps.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A84F9D0237B3D20009BBAD4 /* libfastrtps.a */; }; + 0A84F9D4237B3D4E009BBAD4 /* libfoonathan_memory-0.6.2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A84F9D1237B3D20009BBAD4 /* libfoonathan_memory-0.6.2.a */; }; 0A8A37E32366DC51008E8DC1 /* DDSType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130862363514900817593 /* DDSType.swift */; }; 0A8A37E42366DC51008E8DC1 /* PayloadDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130912363516700817593 /* PayloadDecoder.swift */; }; 0A8A37E52366DC51008E8DC1 /* FastRTPSBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0A7130852363514900817593 /* FastRTPSBridge.mm */; }; @@ -46,10 +49,6 @@ 0A969817236EEF0B00FF958F /* CDRCodable in Frameworks */ = {isa = PBXBuildFile; productRef = 0A969816236EEF0B00FF958F /* CDRCodable */; }; 0AC08A802375F61900A80C2E /* FastRTPSNotifications.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0AC08A7F2375F61900A80C2E /* FastRTPSNotifications.mm */; }; 0AC08A812375F61900A80C2E /* FastRTPSNotifications.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0AC08A7F2375F61900A80C2E /* FastRTPSNotifications.mm */; }; - 0AD993862366F76300D037A3 /* libfastcdr.1.0.10.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AD993842366F76300D037A3 /* libfastcdr.1.0.10.dylib */; }; - 0AD993872366F76300D037A3 /* libfastcdr.1.0.10.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 0AD993842366F76300D037A3 /* libfastcdr.1.0.10.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; - 0AD993882366F76300D037A3 /* libfastrtps.1.9.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AD993852366F76300D037A3 /* libfastrtps.1.9.1.dylib */; }; - 0AD993892366F76300D037A3 /* libfastrtps.1.9.1.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 0AD993852366F76300D037A3 /* libfastrtps.1.9.1.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -69,21 +68,6 @@ }; /* End PBXContainerItemProxy section */ -/* Begin PBXCopyFilesBuildPhase section */ - 0AD9938A2366F76300D037A3 /* Embed Libraries */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - 0AD993892366F76300D037A3 /* libfastrtps.1.9.1.dylib in Embed Libraries */, - 0AD993872366F76300D037A3 /* libfastcdr.1.0.10.dylib in Embed Libraries */, - ); - name = "Embed Libraries"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - /* Begin PBXFileReference section */ 0A2735AB2373385E00A877B0 /* libfastrtps.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfastrtps.a; path = build/osx/lib/libfastrtps.a; sourceTree = ""; }; 0A2735AD237338A900A877B0 /* libfastcdr.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfastcdr.a; path = build/osx/lib/libfastcdr.a; sourceTree = ""; }; @@ -107,11 +91,12 @@ 0A7130932363516700817593 /* BridgedReaderListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BridgedReaderListener.mm; sourceTree = ""; }; 0A7130942363516700817593 /* FastRTPSBridge-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "FastRTPSBridge-Bridging-Header.h"; sourceTree = ""; }; 0A7130952363516700817593 /* BridgedParticipant.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BridgedParticipant.mm; sourceTree = ""; }; + 0A84F9CF237B3D20009BBAD4 /* libfastcdr.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfastcdr.a; path = build/ios/lib/libfastcdr.a; sourceTree = ""; }; + 0A84F9D0237B3D20009BBAD4 /* libfastrtps.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfastrtps.a; path = build/ios/lib/libfastrtps.a; sourceTree = ""; }; + 0A84F9D1237B3D20009BBAD4 /* libfoonathan_memory-0.6.2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libfoonathan_memory-0.6.2.a"; path = "build/ios/lib/libfoonathan_memory-0.6.2.a"; sourceTree = ""; }; 0A8A37CF2366D469008E8DC1 /* fastrtps_build_ios.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = fastrtps_build_ios.sh; sourceTree = ""; }; 0A8A37DB2366DB1B008E8DC1 /* FastRTPSBridge.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FastRTPSBridge.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 0AC08A7F2375F61900A80C2E /* FastRTPSNotifications.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FastRTPSNotifications.mm; sourceTree = ""; }; - 0AD993842366F76300D037A3 /* libfastcdr.1.0.10.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfastcdr.1.0.10.dylib; path = build/ios/lib/libfastcdr.1.0.10.dylib; sourceTree = ""; }; - 0AD993852366F76300D037A3 /* libfastrtps.1.9.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfastrtps.1.9.1.dylib; path = build/ios/lib/libfastrtps.1.9.1.dylib; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -130,9 +115,10 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 0AD993882366F76300D037A3 /* libfastrtps.1.9.1.dylib in Frameworks */, - 0AD993862366F76300D037A3 /* libfastcdr.1.0.10.dylib in Frameworks */, + 0A84F9D4237B3D4E009BBAD4 /* libfoonathan_memory-0.6.2.a in Frameworks */, 0A969817236EEF0B00FF958F /* CDRCodable in Frameworks */, + 0A84F9D3237B3D4E009BBAD4 /* libfastrtps.a in Frameworks */, + 0A84F9D2237B3D40009BBAD4 /* libfastcdr.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -190,8 +176,9 @@ 0A2735AF237338BD00A877B0 /* libfoonathan_memory-0.6.2.a */, 0A2735AD237338A900A877B0 /* libfastcdr.a */, 0A2735AB2373385E00A877B0 /* libfastrtps.a */, - 0AD993842366F76300D037A3 /* libfastcdr.1.0.10.dylib */, - 0AD993852366F76300D037A3 /* libfastrtps.1.9.1.dylib */, + 0A84F9CF237B3D20009BBAD4 /* libfastcdr.a */, + 0A84F9D0237B3D20009BBAD4 /* libfastrtps.a */, + 0A84F9D1237B3D20009BBAD4 /* libfoonathan_memory-0.6.2.a */, ); name = Frameworks; sourceTree = ""; @@ -291,7 +278,6 @@ 0A8A37D72366DB1B008E8DC1 /* Sources */, 0A8A37D82366DB1B008E8DC1 /* Frameworks */, 0A8A37D92366DB1B008E8DC1 /* Resources */, - 0AD9938A2366F76300D037A3 /* Embed Libraries */, ); buildRules = ( ); diff --git a/fastrtps_build_ios.sh b/fastrtps_build_ios.sh index 351d39d..ee7eb20 100755 --- a/fastrtps_build_ios.sh +++ b/fastrtps_build_ios.sh @@ -9,22 +9,23 @@ echo "$1" # Build type export POLLY_IOS_DEVELOPMENT_TEAM=$DEVELOPMENT_TEAM if ! which polly > /dev/null; then - echo "error: polly is not installed. Vistit https://github.com/DimaRU/polly.git to learn more." + echo "error: polly is not installed. Vistit https://github.com/ruslo/polly to learn more." exit 1 fi -if [ ! -f "build/ios/lib/libfastrtps.1.dylib" ]; then +if [ ! -f "build/ios/lib/libfastrtps.a" ]; then if [ ! -d memory ]; then git clone --quiet --recurse-submodules -b ios $Foonathan_memory_repo memory fi rm -rf "$PROJECT_TEMP_DIR/memory" mkdir -p "$PROJECT_TEMP_DIR/memory" || true -polly.py --toolchain ios-13-1-dep-12-1-x86-64-arm64 \ ---verbose --install --ios-combined --ios-multiarch \ +polly.py --toolchain ios \ +--install --ios-combined --ios-multiarch \ --config Release \ --home memory \ --output "$PROJECT_TEMP_DIR/memory" \ --fwd CMAKE_CONFIGURATION_TYPES=Release \ +IOS_DEPLOYMENT_SDK_VERSION=$IPHONEOS_DEPLOYMENT_TARGET \ CMAKE_INSTALL_PREFIX=build/ios \ FOONATHAN_MEMORY_BUILD_EXAMPLES=OFF \ FOONATHAN_MEMORY_BUILD_TESTS=OFF \ @@ -35,13 +36,14 @@ if [ ! -d Fast-RTPS ]; then git clone --quiet --recurse-submodules $FastRTPS_repo Fast-RTPS fi mkdir -p "$PROJECT_TEMP_DIR/Fast-RTPS" || true -polly.py --toolchain ios-13-1-dep-12-1-x86-64-arm64 \ ---verbose --install --ios-combined --ios-multiarch \ +polly.py --toolchain ios \ +--install --ios-combined --ios-multiarch \ --config $1 \ --home Fast-RTPS \ --output "$PROJECT_TEMP_DIR/Fast-RTPS" \ --fwd CMAKE_CONFIGURATION_TYPES=$1 \ -BUILD_SHARED_LIBS=YES \ +IOS_DEPLOYMENT_SDK_VERSION=$IPHONEOS_DEPLOYMENT_TARGET \ +BUILD_SHARED_LIBS=NO \ EXPORT_FILE=NO \ CMAKE_INSTALL_PREFIX=build/ios \ foonathan_memory_DIR=build/ios/foonathan_memory/cmake \ From 3845d8c9d9842008a5b6267ea3f1ad71fbba5424 Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Wed, 20 Nov 2019 20:56:33 +0300 Subject: [PATCH 14/20] Refactoring and documentation --- FastRTPSBridge/BridgedParticipant.mm | 6 ++-- FastRTPSBridge/FastRTPSBridge.h | 2 +- FastRTPSBridge/FastRTPSBridge.mm | 50 +++++++++++++++++++++++----- 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/FastRTPSBridge/BridgedParticipant.mm b/FastRTPSBridge/BridgedParticipant.mm index 2c61008..3a49288 100644 --- a/FastRTPSBridge/BridgedParticipant.mm +++ b/FastRTPSBridge/BridgedParticipant.mm @@ -61,7 +61,7 @@ writerList.clear(); } -bool BridgedParticipant::createParticipant(const char* name, const char *ipv4) +bool BridgedParticipant::createParticipant(const char* name, const char *peerIPv4) { RTPSParticipantAttributes PParam; PParam.builtin.use_WriterLivelinessProtocol = true; @@ -73,9 +73,9 @@ PParam.builtin.domainId = 0; PParam.setName(name); - if (ipv4 != nullptr) { + if (peerIPv4 != nullptr) { Locator_t locator; - IPLocator::setIPv4(locator, ipv4); + IPLocator::setIPv4(locator, peerIPv4); PParam.builtin.initialPeersList.push_back(locator); } diff --git a/FastRTPSBridge/FastRTPSBridge.h b/FastRTPSBridge/FastRTPSBridge.h index 24707b5..c8717e4 100644 --- a/FastRTPSBridge/FastRTPSBridge.h +++ b/FastRTPSBridge/FastRTPSBridge.h @@ -29,7 +29,7 @@ typedef NS_CLOSED_ENUM(NSInteger, LogLevel) { - (bool)removeWriterWithTopicName:(NSString *)topicName; - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data key: (NSData*) key; - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data; -- (bool)createRTPSParticipantWithName:(NSString *)name ipv4:(NSString* _Nullable) ipv4; +- (bool)createRTPSParticipantWithName:(NSString *)name peerIPv4:(NSString* _Nullable) peerIPv4; - (void)setPartition:(NSString *)name; - (void)stopRTPS; - (void)resignAll; diff --git a/FastRTPSBridge/FastRTPSBridge.mm b/FastRTPSBridge/FastRTPSBridge.mm index 9ccbfdb..ecd0ab9 100644 --- a/FastRTPSBridge/FastRTPSBridge.mm +++ b/FastRTPSBridge/FastRTPSBridge.mm @@ -21,6 +21,11 @@ @interface FastRTPSBridge() @implementation FastRTPSBridge +/// Create instance, set FastRTPS log level +/// @param logLevel FastRTPS log level: +// * error +// * warning +// * info - (id)initWithLogLevel:(LogLevel)logLevel { if (!(self = [super init])) { return nil; @@ -45,6 +50,25 @@ - (id)initWithLogLevel:(LogLevel)logLevel { return self; } +/// Create RTPS paticipant and start listening +/// @param name Participant name +/// @param peerIPv4 peer IPv4 address (initially multicast) +- (bool)createRTPSParticipantWithName:(NSString *)name peerLocator: (NSString *)peerIPv4 { + return participant->createParticipant([name cStringUsingEncoding:NSUTF8StringEncoding], + [peerIPv4 cStringUsingEncoding:NSUTF8StringEncoding]); +} + +/// Set partition name for readers and writers +/// @param name partition name (initially "*") +- (void)setPartition:(NSString *) name { + participant->setPartition([name cStringUsingEncoding:NSUTF8StringEncoding]); +} + +/// Rerister RTPS reader +/// @param topicName topic name +/// @param typeName DDS type name +/// @param keyed true if keyed +/// @param payloadDecoder called when sample arrived - (bool)registerReaderWithTopicName:(NSString *)topicName typeName:(NSString*)typeName keyed:(bool) keyed payloadDecoder: (NSObject*) payloadDecoder { return participant->addReader([topicName cStringUsingEncoding:NSUTF8StringEncoding], @@ -53,20 +77,31 @@ - (bool)registerReaderWithTopicName:(NSString *)topicName typeName:(NSString*)ty payloadDecoder); } +/// Remote registered RTPS reader +/// @param topicName topic name - (bool)removeReaderWithTopicName:(NSString *)topicName { return participant->removeReader([topicName cStringUsingEncoding:NSUTF8StringEncoding]); } +/// Register RTPS writer +/// @param topicName topic name +/// @param typeName DDS type name +/// @param keyed true if keyed - (bool)registerWriterWithTopicName:(NSString *)topicName typeName:(NSString*)typeName keyed:(bool) keyed { return participant->addWriter([topicName cStringUsingEncoding:NSUTF8StringEncoding], [typeName cStringUsingEncoding:NSUTF8StringEncoding], keyed); } +/// Remote registered RTPS writer +/// @param topicName topic name - (bool)removeWriterWithTopicName:(NSString *)topicName { return participant->removeReader([topicName cStringUsingEncoding:NSUTF8StringEncoding]); } +/// Send unkeyed sample with RTPS writer +/// @param topicName writer topic name +/// @param data sample data - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data { return participant->send([topicName cStringUsingEncoding:NSUTF8StringEncoding], static_cast(data.bytes), @@ -74,6 +109,10 @@ - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data { NULL, 0); } +/// Send keyed sample with RTPS writer +/// @param topicName writer topic name +/// @param data sample data +/// @param key sample key - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data key: (NSData*) key { return participant->send([topicName cStringUsingEncoding:NSUTF8StringEncoding], static_cast(data.bytes), @@ -82,20 +121,13 @@ - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data key: (NSData static_cast(key.length)); } -- (bool)createRTPSParticipantWithName:(NSString *)name ipv4: (NSString *) ipv4 { - return participant->createParticipant([name cStringUsingEncoding:NSUTF8StringEncoding], - [ipv4 cStringUsingEncoding:NSUTF8StringEncoding]); -} - -- (void)setPartition:(NSString *) name { - participant->setPartition([name cStringUsingEncoding:NSUTF8StringEncoding]); -} - +/// Remove all RTPS readers and writers, stop and delete participand - (void)stopRTPS { participant->resignAll(); delete participant; } +/// Remove all RTPS readers and writers - (void)resignAll { participant->resignAll(); } From e18b93c442e73276264b3200ca28c5b5f9fbf456 Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Fri, 22 Nov 2019 21:32:31 +0300 Subject: [PATCH 15/20] Move documentation comments to header --- FastRTPSBridge/FastRTPSBridge.h | 46 ++++++++++++++++++++++++++++++-- FastRTPSBridge/FastRTPSBridge.mm | 29 +------------------- 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/FastRTPSBridge/FastRTPSBridge.h b/FastRTPSBridge/FastRTPSBridge.h index c8717e4..1b439b4 100644 --- a/FastRTPSBridge/FastRTPSBridge.h +++ b/FastRTPSBridge/FastRTPSBridge.h @@ -22,16 +22,58 @@ typedef NS_CLOSED_ENUM(NSInteger, LogLevel) { error, warning, info }; +/// Create instance, set FastRTPS log level +/// @param logLevel FastRTPS log level: +// * error +// * warning +// * info - (id)initWithLogLevel:(LogLevel)logLevel; + +/// Create RTPS paticipant and start listening +/// @param name Participant name +/// @param peerIPv4 peer IPv4 address (initially multicast) +- (bool)createRTPSParticipantWithName:(NSString *)name peerIPv4:(NSString* _Nullable) peerIPv4; + +/// Set partition name for readers and writers +/// @param name partition name (initially "*") +- (void)setPartition:(NSString *)name; + +/// Rerister RTPS reader +/// @param topicName topic name +/// @param typeName DDS type name +/// @param keyed true if keyed +/// @param payloadDecoder called when sample arrived - (bool)registerReaderWithTopicName:(NSString *)topicName typeName:(NSString*)typeName keyed:(bool) keyed payloadDecoder: (NSObject*) payloadDecoder; + +/// Remote registered RTPS reader +/// @param topicName topic name - (bool)removeReaderWithTopicName:(NSString *)topicName; + +/// Register RTPS writer +/// @param topicName topic name +/// @param typeName DDS type name +/// @param keyed true if keyed - (bool)registerWriterWithTopicName:(NSString *)topicName typeName:(NSString*)typeName keyed:(bool) keyed; + +/// Remote registered RTPS writer +/// @param topicName topic name - (bool)removeWriterWithTopicName:(NSString *)topicName; + +/// Send unkeyed change with RTPS writer +/// @param topicName writer topic name +/// @param data change data - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data key: (NSData*) key; + +/// Send keyed change with RTPS writer +/// @param topicName writer topic name +/// @param data change data +/// @param key sample key - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data; -- (bool)createRTPSParticipantWithName:(NSString *)name peerIPv4:(NSString* _Nullable) peerIPv4; -- (void)setPartition:(NSString *)name; + +/// Remove all RTPS readers and writers, stop and delete participant - (void)stopRTPS; + +/// Remove all RTPS readers and writers - (void)resignAll; @end diff --git a/FastRTPSBridge/FastRTPSBridge.mm b/FastRTPSBridge/FastRTPSBridge.mm index ecd0ab9..206c106 100644 --- a/FastRTPSBridge/FastRTPSBridge.mm +++ b/FastRTPSBridge/FastRTPSBridge.mm @@ -50,25 +50,15 @@ - (id)initWithLogLevel:(LogLevel)logLevel { return self; } -/// Create RTPS paticipant and start listening -/// @param name Participant name -/// @param peerIPv4 peer IPv4 address (initially multicast) -- (bool)createRTPSParticipantWithName:(NSString *)name peerLocator: (NSString *)peerIPv4 { +- (bool)createRTPSParticipantWithName:(NSString *)name peerIPv4: (NSString *)peerIPv4 { return participant->createParticipant([name cStringUsingEncoding:NSUTF8StringEncoding], [peerIPv4 cStringUsingEncoding:NSUTF8StringEncoding]); } -/// Set partition name for readers and writers -/// @param name partition name (initially "*") - (void)setPartition:(NSString *) name { participant->setPartition([name cStringUsingEncoding:NSUTF8StringEncoding]); } -/// Rerister RTPS reader -/// @param topicName topic name -/// @param typeName DDS type name -/// @param keyed true if keyed -/// @param payloadDecoder called when sample arrived - (bool)registerReaderWithTopicName:(NSString *)topicName typeName:(NSString*)typeName keyed:(bool) keyed payloadDecoder: (NSObject*) payloadDecoder { return participant->addReader([topicName cStringUsingEncoding:NSUTF8StringEncoding], @@ -77,31 +67,20 @@ - (bool)registerReaderWithTopicName:(NSString *)topicName typeName:(NSString*)ty payloadDecoder); } -/// Remote registered RTPS reader -/// @param topicName topic name - (bool)removeReaderWithTopicName:(NSString *)topicName { return participant->removeReader([topicName cStringUsingEncoding:NSUTF8StringEncoding]); } -/// Register RTPS writer -/// @param topicName topic name -/// @param typeName DDS type name -/// @param keyed true if keyed - (bool)registerWriterWithTopicName:(NSString *)topicName typeName:(NSString*)typeName keyed:(bool) keyed { return participant->addWriter([topicName cStringUsingEncoding:NSUTF8StringEncoding], [typeName cStringUsingEncoding:NSUTF8StringEncoding], keyed); } -/// Remote registered RTPS writer -/// @param topicName topic name - (bool)removeWriterWithTopicName:(NSString *)topicName { return participant->removeReader([topicName cStringUsingEncoding:NSUTF8StringEncoding]); } -/// Send unkeyed sample with RTPS writer -/// @param topicName writer topic name -/// @param data sample data - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data { return participant->send([topicName cStringUsingEncoding:NSUTF8StringEncoding], static_cast(data.bytes), @@ -109,10 +88,6 @@ - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data { NULL, 0); } -/// Send keyed sample with RTPS writer -/// @param topicName writer topic name -/// @param data sample data -/// @param key sample key - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data key: (NSData*) key { return participant->send([topicName cStringUsingEncoding:NSUTF8StringEncoding], static_cast(data.bytes), @@ -121,13 +96,11 @@ - (bool)sendWithTopicName:(NSString *)topicName data:(NSData*) data key: (NSData static_cast(key.length)); } -/// Remove all RTPS readers and writers, stop and delete participand - (void)stopRTPS { participant->resignAll(); delete participant; } -/// Remove all RTPS readers and writers - (void)resignAll { participant->resignAll(); } From 8c2c0dc1d2a97654f82c4cb07f8b9a21ace59ce0 Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Fri, 22 Nov 2019 21:33:35 +0300 Subject: [PATCH 16/20] Change FastRTPS build base --- FastRTPSBridge.xcodeproj/project.pbxproj | 4 ++-- fastrtps_build_ios.sh | 4 ++-- fastrtps_build_osx.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/FastRTPSBridge.xcodeproj/project.pbxproj b/FastRTPSBridge.xcodeproj/project.pbxproj index 7b33507..9dc7fb0 100644 --- a/FastRTPSBridge.xcodeproj/project.pbxproj +++ b/FastRTPSBridge.xcodeproj/project.pbxproj @@ -475,7 +475,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; - FastRTPS_repo = "https://github.com/DimaRU/Fast-RTPS.git"; + FastRTPS_repo = "-b 1.9.x https://github.com/eProsima/Fast-RTPS.git"; Foonathan_memory_repo = "https://github.com/DimaRU/memory.git"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; @@ -546,7 +546,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; - FastRTPS_repo = "https://github.com/DimaRU/Fast-RTPS.git"; + FastRTPS_repo = "-b 1.9.x https://github.com/eProsima/Fast-RTPS.git"; Foonathan_memory_repo = "https://github.com/DimaRU/memory.git"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; diff --git a/fastrtps_build_ios.sh b/fastrtps_build_ios.sh index ee7eb20..020545a 100755 --- a/fastrtps_build_ios.sh +++ b/fastrtps_build_ios.sh @@ -15,7 +15,7 @@ fi if [ ! -f "build/ios/lib/libfastrtps.a" ]; then if [ ! -d memory ]; then -git clone --quiet --recurse-submodules -b ios $Foonathan_memory_repo memory +git clone --quiet --recurse-submodules --depth 1 -b ios $Foonathan_memory_repo memory fi rm -rf "$PROJECT_TEMP_DIR/memory" mkdir -p "$PROJECT_TEMP_DIR/memory" || true @@ -33,7 +33,7 @@ FOONATHAN_MEMORY_BUILD_TOOLS=OFF rm -rf $PROJECT_TEMP_DIR/Fast-RTPS if [ ! -d Fast-RTPS ]; then -git clone --quiet --recurse-submodules $FastRTPS_repo Fast-RTPS +git clone --quiet --recurse-submodules --depth 1 $FastRTPS_repo Fast-RTPS fi mkdir -p "$PROJECT_TEMP_DIR/Fast-RTPS" || true polly.py --toolchain ios \ diff --git a/fastrtps_build_osx.sh b/fastrtps_build_osx.sh index 9b149b3..04f1d54 100755 --- a/fastrtps_build_osx.sh +++ b/fastrtps_build_osx.sh @@ -8,7 +8,7 @@ set -x echo "$1" # Build type if [ ! -f "build/osx/lib/libfastrtps.a" ]; then if [ ! -d memory ]; then -git clone --quiet --recurse-submodules -b ios $Foonathan_memory_repo memory +git clone --quiet --recurse-submodules --depth 1 -b ios $Foonathan_memory_repo memory fi rm -rf "$PROJECT_TEMP_DIR/memory" mkdir -p "$PROJECT_TEMP_DIR/memory" || true @@ -21,7 +21,7 @@ cmake --build "$PROJECT_TEMP_DIR/memory" --target install rm -rf "$PROJECT_TEMP_DIR/Fast-RTPS" if [ ! -d Fast-RTPS ]; then -git clone --quiet --recurse-submodules $FastRTPS_repo Fast-RTPS +git clone --quiet --recurse-submodules --depth 1 $FastRTPS_repo Fast-RTPS fi mkdir -p "$PROJECT_TEMP_DIR/Fast-RTPS" || true cmake -SFast-RTPS -B"$PROJECT_TEMP_DIR/Fast-RTPS" \ From 4f6df5e444e2c96e1436977160272232c1c9f623 Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Wed, 4 Dec 2019 23:26:28 +0300 Subject: [PATCH 17/20] Add metaLocators to participant notification info. getIPv4address function. --- FastRTPSBridge/BridgedParticipant.h | 1 + FastRTPSBridge/BridgedParticipant.mm | 53 +++++++++++++++----- FastRTPSBridge/BridgedParticipantListener.mm | 1 + FastRTPSBridge/FastRTPSBridge.h | 3 ++ FastRTPSBridge/FastRTPSBridge.mm | 8 ++- FastRTPSBridge/FastRTPSNotifications.swift | 1 + fastrtps_build_osx.sh | 2 +- 7 files changed, 54 insertions(+), 15 deletions(-) diff --git a/FastRTPSBridge/BridgedParticipant.h b/FastRTPSBridge/BridgedParticipant.h index a490b0f..aeb4fed 100644 --- a/FastRTPSBridge/BridgedParticipant.h +++ b/FastRTPSBridge/BridgedParticipant.h @@ -63,4 +63,5 @@ class BridgedParticipant bool removeWriter(const char* name); bool send(const char* name, const uint8_t* data, uint32_t length, const void* key, uint32_t keyLength); void resignAll(); + static NSSet* DumpLocators(eprosima::fastrtps::rtps::LocatorList_t locators); }; diff --git a/FastRTPSBridge/BridgedParticipant.mm b/FastRTPSBridge/BridgedParticipant.mm index 3a49288..389a6a2 100644 --- a/FastRTPSBridge/BridgedParticipant.mm +++ b/FastRTPSBridge/BridgedParticipant.mm @@ -20,6 +20,9 @@ #include #include #include +#include +#include +#include using namespace eprosima::fastrtps; using namespace eprosima::fastrtps::rtps; @@ -63,24 +66,25 @@ bool BridgedParticipant::createParticipant(const char* name, const char *peerIPv4) { - RTPSParticipantAttributes PParam; - PParam.builtin.use_WriterLivelinessProtocol = true; - PParam.builtin.discovery_config.discoveryProtocol = eprosima::fastrtps::rtps::DiscoveryProtocol::SIMPLE; - PParam.builtin.discovery_config.leaseDuration_announcementperiod.seconds = 1; - PParam.builtin.discovery_config.leaseDuration.seconds = 20; - PParam.builtin.readerHistoryMemoryPolicy = PREALLOCATED_WITH_REALLOC_MEMORY_MODE; - PParam.builtin.writerHistoryMemoryPolicy = PREALLOCATED_WITH_REALLOC_MEMORY_MODE; - PParam.builtin.domainId = 0; - PParam.setName(name); + RTPSParticipantAttributes pattr; + pattr.builtin.use_WriterLivelinessProtocol = true; + pattr.builtin.discovery_config.discoveryProtocol = eprosima::fastrtps::rtps::DiscoveryProtocol::SIMPLE; + pattr.builtin.discovery_config.leaseDuration_announcementperiod.seconds = 1; + pattr.builtin.discovery_config.leaseDuration.seconds = 10; + pattr.builtin.discovery_config.ignoreParticipantFlags = FILTER_SAME_PROCESS; + pattr.builtin.readerHistoryMemoryPolicy = PREALLOCATED_WITH_REALLOC_MEMORY_MODE; + pattr.builtin.writerHistoryMemoryPolicy = PREALLOCATED_WITH_REALLOC_MEMORY_MODE; + pattr.builtin.domainId = 0; + pattr.setName(name); if (peerIPv4 != nullptr) { Locator_t locator; IPLocator::setIPv4(locator, peerIPv4); - PParam.builtin.initialPeersList.push_back(locator); + pattr.builtin.initialPeersList.push_back(locator); } mp_listener = new BridgedParticipantListener(); - mp_participant = RTPSDomain::createParticipant(PParam, mp_listener); + mp_participant = RTPSDomain::createParticipant(pattr, mp_listener); if (mp_participant == nullptr) return false; @@ -114,13 +118,13 @@ delete history; return false; } - + auto readerInfo = new ReaderInfo; readerInfo->reader = reader; readerInfo->history = history; readerInfo->listener = listener; readerList[topicName] = readerInfo; - + TopicAttributes Tatt(name, dataType, tKind); ReaderQos Rqos; Rqos.m_partition.push_back(partitionName.c_str()); @@ -253,3 +257,26 @@ return true; } + +NSSet* BridgedParticipant::DumpLocators(LocatorList_t locators) +{ + char addrString[INET6_ADDRSTRLEN+1]; + NSMutableSet *set = [[NSMutableSet alloc] init]; + NSString *locatorString; + + for (auto locator = locators.begin(); locator != locators.end(); locator++) { + switch (locator->kind) { + case LOCATOR_KIND_UDPv4: + locatorString = [NSString stringWithFormat:@"%s:%d", inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)), locator->port]; + [set addObject:locatorString]; + break; + case LOCATOR_KIND_UDPv6: + locatorString = [NSString stringWithFormat:@"%s:%d", inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)), locator->port]; + [set addObject:locatorString]; + break; + default: + break; + } + } + return set; +} diff --git a/FastRTPSBridge/BridgedParticipantListener.mm b/FastRTPSBridge/BridgedParticipantListener.mm index 7ab68fb..fdbce81 100644 --- a/FastRTPSBridge/BridgedParticipantListener.mm +++ b/FastRTPSBridge/BridgedParticipantListener.mm @@ -102,6 +102,7 @@ notificationDictionary[@(RTPSNotificationUserInfoProperties)] = propDict; notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonDiscoveredParticipant); notificationDictionary[@(RTPSNotificationUserInfoLocators)] = DumpLocators(info.info.default_locators.unicast); + notificationDictionary[@(RTPSNotificationUserInfoMetaLocators)] = DumpLocators(info.info.metatraffic_locators.unicast); break; case ParticipantDiscoveryInfo::DROPPED_PARTICIPANT: notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonDroppedParticipant); diff --git a/FastRTPSBridge/FastRTPSBridge.h b/FastRTPSBridge/FastRTPSBridge.h index 1b439b4..9c8acc0 100644 --- a/FastRTPSBridge/FastRTPSBridge.h +++ b/FastRTPSBridge/FastRTPSBridge.h @@ -76,6 +76,9 @@ typedef NS_CLOSED_ENUM(NSInteger, LogLevel) { /// Remove all RTPS readers and writers - (void)resignAll; +/// Return all interfaces IPv4 addresses +- (NSSet*)getIP4Address; + @end NS_ASSUME_NONNULL_END diff --git a/FastRTPSBridge/FastRTPSBridge.mm b/FastRTPSBridge/FastRTPSBridge.mm index 206c106..abad897 100644 --- a/FastRTPSBridge/FastRTPSBridge.mm +++ b/FastRTPSBridge/FastRTPSBridge.mm @@ -7,6 +7,7 @@ #import "BridgedParticipant.h" #include #include "CustomLogConsumer.h" +#include using namespace eprosima; using namespace fastrtps; @@ -44,7 +45,7 @@ - (id)initWithLogLevel:(LogLevel)logLevel { Log::SetVerbosity(Log::Kind::Info); break; } - Log::ReportFilenames(false); + Log::ReportFilenames(true); participant = new BridgedParticipant(); return self; @@ -105,4 +106,9 @@ - (void)resignAll { participant->resignAll(); } +- (NSSet*)getIP4Address { + eprosima::fastrtps::rtps::LocatorList_t locators; + eprosima::fastrtps::rtps::IPFinder::getIP4Address(&locators); + return BridgedParticipant::DumpLocators(locators); +} @end diff --git a/FastRTPSBridge/FastRTPSNotifications.swift b/FastRTPSBridge/FastRTPSNotifications.swift index f905db2..03bce6e 100644 --- a/FastRTPSBridge/FastRTPSNotifications.swift +++ b/FastRTPSBridge/FastRTPSNotifications.swift @@ -41,6 +41,7 @@ public enum RTPSNotificationUserInfo: Int { case reason case topic case locators + case metaLocators case properties case typeName } diff --git a/fastrtps_build_osx.sh b/fastrtps_build_osx.sh index 04f1d54..d31e2b5 100755 --- a/fastrtps_build_osx.sh +++ b/fastrtps_build_osx.sh @@ -29,6 +29,6 @@ cmake -SFast-RTPS -B"$PROJECT_TEMP_DIR/Fast-RTPS" \ -Dfoonathan_memory_DIR=build/osx/share/foonathan_memory/cmake \ -DTHIRDPARTY=ON \ -DBUILD_SHARED_LIBS=OFF \ --DCMAKE_BUILD_TYPE="$1" +-DCMAKE_BUILD_TYPE=Debug cmake --build "$PROJECT_TEMP_DIR/Fast-RTPS" --target install fi From d6d14f64e95f05ffef2b3aa8a85350deab3d32ef Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Sat, 7 Dec 2019 14:22:37 +0300 Subject: [PATCH 18/20] Refactoring --- FastRTPSBridge/BridgedParticipant.h | 1 - FastRTPSBridge/BridgedParticipant.mm | 23 ---------- FastRTPSBridge/BridgedParticipantListener.h | 2 +- FastRTPSBridge/BridgedParticipantListener.mm | 45 +++++++------------- FastRTPSBridge/FastRTPSBridge.mm | 6 ++- 5 files changed, 22 insertions(+), 55 deletions(-) diff --git a/FastRTPSBridge/BridgedParticipant.h b/FastRTPSBridge/BridgedParticipant.h index aeb4fed..a490b0f 100644 --- a/FastRTPSBridge/BridgedParticipant.h +++ b/FastRTPSBridge/BridgedParticipant.h @@ -63,5 +63,4 @@ class BridgedParticipant bool removeWriter(const char* name); bool send(const char* name, const uint8_t* data, uint32_t length, const void* key, uint32_t keyLength); void resignAll(); - static NSSet* DumpLocators(eprosima::fastrtps::rtps::LocatorList_t locators); }; diff --git a/FastRTPSBridge/BridgedParticipant.mm b/FastRTPSBridge/BridgedParticipant.mm index 389a6a2..c5f6243 100644 --- a/FastRTPSBridge/BridgedParticipant.mm +++ b/FastRTPSBridge/BridgedParticipant.mm @@ -257,26 +257,3 @@ return true; } - -NSSet* BridgedParticipant::DumpLocators(LocatorList_t locators) -{ - char addrString[INET6_ADDRSTRLEN+1]; - NSMutableSet *set = [[NSMutableSet alloc] init]; - NSString *locatorString; - - for (auto locator = locators.begin(); locator != locators.end(); locator++) { - switch (locator->kind) { - case LOCATOR_KIND_UDPv4: - locatorString = [NSString stringWithFormat:@"%s:%d", inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)), locator->port]; - [set addObject:locatorString]; - break; - case LOCATOR_KIND_UDPv6: - locatorString = [NSString stringWithFormat:@"%s:%d", inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)), locator->port]; - [set addObject:locatorString]; - break; - default: - break; - } - } - return set; -} diff --git a/FastRTPSBridge/BridgedParticipantListener.h b/FastRTPSBridge/BridgedParticipantListener.h index 51cdb89..b9f3bfd 100644 --- a/FastRTPSBridge/BridgedParticipantListener.h +++ b/FastRTPSBridge/BridgedParticipantListener.h @@ -18,5 +18,5 @@ class BridgedParticipantListener: public eprosima::fastrtps::rtps::RTPSParticipa void onParticipantDiscovery(RTPSParticipant *participant, ParticipantDiscoveryInfo &&info) override; void onReaderDiscovery(RTPSParticipant *participant, ReaderDiscoveryInfo &&info) override; void onWriterDiscovery(RTPSParticipant *participant, WriterDiscoveryInfo &&info) override; - NSSet* DumpLocators(ResourceLimitedVector locators); + NSSet* dumpLocators(ResourceLimitedVector locators); }; diff --git a/FastRTPSBridge/BridgedParticipantListener.mm b/FastRTPSBridge/BridgedParticipantListener.mm index fdbce81..531463e 100644 --- a/FastRTPSBridge/BridgedParticipantListener.mm +++ b/FastRTPSBridge/BridgedParticipantListener.mm @@ -7,6 +7,7 @@ #include "BridgedParticipantListener.h" #include #include +#include #import "FastRTPSBridge/FastRTPSBridge-Swift.h" using namespace eprosima::fastrtps; @@ -22,7 +23,7 @@ switch(info.status) { case ReaderDiscoveryInfo::DISCOVERED_READER: notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonDiscoveredReader); - notificationDictionary[@(RTPSNotificationUserInfoLocators)] = DumpLocators(info.info.remote_locators().unicast); + notificationDictionary[@(RTPSNotificationUserInfoLocators)] = dumpLocators(info.info.remote_locators().unicast); break; case ReaderDiscoveryInfo::CHANGED_QOS_READER: notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonChangedQosReader); @@ -45,7 +46,7 @@ switch(info.status) { case WriterDiscoveryInfo::DISCOVERED_WRITER: notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonDiscoveredWriter); - notificationDictionary[@(RTPSNotificationUserInfoLocators)] = DumpLocators(info.info.remote_locators().unicast); + notificationDictionary[@(RTPSNotificationUserInfoLocators)] = dumpLocators(info.info.remote_locators().unicast); break; case WriterDiscoveryInfo::CHANGED_QOS_WRITER: notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonChangedQosWriter); @@ -58,30 +59,7 @@ [NSNotificationCenter.defaultCenter postNotificationName:RTPSParticipantNotificationName object:NULL userInfo:notificationDictionary]; } -NSSet* BridgedParticipantListener::DumpLocators(ResourceLimitedVector locators) -{ - char addrString[INET6_ADDRSTRLEN+1]; - NSMutableSet *set = [[NSMutableSet alloc] init]; - NSString *locatorString; - - for (auto locator = locators.cbegin(); locator != locators.cend(); locator++) { - switch (locator->kind) { - case LOCATOR_KIND_UDPv4: - locatorString = [NSString stringWithFormat:@"%s:%d", inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)), locator->port]; - [set addObject:locatorString]; - break; - case LOCATOR_KIND_UDPv6: - locatorString = [NSString stringWithFormat:@"%s:%d", inet_ntop(AF_INET, locator->address+12, addrString, sizeof(addrString)), locator->port]; - [set addObject:locatorString]; - break; - default: - break; - } - } - return set; -} - -void BridgedParticipantListener::onParticipantDiscovery(RTPSParticipant *participant, ParticipantDiscoveryInfo &&info) +void BridgedParticipantListener::onParticipantDiscovery(RTPSParticipant *participant, ParticipantDiscoveryInfo&& info) { (void)participant; auto properties = info.info.m_properties.properties; @@ -101,8 +79,8 @@ } notificationDictionary[@(RTPSNotificationUserInfoProperties)] = propDict; notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonDiscoveredParticipant); - notificationDictionary[@(RTPSNotificationUserInfoLocators)] = DumpLocators(info.info.default_locators.unicast); - notificationDictionary[@(RTPSNotificationUserInfoMetaLocators)] = DumpLocators(info.info.metatraffic_locators.unicast); + notificationDictionary[@(RTPSNotificationUserInfoLocators)] = dumpLocators(info.info.default_locators.unicast); + notificationDictionary[@(RTPSNotificationUserInfoMetaLocators)] = dumpLocators(info.info.metatraffic_locators.unicast); break; case ParticipantDiscoveryInfo::DROPPED_PARTICIPANT: notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonDroppedParticipant); @@ -114,6 +92,15 @@ notificationDictionary[@(RTPSNotificationUserInfoReason)] = @(RTPSParticipantNotificationReasonChangedQosParticipant); break; } - + [NSNotificationCenter.defaultCenter postNotificationName:RTPSParticipantNotificationName object:NULL userInfo:notificationDictionary]; } + +NSSet* BridgedParticipantListener::dumpLocators(ResourceLimitedVector locators) +{ + NSMutableSet *set = [[NSMutableSet alloc] init]; + for (auto locator = locators.cbegin(); locator != locators.cend(); locator++) { + [set addObject:[NSString stringWithFormat:@"%s:%d", IPLocator::ip_to_string(*locator).c_str(), locator->port]]; + } + return set; +} diff --git a/FastRTPSBridge/FastRTPSBridge.mm b/FastRTPSBridge/FastRTPSBridge.mm index abad897..57daaf9 100644 --- a/FastRTPSBridge/FastRTPSBridge.mm +++ b/FastRTPSBridge/FastRTPSBridge.mm @@ -109,6 +109,10 @@ - (void)resignAll { - (NSSet*)getIP4Address { eprosima::fastrtps::rtps::LocatorList_t locators; eprosima::fastrtps::rtps::IPFinder::getIP4Address(&locators); - return BridgedParticipant::DumpLocators(locators); + NSMutableSet *set = [[NSMutableSet alloc] init]; + for (auto locator = locators.begin(); locator != locators.end(); locator++) { + [set addObject:[NSString stringWithFormat:@"%s:%d", IPLocator::ip_to_string(*locator).c_str(), locator->port]]; + } + return set; } @end From dc1b26758fa5e20a09dc2303a57141f3623a778e Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Sat, 7 Dec 2019 18:20:59 +0300 Subject: [PATCH 19/20] Connection scheme with address filtering. --- FastRTPSBridge.xcodeproj/project.pbxproj | 4 ++-- FastRTPSBridge/BridgedParticipant.h | 2 +- FastRTPSBridge/BridgedParticipant.mm | 18 ++++++++++++------ FastRTPSBridge/FastRTPSBridge.h | 4 +++- FastRTPSBridge/FastRTPSBridge.mm | 9 ++++++--- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/FastRTPSBridge.xcodeproj/project.pbxproj b/FastRTPSBridge.xcodeproj/project.pbxproj index 9dc7fb0..4f77b1e 100644 --- a/FastRTPSBridge.xcodeproj/project.pbxproj +++ b/FastRTPSBridge.xcodeproj/project.pbxproj @@ -475,7 +475,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; - FastRTPS_repo = "-b 1.9.x https://github.com/eProsima/Fast-RTPS.git"; + FastRTPS_repo = "-b feature/remote-whitelist https://github.com/DimaRU/Fast-RTPS.git"; Foonathan_memory_repo = "https://github.com/DimaRU/memory.git"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; @@ -546,7 +546,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; - FastRTPS_repo = "-b 1.9.x https://github.com/eProsima/Fast-RTPS.git"; + FastRTPS_repo = "-b feature/remote-whitelist https://github.com/DimaRU/Fast-RTPS.git"; Foonathan_memory_repo = "https://github.com/DimaRU/memory.git"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; diff --git a/FastRTPSBridge/BridgedParticipant.h b/FastRTPSBridge/BridgedParticipant.h index a490b0f..3b0eb3d 100644 --- a/FastRTPSBridge/BridgedParticipant.h +++ b/FastRTPSBridge/BridgedParticipant.h @@ -49,7 +49,7 @@ class BridgedParticipant std::map readerList; std::map writerList; - bool createParticipant(const char* name, const char *ipv4); + bool createParticipant(const char* name, const char *interfaceIPv4, const char* networkAddress); void setPartition(const char* name) { partitionName = std::string(name); } bool addReader(const char* name, const char* dataType, diff --git a/FastRTPSBridge/BridgedParticipant.mm b/FastRTPSBridge/BridgedParticipant.mm index c5f6243..7927261 100644 --- a/FastRTPSBridge/BridgedParticipant.mm +++ b/FastRTPSBridge/BridgedParticipant.mm @@ -64,7 +64,7 @@ writerList.clear(); } -bool BridgedParticipant::createParticipant(const char* name, const char *peerIPv4) +bool BridgedParticipant::createParticipant(const char* name, const char *interfaceIPv4, const char* networkAddress) { RTPSParticipantAttributes pattr; pattr.builtin.use_WriterLivelinessProtocol = true; @@ -76,12 +76,18 @@ pattr.builtin.writerHistoryMemoryPolicy = PREALLOCATED_WITH_REALLOC_MEMORY_MODE; pattr.builtin.domainId = 0; pattr.setName(name); - - if (peerIPv4 != nullptr) { - Locator_t locator; - IPLocator::setIPv4(locator, peerIPv4); - pattr.builtin.initialPeersList.push_back(locator); + + auto customTransport = std::make_shared(); + customTransport->sendBufferSize = 65536; + customTransport->receiveBufferSize = 65536; + if (interfaceIPv4 != nullptr) { + customTransport->interfaceWhiteList.emplace_back(interfaceIPv4); + } + if (networkAddress != nullptr) { + customTransport->remoteWhiteList.emplace_back(networkAddress); } + pattr.userTransports.push_back(customTransport); + pattr.useBuiltinTransports = false; mp_listener = new BridgedParticipantListener(); mp_participant = RTPSDomain::createParticipant(pattr, mp_listener); diff --git a/FastRTPSBridge/FastRTPSBridge.h b/FastRTPSBridge/FastRTPSBridge.h index 9c8acc0..e49a295 100644 --- a/FastRTPSBridge/FastRTPSBridge.h +++ b/FastRTPSBridge/FastRTPSBridge.h @@ -32,7 +32,9 @@ typedef NS_CLOSED_ENUM(NSInteger, LogLevel) { /// Create RTPS paticipant and start listening /// @param name Participant name /// @param peerIPv4 peer IPv4 address (initially multicast) -- (bool)createRTPSParticipantWithName:(NSString *)name peerIPv4:(NSString* _Nullable) peerIPv4; +- (bool)createRTPSParticipantWithName:(NSString *)name + interfaceIPv4:(NSString* _Nullable) interfaceIPv4 + networkAddress:(NSString* _Nullable) networkAddress; /// Set partition name for readers and writers /// @param name partition name (initially "*") diff --git a/FastRTPSBridge/FastRTPSBridge.mm b/FastRTPSBridge/FastRTPSBridge.mm index 57daaf9..5cd0d49 100644 --- a/FastRTPSBridge/FastRTPSBridge.mm +++ b/FastRTPSBridge/FastRTPSBridge.mm @@ -51,9 +51,12 @@ - (id)initWithLogLevel:(LogLevel)logLevel { return self; } -- (bool)createRTPSParticipantWithName:(NSString *)name peerIPv4: (NSString *)peerIPv4 { +- (bool)createRTPSParticipantWithName:(NSString *)name + interfaceIPv4:(NSString* _Nullable) interfaceIPv4 + networkAddress:(NSString* _Nullable) networkAddress { return participant->createParticipant([name cStringUsingEncoding:NSUTF8StringEncoding], - [peerIPv4 cStringUsingEncoding:NSUTF8StringEncoding]); + [interfaceIPv4 cStringUsingEncoding:NSUTF8StringEncoding], + [networkAddress cStringUsingEncoding:NSUTF8StringEncoding]); } - (void)setPartition:(NSString *) name { @@ -111,7 +114,7 @@ - (NSSet*)getIP4Address { eprosima::fastrtps::rtps::IPFinder::getIP4Address(&locators); NSMutableSet *set = [[NSMutableSet alloc] init]; for (auto locator = locators.begin(); locator != locators.end(); locator++) { - [set addObject:[NSString stringWithFormat:@"%s:%d", IPLocator::ip_to_string(*locator).c_str(), locator->port]]; + [set addObject:[NSString stringWithUTF8String:IPLocator::ip_to_string(*locator).c_str()]]; } return set; } From e3289d553c70feb6efa8fad6888218783f8df72e Mon Sep 17 00:00:00 2001 From: Dmitriy Borovikov Date: Sat, 7 Dec 2019 18:27:28 +0300 Subject: [PATCH 20/20] Bump version --- FastRTPSBridge.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FastRTPSBridge.xcodeproj/project.pbxproj b/FastRTPSBridge.xcodeproj/project.pbxproj index 4f77b1e..ecdd17a 100644 --- a/FastRTPSBridge.xcodeproj/project.pbxproj +++ b/FastRTPSBridge.xcodeproj/project.pbxproj @@ -494,7 +494,7 @@ HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 12.1; MACOSX_DEPLOYMENT_TARGET = 10.13; - MARKETING_VERSION = 0.0.1; + MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -559,7 +559,7 @@ HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 12.1; MACOSX_DEPLOYMENT_TARGET = 10.13; - MARKETING_VERSION = 0.0.1; + MARKETING_VERSION = 1.0.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = "";