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.
Classes | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
HackRFOutput Class Reference

#include <hackrfoutput.h>

+ Inheritance diagram for HackRFOutput:
+ Collaboration diagram for HackRFOutput:

Classes

class  MsgConfigureHackRF
 
class  MsgReportHackRF
 
class  MsgStartStop
 

Public Member Functions

 HackRFOutput (DeviceAPI *deviceAPI)
 
virtual ~HackRFOutput ()
 
virtual void destroy ()
 
virtual void init ()
 initializations to be done when all collaborating objects are created and possibly connected More...
 
virtual bool start ()
 
virtual void stop ()
 
virtual QByteArray serialize () const
 
virtual bool deserialize (const QByteArray &data)
 
virtual void setMessageQueueToGUI (MessageQueue *queue)
 
virtual const QString & getDeviceDescription () const
 
virtual int getSampleRate () const
 Sample rate exposed by the sink. More...
 
virtual void setSampleRate (int sampleRate)
 For when the sink sample rate is set externally. More...
 
virtual quint64 getCenterFrequency () const
 Center frequency exposed by the sink. More...
 
virtual void setCenterFrequency (qint64 centerFrequency)
 
virtual bool handleMessage (const Message &message)
 
virtual int webapiSettingsGet (SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
 
virtual int webapiSettingsPutPatch (bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
 
virtual int webapiRunGet (SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
 
virtual int webapiRun (bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
 
- Public Member Functions inherited from DeviceSampleSink
 DeviceSampleSink ()
 
virtual ~DeviceSampleSink ()
 
virtual int webapiReportGet (SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
 
MessageQueuegetInputMessageQueue ()
 
MessageQueuegetMessageQueueToGUI ()
 
SampleSourceFifogetSampleFifo ()
 

Private Slots

void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

bool openDevice ()
 
void closeDevice ()
 
bool applySettings (const HackRFOutputSettings &settings, bool force)
 
void setDeviceCenterFrequency (quint64 freq_hz, qint32 LOppmTenths)
 
void webapiFormatDeviceSettings (SWGSDRangel::SWGDeviceSettings &response, const HackRFOutputSettings &settings)
 
void webapiReverseSendSettings (QList< QString > &deviceSettingsKeys, const HackRFOutputSettings &settings, bool force)
 
void webapiReverseSendStartStop (bool start)
 

Private Attributes

DeviceAPIm_deviceAPI
 
QMutex m_mutex
 
HackRFOutputSettings m_settings
 
struct hackrf_device * m_dev
 
HackRFOutputThreadm_hackRFThread
 
QString m_deviceDescription
 
DeviceHackRFParams m_sharedParams
 
QNetworkAccessManager * m_networkManager
 
QNetworkRequest m_networkRequest
 
bool m_running
 

Additional Inherited Members

- Public Types inherited from DeviceSampleSink
enum  fcPos_t { FC_POS_INFRA = 0, FC_POS_SUPRA, FC_POS_CENTER }
 
- Static Public Member Functions inherited from DeviceSampleSink
static qint64 calculateDeviceCenterFrequency (quint64 centerFrequency, qint64 transverterDeltaFrequency, int log2Interp, fcPos_t fcPos, quint32 devSampleRate, bool transverterMode=false)
 
static qint64 calculateCenterFrequency (quint64 deviceCenterFrequency, qint64 transverterDeltaFrequency, int log2Interp, fcPos_t fcPos, quint32 devSampleRate, bool transverterMode=false)
 
static qint32 calculateFrequencyShift (int log2Interp, fcPos_t fcPos, quint32 devSampleRate)
 
- Protected Slots inherited from DeviceSampleSink
void handleInputMessages ()
 
- Protected Attributes inherited from DeviceSampleSink
SampleSourceFifo m_sampleSourceFifo
 
MessageQueue m_inputMessageQueue
 Input queue to the sink. More...
 
MessageQueuem_guiMessageQueue
 Input message queue to the GUI. More...
 

Detailed Description

Definition at line 35 of file hackrfoutput.h.

Constructor & Destructor Documentation

◆ HackRFOutput()

HackRFOutput::HackRFOutput ( DeviceAPI deviceAPI)

Definition at line 40 of file hackrfoutput.cpp.

Referenced by HackRFOutput::MsgReportHackRF::MsgReportHackRF().

40  :
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();
51  m_networkManager = new QNetworkAccessManager();
52  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
53 }
struct hackrf_device * m_dev
Definition: hackrfoutput.h:141
void setNbSinkStreams(uint32_t nbSinkStreams)
Definition: deviceapi.h:169
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:140
QString m_deviceDescription
Definition: hackrfoutput.h:143
DeviceAPI * m_deviceAPI
Definition: hackrfoutput.h:138
void setBuddySharedPtr(void *ptr)
Definition: deviceapi.h:162
bool openDevice()
HackRFOutputThread * m_hackRFThread
Definition: hackrfoutput.h:142
QNetworkAccessManager * m_networkManager
Definition: hackrfoutput.h:145
DeviceHackRFParams m_sharedParams
Definition: hackrfoutput.h:144
void networkManagerFinished(QNetworkReply *reply)
+ Here is the caller graph for this function:

◆ ~HackRFOutput()

HackRFOutput::~HackRFOutput ( )
virtual

Definition at line 55 of file hackrfoutput.cpp.

References closeDevice(), m_deviceAPI, m_networkManager, m_running, networkManagerFinished(), DeviceAPI::setBuddySharedPtr(), and stop().

Referenced by HackRFOutput::MsgReportHackRF::MsgReportHackRF().

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 }
virtual void stop()
void closeDevice()
DeviceAPI * m_deviceAPI
Definition: hackrfoutput.h:138
void setBuddySharedPtr(void *ptr)
Definition: deviceapi.h:162
QNetworkAccessManager * m_networkManager
Definition: hackrfoutput.h:145
void networkManagerFinished(QNetworkReply *reply)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ applySettings()

bool HackRFOutput::applySettings ( const HackRFOutputSettings settings,
bool  force 
)
private

Definition at line 325 of file hackrfoutput.cpp.

References DeviceSampleSink::calculateDeviceCenterFrequency(), DeviceHackRFShared::MsgSynchronizeFrequency::create(), DeviceAPI::getDeviceEngineInputMessageQueue(), DeviceAPI::getSamplingDeviceInputMessageQueue(), DeviceAPI::getSourceBuddies(), HackRFOutputSettings::m_bandwidth, HackRFOutputSettings::m_biasT, HackRFOutputSettings::m_centerFrequency, m_dev, m_deviceAPI, HackRFOutputSettings::m_devSampleRate, HackRFOutputSettings::m_fcPos, m_hackRFThread, HackRFOutputSettings::m_lnaExt, HackRFOutputSettings::m_log2Interp, HackRFOutputSettings::m_LOppmTenths, HackRFOutputSettings::m_reverseAPIAddress, HackRFOutputSettings::m_reverseAPIDeviceIndex, HackRFOutputSettings::m_reverseAPIPort, DeviceHackRFShared::m_sampleFifoLengthInSeconds, DeviceHackRFShared::m_sampleFifoMinSize, DeviceSampleSink::m_sampleSourceFifo, m_settings, HackRFOutputSettings::m_useReverseAPI, HackRFOutputSettings::m_vgaGain, leansdr::max(), MessageQueue::push(), SampleSourceFifo::resize(), setDeviceCenterFrequency(), HackRFOutputThread::setFcPos(), HackRFOutputThread::setLog2Interpolation(), HackRFOutputThread::startWork(), HackRFOutputThread::stopWork(), and webapiReverseSendSettings().

Referenced by handleMessage(), init(), and start().

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 }
struct hackrf_device * m_dev
Definition: hackrfoutput.h:141
void push(Message *message, bool emitSignal=true)
Push message onto queue.
static const float m_sampleFifoLengthInSeconds
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const HackRFOutputSettings &settings, bool force)
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
Definition: deviceapi.cpp:316
unsigned int uint32_t
Definition: rtptypes_win.h:46
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:140
static const int m_sampleFifoMinSize
DeviceAPI * m_deviceAPI
Definition: hackrfoutput.h:138
MessageQueue * getSamplingDeviceInputMessageQueue()
Sampling device (ex: single Rx) input message queue.
Definition: deviceapi.cpp:329
static MsgSynchronizeFrequency * create(uint64_t frequency)
void setLog2Interpolation(unsigned int log2_interp)
void resize(uint32_t size)
SampleSourceFifo m_sampleSourceFifo
const std::vector< DeviceAPI * > & getSourceBuddies() const
Definition: deviceapi.h:165
HackRFOutputThread * m_hackRFThread
Definition: hackrfoutput.h:142
void setDeviceCenterFrequency(quint64 freq_hz, qint32 LOppmTenths)
static qint64 calculateDeviceCenterFrequency(quint64 centerFrequency, qint64 transverterDeltaFrequency, int log2Interp, fcPos_t fcPos, quint32 devSampleRate, bool transverterMode=false)
void setFcPos(int fcPos)
T max(const T &x, const T &y)
Definition: framework.h:446
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ closeDevice()

void HackRFOutput::closeDevice ( )
private

Definition at line 148 of file hackrfoutput.cpp.

References DeviceAPI::getSourceBuddies(), DeviceHackRFParams::m_dev, m_dev, m_deviceAPI, and m_sharedParams.

Referenced by openDevice(), and ~HackRFOutput().

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 }
struct hackrf_device * m_dev
Definition: hackrfoutput.h:141
DeviceAPI * m_deviceAPI
Definition: hackrfoutput.h:138
const std::vector< DeviceAPI * > & getSourceBuddies() const
Definition: deviceapi.h:165
struct hackrf_device * m_dev
device handle if the party has ownership else 0
DeviceHackRFParams m_sharedParams
Definition: hackrfoutput.h:144
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserialize()

