4 Commits

Author SHA1 Message Date
711ed7711f more work on the rigctl client update
Some checks failed
Build Binaries / build_debian_buster (push) Failing after 4s
Build Binaries / build_debian_bullseye (push) Failing after 4s
Build Binaries / build_debian_bookworm (push) Failing after 4s
Build Binaries / build_debian_sid (push) Failing after 4s
Build Binaries / build_ubuntu_focal (push) Failing after 3s
Build Binaries / build_ubuntu_jammy (push) Failing after 3s
Build Binaries / build_ubuntu_mantic (push) Failing after 4s
Build Binaries / build_ubuntu_noble (push) Failing after 4s
Build Binaries / build_android (push) Failing after 5s
Build Binaries / check_spelling (push) Failing after 3s
Build Binaries / check_formatting (push) Successful in 4s
Build Binaries / create_full_archive (push) Has been cancelled
Build Binaries / update_nightly_release (push) Has been cancelled
Build Binaries / build_windows (push) Has been cancelled
Build Binaries / build_macos_intel (push) Has been cancelled
Build Binaries / build_macos_arm (push) Has been cancelled
Build Binaries / build_raspios_bullseye_armhf (push) Has been cancelled
2024-12-19 04:18:19 +01:00
a8e6f24b29 start of work on rewrite 2024-12-18 19:45:51 +01:00
b914587228 Revert "add support for new models (in a bad way) and start the rewrite process"
Some checks failed
Build Binaries / build_debian_buster (push) Failing after 17s
Build Binaries / build_debian_bullseye (push) Failing after 4s
Build Binaries / build_debian_bookworm (push) Failing after 4s
Build Binaries / build_debian_sid (push) Failing after 4s
Build Binaries / build_ubuntu_focal (push) Failing after 4s
Build Binaries / build_ubuntu_jammy (push) Failing after 4s
Build Binaries / build_ubuntu_mantic (push) Failing after 4s
Build Binaries / build_ubuntu_noble (push) Failing after 4s
Build Binaries / build_android (push) Failing after 5s
Build Binaries / check_spelling (push) Failing after 4s
Build Binaries / check_formatting (push) Successful in 3s
Build Binaries / build_windows (push) Has been cancelled
Build Binaries / build_macos_intel (push) Has been cancelled
Build Binaries / build_macos_arm (push) Has been cancelled
Build Binaries / build_raspios_bullseye_armhf (push) Has been cancelled
Build Binaries / create_full_archive (push) Has been cancelled
Build Binaries / update_nightly_release (push) Has been cancelled
This reverts commit 3c1d0c7422.
2024-11-27 21:42:59 +01:00
3c1d0c7422 add support for new models (in a bad way) and start the rewrite process 2024-11-27 21:41:46 +01:00
5 changed files with 404 additions and 148 deletions

View File

