1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 01:39:05 -05:00

Reverse API originator information: implemented for start/stop in all sink plugins

This commit is contained in:
f4exb 2019-03-25 15:26:01 +01:00
parent cd35732807
commit 345112f1fe
8 changed files with 104 additions and 16 deletions

View File

@ -728,16 +728,27 @@ void Bladerf1Output::webapiReverseSendSettings(QList<QString>& deviceSettingsKey
void Bladerf1Output::webapiReverseSendStartStop(bool start) void Bladerf1Output::webapiReverseSendStartStop(bool start)
{ {
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
swgDeviceSettings->setTx(1);
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
swgDeviceSettings->setDeviceHwType(new QString("BladeRF1"));
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run") QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
.arg(m_settings.m_reverseAPIAddress) .arg(m_settings.m_reverseAPIAddress)
.arg(m_settings.m_reverseAPIPort) .arg(m_settings.m_reverseAPIPort)
.arg(m_settings.m_reverseAPIDeviceIndex); .arg(m_settings.m_reverseAPIDeviceIndex);
m_networkRequest.setUrl(QUrl(deviceSettingsURL)); m_networkRequest.setUrl(QUrl(deviceSettingsURL));
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QBuffer *buffer=new QBuffer();
buffer->open((QBuffer::ReadWrite));
buffer->write(swgDeviceSettings->asJson().toUtf8());
buffer->seek(0);
if (start) { if (start) {
m_networkManager->sendCustomRequest(m_networkRequest, "POST"); m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
} else { } else {
m_networkManager->sendCustomRequest(m_networkRequest, "DELETE"); m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
} }
} }

View File

@ -1178,16 +1178,27 @@ void BladeRF2Output::webapiReverseSendSettings(QList<QString>& deviceSettingsKey
void BladeRF2Output::webapiReverseSendStartStop(bool start) void BladeRF2Output::webapiReverseSendStartStop(bool start)
{ {
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
swgDeviceSettings->setTx(1);
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
swgDeviceSettings->setDeviceHwType(new QString("BladeRF2"));
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run") QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
.arg(m_settings.m_reverseAPIAddress) .arg(m_settings.m_reverseAPIAddress)
.arg(m_settings.m_reverseAPIPort) .arg(m_settings.m_reverseAPIPort)
.arg(m_settings.m_reverseAPIDeviceIndex); .arg(m_settings.m_reverseAPIDeviceIndex);
m_networkRequest.setUrl(QUrl(deviceSettingsURL)); m_networkRequest.setUrl(QUrl(deviceSettingsURL));
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QBuffer *buffer=new QBuffer();
buffer->open((QBuffer::ReadWrite));
buffer->write(swgDeviceSettings->asJson().toUtf8());
buffer->seek(0);
if (start) { if (start) {
m_networkManager->sendCustomRequest(m_networkRequest, "POST"); m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
} else { } else {
m_networkManager->sendCustomRequest(m_networkRequest, "DELETE"); m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
} }
} }

View File

@ -676,16 +676,27 @@ void HackRFOutput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys,
void HackRFOutput::webapiReverseSendStartStop(bool start) void HackRFOutput::webapiReverseSendStartStop(bool start)
{ {
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
swgDeviceSettings->setTx(1);
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
swgDeviceSettings->setDeviceHwType(new QString("HackRF"));
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run") QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
.arg(m_settings.m_reverseAPIAddress) .arg(m_settings.m_reverseAPIAddress)
.arg(m_settings.m_reverseAPIPort) .arg(m_settings.m_reverseAPIPort)
.arg(m_settings.m_reverseAPIDeviceIndex); .arg(m_settings.m_reverseAPIDeviceIndex);
m_networkRequest.setUrl(QUrl(deviceSettingsURL)); m_networkRequest.setUrl(QUrl(deviceSettingsURL));
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QBuffer *buffer=new QBuffer();
buffer->open((QBuffer::ReadWrite));
buffer->write(swgDeviceSettings->asJson().toUtf8());
buffer->seek(0);
if (start) { if (start) {
m_networkManager->sendCustomRequest(m_networkRequest, "POST"); m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
} else { } else {
m_networkManager->sendCustomRequest(m_networkRequest, "DELETE"); m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
} }
} }

View File

@ -1514,16 +1514,27 @@ void LimeSDROutput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys
void LimeSDROutput::webapiReverseSendStartStop(bool start) void LimeSDROutput::webapiReverseSendStartStop(bool start)
{ {
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
swgDeviceSettings->setTx(1);
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
swgDeviceSettings->setDeviceHwType(new QString("LimeSDR"));
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run") QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
.arg(m_settings.m_reverseAPIAddress) .arg(m_settings.m_reverseAPIAddress)
.arg(m_settings.m_reverseAPIPort) .arg(m_settings.m_reverseAPIPort)
.arg(m_settings.m_reverseAPIDeviceIndex); .arg(m_settings.m_reverseAPIDeviceIndex);
m_networkRequest.setUrl(QUrl(deviceSettingsURL)); m_networkRequest.setUrl(QUrl(deviceSettingsURL));
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QBuffer *buffer=new QBuffer();
buffer->open((QBuffer::ReadWrite));
buffer->write(swgDeviceSettings->asJson().toUtf8());
buffer->seek(0);
if (start) { if (start) {
m_networkManager->sendCustomRequest(m_networkRequest, "POST"); m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
} else { } else {
m_networkManager->sendCustomRequest(m_networkRequest, "DELETE"); m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
} }
} }

View File

@ -856,16 +856,27 @@ void PlutoSDROutput::webapiReverseSendSettings(QList<QString>& deviceSettingsKey
void PlutoSDROutput::webapiReverseSendStartStop(bool start) void PlutoSDROutput::webapiReverseSendStartStop(bool start)
{ {
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
swgDeviceSettings->setTx(1);
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
swgDeviceSettings->setDeviceHwType(new QString("PlutoSDR"));
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run") QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
.arg(m_settings.m_reverseAPIAddress) .arg(m_settings.m_reverseAPIAddress)
.arg(m_settings.m_reverseAPIPort) .arg(m_settings.m_reverseAPIPort)
.arg(m_settings.m_reverseAPIDeviceIndex); .arg(m_settings.m_reverseAPIDeviceIndex);
m_networkRequest.setUrl(QUrl(deviceSettingsURL)); m_networkRequest.setUrl(QUrl(deviceSettingsURL));
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QBuffer *buffer=new QBuffer();
buffer->open((QBuffer::ReadWrite));
buffer->write(swgDeviceSettings->asJson().toUtf8());
buffer->seek(0);
if (start) { if (start) {
m_networkManager->sendCustomRequest(m_networkRequest, "POST"); m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
} else { } else {
m_networkManager->sendCustomRequest(m_networkRequest, "DELETE"); m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
} }
} }

View File

@ -678,15 +678,26 @@ void RemoteOutput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys,
void RemoteOutput::webapiReverseSendStartStop(bool start) void RemoteOutput::webapiReverseSendStartStop(bool start)
{ {
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
swgDeviceSettings->setTx(1);
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
swgDeviceSettings->setDeviceHwType(new QString("RemoteOutput"));
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run") QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
.arg(m_settings.m_reverseAPIAddress) .arg(m_settings.m_reverseAPIAddress)
.arg(m_settings.m_reverseAPIPort) .arg(m_settings.m_reverseAPIPort)
.arg(m_settings.m_reverseAPIDeviceIndex); .arg(m_settings.m_reverseAPIDeviceIndex);
m_networkRequest.setUrl(QUrl(deviceSettingsURL)); m_networkRequest.setUrl(QUrl(deviceSettingsURL));
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QBuffer *buffer=new QBuffer();
buffer->open((QBuffer::ReadWrite));
buffer->write(swgDeviceSettings->asJson().toUtf8());
buffer->seek(0);
if (start) { if (start) {
m_networkManager->sendCustomRequest(m_networkRequest, "POST"); m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
} else { } else {
m_networkManager->sendCustomRequest(m_networkRequest, "DELETE"); m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
} }
} }

View File

@ -1899,16 +1899,27 @@ void SoapySDROutput::webapiReverseSendSettings(QList<QString>& deviceSettingsKey
void SoapySDROutput::webapiReverseSendStartStop(bool start) void SoapySDROutput::webapiReverseSendStartStop(bool start)
{ {
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
swgDeviceSettings->setTx(1);
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
swgDeviceSettings->setDeviceHwType(new QString("SoapySDR"));
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run") QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
.arg(m_settings.m_reverseAPIAddress) .arg(m_settings.m_reverseAPIAddress)
.arg(m_settings.m_reverseAPIPort) .arg(m_settings.m_reverseAPIPort)
.arg(m_settings.m_reverseAPIDeviceIndex); .arg(m_settings.m_reverseAPIDeviceIndex);
m_networkRequest.setUrl(QUrl(deviceSettingsURL)); m_networkRequest.setUrl(QUrl(deviceSettingsURL));
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QBuffer *buffer=new QBuffer();
buffer->open((QBuffer::ReadWrite));
buffer->write(swgDeviceSettings->asJson().toUtf8());
buffer->seek(0);
if (start) { if (start) {
m_networkManager->sendCustomRequest(m_networkRequest, "POST"); m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
} else { } else {
m_networkManager->sendCustomRequest(m_networkRequest, "DELETE"); m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
} }
} }

View File

@ -1406,16 +1406,27 @@ void XTRXOutput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, c
void XTRXOutput::webapiReverseSendStartStop(bool start) void XTRXOutput::webapiReverseSendStartStop(bool start)
{ {
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
swgDeviceSettings->setTx(1);
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
swgDeviceSettings->setDeviceHwType(new QString("XTRX"));
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run") QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
.arg(m_settings.m_reverseAPIAddress) .arg(m_settings.m_reverseAPIAddress)
.arg(m_settings.m_reverseAPIPort) .arg(m_settings.m_reverseAPIPort)
.arg(m_settings.m_reverseAPIDeviceIndex); .arg(m_settings.m_reverseAPIDeviceIndex);
m_networkRequest.setUrl(QUrl(deviceSettingsURL)); m_networkRequest.setUrl(QUrl(deviceSettingsURL));
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QBuffer *buffer=new QBuffer();
buffer->open((QBuffer::ReadWrite));
buffer->write(swgDeviceSettings->asJson().toUtf8());
buffer->seek(0);
if (start) { if (start) {
m_networkManager->sendCustomRequest(m_networkRequest, "POST"); m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
} else { } else {
m_networkManager->sendCustomRequest(m_networkRequest, "DELETE"); m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
} }
} }