bool HackRFOutput::deserialize ( const QByteArray &  data)
virtual

Implements DeviceSampleSink.

Definition at line 185 of file hackrfoutput.cpp.

References HackRFOutput::MsgConfigureHackRF::create(), HackRFOutputSettings::deserialize(), DeviceSampleSink::m_guiMessageQueue, DeviceSampleSink::m_inputMessageQueue, m_settings, MessageQueue::push(), and HackRFOutputSettings::resetToDefaults().

Referenced by HackRFOutput::MsgReportHackRF::MsgReportHackRF().

186 {
187  bool success = true;
188 
189  if (!m_settings.deserialize(data))
190  {
192  success = false;
193  }
194 
195  MsgConfigureHackRF* message = MsgConfigureHackRF::create(m_settings, true);
196  m_inputMessageQueue.push(message);
197 
198  if (m_guiMessageQueue)
199  {
200  MsgConfigureHackRF* messageToGUI = MsgConfigureHackRF::create(m_settings, true);
201  m_guiMessageQueue->push(messageToGUI);
202  }
203 
204  return success;
205 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
static MsgConfigureHackRF * create(const HackRFOutputSettings &settings, bool force)
Definition: hackrfoutput.h:46
MessageQueue m_inputMessageQueue
Input queue to the sink.
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:140
bool deserialize(const QByteArray &data)
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy()

void HackRFOutput::destroy ( )
virtual

Implements DeviceSampleSink.

Definition at line 68 of file hackrfoutput.cpp.

Referenced by HackRFOutput::MsgReportHackRF::MsgReportHackRF().

69 {
70  delete this;
71 }
+ Here is the caller graph for this function:

◆ getCenterFrequency()

quint64 HackRFOutput::getCenterFrequency ( ) const
virtual

Center frequency exposed by the sink.

Implements DeviceSampleSink.

Definition at line 218 of file hackrfoutput.cpp.

References HackRFOutputSettings::m_centerFrequency, and m_settings.

Referenced by setSampleRate().

219 {
221 }
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:140
+ Here is the caller graph for this function:

◆ getDeviceDescription()

const QString & HackRFOutput::getDeviceDescription ( ) const
virtual

Implements DeviceSampleSink.

Definition at line 207 of file hackrfoutput.cpp.

References m_deviceDescription.

Referenced by setMessageQueueToGUI().

208 {
209  return m_deviceDescription;
210 }
QString m_deviceDescription
Definition: hackrfoutput.h:143
+ Here is the caller graph for this function:

◆ getSampleRate()

int HackRFOutput::getSampleRate ( ) const
virtual

Sample rate exposed by the sink.

Implements DeviceSampleSink.

Definition at line 212 of file hackrfoutput.cpp.

References HackRFOutputSettings::m_devSampleRate, HackRFOutputSettings::m_log2Interp, and m_settings.

Referenced by setMessageQueueToGUI().

213 {
214  int rate = m_settings.m_devSampleRate;
215  return (rate / (1<<m_settings.m_log2Interp));
216 }
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:140
+ Here is the caller graph for this function:

◆ handleMessage()

bool HackRFOutput::handleMessage ( const Message message)
virtual

Implements DeviceSampleSink.

Definition at line 238 of file hackrfoutput.cpp.

References applySettings(), DeviceSampleSink::calculateCenterFrequency(), HackRFOutput::MsgConfigureHackRF::create(), DeviceAPI::getDeviceEngineInputMessageQueue(), HackRFOutput::MsgConfigureHackRF::getForce(), DeviceHackRFShared::MsgSynchronizeFrequency::getFrequency(), HackRFOutput::MsgConfigureHackRF::getSettings(), HackRFOutput::MsgStartStop::getStartStop(), DeviceAPI::initDeviceEngine(), HackRFOutputSettings::m_centerFrequency, m_deviceAPI, HackRFOutputSettings::m_devSampleRate, HackRFOutputSettings::m_fcPos, DeviceSampleSink::m_guiMessageQueue, HackRFOutputSettings::m_log2Interp, m_settings, HackRFOutputSettings::m_useReverseAPI, Message::match(), MessageQueue::push(), DeviceAPI::startDeviceEngine(), DeviceAPI::stopDeviceEngine(), and webapiReverseSendStartStop().

Referenced by setSampleRate().

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 
272  webapiReverseSendStartStop(cmd.getStartStop());
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 }
bool startDeviceEngine()
Start the device engine corresponding to the stream type.
Definition: deviceapi.cpp:253
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
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
Definition: deviceapi.cpp:316
static MsgConfigureHackRF * create(const HackRFOutputSettings &settings, bool force)
Definition: hackrfoutput.h:46
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
Definition: deviceapi.cpp:240
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:140
DeviceAPI * m_deviceAPI
Definition: hackrfoutput.h:138
static bool match(const Message *message)
Definition: message.cpp:45
static qint64 calculateCenterFrequency(quint64 deviceCenterFrequency, qint64 transverterDeltaFrequency, int log2Interp, fcPos_t fcPos, quint32 devSampleRate, bool transverterMode=false)
void webapiReverseSendStartStop(bool start)
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
bool applySettings(const HackRFOutputSettings &settings, bool force)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

