Add ini Configuration File

This commit is contained in:
2021-07-28 16:10:46 +02:00
parent 977f5eed8d
commit 21dfbf1b34
4 changed files with 14 additions and 4 deletions
+10 -1
View File
@@ -1,4 +1,5 @@
#include "VStarCam/Finder.h" #include "VStarCam/Finder.h"
#include <INIReader.h>
#include <Logging.h> #include <Logging.h>
#include <sstream> #include <sstream>
#include <string> #include <string>
@@ -19,11 +20,19 @@ int main(int argc, char** argv)
return 1; 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 ipAddress(argv[1]);
std::string listenAddress = iniReader.Get("VStarCamFinder", "ListenAddress", "0.0.0.0");
int port = 0; int port = 0;
VStarCam::Finder finder("192.168.101.100"); VStarCam::Finder finder(listenAddress);
port = finder.GetPort(ipAddress); port = finder.GetPort(ipAddress);
if (port != 0) if (port != 0)
+1
View File
@@ -0,0 +1 @@
../../Libraries/inih
+1 -1
View File
@@ -8,6 +8,7 @@ LIBRARIES += Utilities
CFLAGS += -I$(ROOTPATH)/Libraries/asio/asio/include CFLAGS += -I$(ROOTPATH)/Libraries/asio/asio/include
CFLAGS += -I$(ROOTPATH)/Libraries/clipp CFLAGS += -I$(ROOTPATH)/Libraries/clipp
CFLAGS += -I$(ROOTPATH)/Libraries/inih
LFLAGS += -pthread LFLAGS += -pthread
@@ -17,4 +18,3 @@ DEBUGDIR := .debug
DEFAULTARCH := armv6-jessie DEFAULTARCH := armv6-jessie
TARGETS += VStarCamFinder TARGETS += VStarCamFinder
+2 -2
View File
@@ -25,7 +25,7 @@ int Finder::GetPort(const std::string& ipAddress)
{ {
std::stringstream ss; std::stringstream ss;
ss << "Retrieving port for " << ipAddress << std::endl; ss << "Retrieving port for " << ipAddress << std::endl;
Logging::Log(Logging::Severity::Info, ss.str()); Logging::Log(Logging::Severity::Debug, ss.str());
{ {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<std::mutex> lock(m_mutex);
@@ -49,7 +49,7 @@ int Finder::GetPort(const std::string& ipAddress)
ss.str(""); ss.str("");
ss << "New port for " << ipAddress << ": " << port << std::endl; ss << "New port for " << ipAddress << ": " << port << std::endl;
Logging::Log(Logging::Severity::Info, ss.str()); Logging::Log(Logging::Severity::Debug, ss.str());
return port; return port;
} }