mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-07-03 07:28:28 +02:00
Fixed autostart for networked sources
This commit is contained in:
@ -109,6 +109,12 @@ private:
|
||||
SDRPPServerSourceModule* _this = (SDRPPServerSourceModule*)ctx;
|
||||
if (_this->running) { return; }
|
||||
|
||||
// Try to connect if not already connected
|
||||
if (!_this->client) {
|
||||
_this->tryConnect();
|
||||
if (!_this->client) { return; }
|
||||
}
|
||||
|
||||
// TODO: Set configuration here
|
||||
if (_this->client) {
|
||||
_this->client->setFrequency(_this->freq);
|
||||
@ -166,15 +172,7 @@ private:
|
||||
|
||||
if (_this->running) { style::beginDisabled(); }
|
||||
if (!connected && ImGui::Button("Connect##sdrpp_srv_source", ImVec2(menuWidth, 0))) {
|
||||
try {
|
||||
if (_this->client) { _this->client.reset(); }
|
||||
_this->client = server::connect(_this->hostname, _this->port, &_this->stream);
|
||||
_this->deviceInit();
|
||||
}
|
||||
catch (std::exception e) {
|
||||
spdlog::error("Could not connect to SDR: {0}", e.what());
|
||||
if (!strcmp(e.what(), "Server busy")) { _this->serverBusy = true; }
|
||||
}
|
||||
_this->tryConnect();
|
||||
}
|
||||
else if (connected && ImGui::Button("Disconnect##sdrpp_srv_source", ImVec2(menuWidth, 0))) {
|
||||
_this->client->close();
|
||||
@ -231,6 +229,18 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void tryConnect() {
|
||||
try {
|
||||
if (client) { client.reset(); }
|
||||
client = server::connect(hostname, port, &stream);
|
||||
deviceInit();
|
||||
}
|
||||
catch (std::exception e) {
|
||||
spdlog::error("Could not connect to SDR: {0}", e.what());
|
||||
if (!strcmp(e.what(), "Server busy")) { serverBusy = true; }
|
||||
}
|
||||
}
|
||||
|
||||
void deviceInit() {
|
||||
// Generate the config name
|
||||
char buf[4096];
|
||||
|
Reference in New Issue
Block a user