void HackRFOutput::init ( )
virtual

initializations to be done when all collaborating objects are created and possibly connected

Implements DeviceSampleSink.

Definition at line 116 of file hackrfoutput.cpp.

References applySettings(), and m_settings.

Referenced by HackRFOutput::MsgReportHackRF::MsgReportHackRF().

117 {
118  applySettings(m_settings, true);
119 }
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:140
bool applySettings(const HackRFOutputSettings &settings, bool force)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ networkManagerFinished

void HackRFOutput::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 758 of file hackrfoutput.cpp.

Referenced by ~HackRFOutput().

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 }
+ Here is the caller graph for this function:

◆ openDevice()

bool HackRFOutput::openDevice ( )
private

Definition at line 73 of file hackrfoutput.cpp.

References closeDevice(), DeviceAPI::getBuddySharedPtr(), DeviceAPI::getSamplingDeviceSerial(), DeviceAPI::getSourceBuddies(), DeviceHackRFParams::m_dev, m_dev, m_deviceAPI, HackRFOutputSettings::m_devSampleRate, HackRFOutputSettings::m_log2Interp, DeviceSampleSink::m_sampleSourceFifo, m_settings, m_sharedParams, DeviceHackRF::open_hackrf(), and SampleSourceFifo::resize().

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 }
struct hackrf_device * m_dev
Definition: hackrfoutput.h:141
void closeDevice()
static hackrf_device * open_hackrf(int sequence)
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:140
void * getBuddySharedPtr() const
Definition: deviceapi.h:161
DeviceAPI * m_deviceAPI
Definition: hackrfoutput.h:138
void resize(uint32_t size)
const QString & getSamplingDeviceSerial() const
Definition: deviceapi.h:121
SampleSourceFifo m_sampleSourceFifo
const std::vector< DeviceAPI * > & getSourceBuddies() const
Definition: deviceapi.h:165
struct hackrf_device * m_dev
device handle if the party has ownership else 0
DeviceHackRFParams m_sharedParams
Definition: hackrfoutput.h:144
+ Here is the call graph for this function:

