mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-11-06 18:57:39 +01:00
Add support for compound commands
This commit is contained in:
parent
e27702c166
commit
4092874f5c
@ -416,53 +416,55 @@ private:
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (parts[0] == "F") {
|
||||
std::lock_guard lck(vfoMtx);
|
||||
for(int i = 0; i < parts[0].length(); i++){
|
||||
if (parts[0].at(i) == 'F') {
|
||||
std::lock_guard lck(vfoMtx);
|
||||
|
||||
// if number of arguments isn't correct, return error
|
||||
if (parts.size() != 2) {
|
||||
// if number of arguments isn't correct, return error
|
||||
if (parts.size() != 2) {
|
||||
resp = "RPRT 1\n";
|
||||
client->write(resp.size(), (uint8_t*)resp.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
// If not controlling the VFO, return
|
||||
if (!tuningEnabled) {
|
||||
resp = "RPRT 0\n";
|
||||
client->write(resp.size(), (uint8_t*)resp.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse frequency and assign it to the VFO
|
||||
long long freq = std::stoll(parts[1]);
|
||||
tuner::tune(tuner::TUNER_MODE_NORMAL, selectedVfo, freq);
|
||||
resp = "RPRT 0\n";
|
||||
client->write(resp.size(), (uint8_t*)resp.c_str());
|
||||
}
|
||||
else if (parts[0].at(i) == 'f') {
|
||||
std::lock_guard lck(vfoMtx);
|
||||
|
||||
// Get center frequency of the SDR
|
||||
double freq = gui::waterfall.getCenterFrequency();
|
||||
|
||||
// Add the offset of the VFO if it exists
|
||||
if (sigpath::vfoManager.vfoExists(selectedVfo)) {
|
||||
freq += sigpath::vfoManager.getOffset(selectedVfo);
|
||||
}
|
||||
|
||||
// Respond with the frequency
|
||||
char buf[128];
|
||||
sprintf(buf, "%" PRIu64 "\n", (uint64_t)freq);
|
||||
client->write(strlen(buf), (uint8_t*)buf);
|
||||
}
|
||||
else if (parts[0].at(i) == 'q') {
|
||||
// Will close automatically
|
||||
}
|
||||
else {
|
||||
spdlog::error("Rigctl client sent invalid command: '{0}'", cmd);
|
||||
resp = "RPRT 1\n";
|
||||
client->write(resp.size(), (uint8_t*)resp.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
// If not controlling the VFO, return
|
||||
if (!tuningEnabled) {
|
||||
resp = "RPRT 0\n";
|
||||
client->write(resp.size(), (uint8_t*)resp.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse frequency and assign it to the VFO
|
||||
long long freq = std::stoll(parts[1]);
|
||||
tuner::tune(tuner::TUNER_MODE_NORMAL, selectedVfo, freq);
|
||||
resp = "RPRT 0\n";
|
||||
client->write(resp.size(), (uint8_t*)resp.c_str());
|
||||
}
|
||||
else if (parts[0] == "f") {
|
||||
std::lock_guard lck(vfoMtx);
|
||||
|
||||
// Get center frequency of the SDR
|
||||
double freq = gui::waterfall.getCenterFrequency();
|
||||
|
||||
// Add the offset of the VFO if it exists
|
||||
if (sigpath::vfoManager.vfoExists(selectedVfo)) {
|
||||
freq += sigpath::vfoManager.getOffset(selectedVfo);
|
||||
}
|
||||
|
||||
// Respond with the frequency
|
||||
char buf[128];
|
||||
sprintf(buf, "%" PRIu64 "\n", (uint64_t)freq);
|
||||
client->write(strlen(buf), (uint8_t*)buf);
|
||||
}
|
||||
else if (parts[0] == "q") {
|
||||
// Will close automatically
|
||||
}
|
||||
else {
|
||||
spdlog::error("Rigctl client sent invalid command: '{0}'", cmd);
|
||||
resp = "RPRT 1\n";
|
||||
client->write(resp.size(), (uint8_t*)resp.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user