1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 12:51:49 -05:00

Merge pull request #1983 from mxi-box/simpleptt_enhance

SimplePTT: bugfix and enhancement
This commit is contained in:
Edouard Griffiths 2024-02-12 20:00:24 +01:00 committed by GitHub
commit 4f2824d67a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 41 additions and 17 deletions

View File

@ -288,6 +288,8 @@ void SimplePTTGUI::updateDeviceSetLists()
ui->rxDevice->clear(); ui->rxDevice->clear();
ui->txDevice->clear(); ui->txDevice->clear();
ui->rxDevice->addItem(tr("None"), -1);
ui->txDevice->addItem(tr("None"), -1);
unsigned int deviceIndex = 0; unsigned int deviceIndex = 0;
unsigned int rxIndex = 0; unsigned int rxIndex = 0;
unsigned int txIndex = 0; unsigned int txIndex = 0;
@ -296,6 +298,7 @@ void SimplePTTGUI::updateDeviceSetLists()
{ {
DSPDeviceSourceEngine *deviceSourceEngine = (*it)->m_deviceSourceEngine; DSPDeviceSourceEngine *deviceSourceEngine = (*it)->m_deviceSourceEngine;
DSPDeviceSinkEngine *deviceSinkEngine = (*it)->m_deviceSinkEngine; DSPDeviceSinkEngine *deviceSinkEngine = (*it)->m_deviceSinkEngine;
DSPDeviceMIMOEngine *deviceMIMOEngine = (*it)->m_deviceMIMOEngine;
if (deviceSourceEngine) if (deviceSourceEngine)
{ {
@ -307,6 +310,14 @@ void SimplePTTGUI::updateDeviceSetLists()
ui->txDevice->addItem(QString("T%1").arg(deviceIndex), deviceIndex); ui->txDevice->addItem(QString("T%1").arg(deviceIndex), deviceIndex);
txIndex++; txIndex++;
} }
else if (deviceMIMOEngine)
{
QString text = QString("M%1").arg(deviceIndex);
ui->rxDevice->addItem(text, deviceIndex);
ui->txDevice->addItem(text, deviceIndex);
rxIndex++;
txIndex++;
}
} }
int rxDeviceIndex; int rxDeviceIndex;
@ -314,11 +325,8 @@ void SimplePTTGUI::updateDeviceSetLists()
if (rxIndex > 0) if (rxIndex > 0)
{ {
if (m_settings.m_rxDeviceSetIndex < 0) { int index = ui->rxDevice->findData(m_settings.m_rxDeviceSetIndex);
ui->rxDevice->setCurrentIndex(0); ui->rxDevice->setCurrentIndex(index == -1 ? 0 : index);
} else {
ui->rxDevice->setCurrentIndex(m_settings.m_rxDeviceSetIndex);
}
rxDeviceIndex = ui->rxDevice->currentData().toInt(); rxDeviceIndex = ui->rxDevice->currentData().toInt();
} }
@ -330,11 +338,8 @@ void SimplePTTGUI::updateDeviceSetLists()
if (txIndex > 0) if (txIndex > 0)
{ {
if (m_settings.m_txDeviceSetIndex < 0) { int index = ui->txDevice->findData(m_settings.m_txDeviceSetIndex);
ui->txDevice->setCurrentIndex(0); ui->txDevice->setCurrentIndex(index == -1 ? 0 : index);
} else {
ui->txDevice->setCurrentIndex(m_settings.m_txDeviceSetIndex);
}
txDeviceIndex = ui->txDevice->currentData().toInt(); txDeviceIndex = ui->txDevice->currentData().toInt();
} }
@ -425,7 +430,7 @@ void SimplePTTGUI::on_rxDevice_currentIndexChanged(int index)
{ {
if (index >= 0) if (index >= 0)
{ {
m_settings.m_rxDeviceSetIndex = index; m_settings.m_rxDeviceSetIndex = ui->rxDevice->currentData().toInt();
m_settingsKeys.append("rxDeviceSetIndex"); m_settingsKeys.append("rxDeviceSetIndex");
applySettings(); applySettings();
} }
@ -435,7 +440,7 @@ void SimplePTTGUI::on_txDevice_currentIndexChanged(int index)
{ {
if (index >= 0) if (index >= 0)
{ {
m_settings.m_txDeviceSetIndex = index; m_settings.m_txDeviceSetIndex = ui->txDevice->currentData().toInt();
m_settingsKeys.append("txDeviceSetIndex"); m_settingsKeys.append("txDeviceSetIndex");
applySettings(); applySettings();
} }

View File

@ -23,6 +23,7 @@
#include "SWGSuccessResponse.h" #include "SWGSuccessResponse.h"
#include "SWGErrorResponse.h" #include "SWGErrorResponse.h"
#include "maincore.h"
#include "webapi/webapiadapterinterface.h" #include "webapi/webapiadapterinterface.h"
#include "audio/audiodevicemanager.h" #include "audio/audiodevicemanager.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
@ -242,13 +243,31 @@ bool SimplePTTWorker::turnDevice(bool on)
SWGSDRangel::SWGDeviceState response; SWGSDRangel::SWGDeviceState response;
SWGSDRangel::SWGErrorResponse error; SWGSDRangel::SWGErrorResponse error;
int httpCode; int httpCode;
unsigned int deviceSetIndex = m_tx ? m_settings.m_txDeviceSetIndex : m_settings.m_rxDeviceSetIndex;
MainCore *mainCore = MainCore::instance();
auto deviceSets = mainCore->getDeviceSets();
if (deviceSetIndex >= deviceSets.size())
{
qWarning("SimplePTTWorker::turnDevice: deviceSetIndex out of range");
return false;
}
bool isDeviceMIMO = mainCore->getDeviceSetTypeId(deviceSets[deviceSetIndex]) == 'M';
if (on) { if (on) {
if (isDeviceMIMO) {
httpCode = m_webAPIAdapterInterface->devicesetDeviceSubsystemRunPost(
deviceSetIndex, m_tx ? 1 : 0, response, error);
} else {
httpCode = m_webAPIAdapterInterface->devicesetDeviceRunPost( httpCode = m_webAPIAdapterInterface->devicesetDeviceRunPost(
m_tx ? m_settings.m_txDeviceSetIndex : m_settings.m_rxDeviceSetIndex, response, error); deviceSetIndex, response, error);
}
} else {
if (isDeviceMIMO) {
httpCode = m_webAPIAdapterInterface->devicesetDeviceSubsystemRunDelete(
deviceSetIndex, m_tx ? 1 : 0, response, error);
} else { } else {
httpCode = m_webAPIAdapterInterface->devicesetDeviceRunDelete( httpCode = m_webAPIAdapterInterface->devicesetDeviceRunDelete(
m_tx ? m_settings.m_txDeviceSetIndex : m_settings.m_rxDeviceSetIndex, response, error); deviceSetIndex, response, error);
}
} }
if (httpCode/100 == 2) if (httpCode/100 == 2)