◆ serialize()

QByteArray HackRFOutput::serialize ( ) const
virtual

Implements DeviceSampleSink.

Definition at line 180 of file hackrfoutput.cpp.

References m_settings, and HackRFOutputSettings::serialize().

Referenced by HackRFOutput::MsgReportHackRF::MsgReportHackRF().

181 {
182  return m_settings.serialize();
183 }
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:140
QByteArray serialize() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCenterFrequency()

void HackRFOutput::setCenterFrequency ( qint64  centerFrequency)
virtual

Implements DeviceSampleSink.

Definition at line 223 of file hackrfoutput.cpp.

References HackRFOutput::MsgConfigureHackRF::create(), HackRFOutputSettings::m_centerFrequency, DeviceSampleSink::m_guiMessageQueue, DeviceSampleSink::m_inputMessageQueue, m_settings, and MessageQueue::push().

Referenced by setSampleRate().

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 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
static MsgConfigureHackRF * create(const HackRFOutputSettings &settings, bool force)
Definition: hackrfoutput.h:46
MessageQueue m_inputMessageQueue
Input queue to the sink.
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:140
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDeviceCenterFrequency()

void HackRFOutput::setDeviceCenterFrequency ( quint64  freq_hz,
qint32  LOppmTenths 
)
private

Definition at line 309 of file hackrfoutput.cpp.

