SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
hackrfoutput.cpp
Go to the documentation of this file.
1 // Copyright (C) 2017 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #include <string.h>
19 #include <errno.h>
20 
21 #include <QDebug>
22 #include <QNetworkReply>
23 #include <QBuffer>
24 
25 #include "SWGDeviceSettings.h"
26 #include "SWGDeviceState.h"
27 
28 #include "util/simpleserializer.h"
29 #include "dsp/dspcommands.h"
30 #include "dsp/dspengine.h"
31 #include "device/deviceapi.h"
33 #include "hackrfoutputthread.h"
34 #include "hackrfoutput.h"
35 
39 
41  m_deviceAPI(deviceAPI),
42  m_settings(),
43  m_dev(0),
44  m_hackRFThread(0),
45  m_deviceDescription("HackRFOutput"),
46  m_running(false)
47 {
48  openDevice();
49  m_deviceAPI->setNbSinkStreams(1);
50  m_deviceAPI->setBuddySharedPtr(&m_sharedParams);
51  m_networkManager = new QNetworkAccessManager();
52  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
53 }
54 
56 {
57  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
58  delete m_networkManager;
59 
60  if (m_running) {
61  stop();
62  }
63 
64  closeDevice();
66 }
67 
69 {
70  delete this;
71 }
72 
74 {
75  if (m_dev != 0)
76  {
77  closeDevice();
78  }
79 
81 
82  if (m_deviceAPI->getSourceBuddies().size() > 0)
83  {
84  DeviceAPI *buddy = m_deviceAPI->getSourceBuddies()[0];
85  DeviceHackRFParams *buddySharedParams = (DeviceHackRFParams *) buddy->getBuddySharedPtr();
86 
87  if (buddySharedParams == 0)
88  {
89  qCritical("HackRFOutput::openDevice: could not get shared parameters from buddy");
90  return false;
91  }
92 
93  if ((m_dev = buddySharedParams->m_dev) == 0) // device is not opened by buddy
94  {
95  qCritical("HackRFOutput::openDevice: could not get HackRF handle from buddy");
96  return false;
97  }
98 
99  m_sharedParams = *(buddySharedParams); // copy parameters from buddy
101  }
102  else
103  {
105  {
106  qCritical("HackRFOutput::openDevice: could not open HackRF %s", qPrintable(m_deviceAPI->getSamplingDeviceSerial()));
107  return false;
108  }
109 
111  }
112 
113  return true;
114 }
115 
117 {
118  applySettings(m_settings, true);
119 }
120 
122 {
123  if (!m_dev) {
124  return false;
125  }
126 
127  if (m_running) {
128  stop();
129  }
130 
132 
133 // mutexLocker.unlock();
134 
135  applySettings(m_settings, true);
136 
139 
141 
142  qDebug("HackRFOutput::start: started");
143  m_running = true;
144 
145  return true;
146 }
147 
149 {
150  if (m_deviceAPI->getSourceBuddies().size() == 0)
151  {
152  qDebug("HackRFOutput::closeDevice: closing device since Rx side is not open");
153 
154  if(m_dev != 0) // close HackRF
155  {
156  hackrf_close(m_dev);
157  //hackrf_exit(); // TODO: this may not work if several HackRF Devices are running concurrently. It should be handled globally in the application
158  }
159  }
160 
161  m_sharedParams.m_dev = 0;
162  m_dev = 0;
163 }
164 
166 {
167  qDebug("HackRFOutput::stop");
168 // QMutexLocker mutexLocker(&m_mutex);
169 
170  if(m_hackRFThread != 0)
171  {
173  delete m_hackRFThread;
174  m_hackRFThread = 0;
175  }
176 
177  m_running = false;
178 }
179 
180 QByteArray HackRFOutput::serialize() const
181 {
182  return m_settings.serialize();
183 }
184 
185 bool HackRFOutput::deserialize(const QByteArray& data)
186 {
187  bool success = true;
188 
189  if (!m_settings.deserialize(data))
190  {
192  success = false;
193  }
194 
196  m_inputMessageQueue.push(message);
197 
198  if (m_guiMessageQueue)
199  {
201  m_guiMessageQueue->push(messageToGUI);
202  }
203 
204  return success;
205 }
206 
208 {
209  return m_deviceDescription;
210 }
211 
213 {
214  int rate = m_settings.m_devSampleRate;
215  return (rate / (1<<m_settings.m_log2Interp));
216 }
217 
219 {
221 }
222 
223 void HackRFOutput::setCenterFrequency(qint64 centerFrequency)
224 {
225  HackRFOutputSettings settings = m_settings;
226  settings.m_centerFrequency = centerFrequency;
227 
228  MsgConfigureHackRF* message = MsgConfigureHackRF::create(settings, false);
229  m_inputMessageQueue.push(message);
230 
231  if (m_guiMessageQueue)
232  {
233  MsgConfigureHackRF* messageToGUI = MsgConfigureHackRF::create(settings, false);
234  m_guiMessageQueue->push(messageToGUI);
235  }
236 }
237 
239 {
240  if (MsgConfigureHackRF::match(message))
241  {
242  MsgConfigureHackRF& conf = (MsgConfigureHackRF&) message;
243  qDebug() << "HackRFOutput::handleMessage: MsgConfigureHackRF";
244 
245  bool success = applySettings(conf.getSettings(), conf.getForce());
246 
247  if (!success)
248  {
249  qDebug("HackRFOutput::handleMessage: MsgConfigureHackRF: config error");
250  }
251 
252  return true;
253  }
254  else if (MsgStartStop::match(message))
255  {
256  MsgStartStop& cmd = (MsgStartStop&) message;
257  qDebug() << "HackRFOutput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
258 
259  if (cmd.getStartStop())
260  {
262  {
264  }
265  }
266  else
267  {
269  }
270 
273  }
274 
275  return true;
276  }
278  {
280  qint64 centerFrequency = DeviceSampleSink::calculateCenterFrequency(
281  freqMsg.getFrequency(),
282  0,
286  qDebug("HackRFOutput::handleMessage: MsgSynchronizeFrequency: centerFrequency: %lld Hz", centerFrequency);
287  HackRFOutputSettings settings = m_settings;
288  settings.m_centerFrequency = centerFrequency;
289 
290  if (m_guiMessageQueue)
291  {
292  MsgConfigureHackRF* messageToGUI = MsgConfigureHackRF::create(settings, false);
293  m_guiMessageQueue->push(messageToGUI);
294  }
295 
297  int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Interp);
300 
301  return true;
302  }
303  else
304  {
305  return false;
306  }
307 }
308 
309 void HackRFOutput::setDeviceCenterFrequency(quint64 freq_hz, qint32 LOppmTenths)
310 {
311  if (!m_dev) {
312  return;
313  }
314 
315  qint64 df = ((qint64)freq_hz * LOppmTenths) / 10000000LL;
316  hackrf_error rc = (hackrf_error) hackrf_set_freq(m_dev, static_cast<uint64_t>(freq_hz + df));
317 
318  if (rc != HACKRF_SUCCESS) {
319  qWarning("HackRFOutput::setDeviceCenterFrequency: could not frequency to %llu Hz", freq_hz + df);
320  } else {
321  qDebug("HackRFOutput::setDeviceCenterFrequency: frequency set to %llu Hz", freq_hz + df);
322  }
323 }
324 
325 bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool force)
326 {
327 // QMutexLocker mutexLocker(&m_mutex);
328 
329  bool forwardChange = false;
330  bool suspendThread = false;
331  bool threadWasRunning = false;
332  hackrf_error rc;
333  QList<QString> reverseAPIKeys;
334 
335  qDebug() << "HackRFOutput::applySettings"
336  << " m_centerFrequency: " << settings.m_centerFrequency
337  << " m_LOppmTenths: " << settings.m_LOppmTenths
338  << " m_bandwidth: " << settings.m_bandwidth
339  << " m_devSampleRate: " << settings.m_devSampleRate
340  << " m_log2Interp: " << settings.m_log2Interp
341  << " m_fcPos: " << settings.m_fcPos
342  << " m_biasT: " << settings.m_biasT
343  << " m_lnaExt: " << settings.m_lnaExt
344  << " m_vgaGain: " << settings.m_vgaGain
345  << " m_useReverseAPI: " << settings.m_useReverseAPI
346  << " m_reverseAPIAddress: " << settings.m_reverseAPIAddress
347  << " m_reverseAPIPort: " << settings.m_reverseAPIPort
348  << " m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex
349  << " force: " << force;
350 
351  if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force) {
352  reverseAPIKeys.append("devSampleRate");
353  }
354 
355  if ((m_settings.m_devSampleRate != settings.m_devSampleRate) ||
356  (m_settings.m_log2Interp != settings.m_log2Interp) || force)
357  {
358  suspendThread = true;
359  }
360 
361  if (suspendThread)
362  {
363  if (m_hackRFThread)
364  {
365  if (m_hackRFThread->isRunning())
366  {
368  threadWasRunning = true;
369  }
370  }
371  }
372 
373  if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || (m_settings.m_log2Interp != settings.m_log2Interp) || force)
374  {
375  forwardChange = true;
376  int fifoSize = std::max(
379  m_sampleSourceFifo.resize(fifoSize);
380  }
381 
382  if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force)
383  {
384  if (m_dev != 0)
385  {
386  rc = (hackrf_error) hackrf_set_sample_rate_manual(m_dev, settings.m_devSampleRate, 1);
387 
388  if (rc != HACKRF_SUCCESS)
389  {
390  qCritical("HackRFOutput::applySettings: could not set sample rate to %llu S/s: %s",
391  settings.m_devSampleRate,
392  hackrf_error_name(rc));
393  }
394  else
395  {
396  qDebug("HackRFOutput::applySettings: sample rate set to %llu S/s",
397  settings.m_devSampleRate);
398  }
399  }
400  }
401 
402  if ((m_settings.m_log2Interp != settings.m_log2Interp) || force)
403  {
404  reverseAPIKeys.append("log2Interp");
405 
406  if (m_hackRFThread != 0)
407  {
409  qDebug() << "HackRFOutput: set interpolation to " << (1<<settings.m_log2Interp);
410  }
411  }
412 
413  if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) {
414  reverseAPIKeys.append("centerFrequency");
415  }
416  if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) {
417  reverseAPIKeys.append("LOppmTenths");
418  }
419  if ((m_settings.m_fcPos != settings.m_fcPos) || force) {
420  reverseAPIKeys.append("fcPos");
421  }
422 
423  if ((m_settings.m_centerFrequency != settings.m_centerFrequency) ||
425  (m_settings.m_LOppmTenths != settings.m_LOppmTenths) ||
426  (m_settings.m_log2Interp != settings.m_log2Interp) ||
427  (m_settings.m_fcPos != settings.m_fcPos) || force)
428  {
429  qint64 deviceCenterFrequency = DeviceSampleSink::calculateDeviceCenterFrequency(
430  settings.m_centerFrequency,
431  0,
432  settings.m_log2Interp,
434  settings.m_devSampleRate);
435  setDeviceCenterFrequency(deviceCenterFrequency, settings.m_LOppmTenths);
436 
437  if (m_deviceAPI->getSourceBuddies().size() > 0)
438  {
439  DeviceAPI *buddy = m_deviceAPI->getSourceBuddies()[0];
441  buddy->getSamplingDeviceInputMessageQueue()->push(freqMsg);
442  }
443 
444  forwardChange = true;
445  }
446 
447  if ((m_settings.m_fcPos != settings.m_fcPos) || force)
448  {
449  if (m_hackRFThread != 0) {
450  m_hackRFThread->setFcPos((int) settings.m_fcPos);
451  }
452  }
453 
454  if ((m_settings.m_vgaGain != settings.m_vgaGain) || force)
455  {
456  reverseAPIKeys.append("vgaGain");
457 
458  if (m_dev != 0)
459  {
460  rc = (hackrf_error) hackrf_set_txvga_gain(m_dev, settings.m_vgaGain);
461 
462  if (rc != HACKRF_SUCCESS) {
463  qDebug("HackRFOutput::applySettings: hackrf_set_txvga_gain failed: %s", hackrf_error_name(rc));
464  } else {
465  qDebug() << "HackRFOutput:applySettings: TxVGA gain set to " << settings.m_vgaGain;
466  }
467  }
468  }
469 
470  if ((m_settings.m_bandwidth != settings.m_bandwidth) || force)
471  {
472  reverseAPIKeys.append("bandwidth");
473 
474  if (m_dev != 0)
475  {
476  uint32_t bw_index = hackrf_compute_baseband_filter_bw_round_down_lt(settings.m_bandwidth + 1); // +1 so the round down to lower than yields desired bandwidth
477  rc = (hackrf_error) hackrf_set_baseband_filter_bandwidth(m_dev, bw_index);
478 
479  if (rc != HACKRF_SUCCESS) {
480  qDebug("HackRFInput::applySettings: hackrf_set_baseband_filter_bandwidth failed: %s", hackrf_error_name(rc));
481  } else {
482  qDebug() << "HackRFInput:applySettings: Baseband BW filter set to " << settings.m_bandwidth << " Hz";
483  }
484  }
485  }
486 
487  if ((m_settings.m_biasT != settings.m_biasT) || force)
488  {
489  reverseAPIKeys.append("biasT");
490 
491  if (m_dev != 0)
492  {
493  rc = (hackrf_error) hackrf_set_antenna_enable(m_dev, (settings.m_biasT ? 1 : 0));
494 
495  if (rc != HACKRF_SUCCESS) {
496  qDebug("HackRFInput::applySettings: hackrf_set_antenna_enable failed: %s", hackrf_error_name(rc));
497  } else {
498  qDebug() << "HackRFInput:applySettings: bias tee set to " << settings.m_biasT;
499  }
500  }
501  }
502 
503  if ((m_settings.m_lnaExt != settings.m_lnaExt) || force)
504  {
505  reverseAPIKeys.append("lnaExt");
506 
507  if (m_dev != 0)
508  {
509  rc = (hackrf_error) hackrf_set_amp_enable(m_dev, (settings.m_lnaExt ? 1 : 0));
510 
511  if (rc != HACKRF_SUCCESS) {
512  qDebug("HackRFInput::applySettings: hackrf_set_amp_enable failed: %s", hackrf_error_name(rc));
513  } else {
514  qDebug() << "HackRFInput:applySettings: extra LNA set to " << settings.m_lnaExt;
515  }
516  }
517  }
518 
519  if (threadWasRunning)
520  {
522  }
523 
524  if (settings.m_useReverseAPI)
525  {
526  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
530  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
531  }
532 
533  m_settings = settings;
534 
535  if (forwardChange)
536  {
537  int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Interp);
540  }
541 
542  return true;
543 }
544 
547  QString& errorMessage)
548 {
549  (void) errorMessage;
551  response.getHackRfOutputSettings()->init();
553  return 200;
554 }
555 
557  bool force,
558  const QStringList& deviceSettingsKeys,
559  SWGSDRangel::SWGDeviceSettings& response, // query + response
560  QString& errorMessage)
561 {
562  (void) errorMessage;
563  HackRFOutputSettings settings = m_settings;
564 
565  if (deviceSettingsKeys.contains("centerFrequency")) {
567  }
568  if (deviceSettingsKeys.contains("LOppmTenths")) {
569  settings.m_LOppmTenths = response.getHackRfOutputSettings()->getLOppmTenths();
570  }
571  if (deviceSettingsKeys.contains("bandwidth")) {
572  settings.m_bandwidth = response.getHackRfOutputSettings()->getBandwidth();
573  }
574  if (deviceSettingsKeys.contains("vgaGain")) {
575  settings.m_vgaGain = response.getHackRfOutputSettings()->getVgaGain();
576  }
577  if (deviceSettingsKeys.contains("log2Interp")) {
578  settings.m_log2Interp = response.getHackRfOutputSettings()->getLog2Interp();
579  }
580  if (deviceSettingsKeys.contains("fcPos"))
581  {
582  int fcPos = response.getHackRfOutputSettings()->getFcPos();
583  fcPos = fcPos < 0 ? 0 : fcPos > 2 ? 2 : fcPos;
584  settings.m_fcPos = (HackRFOutputSettings::fcPos_t) fcPos;
585  }
586  if (deviceSettingsKeys.contains("devSampleRate")) {
588  }
589  if (deviceSettingsKeys.contains("biasT")) {
590  settings.m_biasT = response.getHackRfOutputSettings()->getBiasT() != 0;
591  }
592  if (deviceSettingsKeys.contains("lnaExt")) {
593  settings.m_lnaExt = response.getHackRfOutputSettings()->getLnaExt() != 0;
594  }
595  if (deviceSettingsKeys.contains("useReverseAPI")) {
596  settings.m_useReverseAPI = response.getHackRfOutputSettings()->getUseReverseApi() != 0;
597  }
598  if (deviceSettingsKeys.contains("reverseAPIAddress")) {
600  }
601  if (deviceSettingsKeys.contains("reverseAPIPort")) {
603  }
604  if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
606  }
607 
608  MsgConfigureHackRF *msg = MsgConfigureHackRF::create(settings, force);
610 
611  if (m_guiMessageQueue) // forward to GUI if any
612  {
613  MsgConfigureHackRF *msgToGUI = MsgConfigureHackRF::create(settings, force);
614  m_guiMessageQueue->push(msgToGUI);
615  }
616 
617  webapiFormatDeviceSettings(response, settings);
618  return 200;
619 }
620 
622 {
625  response.getHackRfOutputSettings()->setBandwidth(settings.m_bandwidth);
626  response.getHackRfOutputSettings()->setVgaGain(settings.m_vgaGain);
627  response.getHackRfOutputSettings()->setLog2Interp(settings.m_log2Interp);
628  response.getHackRfOutputSettings()->setFcPos(settings.m_fcPos);
630  response.getHackRfOutputSettings()->setBiasT(settings.m_biasT ? 1 : 0);
631  response.getHackRfOutputSettings()->setLnaExt(settings.m_lnaExt ? 1 : 0);
632 
633  response.getHackRfOutputSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
634 
635  if (response.getHackRfOutputSettings()->getReverseApiAddress()) {
637  } else {
638  response.getHackRfOutputSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
639  }
640 
643 }
644 
646  SWGSDRangel::SWGDeviceState& response,
647  QString& errorMessage)
648 {
649  (void) errorMessage;
651  return 200;
652 }
653 
655  bool run,
656  SWGSDRangel::SWGDeviceState& response,
657  QString& errorMessage)
658 {
659  (void) errorMessage;
661  MsgStartStop *message = MsgStartStop::create(run);
662  m_inputMessageQueue.push(message);
663 
664  if (m_guiMessageQueue)
665  {
666  MsgStartStop *messagetoGui = MsgStartStop::create(run);
667  m_guiMessageQueue->push(messagetoGui);
668  }
669 
670  return 200;
671 }
672 
673 void HackRFOutput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const HackRFOutputSettings& settings, bool force)
674 {
676  swgDeviceSettings->setDirection(1); // single Tx
677  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
678  swgDeviceSettings->setDeviceHwType(new QString("HackRF"));
680  SWGSDRangel::SWGHackRFOutputSettings *swgHackRFOutputSettings = swgDeviceSettings->getHackRfOutputSettings();
681 
682  // transfer data that has been modified. When force is on transfer all data except reverse API data
683 
684  if (deviceSettingsKeys.contains("centerFrequency") || force) {
685  swgHackRFOutputSettings->setCenterFrequency(settings.m_centerFrequency);
686  }
687  if (deviceSettingsKeys.contains("LOppmTenths") || force) {
688  swgHackRFOutputSettings->setLOppmTenths(settings.m_LOppmTenths);
689  }
690  if (deviceSettingsKeys.contains("bandwidth") || force) {
691  swgHackRFOutputSettings->setBandwidth(settings.m_bandwidth);
692  }
693  if (deviceSettingsKeys.contains("vgaGain") || force) {
694  swgHackRFOutputSettings->setVgaGain(settings.m_vgaGain);
695  }
696  if (deviceSettingsKeys.contains("log2Interp") || force) {
697  swgHackRFOutputSettings->setLog2Interp(settings.m_log2Interp);
698  }
699  if (deviceSettingsKeys.contains("fcPos") || force) {
700  swgHackRFOutputSettings->setFcPos((int) settings.m_fcPos);
701  }
702  if (deviceSettingsKeys.contains("devSampleRate") || force) {
703  swgHackRFOutputSettings->setDevSampleRate(settings.m_devSampleRate);
704  }
705  if (deviceSettingsKeys.contains("biasT") || force) {
706  swgHackRFOutputSettings->setBiasT(settings.m_biasT ? 1 : 0);
707  }
708  if (deviceSettingsKeys.contains("lnaExt") || force) {
709  swgHackRFOutputSettings->setLnaExt(settings.m_lnaExt ? 1 : 0);
710  }
711 
712  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
713  .arg(settings.m_reverseAPIAddress)
714  .arg(settings.m_reverseAPIPort)
715  .arg(settings.m_reverseAPIDeviceIndex);
716  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
717  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
718 
719  QBuffer *buffer=new QBuffer();
720  buffer->open((QBuffer::ReadWrite));
721  buffer->write(swgDeviceSettings->asJson().toUtf8());
722  buffer->seek(0);
723 
724  // Always use PATCH to avoid passing reverse API settings
725  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
726 
727  delete swgDeviceSettings;
728 }
729 
731 {
733  swgDeviceSettings->setDirection(1); // single Tx
734  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
735  swgDeviceSettings->setDeviceHwType(new QString("HackRF"));
736 
737  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
741  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
742  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
743 
744  QBuffer *buffer=new QBuffer();
745  buffer->open((QBuffer::ReadWrite));
746  buffer->write(swgDeviceSettings->asJson().toUtf8());
747  buffer->seek(0);
748 
749  if (start) {
750  m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
751  } else {
752  m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
753  }
754 
755  delete swgDeviceSettings;
756 }
757 
758 void HackRFOutput::networkManagerFinished(QNetworkReply *reply)
759 {
760  QNetworkReply::NetworkError replyError = reply->error();
761 
762  if (replyError)
763  {
764  qWarning() << "HackRFOutput::networkManagerFinished:"
765  << " error(" << (int) replyError
766  << "): " << replyError
767  << ": " << reply->errorString();
768  return;
769  }
770 
771  QString answer = reply->readAll();
772  answer.chop(1); // remove last \n
773  qDebug("HackRFOutput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
774 }
bool startDeviceEngine()
Start the device engine corresponding to the stream type.
Definition: deviceapi.cpp:253
struct hackrf_device * m_dev
Definition: hackrfoutput.h:141
virtual int getSampleRate() const
Sample rate exposed by the sink.
QNetworkRequest m_networkRequest
Definition: hackrfoutput.h:146
virtual const QString & getDeviceDescription() const
virtual void stop()
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void stopDeviceEngine()
Stop the device engine corresponding to the stream type.
Definition: deviceapi.cpp:266
void setUseReverseApi(qint32 use_reverse_api)
static const float m_sampleFifoLengthInSeconds
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const HackRFOutputSettings &settings, bool force)
virtual QString asJson() override
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const HackRFOutputSettings &settings)
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
Definition: deviceapi.cpp:316
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
static MsgConfigureHackRF * create(const HackRFOutputSettings &settings, bool force)
Definition: hackrfoutput.h:46
virtual bool deserialize(const QByteArray &data)
void closeDevice()
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
Definition: deviceapi.cpp:240
virtual void destroy()
void setReverseApiPort(qint32 reverse_api_port)
void setOriginatorIndex(qint32 originator_index)
static hackrf_device * open_hackrf(int sequence)
virtual QByteArray serialize() const
void setDevSampleRate(qint32 dev_sample_rate)
unsigned int uint32_t
Definition: rtptypes_win.h:46
virtual quint64 getCenterFrequency() const
Center frequency exposed by the sink.
MessageQueue m_inputMessageQueue
Input queue to the sink.
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:140
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
virtual bool handleMessage(const Message &message)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
static const int m_sampleFifoMinSize
void * getBuddySharedPtr() const
Definition: deviceapi.h:161
virtual ~HackRFOutput()
#define MESSAGE_CLASS_DEFINITION(Name, BaseClass)
Definition: message.h:52
void setHackRfOutputSettings(SWGHackRFOutputSettings *hack_rf_output_settings)
QString m_deviceDescription
Definition: hackrfoutput.h:143
DeviceAPI * m_deviceAPI
Definition: hackrfoutput.h:138
void setBuddySharedPtr(void *ptr)
Definition: deviceapi.h:162
MessageQueue * getSamplingDeviceInputMessageQueue()
Sampling device (ex: single Rx) input message queue.
Definition: deviceapi.cpp:329
virtual void setCenterFrequency(qint64 centerFrequency)
static bool match(const Message *message)
Definition: message.cpp:45
bool deserialize(const QByteArray &data)
static MsgSynchronizeFrequency * create(uint64_t frequency)
static qint64 calculateCenterFrequency(quint64 deviceCenterFrequency, qint64 transverterDeltaFrequency, int log2Interp, fcPos_t fcPos, quint32 devSampleRate, bool transverterMode=false)
void setCenterFrequency(qint64 center_frequency)
bool openDevice()
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
void setLog2Interpolation(unsigned int log2_interp)
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
void resize(uint32_t size)
const QString & getSamplingDeviceSerial() const
Definition: deviceapi.h:121
void webapiReverseSendStartStop(bool start)
SampleSourceFifo m_sampleSourceFifo
const std::vector< DeviceAPI * > & getSourceBuddies() const
Definition: deviceapi.h:165
HackRFOutputThread * m_hackRFThread
Definition: hackrfoutput.h:142
SWGHackRFOutputSettings * getHackRfOutputSettings()
virtual bool start()
void setReverseApiAddress(QString *reverse_api_address)
void setDeviceCenterFrequency(quint64 freq_hz, qint32 LOppmTenths)
static qint64 calculateDeviceCenterFrequency(quint64 centerFrequency, qint64 transverterDeltaFrequency, int log2Interp, fcPos_t fcPos, quint32 devSampleRate, bool transverterMode=false)
struct hackrf_device * m_dev
device handle if the party has ownership else 0
QNetworkAccessManager * m_networkManager
Definition: hackrfoutput.h:145
DeviceHackRFParams m_sharedParams
Definition: hackrfoutput.h:144
static MsgStartStop * create(bool startStop)
Definition: hackrfoutput.h:68
void setDirection(qint32 direction)
QByteArray serialize() const
void setFcPos(int fcPos)
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
const HackRFOutputSettings & getSettings() const
Definition: hackrfoutput.h:43
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
bool applySettings(const HackRFOutputSettings &settings, bool force)
T max(const T &x, const T &y)
Definition: framework.h:446
void setDeviceHwType(QString *device_hw_type)
void networkManagerFinished(QNetworkReply *reply)