@ -10,23 +10,54 @@
#include <config.h> #include <config.h>
#include <cctype> #include <cctype>
#include <radio_interface.h> #include <radio_interface.h>
#include <utils/optionlist.h>
#include <atomic>
#define CONCAT(a, b) ((std::string(a) + b).c_str()) #define CONCAT(a, b) ((std::string(a) + b).c_str())
SDRPP_MOD_INFO{ SDRPP_MOD_INFO{
/* Name: */ "rigctl_client", /* Name: */ "rigctl_client",
/* Description: */ "Client for the RigCTL protocol", /* Description: */ "Client for the RigCTL protocol",
/* Author: */ "Ryzerth", /* Author: */ "Ryzerth",
/* Version: */ 0, 1, 0, /* Version: */ 0, 2, 0,
/* Max instances */ 1 /* Max instances */ 1
}; };
ConfigManager config; ConfigManager config;
enum Mode {
MODE_PANADAPTER,
MODE_MIRROR
};
enum Priority {
PRIOR_SDR,
PRIOR_RIGCTL
};
const std::map<int, net::rigctl::Mode> RADIO_TO_RIGCTL = {
{ RADIO_IFACE_MODE_NFM, net::rigctl::MODE_FM },
{ RADIO_IFACE_MODE_WFM, net::rigctl::MODE_WFM },
{ RADIO_IFACE_MODE_AM , net::rigctl::MODE_AM },
{ RADIO_IFACE_MODE_DSB, net::rigctl::MODE_DSB },
{ RADIO_IFACE_MODE_USB, net::rigctl::MODE_USB },
{ RADIO_IFACE_MODE_CW , net::rigctl::MODE_CW },
{ RADIO_IFACE_MODE_LSB, net::rigctl::MODE_LSB }
};
class RigctlClientModule : public ModuleManager::Instance { class RigctlClientModule : public ModuleManager::Instance {
public: public:
RigctlClientModule(std::string name) { RigctlClientModule(std::string name) {
this->name = name; this->name = name;
// Define the operation modes
modes.define("panadapter", "Pandapter", MODE_PANADAPTER);
modes.define("mirror", "Mirror", MODE_MIRROR);
// Define the priority modes
priorities.define("sdr", "SDR", PRIOR_SDR);
priorities.define("rigctl", "RigCTL", PRIOR_RIGCTL);
// Load default // Load default
strcpy(host, "127.0.0.1"); strcpy(host, "127.0.0.1");
@ -40,13 +71,28 @@ public:
port = config.conf[name]["port"]; port = config.conf[name]["port"];
port = std::clamp<int>(port, 1, 65535); port = std::clamp<int>(port, 1, 65535);
} }
if (config.conf[name].contains("mode")) {
std::string modeStr = config.conf[name]["mode"];
if (modes.keyExists(modeStr)) { modeId = modes.keyId(modeStr); }
}
if (config.conf[name].contains("priority")) {
std::string priorityStr = config.conf[name]["priority"];
if (priorities.keyExists(priorityStr)) { priorityId = modes.keyId(priorityStr); }
}
if (config.conf[name].contains("interval")) {
interval = config.conf[name]["interval"];
interval = std::clamp<int>(interval, 100, 1000);
}
if (config.conf[name].contains("ifFreq")) { if (config.conf[name].contains("ifFreq")) {
ifFreq = config.conf[name]["ifFreq"]; ifFreq = config.conf[name]["ifFreq"];
} }
if (config.conf[name].contains("vfo")) {
selectedVFO = config.conf[name]["vfo"];
}
config.release(); config.release();
_retuneHandler.ctx = this; // Refresh VFOs
_retuneHandler.handler = retuneHandler; refreshVFOs();
gui::menu.registerEntry(name, menuHandler, this, NULL); gui::menu.registerEntry(name, menuHandler, this, NULL);
} }
@ -85,10 +131,20 @@ public:
return; return;
} }
// Switch source to panadapter mode if (mode == MODE_PANADAPTER) {
sigpath::sourceManager.setPanadapterIF(ifFreq); // Switch source to panadapter mode
sigpath::sourceManager.setTuningMode(SourceManager::TuningMode::PANADAPTER); sigpath::sourceManager.setPanadapterIF(ifFreq);
sigpath::sourceManager.onRetune.bindHandler(&_retuneHandler); sigpath::sourceManager.setTuningMode(SourceManager::TuningMode::PANADAPTER);
}
// Start the worker thread
run = true;
if (mode == MODE_PANADAPTER) {
workerThread = std::thread(&RigctlClientModule::panadapterWorker, this);
}
else if (mode == MODE_MIRROR) {
workerThread = std::thread(&RigctlClientModule::mirrorWorker, this);
}
running = true; running = true;
} }
@ -97,9 +153,15 @@ public:
std::lock_guard<std::recursive_mutex> lck(mtx); std::lock_guard<std::recursive_mutex> lck(mtx);
if (!running) { return; } if (!running) { return; }
// Switch source back to normal mode // Stop the worker thread
sigpath::sourceManager.onRetune.unbindHandler(&_retuneHandler); run = false;
sigpath::sourceManager.setTuningMode(SourceManager::TuningMode::NORMAL); if (workerThread.joinable()) { workerThread.join(); }
if (mode == MODE_PANADAPTER) {
// Switch source back to normal mode
sigpath::sourceManager.onRetune.unbindHandler(&_retuneHandler);
sigpath::sourceManager.setTuningMode(SourceManager::TuningMode::NORMAL);
}
// Disconnect from rigctl server // Disconnect from rigctl server
client->close(); client->close();
@ -125,19 +187,70 @@ private:
config.conf[_this->name]["port"] = _this->port; config.conf[_this->name]["port"] = _this->port;
config.release(true); config.release(true);
} }
if (_this->running) { style::endDisabled(); }
ImGui::LeftLabel("IF Frequency"); ImGui::LeftLabel("Mode");
ImGui::FillWidth(); ImGui::FillWidth();
if (ImGui::InputDouble(CONCAT("##_rigctl_if_freq_", _this->name), &_this->ifFreq, 100.0, 100000.0, "%.0f")) { if (ImGui::Combo(CONCAT("##_rigctl_cli_mode_", _this->name), &_this->modeId, _this->modes.txt)) {
if (_this->running) { _this->mode = _this->modes[_this->modeId];
sigpath::sourceManager.setPanadapterIF(_this->ifFreq);
}
config.acquire(); config.acquire();
config.conf[_this->name]["ifFreq"] = _this->ifFreq; config.conf[_this->name]["mode"] = _this->modes.key(_this->modeId);
config.release(true); config.release(true);
} }
ImGui::LeftLabel("Priority");
ImGui::FillWidth();
if (ImGui::Combo(CONCAT("##_rigctl_cli_priority_", _this->name), &_this->priorityId, _this->priorities.txt)) {
_this->priority = _this->priorities[_this->priorityId];
config.acquire();
config.conf[_this->name]["priority"] = _this->priorities.key(_this->priorityId);
config.release(true);
}
ImGui::LeftLabel("Interval");
ImGui::FillWidth();
if (ImGui::InputInt(CONCAT("##_rigctl_cli_interval_", _this->name), &_this->interval, 10, 100)) {
_this->interval = std::clamp<int>(_this->interval, 100, 1000);
config.acquire();
config.conf[_this->name]["interval"] = _this->interval;
config.release(true);
}
if (_this->mode == MODE_PANADAPTER) {
ImGui::LeftLabel("IF Frequency");
ImGui::FillWidth();
if (ImGui::InputDouble(CONCAT("##_rigctl_if_freq_", _this->name), &_this->ifFreq, 100.0, 100000.0, "%.0f")) {
if (_this->running) {
sigpath::sourceManager.setPanadapterIF(_this->ifFreq);
}
config.acquire();
config.conf[_this->name]["ifFreq"] = _this->ifFreq;
config.release(true);
}
}
else if (_this->mode == MODE_MIRROR) {
ImGui::LeftLabel("Controlled VFO");
ImGui::FillWidth();
if (ImGui::Combo(CONCAT("##_rigctl_cli_vfo_", _this->name), &_this->vfoId, _this->vfos.txt)) {
_this->selectedVFO = _this->vfos[_this->vfoId];
config.acquire();
config.conf[_this->name]["vfo"] = _this->vfos.key(_this->vfoId);
config.release(true);
}
ImGui::Checkbox(CONCAT("Sync Frequency##_rigctl_sync_freq_", _this->name), &_this->syncFrequency);
if (_this->vfoIsRadio) {
ImGui::Checkbox(CONCAT("Sync Mode##_rigctl_sync_freq_", _this->name), &_this->syncMode);
}
else {
bool dummy = false;
if (!_this->running) { style::beginDisabled(); }
ImGui::Checkbox(CONCAT("Sync Mode##_rigctl_sync_freq_", _this->name), &dummy);
if (!_this->running) { style::endDisabled(); }
}
}
if (_this->running) { style::endDisabled(); }
ImGui::FillWidth(); ImGui::FillWidth();
if (_this->running && ImGui::Button(CONCAT("Stop##_rigctl_cli_stop_", _this->name), ImVec2(menuWidth, 0))) { if (_this->running && ImGui::Button(CONCAT("Stop##_rigctl_cli_stop_", _this->name), ImVec2(menuWidth, 0))) {
_this->stop(); _this->stop();
@ -159,11 +272,131 @@ private:
} }
} }
static void retuneHandler(double freq, void* ctx) { void selectVFO(const std::string& vfoName) {
RigctlClientModule* _this = (RigctlClientModule*)ctx; // If no vfo is available, deselect
if (!_this->client || !_this->client->isOpen()) { return; } if (vfos.empty()) {
if (_this->client->setFreq(freq)) { selectedVFO.clear();
flog::error("Could not set frequency"); vfoIsRadio = false;
return;
}
// If a vfo with that name isn't found, select the first VFO in the list
if (!vfos.keyExists(vfoName)) {
selectVFO(vfos.key(0));
return;
}
// Check if the VFO is from a radio module
vfoIsRadio = (core::moduleManager.getInstanceModuleName(vfoName) == "radio");
// Update the selected VFO
selectedVFO = vfoName;
vfoId = vfos.keyId(vfoName);
}
void refreshVFOs() {
// Clear the list
vfos.clear();
// Define using the VFO list from the waterfall
for (auto const& [_name, vfo] : gui::waterfall.vfos) {
vfos.define(_name, _name, _name);
}
// Reselect the current VFO
selectVFO(selectedVFO);
}
void panadapterWorker() {
int64_t lastRigctlFreq = -1;
int64_t lastCenterFreq = -1;
int64_t rigctlFreq;
int64_t centerFreq;
while (run) {
// Query the current modes
try {
// Get the current rigctl frequency
rigctlFreq = (int64_t)client->getFreq();
// Get the current center frequency
centerFreq = (int64_t)gui::waterfall.getCenterFrequency();
}
catch (const std::exception& e) {
flog::error("Error while getting frequencies: {}", e.what());
}
// Update frequencies depending on the priority
if (priority == PRIOR_SDR) {
}
else if (priority == PRIOR_RIGCTL) {
}
// Save frequencies
lastRigctlFreq = rigctlFreq;
lastCenterFreq = centerFreq;
// Wait for the time interval
std::this_thread::sleep_for(std::chrono::milliseconds(interval));
}
}
void mirrorWorker() {
int64_t lastRigctlFreq = -1;
int64_t lastFreq = -1;
int64_t rigctlFreq;
int64_t freq;
int lastRigctlMode = -1;
int lastVFOMode = -1;
int rigctlMode;
int vfoMode;
while (run) {
// Query the current modes
try {
// Get the current rigctl frequency
rigctlFreq = (int64_t)client->getFreq();
// Get the rigctl and VFO modes
if (selectedVFO.empty()) {
// Get the VFO frequency
// TODO
// Get the mode if needed
if (syncMode && vfoIsRadio) {
// Get the current rigctl mode
// rigctlMode = client->getMode();
// Get the current VFO mode
core::modComManager.callInterface(selectedVFO, RADIO_IFACE_CMD_GET_MODE, NULL, &vfoMode);
}
}
else {
freq = (int64_t)gui::waterfall.getCenterFrequency();
}
}
catch (const std::exception& e) {
flog::error("Error while getting frequencies: {}", e.what());
}
// Update frequencies depending on the priority
if (priority == PRIOR_SDR) {
}
else if (priority == PRIOR_RIGCTL) {
}
// Save modes and frequencies
lastRigctlFreq = rigctlFreq;
lastFreq = freq;
lastRigctlMode = rigctlMode;
lastVFOMode = vfoMode;
// Wait for the time interval
std::this_thread::sleep_for(std::chrono::milliseconds(interval));
} }
} }
@ -176,9 +409,31 @@ private:
int port = 4532; int port = 4532;
std::shared_ptr<net::rigctl::Client> client; std::shared_ptr<net::rigctl::Client> client;
Mode mode = MODE_PANADAPTER;
int modeId = 0;
Priority priority = PRIOR_SDR;
int priorityId = 0;
int interval = 100;
double ifFreq = 8830000.0; double ifFreq = 8830000.0;
bool syncFrequency = true;
bool syncMode = true;
bool vfoIsRadio = false;
EventHandler<double> _retuneHandler; EventHandler<double> _retuneHandler;
OptionList<std::string, Mode> modes;
OptionList<std::string, Priority> priorities;
std::string selectedVFO = "";
int vfoId = 0;
OptionList<std::string, std::string> vfos;
std::atomic_bool run;
std::thread workerThread;
}; };
MOD_EXPORT void _INIT_() { MOD_EXPORT void _INIT_() {

View File

@ -1,10 +0,0 @@
#pragma once
#include <utils/networking.h>
class RigCTLClient {
public:
private:
};

View File

@ -18,7 +18,7 @@ SDRPP_MOD_INFO{
/* Name: */ "rigctl_server", /* Name: */ "rigctl_server",
/* Description: */ "My fancy new module", /* Description: */ "My fancy new module",
/* Author: */ "Ryzerth", /* Author: */ "Ryzerth",
/* Version: */ 0, 1, 0, /* Version: */ 0, 1, 1,
/* Max instances */ -1 /* Max instances */ -1
}; };
@ -153,21 +153,16 @@ private:
} }
} }
ImGui::BeginTable(CONCAT("Stop##_rigctl_srv_tbl_", _this->name), 2);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
if (ImGui::Checkbox(CONCAT("Tuning##_rigctl_srv_tune_ena_", _this->name), &_this->tuningEnabled)) { if (ImGui::Checkbox(CONCAT("Tuning##_rigctl_srv_tune_ena_", _this->name), &_this->tuningEnabled)) {
config.acquire(); config.acquire();
config.conf[_this->name]["tuning"] = _this->tuningEnabled; config.conf[_this->name]["tuning"] = _this->tuningEnabled;
config.release(true); config.release(true);
} }
ImGui::TableSetColumnIndex(1);
if (ImGui::Checkbox(CONCAT("Recording##_rigctl_srv_tune_ena_", _this->name), &_this->recordingEnabled)) { if (ImGui::Checkbox(CONCAT("Recording##_rigctl_srv_tune_ena_", _this->name), &_this->recordingEnabled)) {
config.acquire(); config.acquire();
config.conf[_this->name]["recording"] = _this->recordingEnabled; config.conf[_this->name]["recording"] = _this->recordingEnabled;
config.release(true); config.release(true);
} }
ImGui::EndTable();
if (ImGui::Checkbox(CONCAT("Listen on startup##_rigctl_srv_auto_lst_", _this->name), &_this->autoStart)) { if (ImGui::Checkbox(CONCAT("Listen on startup##_rigctl_srv_auto_lst_", _this->name), &_this->autoStart)) {
config.acquire(); config.acquire();

View File

@ -377,7 +377,7 @@ Modules in beta are still included in releases for the most part but not enabled
| frequency_manager | Working | - | OPT_BUILD_FREQUENCY_MANAGER | ✅ | ✅ | ✅ | | frequency_manager | Working | - | OPT_BUILD_FREQUENCY_MANAGER | ✅ | ✅ | ✅ |
| iq_exporter | Working | - | OPT_BUILD_IQ_EXPORTER | ✅ | ✅ | ⛔ | | iq_exporter | Working | - | OPT_BUILD_IQ_EXPORTER | ✅ | ✅ | ⛔ |
| recorder | Working | - | OPT_BUILD_RECORDER | ✅ | ✅ | ✅ | | recorder | Working | - | OPT_BUILD_RECORDER | ✅ | ✅ | ✅ |
| rigctl_client | Unfinished | - | OPT_BUILD_RIGCTL_CLIENT | ✅ | ✅ | ⛔ | | rigctl_client | Beta | - | OPT_BUILD_RIGCTL_CLIENT | ✅ | ✅ | ⛔ |
| rigctl_server | Working | - | OPT_BUILD_RIGCTL_SERVER | ✅ | ✅ | ✅ | | rigctl_server | Working | - | OPT_BUILD_RIGCTL_SERVER | ✅ | ✅ | ✅ |
| scanner | Beta | - | OPT_BUILD_SCANNER | ✅ | ✅ | ⛔ | | scanner | Beta | - | OPT_BUILD_SCANNER | ✅ | ✅ | ⛔ |
| scheduler | Unfinished | - | OPT_BUILD_SCHEDULER | ⛔ | ⛔ | ⛔ | | scheduler | Unfinished | - | OPT_BUILD_SCHEDULER | ⛔ | ⛔ | ⛔ |

View File

@ -8,7 +8,6 @@
#include <config.h> #include <config.h>
#include <sdrplay_api.h> #include <sdrplay_api.h>
#include <gui/smgui.h> #include <gui/smgui.h>
#include <utils/optionlist.h>
#define CONCAT(a, b) ((std::string(a) + b).c_str()) #define CONCAT(a, b) ((std::string(a) + b).c_str())
@ -16,12 +15,57 @@ SDRPP_MOD_INFO{
/* Name: */ "sdrplay_source", /* Name: */ "sdrplay_source",
/* Description: */ "SDRplay source module for SDR++", /* Description: */ "SDRplay source module for SDR++",
/* Author: */ "Ryzerth", /* Author: */ "Ryzerth",
/* Version: */ 0, 2, 0, /* Version: */ 0, 1, 0,
/* Max instances */ 1 /* Max instances */ 1
}; };
ConfigManager config; ConfigManager config;
unsigned int sampleRates[] = {
2000000,
3000000,
4000000,
5000000,
6000000,
7000000,
8000000,
9000000,
10000000
};
const char* sampleRatesTxt =
"2MHz\0"
"3MHz\0"
"4MHz\0"
"5MHz\0"
"6MHz\0"
"7MHz\0"
"8MHz\0"
"9MHz\0"
"10MHz\0";
sdrplay_api_Bw_MHzT bandwidths[] = {
sdrplay_api_BW_0_200,
sdrplay_api_BW_0_300,
sdrplay_api_BW_0_600,
sdrplay_api_BW_1_536,
sdrplay_api_BW_5_000,
sdrplay_api_BW_6_000,
sdrplay_api_BW_7_000,
sdrplay_api_BW_8_000,
};
const char* bandwidthsTxt =
"200KHz\0"
"300KHz\0"
"600KHz\0"
"1.536MHz\0"
"5MHz\0"
"6MHz\0"
"7MHz\0"
"8MHz\0"
"Auto\0";
sdrplay_api_Bw_MHzT preferedBandwidth[] = { sdrplay_api_Bw_MHzT preferedBandwidth[] = {
sdrplay_api_BW_5_000, sdrplay_api_BW_5_000,
sdrplay_api_BW_5_000, sdrplay_api_BW_5_000,
@ -164,11 +208,6 @@ public:
name += devArr[i].SerNo; name += devArr[i].SerNo;
name += ')'; name += ')';
break; break;
case SDRPLAY_RSP1B_ID:
name = "RSP1B (";
name += devArr[i].SerNo;
name += ')';
break;
case SDRPLAY_RSP2_ID: case SDRPLAY_RSP2_ID:
name = "RSP2 ("; name = "RSP2 (";
name += devArr[i].SerNo; name += devArr[i].SerNo;
@ -184,11 +223,6 @@ public:
name += devArr[i].SerNo; name += devArr[i].SerNo;
name += ')'; name += ')';
break; break;
case SDRPLAY_RSPdxR2_ID:
name = "RSPdx-R2 (";
name += devArr[i].SerNo;
name += ')';
break;
default: default:
name = "Unknown ("; name = "Unknown (";
name += devArr[i].SerNo; name += devArr[i].SerNo;
@ -256,30 +290,6 @@ public:
return; return;
} }
// Define the valid samplerates
samplerates.clear();
samplerates.define(2e6, "2MHz", 2e6);
samplerates.define(3e6, "3MHz", 3e6);
samplerates.define(4e6, "4MHz", 4e6);
samplerates.define(5e6, "5MHz", 5e6);
samplerates.define(6e6, "6MHz", 6e6);
samplerates.define(7e6, "7MHz", 7e6);
samplerates.define(8e6, "8MHz", 8e6);
samplerates.define(9e6, "9MHz", 9e6);
samplerates.define(10e6, "10MHz", 10e6);
// Define the valid bandwidths
bandwidths.clear();
bandwidths.define(200e3, "200KHz", sdrplay_api_BW_0_200);
bandwidths.define(300e3, "300KHz", sdrplay_api_BW_0_300);
bandwidths.define(600e3, "600KHz", sdrplay_api_BW_0_600);
bandwidths.define(1.536e6, "1.536MHz", sdrplay_api_BW_1_536);
bandwidths.define(5e6, "5MHz", sdrplay_api_BW_5_000);
bandwidths.define(6e6, "6MHz", sdrplay_api_BW_6_000);
bandwidths.define(7e6, "7MHz", sdrplay_api_BW_7_000);
bandwidths.define(8e6, "8MHz", sdrplay_api_BW_8_000);
bandwidths.define(0, "Auto", sdrplay_api_BW_Undefined);
channelParams = openDevParams->rxChannelA; channelParams = openDevParams->rxChannelA;
selectedName = devNameList[id]; selectedName = devNameList[id];
@ -287,7 +297,7 @@ public:
if (openDev.hwVer == SDRPLAY_RSP1_ID) { if (openDev.hwVer == SDRPLAY_RSP1_ID) {
lnaSteps = 4; lnaSteps = 4;
} }
else if (openDev.hwVer == SDRPLAY_RSP1A_ID || openDev.hwVer == SDRPLAY_RSP1B_ID) { else if (openDev.hwVer == SDRPLAY_RSP1A_ID) {
lnaSteps = 10; lnaSteps = 10;
} }
else if (openDev.hwVer == SDRPLAY_RSP2_ID) { else if (openDev.hwVer == SDRPLAY_RSP2_ID) {
@ -296,54 +306,78 @@ public:
else if (openDev.hwVer == SDRPLAY_RSPduo_ID) { else if (openDev.hwVer == SDRPLAY_RSPduo_ID) {
lnaSteps = 10; lnaSteps = 10;
} }
else if (openDev.hwVer == SDRPLAY_RSPdx_ID || openDev.hwVer == SDRPLAY_RSPdxR2_ID) { else if (openDev.hwVer == SDRPLAY_RSPdx_ID) {
lnaSteps = 28; lnaSteps = 28;
} }
// Select default settings bool created = false;
srId = 0;
sampleRate = samplerates.value(0);
bandwidthId = 8;
lnaGain = lnaSteps - 1;
gain = 59;
agc = false;
agcAttack = 500;
agcDecay = 500;
agcDecayDelay = 200;
agcDecayThreshold = 5;
agcSetPoint = -30;
ifModeId = 0;
rsp1a_fmmwNotch = false;
rsp2_fmmwNotch = false;
rspdx_fmmwNotch = false;
rspduo_fmmwNotch = false;
rsp1a_dabNotch = false;
rspdx_dabNotch = false;
rspduo_dabNotch = false;
rsp1a_biasT = false;
rsp2_biasT = false;
rspdx_biasT = false;
rspduo_biasT = false;
rsp2_antennaPort = 0;
rspdx_antennaPort = 0;
rspduo_antennaPort = 0;
config.acquire(); config.acquire();
if (!config.conf["devices"].contains(selectedName)) {
created = true;
config.conf["devices"][selectedName]["sampleRate"] = sampleRates[0];
config.conf["devices"][selectedName]["bwMode"] = 8; // Auto
config.conf["devices"][selectedName]["lnaGain"] = lnaSteps - 1;
config.conf["devices"][selectedName]["ifGain"] = 59;
config.conf["devices"][selectedName]["agc"] = false;
// General options config.conf["devices"][selectedName]["agcAttack"] = 500;
if (config.conf["devices"][selectedName].contains("samplerate")) { config.conf["devices"][selectedName]["agcDecay"] = 500;
int sr = config.conf["devices"][selectedName]["samplerate"]; config.conf["devices"][selectedName]["agcDecayDelay"] = 200;
if (samplerates.keyExists(sr)) { config.conf["devices"][selectedName]["agcDecayThreshold"] = 5;
srId = samplerates.keyId(sr); config.conf["devices"][selectedName]["agcSetPoint"] = -30;
sampleRate = samplerates[srId];
config.conf["devices"][selectedName]["ifModeId"] = 0;
if (openDev.hwVer == SDRPLAY_RSP1_ID) {
// No config to load
}
else if (openDev.hwVer == SDRPLAY_RSP1A_ID) {
config.conf["devices"][selectedName]["fmmwNotch"] = false;
config.conf["devices"][selectedName]["dabNotch"] = false;
config.conf["devices"][selectedName]["biast"] = false;
}
else if (openDev.hwVer == SDRPLAY_RSP2_ID) {
config.conf["devices"][selectedName]["antenna"] = 0;
config.conf["devices"][selectedName]["fmmwNotch"] = false;
config.conf["devices"][selectedName]["biast"] = false;
}
else if (openDev.hwVer == SDRPLAY_RSPduo_ID) {
config.conf["devices"][selectedName]["antenna"] = 0;
config.conf["devices"][selectedName]["fmmwNotch"] = false;
config.conf["devices"][selectedName]["dabNotch"] = false;
config.conf["devices"][selectedName]["biast"] = false;
}
else if (openDev.hwVer == SDRPLAY_RSPdx_ID) {
config.conf["devices"][selectedName]["antenna"] = 0;
config.conf["devices"][selectedName]["fmmwNotch"] = false;
config.conf["devices"][selectedName]["dabNotch"] = false;
config.conf["devices"][selectedName]["biast"] = false;
} }
} }
// General options
if (config.conf["devices"][selectedName].contains("sampleRate")) {
sampleRate = config.conf["devices"][selectedName]["sampleRate"];
bool found = false;
for (int i = 0; i < 9; i++) {
if (sampleRates[i] == sampleRate) {
srId = i;
found = true;
}
}
if (!found) {
sampleRate = sampleRates[0];
srId = 0;
}
}
if (config.conf["devices"][selectedName].contains("ifModeId")) { if (config.conf["devices"][selectedName].contains("ifModeId")) {
ifModeId = config.conf["devices"][selectedName]["ifModeId"]; ifModeId = config.conf["devices"][selectedName]["ifModeId"];
if (ifModeId != 0) { if (ifModeId != 0) {
sampleRate = ifModes[ifModeId].effectiveSamplerate; sampleRate = ifModes[ifModeId].effectiveSamplerate;
} }
} }
if (config.conf["devices"][selectedName].contains("bwMode")) { if (config.conf["devices"][selectedName].contains("bwMode")) {
bandwidthId = config.conf["devices"][selectedName]["bwMode"]; bandwidthId = config.conf["devices"][selectedName]["bwMode"];
} }
@ -354,6 +388,11 @@ public:
gain = config.conf["devices"][selectedName]["ifGain"]; gain = config.conf["devices"][selectedName]["ifGain"];
} }
if (config.conf["devices"][selectedName].contains("agc")) { if (config.conf["devices"][selectedName].contains("agc")) {
if (!config.conf["devices"][selectedName]["agc"].is_boolean()) {
int oldMode = config.conf["devices"][selectedName]["agc"];
config.conf["devices"][selectedName]["agc"] = (bool)(oldMode != 0);
created = true;
}
agc = config.conf["devices"][selectedName]["agc"]; agc = config.conf["devices"][selectedName]["agc"];
} }
if (config.conf["devices"][selectedName].contains("agcAttack")) { if (config.conf["devices"][selectedName].contains("agcAttack")) {
@ -376,7 +415,7 @@ public:
if (openDev.hwVer == SDRPLAY_RSP1_ID) { if (openDev.hwVer == SDRPLAY_RSP1_ID) {
// No config to load // No config to load
} }
else if (openDev.hwVer == SDRPLAY_RSP1A_ID || openDev.hwVer == SDRPLAY_RSP1B_ID) { else if (openDev.hwVer == SDRPLAY_RSP1A_ID) {
if (config.conf["devices"][selectedName].contains("fmmwNotch")) { if (config.conf["devices"][selectedName].contains("fmmwNotch")) {
rsp1a_fmmwNotch = config.conf["devices"][selectedName]["fmmwNotch"]; rsp1a_fmmwNotch = config.conf["devices"][selectedName]["fmmwNotch"];
} }
@ -412,7 +451,7 @@ public:
rspduo_biasT = config.conf["devices"][selectedName]["biast"]; rspduo_biasT = config.conf["devices"][selectedName]["biast"];
} }
} }
else if (openDev.hwVer == SDRPLAY_RSPdx_ID || openDev.hwVer == SDRPLAY_RSPdxR2_ID) { else if (openDev.hwVer == SDRPLAY_RSPdx_ID) {
if (config.conf["devices"][selectedName].contains("antenna")) { if (config.conf["devices"][selectedName].contains("antenna")) {
rspdx_antennaPort = config.conf["devices"][selectedName]["antenna"]; rspdx_antennaPort = config.conf["devices"][selectedName]["antenna"];
} }
@ -427,7 +466,7 @@ public:
} }
} }
config.release(); config.release(created);
if (lnaGain >= lnaSteps) { lnaGain = lnaSteps - 1; } if (lnaGain >= lnaSteps) { lnaGain = lnaSteps - 1; }
@ -575,7 +614,7 @@ private:
// General options // General options
if (_this->ifModeId == 0) { if (_this->ifModeId == 0) {
_this->bandwidth = (_this->bandwidthId == 8) ? preferedBandwidth[_this->srId] : _this->bandwidths[_this->bandwidthId]; _this->bandwidth = (_this->bandwidthId == 8) ? preferedBandwidth[_this->srId] : bandwidths[_this->bandwidthId];
_this->openDevParams->devParams->fsFreq.fsHz = _this->sampleRate; _this->openDevParams->devParams->fsFreq.fsHz = _this->sampleRate;
_this->channelParams->tunerParams.bwType = _this->bandwidth; _this->channelParams->tunerParams.bwType = _this->bandwidth;
} }
@ -654,14 +693,14 @@ private:
} }
if (_this->ifModeId == 0) { if (_this->ifModeId == 0) {
if (SmGui::Combo(CONCAT("##sdrplay_sr", _this->name), &_this->srId, _this->samplerates.txt)) { if (SmGui::Combo(CONCAT("##sdrplay_sr", _this->name), &_this->srId, sampleRatesTxt)) {
_this->sampleRate = _this->samplerates[_this->srId]; _this->sampleRate = sampleRates[_this->srId];
if (_this->bandwidthId == 8) { if (_this->bandwidthId == 8) {
_this->bandwidth = preferedBandwidth[_this->srId]; _this->bandwidth = preferedBandwidth[_this->srId];
} }
core::setInputSampleRate(_this->sampleRate); core::setInputSampleRate(_this->sampleRate);
config.acquire(); config.acquire();
config.conf["devices"][_this->selectedName]["samplerate"] = _this->samplerates.key(_this->srId); config.conf["devices"][_this->selectedName]["sampleRate"] = _this->sampleRate;
config.release(true); config.release(true);
} }
@ -676,8 +715,8 @@ private:
SmGui::LeftLabel("Bandwidth"); SmGui::LeftLabel("Bandwidth");
SmGui::FillWidth(); SmGui::FillWidth();
if (SmGui::Combo(CONCAT("##sdrplay_bw", _this->name), &_this->bandwidthId, _this->bandwidths.txt)) { if (SmGui::Combo(CONCAT("##sdrplay_bw", _this->name), &_this->bandwidthId, bandwidthsTxt)) {
_this->bandwidth = (_this->bandwidthId == 8) ? preferedBandwidth[_this->srId] : _this->bandwidths[_this->bandwidthId]; _this->bandwidth = (_this->bandwidthId == 8) ? preferedBandwidth[_this->srId] : bandwidths[_this->bandwidthId];
if (_this->running) { if (_this->running) {
_this->channelParams->tunerParams.bwType = _this->bandwidth; _this->channelParams->tunerParams.bwType = _this->bandwidth;
sdrplay_api_Update(_this->openDev.dev, _this->openDev.tuner, sdrplay_api_Update_Tuner_BwType, sdrplay_api_Update_Ext1_None); sdrplay_api_Update(_this->openDev.dev, _this->openDev.tuner, sdrplay_api_Update_Tuner_BwType, sdrplay_api_Update_Ext1_None);
@ -706,28 +745,10 @@ private:
} }
else { else {
config.acquire(); config.acquire();
// Reload samplerate _this->sampleRate = config.conf["devices"][_this->selectedName]["sampleRate"];
if (config.conf["devices"][_this->selectedName].contains("samplerate")) { _this->bandwidthId = config.conf["devices"][_this->selectedName]["bwMode"];
int sr = config.conf["devices"][_this->selectedName]["samplerate"]; config.release(false);
if (_this->samplerates.keyExists(sr)) { _this->bandwidth = (_this->bandwidthId == 8) ? preferedBandwidth[_this->srId] : bandwidths[_this->bandwidthId];
_this->srId = _this->samplerates.keyId(sr);
}
}
else {
_this->srId = 0;
}
// Reload bandwidth
if (config.conf["devices"][_this->selectedName].contains("bwMode")) {
_this->bandwidthId = config.conf["devices"][_this->selectedName]["bwMode"];
}
else {
// Auto
_this->bandwidthId = 8;
}
_this->sampleRate = _this->samplerates[_this->srId];
config.release();
_this->bandwidth = (_this->bandwidthId == 8) ? preferedBandwidth[_this->srId] : _this->bandwidths[_this->bandwidthId];
} }
core::setInputSampleRate(_this->sampleRate); core::setInputSampleRate(_this->sampleRate);
config.acquire(); config.acquire();
@ -833,7 +854,6 @@ private:
_this->RSP1Menu(); _this->RSP1Menu();
break; break;
case SDRPLAY_RSP1A_ID: case SDRPLAY_RSP1A_ID:
case SDRPLAY_RSP1B_ID:
_this->RSP1AMenu(); _this->RSP1AMenu();
break; break;
case SDRPLAY_RSP2_ID: case SDRPLAY_RSP2_ID:
@ -843,7 +863,6 @@ private:
_this->RSPduoMenu(); _this->RSPduoMenu();
break; break;
case SDRPLAY_RSPdx_ID: case SDRPLAY_RSPdx_ID:
case SDRPLAY_RSPdxR2_ID:
_this->RSPdxMenu(); _this->RSPdxMenu();
break; break;
default: default:
@ -1127,7 +1146,7 @@ private:
sdrplay_api_RxChannelParamsT* channelParams; sdrplay_api_RxChannelParamsT* channelParams;
sdrplay_api_Bw_MHzT bandwidth; sdrplay_api_Bw_MHzT bandwidth;
int bandwidthId = 8; // Auto int bandwidthId = 0;
int devId = 0; int devId = 0;
int srId = 0; int srId = 0;
@ -1182,9 +1201,6 @@ private:
std::string devListTxt; std::string devListTxt;
std::vector<std::string> devNameList; std::vector<std::string> devNameList;
std::string selectedName; std::string selectedName;
OptionList<int, int> samplerates;
OptionList<int, sdrplay_api_Bw_MHzT> bandwidths;
}; };
MOD_EXPORT void _INIT_() { MOD_EXPORT void _INIT_() {