References m_dev.

Referenced by applySettings().

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 }
struct hackrf_device * m_dev
Definition: hackrfoutput.h:141
+ Here is the caller graph for this function:

◆ setMessageQueueToGUI()

virtual void HackRFOutput::setMessageQueueToGUI ( MessageQueue queue)
inlinevirtual

Implements DeviceSampleSink.

Definition at line 109 of file hackrfoutput.h.

References getDeviceDescription(), getSampleRate(), and DeviceSampleSink::m_guiMessageQueue.

109 { m_guiMessageQueue = queue; }
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
+ Here is the call graph for this function:

◆ setSampleRate()

virtual void HackRFOutput::setSampleRate ( int  sampleRate)
inlinevirtual

For when the sink sample rate is set externally.

Implements DeviceSampleSink.

Definition at line 112 of file hackrfoutput.h.

References getCenterFrequency(), handleMessage(), setCenterFrequency(), webapiRun(), webapiRunGet(), webapiSettingsGet(), and webapiSettingsPutPatch().

112 { (void) sampleRate; }
+ Here is the call graph for this function:

◆ start()

bool HackRFOutput::start ( )
virtual

Implements DeviceSampleSink.

Definition at line 121 of file hackrfoutput.cpp.

References applySettings(), m_dev, HackRFOutputSettings::m_fcPos, m_hackRFThread, HackRFOutputSettings::m_log2Interp, m_running, DeviceSampleSink::m_sampleSourceFifo, m_settings, HackRFOutputThread::setFcPos(), HackRFOutputThread::setLog2Interpolation(), HackRFOutputThread::startWork(), and stop().

Referenced by HackRFOutput::MsgReportHackRF::MsgReportHackRF().

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 }
struct hackrf_device * m_dev
Definition: hackrfoutput.h:141
virtual void stop()
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:140
void setLog2Interpolation(unsigned int log2_interp)
SampleSourceFifo m_sampleSourceFifo
HackRFOutputThread * m_hackRFThread
Definition: hackrfoutput.h:142
void setFcPos(int fcPos)
bool applySettings(const HackRFOutputSettings &settings, bool force)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void HackRFOutput::stop ( )
virtual

Implements DeviceSampleSink.

Definition at line 165 of file hackrfoutput.cpp.

References m_hackRFThread, m_running, and HackRFOutputThread::stopWork().

Referenced by HackRFOutput::MsgReportHackRF::MsgReportHackRF(), start(), and ~HackRFOutput().

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 }
HackRFOutputThread * m_hackRFThread
Definition: hackrfoutput.h:142
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatDeviceSettings()

