mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-17 23:28:50 -05:00
Server: web API: /sdrangel/deviceset/{deviceSetIndex}/device/run POST,DELETE. LimeSDR Tx example working
This commit is contained in:
parent
6eda2fa087
commit
3bc221bab8
@ -37,7 +37,6 @@ MESSAGE_CLASS_DEFINITION(NFMMod::MsgConfigureNFMMod, Message)
|
||||
MESSAGE_CLASS_DEFINITION(NFMMod::MsgConfigureChannelizer, Message)
|
||||
MESSAGE_CLASS_DEFINITION(NFMMod::MsgConfigureFileSourceName, Message)
|
||||
MESSAGE_CLASS_DEFINITION(NFMMod::MsgConfigureFileSourceSeek, Message)
|
||||
MESSAGE_CLASS_DEFINITION(NFMMod::MsgConfigureAFInput, Message)
|
||||
MESSAGE_CLASS_DEFINITION(NFMMod::MsgConfigureFileSourceStreamTiming, Message)
|
||||
MESSAGE_CLASS_DEFINITION(NFMMod::MsgReportFileSourceStreamData, Message)
|
||||
MESSAGE_CLASS_DEFINITION(NFMMod::MsgReportFileSourceStreamTiming, Message)
|
||||
@ -356,15 +355,6 @@ bool NFMMod::handleMessage(const Message& cmd)
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureAFInput::match(cmd))
|
||||
{
|
||||
MsgConfigureAFInput& conf = (MsgConfigureAFInput&) cmd;
|
||||
m_afInput = conf.getAFInput();
|
||||
qDebug() << "NFMMod::handleMessage: MsgConfigureAFInput:"
|
||||
<< " m_afInput: " << m_afInput;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureFileSourceStreamTiming::match(cmd))
|
||||
{
|
||||
std::size_t samplesCount;
|
||||
@ -537,6 +527,7 @@ int NFMMod::webapiSettingsPutPatch(
|
||||
QString& errorMessage __attribute__((unused)))
|
||||
{
|
||||
NFMModSettings settings;
|
||||
bool frequencyOffsetChanged = false;
|
||||
|
||||
// for (int i = 0; i < channelSettingsKeys.size(); i++) {
|
||||
// qDebug("NFMMod::webapiSettingsPutPatch: settingKey: %s", qPrintable(channelSettingsKeys.at(i)));
|
||||
@ -563,8 +554,10 @@ int NFMMod::webapiSettingsPutPatch(
|
||||
if (channelSettingsKeys.contains("fmDeviation")) {
|
||||
settings.m_fmDeviation = response.getNfmModSettings()->getFmDeviation();
|
||||
}
|
||||
if (channelSettingsKeys.contains("inputFrequencyOffset")) {
|
||||
if (channelSettingsKeys.contains("inputFrequencyOffset"))
|
||||
{
|
||||
settings.m_inputFrequencyOffset = response.getNfmModSettings()->getInputFrequencyOffset();
|
||||
frequencyOffsetChanged = true;
|
||||
}
|
||||
if (channelSettingsKeys.contains("modAFInput")) {
|
||||
settings.m_modAFInput = (NFMModSettings::NFMModInputAF) response.getNfmModSettings()->getModAfInput();
|
||||
@ -625,6 +618,13 @@ int NFMMod::webapiSettingsPutPatch(
|
||||
}
|
||||
}
|
||||
|
||||
if (frequencyOffsetChanged)
|
||||
{
|
||||
NFMMod::MsgConfigureChannelizer *msgChan = NFMMod::MsgConfigureChannelizer::create(
|
||||
48000, settings.m_inputFrequencyOffset);
|
||||
m_inputMessageQueue.push(msgChan);
|
||||
}
|
||||
|
||||
MsgConfigureNFMMod *msg = MsgConfigureNFMMod::create(settings, force);
|
||||
m_inputMessageQueue.push(msg);
|
||||
|
||||
|
@ -159,27 +159,6 @@ public:
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgConfigureAFInput : public Message
|
||||
{
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
NFMModInputAF getAFInput() const { return m_afInput; }
|
||||
|
||||
static MsgConfigureAFInput* create(NFMModInputAF afInput)
|
||||
{
|
||||
return new MsgConfigureAFInput(afInput);
|
||||
}
|
||||
|
||||
private:
|
||||
NFMModInputAF m_afInput;
|
||||
|
||||
MsgConfigureAFInput(NFMModInputAF afInput) :
|
||||
Message(),
|
||||
m_afInput(afInput)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgReportFileSourceStreamTiming : public Message
|
||||
{
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
@ -205,8 +205,6 @@ void NFMModGUI::on_play_toggled(bool checked)
|
||||
ui->morseKeyer->setEnabled(!checked);
|
||||
m_settings.m_modAFInput = checked ? NFMModSettings::NFMModInputFile : NFMModSettings::NFMModInputNone;
|
||||
applySettings();
|
||||
// NFMMod::MsgConfigureAFInput* message = NFMMod::MsgConfigureAFInput::create(m_modAFInput);
|
||||
// m_nfmMod->getInputMessageQueue()->push(message);
|
||||
ui->navTimeSlider->setEnabled(!checked);
|
||||
m_enableNavTime = !checked;
|
||||
}
|
||||
@ -218,8 +216,6 @@ void NFMModGUI::on_tone_toggled(bool checked)
|
||||
ui->morseKeyer->setEnabled(!checked);
|
||||
m_settings.m_modAFInput = checked ? NFMModSettings::NFMModInputTone : NFMModSettings::NFMModInputNone;
|
||||
applySettings();
|
||||
// NFMMod::MsgConfigureAFInput* message = NFMMod::MsgConfigureAFInput::create(m_modAFInput);
|
||||
// m_nfmMod->getInputMessageQueue()->push(message);
|
||||
}
|
||||
|
||||
void NFMModGUI::on_morseKeyer_toggled(bool checked)
|
||||
@ -229,8 +225,6 @@ void NFMModGUI::on_morseKeyer_toggled(bool checked)
|
||||
ui->play->setEnabled(!checked);
|
||||
m_settings.m_modAFInput = checked ? NFMModSettings::NFMModInputCWTone : NFMModSettings::NFMModInputNone;
|
||||
applySettings();
|
||||
// NFMMod::MsgConfigureAFInput* message = NFMMod::MsgConfigureAFInput::create(m_modAFInput);
|
||||
// m_nfmMod->getInputMessageQueue()->push(message);
|
||||
}
|
||||
|
||||
void NFMModGUI::on_mic_toggled(bool checked)
|
||||
@ -240,8 +234,6 @@ void NFMModGUI::on_mic_toggled(bool checked)
|
||||
ui->morseKeyer->setEnabled(!checked);
|
||||
m_settings.m_modAFInput = checked ? NFMModSettings::NFMModInputAudio : NFMModSettings::NFMModInputNone;
|
||||
applySettings();
|
||||
// NFMMod::MsgConfigureAFInput* message = NFMMod::MsgConfigureAFInput::create(m_modAFInput);
|
||||
// m_nfmMod->getInputMessageQueue()->push(message);
|
||||
}
|
||||
|
||||
void NFMModGUI::on_navTimeSlider_valueChanged(int value)
|
||||
|
@ -45,6 +45,7 @@ NFMModSettings::NFMModSettings() :
|
||||
|
||||
void NFMModSettings::resetToDefaults()
|
||||
{
|
||||
m_afBandwidth = 3000;
|
||||
m_basebandSampleRate = 48000;
|
||||
m_outputSampleRate = 48000;
|
||||
m_inputFrequencyOffset = 0;
|
||||
|
@ -353,9 +353,12 @@ DSPDeviceSinkEngine::State DSPDeviceSinkEngine::gotoIdle()
|
||||
(*it)->stop();
|
||||
}
|
||||
|
||||
disconnect(m_deviceSampleSink->getSampleFifo(), SIGNAL(dataRead(int)), this, SLOT(handleForwardToSpectrumSink(int)));
|
||||
if (m_spectrumSink)
|
||||
{
|
||||
disconnect(m_deviceSampleSink->getSampleFifo(), SIGNAL(dataRead(int)), this, SLOT(handleForwardToSpectrumSink(int)));
|
||||
m_spectrumSink->stop();
|
||||
}
|
||||
|
||||
m_spectrumSink->stop();
|
||||
m_deviceSampleSink->stop();
|
||||
m_deviceDescription.clear();
|
||||
m_sampleRate = 0;
|
||||
@ -410,7 +413,9 @@ DSPDeviceSinkEngine::State DSPDeviceSinkEngine::gotoInit()
|
||||
(*it)->handleSourceMessage(notif);
|
||||
}
|
||||
|
||||
m_spectrumSink->handleMessage(notif);
|
||||
if (m_spectrumSink) {
|
||||
m_spectrumSink->handleMessage(notif);
|
||||
}
|
||||
|
||||
// pass data to listeners
|
||||
if (m_deviceSampleSink->getMessageQueueToGUI())
|
||||
@ -481,8 +486,11 @@ DSPDeviceSinkEngine::State DSPDeviceSinkEngine::gotoRunning()
|
||||
(*it)->start();
|
||||
}
|
||||
|
||||
connect(m_deviceSampleSink->getSampleFifo(), SIGNAL(dataRead(int)), this, SLOT(handleForwardToSpectrumSink(int)));
|
||||
m_spectrumSink->start();
|
||||
if (m_spectrumSink)
|
||||
{
|
||||
connect(m_deviceSampleSink->getSampleFifo(), SIGNAL(dataRead(int)), this, SLOT(handleForwardToSpectrumSink(int)));
|
||||
m_spectrumSink->start();
|
||||
}
|
||||
|
||||
qDebug() << "DSPDeviceSinkEngine::gotoRunning: input message queue pending: " << m_inputMessageQueue.size();
|
||||
|
||||
|
@ -925,6 +925,76 @@ int WebAPIAdapterSrv::devicesetDeviceSettingsPutPatch(
|
||||
}
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::devicesetDeviceRunPost(
|
||||
int deviceSetIndex,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size()))
|
||||
{
|
||||
DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex];
|
||||
|
||||
if (deviceSet->m_deviceSourceEngine) // Rx
|
||||
{
|
||||
DeviceSampleSource *source = deviceSet->m_deviceSourceAPI->getSampleSource();
|
||||
return source->webapiRun(true, response, *error.getMessage());
|
||||
}
|
||||
else if (deviceSet->m_deviceSinkEngine) // Tx
|
||||
{
|
||||
DeviceSampleSink *sink = deviceSet->m_deviceSinkAPI->getSampleSink();
|
||||
return sink->webapiRun(true, response, *error.getMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("DeviceSet error");
|
||||
return 500;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
|
||||
|
||||
return 404;
|
||||
}
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::devicesetDeviceRunDelete(
|
||||
int deviceSetIndex,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size()))
|
||||
{
|
||||
DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex];
|
||||
|
||||
if (deviceSet->m_deviceSourceEngine) // Rx
|
||||
{
|
||||
DeviceSampleSource *source = deviceSet->m_deviceSourceAPI->getSampleSource();
|
||||
return source->webapiRun(false, response, *error.getMessage());
|
||||
}
|
||||
else if (deviceSet->m_deviceSinkEngine) // Tx
|
||||
{
|
||||
DeviceSampleSink *sink = deviceSet->m_deviceSinkAPI->getSampleSink();
|
||||
return sink->webapiRun(false, response, *error.getMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("DeviceSet error");
|
||||
return 500;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
|
||||
|
||||
return 404;
|
||||
}
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::devicesetChannelPost(
|
||||
int deviceSetIndex,
|
||||
SWGSDRangel::SWGChannelSettings& query,
|
||||
|
@ -147,6 +147,16 @@ public:
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int devicesetDeviceRunPost(
|
||||
int deviceSetIndex,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int devicesetDeviceRunDelete(
|
||||
int deviceSetIndex,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int devicesetChannelPost(
|
||||
int deviceSetIndex,
|
||||
SWGSDRangel::SWGChannelSettings& query,
|
||||
|
Loading…
Reference in New Issue
Block a user