satdump/plugins/sdr_sources/remote_sdr_support/server/main.cpp

86 lines
2.5 KiB
C++
Raw Permalink Normal View History

2023-09-10 00:53:18 +02:00
/**********************************************************************
* This file is used for testing random stuff without running the
* whole of SatDump, which comes in handy for debugging individual
* elements before putting them all together in modules...
*
* If you are an user, ignore this file which will not be built by
* default, and if you're a developper in need of doing stuff here...
* Go ahead!
*
* Don't judge the code you might see in there! :)
**********************************************************************/
#include "logger.h"
#include "init.h"
#include "udp_discovery.h"
2023-09-12 18:30:01 +02:00
#include "main.h"
#include "gui.h"
#include "streaming.h"
#include "remote.h"
#include "actions.h"
#include "pkt_handler.h"
2025-01-20 11:01:28 +01:00
#include "satdump_vars.h"
2023-09-11 17:11:24 +02:00
2023-09-10 00:53:18 +02:00
// The TCP Server
TCPServer *tcp_server;
// Currently open source & statuses
std::mutex source_mtx;
std::shared_ptr<dsp::DSPSampleSource> current_sample_source;
2023-09-12 18:30:01 +02:00
// Source status
2023-09-10 00:53:18 +02:00
bool source_is_open = false;
bool source_is_started = false;
int main(int argc, char *argv[])
{
initLogger();
2025-01-20 11:01:28 +01:00
logger->info("Starting SatDump SDR Server v" + (std::string)satdump::SATDUMP_VERSION);
2023-09-10 00:53:18 +02:00
2023-09-12 19:35:34 +02:00
int port_used = 5656;
2023-10-03 10:31:16 -04:00
try
{
if (argc > 1)
port_used = std::stoi(argv[1]);
}
catch (std::exception&)
{
logger->error("Usage : " + std::string(argv[0]) + " [port]");
return 1;
}
2023-09-10 00:53:18 +02:00
// We don't wanna spam with init this time around
logger->set_level(slog::LOG_OFF);
satdump::tle_do_update_on_init = false;
2023-09-10 00:53:18 +02:00
satdump::initSatdump();
completeLoggerInit();
2023-09-10 00:53:18 +02:00
logger->set_level(slog::LOG_TRACE);
dsp::registerAllSources();
2023-09-12 18:30:01 +02:00
// dsp::registerAllSinks();
2023-09-10 00:53:18 +02:00
// Start UDP discovery system
service_discovery::UDPDiscoveryConfig cfg = {REMOTE_NETWORK_DISCOVERY_REQPORT, REMOTE_NETWORK_DISCOVERY_REPPORT, REMOTE_NETWORK_DISCOVERY_REQPKT, REMOTE_NETWORK_DISCOVERY_REPPKT, (uint32_t)port_used};
2023-09-10 00:53:18 +02:00
service_discovery::UDPDiscoveryServerRunner runner(cfg);
// Start the main TCP Server
tcp_server = new TCPServer(port_used);
tcp_server->callback_func = tcp_rx_handler;
tcp_server->callback_func_on_lost_client = []()
{
action_sourceStop();
action_sourceClose();
};
2023-09-10 00:53:18 +02:00
// Start source GUI loop
std::thread source_gui_th(sourceGuiThread);
// Start source IQ loop
std::thread source_iq_th(sourceStreamThread);
while (1)
2023-09-11 00:49:33 +02:00
tcp_server->wait_client();
// std::this_thread::sleep_for(std::chrono::seconds(1));
2023-09-10 00:53:18 +02:00
return 0;
}