void HackRFOutput::webapiFormatDeviceSettings ( SWGSDRangel::SWGDeviceSettings response,
const HackRFOutputSettings settings 
)
private

Definition at line 621 of file hackrfoutput.cpp.

References SWGSDRangel::SWGDeviceSettings::getHackRfOutputSettings(), SWGSDRangel::SWGHackRFOutputSettings::getReverseApiAddress(), HackRFOutputSettings::m_bandwidth, HackRFOutputSettings::m_biasT, HackRFOutputSettings::m_centerFrequency, HackRFOutputSettings::m_devSampleRate, HackRFOutputSettings::m_fcPos, HackRFOutputSettings::m_lnaExt, HackRFOutputSettings::m_log2Interp, HackRFOutputSettings::m_LOppmTenths, HackRFOutputSettings::m_reverseAPIAddress, HackRFOutputSettings::m_reverseAPIDeviceIndex, HackRFOutputSettings::m_reverseAPIPort, HackRFOutputSettings::m_useReverseAPI, HackRFOutputSettings::m_vgaGain, SWGSDRangel::SWGHackRFOutputSettings::setBandwidth(), SWGSDRangel::SWGHackRFOutputSettings::setBiasT(), SWGSDRangel::SWGHackRFOutputSettings::setCenterFrequency(), SWGSDRangel::SWGHackRFOutputSettings::setDevSampleRate(), SWGSDRangel::SWGHackRFOutputSettings::setFcPos(), SWGSDRangel::SWGHackRFOutputSettings::setLnaExt(), SWGSDRangel::SWGHackRFOutputSettings::setLog2Interp(), SWGSDRangel::SWGHackRFOutputSettings::setLOppmTenths(), SWGSDRangel::SWGHackRFOutputSettings::setReverseApiAddress(), SWGSDRangel::SWGHackRFOutputSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGHackRFOutputSettings::setReverseApiPort(), SWGSDRangel::SWGHackRFOutputSettings::setUseReverseApi(), and SWGSDRangel::SWGHackRFOutputSettings::setVgaGain().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

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 }
void setUseReverseApi(qint32 use_reverse_api)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setReverseApiPort(qint32 reverse_api_port)
void setDevSampleRate(qint32 dev_sample_rate)
void setCenterFrequency(qint64 center_frequency)
SWGHackRFOutputSettings * getHackRfOutputSettings()
void setReverseApiAddress(QString *reverse_api_address)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

void HackRFOutput::webapiReverseSendSettings ( QList< QString > &  deviceSettingsKeys,
const HackRFOutputSettings settings,
bool  force 
)
private

Definition at line 673 of file hackrfoutput.cpp.

References SWGSDRangel::SWGDeviceSettings::asJson(), DeviceAPI::getDeviceSetIndex(), SWGSDRangel::SWGDeviceSettings::getHackRfOutputSettings(), HackRFOutputSettings::m_bandwidth, HackRFOutputSettings::m_biasT, HackRFOutputSettings::m_centerFrequency, m_deviceAPI, HackRFOutputSettings::m_devSampleRate, HackRFOutputSettings::m_fcPos, HackRFOutputSettings::m_lnaExt, HackRFOutputSettings::m_log2Interp, HackRFOutputSettings::m_LOppmTenths, m_networkManager, m_networkRequest, HackRFOutputSettings::m_reverseAPIAddress, HackRFOutputSettings::m_reverseAPIDeviceIndex, HackRFOutputSettings::m_reverseAPIPort, HackRFOutputSettings::m_vgaGain, SWGSDRangel::SWGHackRFOutputSettings::setBandwidth(), SWGSDRangel::SWGHackRFOutputSettings::setBiasT(), SWGSDRangel::SWGHackRFOutputSettings::setCenterFrequency(), SWGSDRangel::SWGDeviceSettings::setDeviceHwType(), SWGSDRangel::SWGHackRFOutputSettings::setDevSampleRate(), SWGSDRangel::SWGDeviceSettings::setDirection(), SWGSDRangel::SWGHackRFOutputSettings::setFcPos(), SWGSDRangel::SWGDeviceSettings::setHackRfOutputSettings(), SWGSDRangel::SWGHackRFOutputSettings::setLnaExt(), SWGSDRangel::SWGHackRFOutputSettings::setLog2Interp(), SWGSDRangel::SWGHackRFOutputSettings::setLOppmTenths(), SWGSDRangel::SWGDeviceSettings::setOriginatorIndex(), and SWGSDRangel::SWGHackRFOutputSettings::setVgaGain().

