mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05:00
UDP source: implemeted WEB API (2)
This commit is contained in:
parent
54019d7a06
commit
3d8d9d34e0
@ -643,6 +643,118 @@ bool UDPSrc::deserialize(const QByteArray& data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int UDPSrc::webapiSettingsGet(
|
||||||
|
SWGSDRangel::SWGChannelSettings& response,
|
||||||
|
QString& errorMessage __attribute__((unused)))
|
||||||
|
{
|
||||||
|
response.setUdpSrcSettings(new SWGSDRangel::SWGUDPSrcSettings());
|
||||||
|
response.getUdpSrcSettings()->init();
|
||||||
|
webapiFormatChannelSettings(response, m_settings);
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
int UDPSrc::webapiSettingsPutPatch(
|
||||||
|
bool force,
|
||||||
|
const QStringList& channelSettingsKeys,
|
||||||
|
SWGSDRangel::SWGChannelSettings& response,
|
||||||
|
QString& errorMessage __attribute__((unused)))
|
||||||
|
{
|
||||||
|
UDPSrcSettings settings;
|
||||||
|
bool frequencyOffsetChanged = false;
|
||||||
|
|
||||||
|
if (channelSettingsKeys.contains("outputSampleRate")) {
|
||||||
|
settings.m_outputSampleRate = response.getUdpSrcSettings()->getOutputSampleRate();
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("sampleFormat")) {
|
||||||
|
settings.m_sampleFormat = (UDPSrcSettings::SampleFormat) response.getUdpSrcSettings()->getSampleFormat();
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("inputFrequencyOffset"))
|
||||||
|
{
|
||||||
|
settings.m_inputFrequencyOffset = response.getUdpSrcSettings()->getInputFrequencyOffset();
|
||||||
|
frequencyOffsetChanged = true;
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("rfBandwidth")) {
|
||||||
|
settings.m_rfBandwidth = response.getUdpSrcSettings()->getRfBandwidth();
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("fmDeviation")) {
|
||||||
|
settings.m_fmDeviation = response.getUdpSrcSettings()->getFmDeviation();
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("channelMute")) {
|
||||||
|
settings.m_channelMute = response.getUdpSrcSettings()->getChannelMute() != 0;
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("gain")) {
|
||||||
|
settings.m_gain = response.getUdpSrcSettings()->getGain();
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("squelchDB")) {
|
||||||
|
settings.m_squelchdB = response.getUdpSrcSettings()->getSquelchDb();
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("squelchGate")) {
|
||||||
|
settings.m_squelchGate = response.getUdpSrcSettings()->getSquelchGate();
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("squelchEnabled")) {
|
||||||
|
settings.m_squelchEnabled = response.getUdpSrcSettings()->getSquelchEnabled() != 0;
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("agc")) {
|
||||||
|
settings.m_agc = response.getUdpSrcSettings()->getAgc() != 0;
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("audioActive")) {
|
||||||
|
settings.m_audioActive = response.getUdpSrcSettings()->getAudioActive() != 0;
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("audioStereo")) {
|
||||||
|
settings.m_audioStereo = response.getUdpSrcSettings()->getAudioStereo() != 0;
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("volume")) {
|
||||||
|
settings.m_volume = response.getUdpSrcSettings()->getVolume();
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("udpAddress")) {
|
||||||
|
settings.m_udpAddress = *response.getUdpSrcSettings()->getUdpAddress();
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("udpPort")) {
|
||||||
|
settings.m_udpPort = response.getUdpSrcSettings()->getUdpPort();
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("audioPort")) {
|
||||||
|
settings.m_audioPort = response.getUdpSrcSettings()->getAudioPort();
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("rgbColor")) {
|
||||||
|
settings.m_rgbColor = response.getUdpSrcSettings()->getRgbColor();
|
||||||
|
}
|
||||||
|
if (channelSettingsKeys.contains("title")) {
|
||||||
|
settings.m_title = *response.getUdpSrcSettings()->getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frequencyOffsetChanged)
|
||||||
|
{
|
||||||
|
UDPSrc::MsgConfigureChannelizer *msgChan = UDPSrc::MsgConfigureChannelizer::create(
|
||||||
|
(int) settings.m_outputSampleRate,
|
||||||
|
(int) settings.m_inputFrequencyOffset);
|
||||||
|
m_inputMessageQueue.push(msgChan);
|
||||||
|
}
|
||||||
|
|
||||||
|
MsgConfigureUDPSrc *msg = MsgConfigureUDPSrc::create(settings, force);
|
||||||
|
m_inputMessageQueue.push(msg);
|
||||||
|
|
||||||
|
qDebug("UDPSrc::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue);
|
||||||
|
if (m_guiMessageQueue) // forward to GUI if any
|
||||||
|
{
|
||||||
|
MsgConfigureUDPSrc *msgToGUI = MsgConfigureUDPSrc::create(settings, force);
|
||||||
|
m_guiMessageQueue->push(msgToGUI);
|
||||||
|
}
|
||||||
|
|
||||||
|
webapiFormatChannelSettings(response, settings);
|
||||||
|
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
int UDPSrc::webapiReportGet(
|
||||||
|
SWGSDRangel::SWGChannelReport& response,
|
||||||
|
QString& errorMessage __attribute__((unused)))
|
||||||
|
{
|
||||||
|
response.setUdpSrcReport(new SWGSDRangel::SWGUDPSrcReport());
|
||||||
|
response.getUdpSrcReport()->init();
|
||||||
|
webapiFormatChannelReport(response);
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
void UDPSrc::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const UDPSrcSettings& settings)
|
void UDPSrc::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const UDPSrcSettings& settings)
|
||||||
{
|
{
|
||||||
response.getUdpSrcSettings()->setOutputSampleRate(settings.m_outputSampleRate);
|
response.getUdpSrcSettings()->setOutputSampleRate(settings.m_outputSampleRate);
|
||||||
|
@ -114,6 +114,20 @@ public:
|
|||||||
virtual QByteArray serialize() const;
|
virtual QByteArray serialize() const;
|
||||||
virtual bool deserialize(const QByteArray& data);
|
virtual bool deserialize(const QByteArray& data);
|
||||||
|
|
||||||
|
virtual int webapiSettingsGet(
|
||||||
|
SWGSDRangel::SWGChannelSettings& response,
|
||||||
|
QString& errorMessage);
|
||||||
|
|
||||||
|
virtual int webapiSettingsPutPatch(
|
||||||
|
bool force,
|
||||||
|
const QStringList& channelSettingsKeys,
|
||||||
|
SWGSDRangel::SWGChannelSettings& response,
|
||||||
|
QString& errorMessage);
|
||||||
|
|
||||||
|
virtual int webapiReportGet(
|
||||||
|
SWGSDRangel::SWGChannelReport& response,
|
||||||
|
QString& errorMessage);
|
||||||
|
|
||||||
static const QString m_channelIdURI;
|
static const QString m_channelIdURI;
|
||||||
static const QString m_channelId;
|
static const QString m_channelId;
|
||||||
static const int udpBlockSize = 512; // UDP block size in number of bytes
|
static const int udpBlockSize = 512; // UDP block size in number of bytes
|
||||||
|
@ -89,10 +89,34 @@ bool UDPSrcGUI::deserialize(const QByteArray& data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UDPSrcGUI::handleMessage(const Message& message __attribute__((unused)))
|
bool UDPSrcGUI::handleMessage(const Message& message )
|
||||||
{
|
{
|
||||||
qDebug() << "UDPSrcGUI::handleMessage";
|
if (UDPSrc::MsgConfigureUDPSrc::match(message))
|
||||||
return false;
|
{
|
||||||
|
const UDPSrc::MsgConfigureUDPSrc& cfg = (UDPSrc::MsgConfigureUDPSrc&) message;
|
||||||
|
m_settings = cfg.getSettings();
|
||||||
|
blockApplySettings(true);
|
||||||
|
displaySettings();
|
||||||
|
blockApplySettings(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UDPSrcGUI::handleSourceMessages()
|
||||||
|
{
|
||||||
|
Message* message;
|
||||||
|
|
||||||
|
while ((message = getInputMessageQueue()->pop()) != 0)
|
||||||
|
{
|
||||||
|
if (handleMessage(*message))
|
||||||
|
{
|
||||||
|
delete message;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPSrcGUI::channelMarkerChangedByCursor()
|
void UDPSrcGUI::channelMarkerChangedByCursor()
|
||||||
@ -150,6 +174,7 @@ UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam
|
|||||||
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum);
|
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum);
|
||||||
m_udpSrc = (UDPSrc*) rxChannel; //new UDPSrc(m_deviceUISet->m_deviceSourceAPI);
|
m_udpSrc = (UDPSrc*) rxChannel; //new UDPSrc(m_deviceUISet->m_deviceSourceAPI);
|
||||||
m_udpSrc->setSpectrum(m_spectrumVis);
|
m_udpSrc->setSpectrum(m_spectrumVis);
|
||||||
|
m_udpSrc->setMessageQueueToGUI(getInputMessageQueue());
|
||||||
|
|
||||||
ui->fmDeviation->setEnabled(false);
|
ui->fmDeviation->setEnabled(false);
|
||||||
|
|
||||||
@ -186,6 +211,7 @@ UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam
|
|||||||
|
|
||||||
connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor()));
|
connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor()));
|
||||||
connect(&m_channelMarker, SIGNAL(highlightedByCursor()), this, SLOT(channelMarkerHighlightedByCursor()));
|
connect(&m_channelMarker, SIGNAL(highlightedByCursor()), this, SLOT(channelMarkerHighlightedByCursor()));
|
||||||
|
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
|
||||||
|
|
||||||
ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
|
ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
|
||||||
|
|
||||||
|
@ -92,6 +92,7 @@ private:
|
|||||||
void enterEvent(QEvent*);
|
void enterEvent(QEvent*);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void handleSourceMessages();
|
||||||
void on_deltaFrequency_changed(qint64 value);
|
void on_deltaFrequency_changed(qint64 value);
|
||||||
void on_sampleFormat_currentIndexChanged(int index);
|
void on_sampleFormat_currentIndexChanged(int index);
|
||||||
void on_outputUDPAddress_editingFinished();
|
void on_outputUDPAddress_editingFinished();
|
||||||
|
@ -83,7 +83,7 @@ bool UDPSinkGUI::deserialize(const QByteArray& data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UDPSinkGUI::handleMessage(const Message& message __attribute__((unused)))
|
bool UDPSinkGUI::handleMessage(const Message& message)
|
||||||
{
|
{
|
||||||
if (UDPSink::MsgConfigureUDPSink::match(message))
|
if (UDPSink::MsgConfigureUDPSink::match(message))
|
||||||
{
|
{
|
||||||
|
@ -1973,6 +1973,20 @@ bool WebAPIRequestMapper::validateChannelSettings(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (*channelType == "UDPSrc")
|
||||||
|
{
|
||||||
|
if (channelSettings.getTx() == 0)
|
||||||
|
{
|
||||||
|
QJsonObject udpSrcSettingsJsonObject = jsonObject["UDPSrcSettings"].toObject();
|
||||||
|
channelSettingsKeys = udpSrcSettingsJsonObject.keys();
|
||||||
|
channelSettings.setUdpSrcSettings(new SWGSDRangel::SWGUDPSrcSettings());
|
||||||
|
channelSettings.getUdpSrcSettings()->fromJsonObject(udpSrcSettingsJsonObject);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (*channelType == "WFMDemod")
|
else if (*channelType == "WFMDemod")
|
||||||
{
|
{
|
||||||
if (channelSettings.getTx() == 0)
|
if (channelSettings.getTx() == 0)
|
||||||
|
@ -199,6 +199,13 @@ def setupChannel(deviceset_url, options):
|
|||||||
settings["DSDDemodSettings"]["enableCosineFiltering"] = 1
|
settings["DSDDemodSettings"]["enableCosineFiltering"] = 1
|
||||||
settings["DSDDemodSettings"]["pllLock"] = 1
|
settings["DSDDemodSettings"]["pllLock"] = 1
|
||||||
settings["DSDDemodSettings"]["title"] = "Channel %d" % i
|
settings["DSDDemodSettings"]["title"] = "Channel %d" % i
|
||||||
|
elif options.channel_id == "UDPSrc":
|
||||||
|
settings["UDPSrcSettings"]["inputFrequencyOffset"] = options.channel_freq
|
||||||
|
settings["UDPSrcSettings"]["rfBandwidth"] = options.rf_bw
|
||||||
|
settings["UDPSrcSettings"]["volume"] = options.volume
|
||||||
|
settings["UDPSrcSettings"]["squelchDB"] = options.squelch_db
|
||||||
|
settings["UDPSrcSettings"]["channelMute"] = 0
|
||||||
|
settings["UDPSrcSettings"]["title"] = "Channel %d" % i
|
||||||
|
|
||||||
r = callAPI(deviceset_url + "/channel/%d/settings" % i, "PATCH", None, settings, "Change demod")
|
r = callAPI(deviceset_url + "/channel/%d/settings" % i, "PATCH", None, settings, "Change demod")
|
||||||
if r is None:
|
if r is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user