From 21dfbf1b34a2beafcd5f5f049c375e1efcdfc157 Mon Sep 17 00:00:00 2001 From: JDierkse Date: Wed, 28 Jul 2021 16:10:46 +0200 Subject: [PATCH] Add ini Configuration File --- Application/VStarCamFinder.cc | 11 ++++++++++- Libraries/inih | 1 + Makefile.conf | 2 +- VStarCam/Finder.cpp | 4 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) create mode 120000 Libraries/inih diff --git a/Application/VStarCamFinder.cc b/Application/VStarCamFinder.cc index ba8d169..465a8ad 100644 --- a/Application/VStarCamFinder.cc +++ b/Application/VStarCamFinder.cc @@ -1,4 +1,5 @@ #include "VStarCam/Finder.h" +#include #include #include #include @@ -19,11 +20,19 @@ int main(int argc, char** argv) return 1; } + INIReader iniReader("VStarCamFinder.ini"); + if (iniReader.ParseError() != 0) + { + Logging::Log(Logging::Severity::Error, "Can't read VStarCamFinder.ini"); + return 1; + } + std::string ipAddress(argv[1]); + std::string listenAddress = iniReader.Get("VStarCamFinder", "ListenAddress", "0.0.0.0"); int port = 0; - VStarCam::Finder finder("192.168.101.100"); + VStarCam::Finder finder(listenAddress); port = finder.GetPort(ipAddress); if (port != 0) diff --git a/Libraries/inih b/Libraries/inih new file mode 120000 index 0000000..f48979f --- /dev/null +++ b/Libraries/inih @@ -0,0 +1 @@ +../../Libraries/inih \ No newline at end of file diff --git a/Makefile.conf b/Makefile.conf index cba0dd7..29705bf 100644 --- a/Makefile.conf +++ b/Makefile.conf @@ -8,6 +8,7 @@ LIBRARIES += Utilities CFLAGS += -I$(ROOTPATH)/Libraries/asio/asio/include CFLAGS += -I$(ROOTPATH)/Libraries/clipp +CFLAGS += -I$(ROOTPATH)/Libraries/inih LFLAGS += -pthread @@ -17,4 +18,3 @@ DEBUGDIR := .debug DEFAULTARCH := armv6-jessie TARGETS += VStarCamFinder - diff --git a/VStarCam/Finder.cpp b/VStarCam/Finder.cpp index 9325771..529e7e8 100644 --- a/VStarCam/Finder.cpp +++ b/VStarCam/Finder.cpp @@ -25,7 +25,7 @@ int Finder::GetPort(const std::string& ipAddress) { std::stringstream ss; ss << "Retrieving port for " << ipAddress << std::endl; - Logging::Log(Logging::Severity::Info, ss.str()); + Logging::Log(Logging::Severity::Debug, ss.str()); { std::unique_lock lock(m_mutex); @@ -49,7 +49,7 @@ int Finder::GetPort(const std::string& ipAddress) ss.str(""); ss << "New port for " << ipAddress << ": " << port << std::endl; - Logging::Log(Logging::Severity::Info, ss.str()); + Logging::Log(Logging::Severity::Debug, ss.str()); return port; }