Referenced by applySettings().

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 }
QNetworkRequest m_networkRequest
Definition: hackrfoutput.h:146
virtual QString asJson() override
void setOriginatorIndex(qint32 originator_index)
void setDevSampleRate(qint32 dev_sample_rate)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
void setHackRfOutputSettings(SWGHackRFOutputSettings *hack_rf_output_settings)
DeviceAPI * m_deviceAPI
Definition: hackrfoutput.h:138
void setCenterFrequency(qint64 center_frequency)
SWGHackRFOutputSettings * getHackRfOutputSettings()
QNetworkAccessManager * m_networkManager
Definition: hackrfoutput.h:145
void setDirection(qint32 direction)
void setDeviceHwType(QString *device_hw_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendStartStop()

void HackRFOutput::webapiReverseSendStartStop ( bool  start)
private

Definition at line 730 of file hackrfoutput.cpp.

References SWGSDRangel::SWGDeviceSettings::asJson(), DeviceAPI::getDeviceSetIndex(), m_deviceAPI, m_networkManager, m_networkRequest, HackRFOutputSettings::m_reverseAPIAddress, HackRFOutputSettings::m_reverseAPIDeviceIndex, HackRFOutputSettings::m_reverseAPIPort, m_settings, SWGSDRangel::SWGDeviceSettings::setDeviceHwType(), SWGSDRangel::SWGDeviceSettings::setDirection(), and SWGSDRangel::SWGDeviceSettings::setOriginatorIndex().

Referenced by handleMessage().

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 }
QNetworkRequest m_networkRequest
Definition: hackrfoutput.h:146
virtual QString asJson() override
void setOriginatorIndex(qint32 originator_index)
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:140
int getDeviceSetIndex() const
Definition: deviceapi.h:131
DeviceAPI * m_deviceAPI
Definition: hackrfoutput.h:138
virtual bool start()
QNetworkAccessManager * m_networkManager
Definition: hackrfoutput.h:145
void setDirection(qint32 direction)
void setDeviceHwType(QString *device_hw_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiRun()

int HackRFOutput::webapiRun ( bool  run,
SWGSDRangel::SWGDeviceState response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSink.

Definition at line 654 of file hackrfoutput.cpp.

References HackRFOutput::MsgStartStop::create(), DeviceAPI::getDeviceEngineStateStr(), SWGSDRangel::SWGDeviceState::getState(), m_deviceAPI, DeviceSampleSink::m_guiMessageQueue, DeviceSampleSink::m_inputMessageQueue, and MessageQueue::push().

Referenced by setSampleRate().

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 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the sink.
DeviceAPI * m_deviceAPI
Definition: hackrfoutput.h:138
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
static MsgStartStop * create(bool startStop)
Definition: hackrfoutput.h:68
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiRunGet()

int HackRFOutput::webapiRunGet ( SWGSDRangel::SWGDeviceState response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSink.

Definition at line 645 of file hackrfoutput.cpp.

References DeviceAPI::getDeviceEngineStateStr(), SWGSDRangel::SWGDeviceState::getState(), and m_deviceAPI.

Referenced by setSampleRate().

648 {
649  (void) errorMessage;
651  return 200;
652 }
DeviceAPI * m_deviceAPI
Definition: hackrfoutput.h:138
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

int HackRFOutput::webapiSettingsGet ( SWGSDRangel::SWGDeviceSettings response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSink.

Definition at line 545 of file hackrfoutput.cpp.

References SWGSDRangel::SWGDeviceSettings::getHackRfOutputSettings(), SWGSDRangel::SWGHackRFOutputSettings::init(), m_settings, SWGSDRangel::SWGDeviceSettings::setHackRfOutputSettings(), and webapiFormatDeviceSettings().

Referenced by setSampleRate().

548 {
549  (void) errorMessage;
551  response.getHackRfOutputSettings()->init();
553  return 200;
554 }
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const HackRFOutputSettings &settings)
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:140
void setHackRfOutputSettings(SWGHackRFOutputSettings *hack_rf_output_settings)
SWGHackRFOutputSettings * getHackRfOutputSettings()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

int HackRFOutput::webapiSettingsPutPatch ( bool  force,
const QStringList &  deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSink.

Definition at line 556 of file hackrfoutput.cpp.

References HackRFOutput::MsgConfigureHackRF::create(), SWGSDRangel::SWGHackRFOutputSettings::getBandwidth(), SWGSDRangel::SWGHackRFOutputSettings::getBiasT(), SWGSDRangel::SWGHackRFOutputSettings::getCenterFrequency(), SWGSDRangel::SWGHackRFOutputSettings::getDevSampleRate(), SWGSDRangel::SWGHackRFOutputSettings::getFcPos(), SWGSDRangel::SWGDeviceSettings::getHackRfOutputSettings(), SWGSDRangel::SWGHackRFOutputSettings::getLnaExt(), SWGSDRangel::SWGHackRFOutputSettings::getLog2Interp(), SWGSDRangel::SWGHackRFOutputSettings::getLOppmTenths(), SWGSDRangel::SWGHackRFOutputSettings::getReverseApiAddress(), SWGSDRangel::SWGHackRFOutputSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGHackRFOutputSettings::getReverseApiPort(), SWGSDRangel::SWGHackRFOutputSettings::getUseReverseApi(), SWGSDRangel::SWGHackRFOutputSettings::getVgaGain(), HackRFOutputSettings::m_bandwidth, HackRFOutputSettings::m_biasT, HackRFOutputSettings::m_centerFrequency, HackRFOutputSettings::m_devSampleRate, HackRFOutputSettings::m_fcPos, DeviceSampleSink::m_guiMessageQueue, DeviceSampleSink::m_inputMessageQueue, HackRFOutputSettings::m_lnaExt, HackRFOutputSettings::m_log2Interp, HackRFOutputSettings::m_LOppmTenths, HackRFOutputSettings::m_reverseAPIAddress, HackRFOutputSettings::m_reverseAPIDeviceIndex, HackRFOutputSettings::m_reverseAPIPort, m_settings, HackRFOutputSettings::m_useReverseAPI, HackRFOutputSettings::m_vgaGain, MessageQueue::push(), and webapiFormatDeviceSettings().

Referenced by setSampleRate().

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 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const HackRFOutputSettings &settings)
static MsgConfigureHackRF * create(const HackRFOutputSettings &settings, bool force)
Definition: hackrfoutput.h:46
MessageQueue m_inputMessageQueue
Input queue to the sink.
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:140
SWGHackRFOutputSettings * getHackRfOutputSettings()
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_dev

struct hackrf_device* HackRFOutput::m_dev
private

◆ m_deviceAPI

DeviceAPI* HackRFOutput::m_deviceAPI
private

◆ m_deviceDescription

QString HackRFOutput::m_deviceDescription
private

Definition at line 143 of file hackrfoutput.h.

Referenced by getDeviceDescription().

◆ m_hackRFThread

HackRFOutputThread* HackRFOutput::m_hackRFThread
private

Definition at line 142 of file hackrfoutput.h.

Referenced by applySettings(), start(), and stop().

◆ m_mutex

QMutex HackRFOutput::m_mutex
private

Definition at line 139 of file hackrfoutput.h.

◆ m_networkManager

QNetworkAccessManager* HackRFOutput::m_networkManager
private

◆ m_networkRequest

QNetworkRequest HackRFOutput::m_networkRequest
private

Definition at line 146 of file hackrfoutput.h.

Referenced by webapiReverseSendSettings(), and webapiReverseSendStartStop().

◆ m_running

bool HackRFOutput::m_running
private

Definition at line 147 of file hackrfoutput.h.

Referenced by start(), stop(), and ~HackRFOutput().

◆ m_settings

HackRFOutputSettings HackRFOutput::m_settings
private

◆ m_sharedParams

DeviceHackRFParams HackRFOutput::m_sharedParams
private

Definition at line 144 of file hackrfoutput.h.

Referenced by closeDevice(), and openDevice().


The documentation for this class was generated from the following files: