23 #include <QNetworkReply> 24 #include <QNetworkAccessManager> 46 m_deviceAPI(deviceAPI),
48 m_kiwiSDRWorker(
nullptr),
49 m_deviceDescription(),
51 m_masterTimer(deviceAPI->getMasterTimer())
53 m_kiwiSDRWorkerThread.
start();
56 m_deviceAPI->setNbSourceStreams(1);
57 m_deviceAPI->addAncillarySink(m_fileSink);
59 if (!m_sampleFifo.setSize(getSampleRate() * 2)) {
60 qCritical(
"KiwiSDRInput::KiwiSDRInput: Could not allocate SampleFifo");
63 m_networkManager =
new QNetworkAccessManager();
64 connect(m_networkManager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(networkManagerFinished(QNetworkReply*)));
95 QMutexLocker mutexLocker(&
m_mutex);
107 mutexLocker.unlock();
117 QMutexLocker mutexLocker(&
m_mutex);
199 qDebug() <<
"KiwiSDRInput::handleMessage: MsgConfigureKiwiSDR";
205 qDebug(
"KiwiSDRInput::handleMessage: config error");
213 qDebug() <<
"KiwiSDRInput::handleMessage: MsgFileRecord: " << conf.
getStartStop();
235 qDebug() <<
"KiwiSDRInput::handleMessage: MsgStartStop: " << (cmd.
getStartStop() ?
"start" :
"stop");
272 qDebug() <<
"KiwiSDRInput::applySettings: " 275 <<
" m_gain: " << settings.
m_gain 276 <<
" m_useAGC: " << settings.
m_useAGC 278 <<
" m_useAGC: " << settings.
m_useAGC 284 QList<QString> reverseAPIKeys;
288 reverseAPIKeys.append(
"serverAddress");
293 reverseAPIKeys.append(
"gain");
296 reverseAPIKeys.append(
"useAGC");
307 reverseAPIKeys.append(
"dcBlock");
313 reverseAPIKeys.append(
"centerFrequency");
325 qDebug(
"KiwiSDRInput::applySettings: call webapiReverseSendSettings");
339 QString& errorMessage)
349 QString& errorMessage)
367 QString& errorMessage)
378 const QStringList& deviceSettingsKeys,
380 QString& errorMessage)
385 if (deviceSettingsKeys.contains(
"gain")) {
388 if (deviceSettingsKeys.contains(
"useAGC")) {
391 if (deviceSettingsKeys.contains(
"dcBlock")) {
394 if (deviceSettingsKeys.contains(
"centerFrequency")) {
397 if (deviceSettingsKeys.contains(
"serverAddress")) {
400 if (deviceSettingsKeys.contains(
"fileRecordName")) {
403 if (deviceSettingsKeys.contains(
"useReverseAPI")) {
406 if (deviceSettingsKeys.contains(
"reverseAPIAddress")) {
409 if (deviceSettingsKeys.contains(
"reverseAPIPort")) {
412 if (deviceSettingsKeys.contains(
"reverseAPIDeviceIndex")) {
431 QString& errorMessage)
487 if (deviceSettingsKeys.contains(
"gain")) {
490 if (deviceSettingsKeys.contains(
"useAGC")) {
493 if (deviceSettingsKeys.contains(
"dcBlock") || force) {
496 if (deviceSettingsKeys.contains(
"centerFrequency") || force) {
499 if (deviceSettingsKeys.contains(
"serverAddress") || force) {
502 if (deviceSettingsKeys.contains(
"fileRecordName") || force) {
506 QString deviceSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/device/settings")
511 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
513 QBuffer *buffer=
new QBuffer();
514 buffer->open((QBuffer::ReadWrite));
515 buffer->write(swgDeviceSettings->
asJson().toUtf8());
521 delete swgDeviceSettings;
531 QString deviceSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/device/run")
536 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
538 QBuffer *buffer=
new QBuffer();
539 buffer->open((QBuffer::ReadWrite));
540 buffer->write(swgDeviceSettings->
asJson().toUtf8());
549 delete swgDeviceSettings;
554 QNetworkReply::NetworkError replyError = reply->error();
558 qWarning() <<
"KiwiSDRInput::networkManagerFinished:" 559 <<
" error(" << (int) replyError
560 <<
"): " << replyError
561 <<
": " << reply->errorString();
565 QString answer = reply->readAll();
567 qDebug(
"KiwiSDRInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
void setReverseApiPort(qint32 reverse_api_port)
bool startDeviceEngine()
Start the device engine corresponding to the stream type.
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void stopDeviceEngine()
Stop the device engine corresponding to the stream type.
void setFileName(const QString &filename)
void onCenterFrequencyChanged(quint64 centerFrequency)
uint getDeviceUID() const
Return the current device engine unique ID.
QString * getReverseApiAddress()
MessageQueue m_inputMessageQueue
Input queue to the source.
virtual QString asJson() override
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
void setCenterFrequency(qint64 center_frequency)
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
void setKiwiSdrReport(SWGKiwiSDRReport *kiwi_sdr_report)
QString * getFileRecordName()
void setOriginatorIndex(qint32 originator_index)
SampleSinkFifo m_sampleFifo
QString m_reverseAPIAddress
virtual bool handleMessage(const Message &message)
Processing of a message. Returns true if message has actually been processed.
SWGKiwiSDRReport * getKiwiSdrReport()
QString * getServerAddress()
void setServerAddress(QString *server_address)
int getDeviceSetIndex() const
#define MESSAGE_CLASS_DEFINITION(Name, BaseClass)
void genUniqueFileName(uint deviceUID, int istream=-1)
void setFileRecordName(QString *file_record_name)
void updateStatus(int status)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setKiwiSdrSettings(SWGKiwiSDRSettings *kiwi_sdr_settings)
static bool match(const Message *message)
void setUseReverseApi(qint32 use_reverse_api)
uint16_t m_reverseAPIDeviceIndex
void removeAncillarySink(BasebandSampleSink *sink, unsigned int index=0)
Removes it.
void onServerAddressChanged(QString serverAddress)
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
void setReverseApiAddress(QString *reverse_api_address)
void getDeviceEngineStateStr(QString &state)
qint32 getUseReverseApi()
void setGain(qint32 gain)
qint32 getReverseApiDeviceIndex()
bool deserialize(const QByteArray &data)
void setStatus(qint32 status)
uint16_t m_reverseAPIPort
quint64 m_centerFrequency
void setUseAgc(qint32 use_agc)
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection, int streamIndex=0)
Configure current device engine DSP corrections (Rx)
void setDirection(qint32 direction)
qint32 getReverseApiPort()
void onGainChanged(quint32 gain, bool useAGC)
QByteArray serialize() const
void setDeviceHwType(QString *device_hw_type)
SWGKiwiSDRSettings * getKiwiSdrSettings()
void setDcBlock(qint32 dc_block)
qint64 getCenterFrequency()