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

#include <airspyinput.h>

+ Inheritance diagram for AirspyInput:
+ Collaboration diagram for AirspyInput:

Classes

class  MsgConfigureAirspy
 
class  MsgFileRecord
 
class  MsgStartStop
 

Public Member Functions

 AirspyInput (DeviceAPI *deviceAPI)
 
virtual ~AirspyInput ()
 
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 source. More...
 
virtual void setSampleRate (int sampleRate)
 For when the source sample rate is set externally. More...
 
virtual quint64 getCenterFrequency () const
 Center frequency exposed by the source. More...
 
virtual void setCenterFrequency (qint64 centerFrequency)
 
const std::vector< uint32_t > & getSampleRates () const
 
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)
 
virtual int webapiReportGet (SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
 
- Public Member Functions inherited from DeviceSampleSource
 DeviceSampleSource ()
 
virtual ~DeviceSampleSource ()
 
MessageQueuegetInputMessageQueue ()
 
MessageQueuegetMessageQueueToGUI ()
 
SampleSinkFifogetSampleFifo ()
 

Static Public Attributes

static const qint64 loLowLimitFreq = 24000000L
 
static const qint64 loHighLimitFreq = 1900000000L
 

Private Slots

void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

bool openDevice ()
 
void closeDevice ()
 
bool applySettings (const AirspySettings &settings, bool force)
 
struct airspy_device * open_airspy_from_sequence (int sequence)
 
void setDeviceCenterFrequency (quint64 freq)
 
void webapiFormatDeviceSettings (SWGSDRangel::SWGDeviceSettings &response, const AirspySettings &settings)
 
void webapiFormatDeviceReport (SWGSDRangel::SWGDeviceReport &response)
 
void webapiReverseSendSettings (QList< QString > &deviceSettingsKeys, const AirspySettings &settings, bool force)
 
void webapiReverseSendStartStop (bool start)
 

Private Attributes

DeviceAPIm_deviceAPI
 
QMutex m_mutex
 
AirspySettings m_settings
 
struct airspy_device * m_dev
 
AirspyThreadm_airspyThread
 
QString m_deviceDescription
 
std::vector< uint32_tm_sampleRates
 
bool m_running
 
FileRecordm_fileSink
 File sink to record device I/Q output. More...
 
QNetworkAccessManager * m_networkManager
 
QNetworkRequest m_networkRequest
 

Additional Inherited Members

- Public Types inherited from DeviceSampleSource
enum  fcPos_t { FC_POS_INFRA = 0, FC_POS_SUPRA, FC_POS_CENTER }
 
enum  FrequencyShiftScheme { FSHIFT_STD = 0, FSHIFT_TXSYNC }
 
- Static Public Member Functions inherited from DeviceSampleSource
static qint64 calculateDeviceCenterFrequency (quint64 centerFrequency, qint64 transverterDeltaFrequency, int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme, bool transverterMode=false)
 
static qint64 calculateCenterFrequency (quint64 deviceCenterFrequency, qint64 transverterDeltaFrequency, int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme, bool transverterMode=false)
 
static qint32 calculateFrequencyShift (int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme)
 
- Protected Slots inherited from DeviceSampleSource
void handleInputMessages ()
 
- Protected Attributes inherited from DeviceSampleSource
SampleSinkFifo m_sampleFifo
 
MessageQueue m_inputMessageQueue
 Input queue to the source. More...
 
MessageQueuem_guiMessageQueue
 Input message queue to the GUI. More...
 

Detailed Description

Definition at line 35 of file airspyinput.h.

Constructor & Destructor Documentation

◆ AirspyInput()

AirspyInput::AirspyInput ( DeviceAPI deviceAPI)

Definition at line 48 of file airspyinput.cpp.

References DeviceAPI::addAncillarySink(), arg(), DeviceAPI::getDeviceUID(), m_deviceAPI, m_fileSink, m_networkManager, networkManagerFinished(), openDevice(), and DeviceAPI::setNbSourceStreams().

Referenced by AirspyInput::MsgStartStop::MsgStartStop().

48  :
49  m_deviceAPI(deviceAPI),
50  m_settings(),
51  m_dev(0),
52  m_airspyThread(0),
53  m_deviceDescription("Airspy"),
54  m_running(false)
55 {
56  openDevice();
57  m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID()));
60 
61  m_networkManager = new QNetworkAccessManager();
62  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
63 }
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: airspyinput.h:155
bool m_running
Definition: airspyinput.h:154
uint getDeviceUID() const
Return the current device engine unique ID.
Definition: deviceapi.cpp:303
void networkManagerFinished(QNetworkReply *reply)
QString m_deviceDescription
Definition: airspyinput.h:152
void setNbSourceStreams(uint32_t nbSourceStreams)
Definition: deviceapi.h:168
bool openDevice()
Definition: airspyinput.cpp:84
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
void addAncillarySink(BasebandSampleSink *sink, unsigned int index=0)
Adds a sink to receive full baseband and that is not a channel (e.g. spectrum)
Definition: deviceapi.cpp:89
AirspySettings m_settings
Definition: airspyinput.h:149
DeviceAPI * m_deviceAPI
Definition: airspyinput.h:147
AirspyThread * m_airspyThread
Definition: airspyinput.h:151
QNetworkAccessManager * m_networkManager
Definition: airspyinput.h:156
struct airspy_device * m_dev
Definition: airspyinput.h:150
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~AirspyInput()

AirspyInput::~AirspyInput ( )
virtual

Definition at line 65 of file airspyinput.cpp.

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

Referenced by AirspyInput::MsgStartStop::MsgStartStop().

66 {
67  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
68  delete m_networkManager;
69 
70  if (m_running) {
71  stop();
72  }
73 
75  delete m_fileSink;
76  closeDevice();
77 }
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: airspyinput.h:155
bool m_running
Definition: airspyinput.h:154
void networkManagerFinished(QNetworkReply *reply)
void removeAncillarySink(BasebandSampleSink *sink, unsigned int index=0)
Removes it.
Definition: deviceapi.cpp:100
DeviceAPI * m_deviceAPI
Definition: airspyinput.h:147
QNetworkAccessManager * m_networkManager
Definition: airspyinput.h:156
void closeDevice()
virtual void stop()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ applySettings()

bool AirspyInput::applySettings ( const AirspySettings settings,
bool  force 
)
private

Definition at line 366 of file airspyinput.cpp.

References DeviceSampleSource::calculateDeviceCenterFrequency(), DeviceAPI::configureCorrections(), DeviceAPI::getDeviceEngineInputMessageQueue(), FileRecord::handleMessage(), m_airspyThread, AirspySettings::m_biasT, AirspySettings::m_centerFrequency, AirspySettings::m_dcBlock, m_dev, m_deviceAPI, AirspySettings::m_devSampleRateIndex, AirspySettings::m_fcPos, m_fileSink, AirspySettings::m_iqCorrection, AirspySettings::m_lnaAGC, AirspySettings::m_lnaGain, AirspySettings::m_log2Decim, AirspySettings::m_LOppmTenths, AirspySettings::m_mixerAGC, AirspySettings::m_mixerGain, m_mutex, AirspySettings::m_reverseAPIAddress, AirspySettings::m_reverseAPIDeviceIndex, AirspySettings::m_reverseAPIPort, m_sampleRates, m_settings, AirspySettings::m_transverterDeltaFrequency, AirspySettings::m_transverterMode, AirspySettings::m_useReverseAPI, AirspySettings::m_vgaGain, MessageQueue::push(), setDeviceCenterFrequency(), AirspyThread::setFcPos(), AirspyThread::setLog2Decimation(), AirspyThread::setSamplerate(), and webapiReverseSendSettings().

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

367 {
368  QMutexLocker mutexLocker(&m_mutex);
369 
370  bool forwardChange = false;
371  airspy_error rc = AIRSPY_ERROR_OTHER;
372  QList<QString> reverseAPIKeys;
373 
374  qDebug() << "AirspyInput::applySettings";
375 
376  if ((m_settings.m_dcBlock != settings.m_dcBlock) || force) {
377  reverseAPIKeys.append("dcBlock");
378  }
379  if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force) {
380  reverseAPIKeys.append("iqCorrection");
381  }
382 
383  if ((m_settings.m_dcBlock != settings.m_dcBlock) ||
384  (m_settings.m_iqCorrection != settings.m_iqCorrection) || force)
385  {
387  }
388 
389  if ((m_settings.m_devSampleRateIndex != settings.m_devSampleRateIndex) || force)
390  {
391  reverseAPIKeys.append("devSampleRateIndex");
392  forwardChange = true;
393 
394  if (m_dev != 0)
395  {
396  rc = (airspy_error) airspy_set_samplerate(m_dev, static_cast<airspy_samplerate_t>(settings.m_devSampleRateIndex));
397 
398  if (rc != AIRSPY_SUCCESS)
399  {
400  qCritical("AirspyInput::applySettings: could not set sample rate index %u (%d S/s): %s", settings.m_devSampleRateIndex, m_sampleRates[settings.m_devSampleRateIndex], airspy_error_name(rc));
401  }
402  else if (m_airspyThread != 0)
403  {
404  qDebug("AirspyInput::applySettings: sample rate set to index: %u (%d S/s)", settings.m_devSampleRateIndex, m_sampleRates[settings.m_devSampleRateIndex]);
406  }
407  }
408  }
409 
410  if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
411  {
412  reverseAPIKeys.append("log2Decim");
413  forwardChange = true;
414 
415  if (m_airspyThread != 0)
416  {
418  qDebug() << "AirspyInput: set decimation to " << (1<<settings.m_log2Decim);
419  }
420  }
421 
422  if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) {
423  reverseAPIKeys.append("centerFrequency");
424  }
425  if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) {
426  reverseAPIKeys.append("LOppmTenths");
427  }
428  if ((m_settings.m_fcPos != settings.m_fcPos) || force) {
429  reverseAPIKeys.append("fcPos");
430  }
431  if ((m_settings.m_transverterMode != settings.m_transverterMode) || force) {
432  reverseAPIKeys.append("transverterMode");
433  }
435  reverseAPIKeys.append("transverterDeltaFrequency");
436  }
437 
439  || (m_settings.m_LOppmTenths != settings.m_LOppmTenths)
440  || (m_settings.m_fcPos != settings.m_fcPos)
441  || (m_settings.m_log2Decim != settings.m_log2Decim)
444  {
445  qint64 deviceCenterFrequency = DeviceSampleSource::calculateDeviceCenterFrequency(
446  settings.m_centerFrequency,
448  settings.m_log2Decim,
451  DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
452  settings.m_transverterMode);
453 
454  if (m_dev != 0) {
455  setDeviceCenterFrequency(deviceCenterFrequency);
456  }
457 
458  forwardChange = true;
459  }
460 
461  if ((m_settings.m_fcPos != settings.m_fcPos) || force)
462  {
463  if (m_airspyThread != 0)
464  {
465  m_airspyThread->setFcPos((int) settings.m_fcPos);
466  qDebug() << "AirspyInput: set fc pos (enum) to " << (int) settings.m_fcPos;
467  }
468  }
469 
470  if ((m_settings.m_lnaGain != settings.m_lnaGain) || force)
471  {
472  reverseAPIKeys.append("lnaGain");
473 
474  if (m_dev != 0)
475  {
476  rc = (airspy_error) airspy_set_lna_gain(m_dev, settings.m_lnaGain);
477 
478  if (rc != AIRSPY_SUCCESS) {
479  qDebug("AirspyInput::applySettings: airspy_set_lna_gain failed: %s", airspy_error_name(rc));
480  } else {
481  qDebug() << "AirspyInput:applySettings: LNA gain set to " << settings.m_lnaGain;
482  }
483  }
484  }
485 
486  if ((m_settings.m_lnaAGC != settings.m_lnaAGC) || force)
487  {
488  reverseAPIKeys.append("lnaAGC");
489 
490  if (m_dev != 0) {
491  rc = (airspy_error) airspy_set_lna_agc(m_dev, (settings.m_lnaAGC ? 1 : 0));
492  }
493 
494  if (rc != AIRSPY_SUCCESS) {
495  qDebug("AirspyInput::applySettings: airspy_set_lna_agc failed: %s", airspy_error_name(rc));
496  } else {
497  qDebug() << "AirspyInput:applySettings: LNA AGC set to " << settings.m_lnaAGC;
498  }
499  }
500 
501  if ((m_settings.m_mixerGain != settings.m_mixerGain) || force)
502  {
503  reverseAPIKeys.append("mixerGain");
504 
505  if (m_dev != 0)
506  {
507  rc = (airspy_error) airspy_set_mixer_gain(m_dev, settings.m_mixerGain);
508 
509  if (rc != AIRSPY_SUCCESS) {
510  qDebug("AirspyInput::applySettings: airspy_set_mixer_gain failed: %s", airspy_error_name(rc));
511  } else {
512  qDebug() << "AirspyInput:applySettings: mixer gain set to " << settings.m_mixerGain;
513  }
514  }
515  }
516 
517  if ((m_settings.m_mixerAGC != settings.m_mixerAGC) || force)
518  {
519  reverseAPIKeys.append("mixerAGC");
520 
521  if (m_dev != 0) {
522  rc = (airspy_error) airspy_set_mixer_agc(m_dev, (settings.m_mixerAGC ? 1 : 0));
523  }
524 
525  if (rc != AIRSPY_SUCCESS) {
526  qDebug("AirspyInput::applySettings: airspy_set_mixer_agc failed: %s", airspy_error_name(rc));
527  } else {
528  qDebug() << "AirspyInput:applySettings: Mixer AGC set to " << settings.m_mixerAGC;
529  }
530  }
531 
532  if ((m_settings.m_vgaGain != settings.m_vgaGain) || force)
533  {
534  reverseAPIKeys.append("vgaGain");
535 
536  if (m_dev != 0)
537  {
538  rc = (airspy_error) airspy_set_vga_gain(m_dev, settings.m_vgaGain);
539 
540  if (rc != AIRSPY_SUCCESS) {
541  qDebug("AirspyInput::applySettings: airspy_set_vga_gain failed: %s", airspy_error_name(rc));
542  } else {
543  qDebug() << "AirspyInput:applySettings: VGA gain set to " << settings.m_vgaGain;
544  }
545  }
546  }
547 
548  if ((m_settings.m_biasT != settings.m_biasT) || force)
549  {
550  reverseAPIKeys.append("biasT");
551 
552  if (m_dev != 0)
553  {
554  rc = (airspy_error) airspy_set_rf_bias(m_dev, (settings.m_biasT ? 1 : 0));
555 
556  if (rc != AIRSPY_SUCCESS) {
557  qDebug("AirspyInput::applySettings: airspy_set_rf_bias failed: %s", airspy_error_name(rc));
558  } else {
559  qDebug() << "AirspyInput:applySettings: bias tee set to " << settings.m_biasT;
560  }
561  }
562  }
563 
564  if (settings.m_useReverseAPI)
565  {
566  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
570  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
571  }
572 
573  m_settings = settings;
574 
575  if (forwardChange)
576  {
579  m_fileSink->handleMessage(*notif); // forward to file sink
581  }
582 
583  return true;
584 }
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: airspyinput.h:155
quint32 m_devSampleRateIndex
quint64 m_centerFrequency
static qint64 calculateDeviceCenterFrequency(quint64 centerFrequency, qint64 transverterDeltaFrequency, int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme, bool transverterMode=false)
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
Definition: deviceapi.cpp:316
quint32 m_log2Decim
quint32 m_mixerGain
virtual bool handleMessage(const Message &message)
Processing of a message. Returns true if message has actually been processed.
Definition: filerecord.cpp:128
std::vector< uint32_t > m_sampleRates
Definition: airspyinput.h:153
void setLog2Decimation(unsigned int log2_decim)
AirspySettings m_settings
Definition: airspyinput.h:149
qint64 m_transverterDeltaFrequency
QMutex m_mutex
Definition: airspyinput.h:148
DeviceAPI * m_deviceAPI
Definition: airspyinput.h:147
AirspyThread * m_airspyThread
Definition: airspyinput.h:151
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const AirspySettings &settings, bool force)
uint16_t m_reverseAPIPort
void setSamplerate(uint32_t samplerate)
void setFcPos(int fcPos)
QString m_reverseAPIAddress
struct airspy_device * m_dev
Definition: airspyinput.h:150
uint16_t m_reverseAPIDeviceIndex
void setDeviceCenterFrequency(quint64 freq)
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection, int streamIndex=0)
Configure current device engine DSP corrections (Rx)
Definition: deviceapi.cpp:355
qint32 m_LOppmTenths
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ closeDevice()

void AirspyInput::closeDevice ( )
private

Definition at line 196 of file airspyinput.cpp.

References m_dev, and m_deviceDescription.

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

197 {
198  if (m_dev != 0)
199  {
200  airspy_stop_rx(m_dev);
201  airspy_close(m_dev);
202  m_dev = 0;
203  }
204 
205  m_deviceDescription.clear();
206  airspy_exit();
207 }
QString m_deviceDescription
Definition: airspyinput.h:152
struct airspy_device * m_dev
Definition: airspyinput.h:150
+ Here is the caller graph for this function:

◆ deserialize()

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

Implements DeviceSampleSource.

Definition at line 229 of file airspyinput.cpp.

References AirspyInput::MsgConfigureAirspy::create(), AirspySettings::deserialize(), DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, m_settings, MessageQueue::push(), and AirspySettings::resetToDefaults().

Referenced by AirspyInput::MsgStartStop::MsgStartStop().

230 {
231  bool success = true;
232 
233  if (!m_settings.deserialize(data))
234  {
236  success = false;
237  }
238 
239  MsgConfigureAirspy* message = MsgConfigureAirspy::create(m_settings, true);
240  m_inputMessageQueue.push(message);
241 
242  if (m_guiMessageQueue)
243  {
244  MsgConfigureAirspy* messageToGUI = MsgConfigureAirspy::create(m_settings, true);
245  m_guiMessageQueue->push(messageToGUI);
246  }
247 
248  return success;
249 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
AirspySettings m_settings
Definition: airspyinput.h:149
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
bool deserialize(const QByteArray &data)
static MsgConfigureAirspy * create(const AirspySettings &settings, bool force)
Definition: airspyinput.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy()

void AirspyInput::destroy ( )
virtual

Implements DeviceSampleSource.

Definition at line 79 of file airspyinput.cpp.

Referenced by AirspyInput::MsgStartStop::MsgStartStop().

80 {
81  delete this;
82 }
+ Here is the caller graph for this function:

◆ getCenterFrequency()

quint64 AirspyInput::getCenterFrequency ( ) const
virtual

Center frequency exposed by the source.

Implements DeviceSampleSource.

Definition at line 262 of file airspyinput.cpp.

References AirspySettings::m_centerFrequency, and m_settings.

Referenced by setSampleRate().

263 {
265 }
quint64 m_centerFrequency
AirspySettings m_settings
Definition: airspyinput.h:149
+ Here is the caller graph for this function:

◆ getDeviceDescription()

const QString & AirspyInput::getDeviceDescription ( ) const
virtual

Implements DeviceSampleSource.

Definition at line 251 of file airspyinput.cpp.

References m_deviceDescription.

Referenced by setMessageQueueToGUI().

252 {
253  return m_deviceDescription;
254 }
QString m_deviceDescription
Definition: airspyinput.h:152
+ Here is the caller graph for this function:

◆ getSampleRate()

int AirspyInput::getSampleRate ( ) const
virtual

Sample rate exposed by the source.

Implements DeviceSampleSource.

Definition at line 256 of file airspyinput.cpp.

References AirspySettings::m_devSampleRateIndex, AirspySettings::m_log2Decim, m_sampleRates, and m_settings.

Referenced by setMessageQueueToGUI().

257 {
259  return (rate / (1<<m_settings.m_log2Decim));
260 }
quint32 m_devSampleRateIndex
quint32 m_log2Decim
std::vector< uint32_t > m_sampleRates
Definition: airspyinput.h:153
AirspySettings m_settings
Definition: airspyinput.h:149
+ Here is the caller graph for this function:

◆ getSampleRates()

const std::vector<uint32_t>& AirspyInput::getSampleRates ( ) const
inline

Definition at line 116 of file airspyinput.h.

References handleMessage(), m_sampleRates, webapiReportGet(), webapiRun(), webapiRunGet(), webapiSettingsGet(), and webapiSettingsPutPatch().

Referenced by webapiFormatDeviceReport().

116 { return m_sampleRates; }
std::vector< uint32_t > m_sampleRates
Definition: airspyinput.h:153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleMessage()

bool AirspyInput::handleMessage ( const Message message)
virtual

Implements DeviceSampleSource.

Definition at line 282 of file airspyinput.cpp.

References applySettings(), FileRecord::genUniqueFileName(), DeviceAPI::getDeviceUID(), AirspyInput::MsgConfigureAirspy::getForce(), AirspyInput::MsgConfigureAirspy::getSettings(), AirspyInput::MsgFileRecord::getStartStop(), AirspyInput::MsgStartStop::getStartStop(), DeviceAPI::initDeviceEngine(), m_deviceAPI, AirspySettings::m_fileRecordName, m_fileSink, m_settings, AirspySettings::m_useReverseAPI, Message::match(), FileRecord::setFileName(), DeviceAPI::startDeviceEngine(), FileRecord::startRecording(), DeviceAPI::stopDeviceEngine(), FileRecord::stopRecording(), and webapiReverseSendStartStop().

Referenced by getSampleRates().

283 {
284  if (MsgConfigureAirspy::match(message))
285  {
286  MsgConfigureAirspy& conf = (MsgConfigureAirspy&) message;
287  qDebug() << "AirspyInput::handleMessage: MsgConfigureAirspy";
288 
289  bool success = applySettings(conf.getSettings(), conf.getForce());
290 
291  if (!success)
292  {
293  qDebug("AirspyInput::handleMessage: Airspy config error");
294  }
295 
296  return true;
297  }
298  else if (MsgStartStop::match(message))
299  {
300  MsgStartStop& cmd = (MsgStartStop&) message;
301  qDebug() << "AirspyInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
302 
303  if (cmd.getStartStop())
304  {
306  {
308  }
309  }
310  else
311  {
313  }
314 
316  webapiReverseSendStartStop(cmd.getStartStop());
317  }
318 
319  return true;
320  }
321  else if (MsgFileRecord::match(message))
322  {
323  MsgFileRecord& conf = (MsgFileRecord&) message;
324  qDebug() << "AirspyInput::handleMessage: MsgFileRecord: " << conf.getStartStop();
325 
326  if (conf.getStartStop())
327  {
328  if (m_settings.m_fileRecordName.size() != 0) {
330  } else {
332  }
333 
335  }
336  else
337  {
339  }
340 
341  return true;
342  }
343  else
344  {
345  return false;
346  }
347 }
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: airspyinput.h:155
bool startDeviceEngine()
Start the device engine corresponding to the stream type.
Definition: deviceapi.cpp:253
void stopDeviceEngine()
Stop the device engine corresponding to the stream type.
Definition: deviceapi.cpp:266
void setFileName(const QString &filename)
Definition: filerecord.cpp:59
uint getDeviceUID() const
Return the current device engine unique ID.
Definition: deviceapi.cpp:303
void startRecording()
Definition: filerecord.cpp:105
QString m_fileRecordName
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
Definition: deviceapi.cpp:240
void genUniqueFileName(uint deviceUID, int istream=-1)
Definition: filerecord.cpp:67
void stopRecording()
Definition: filerecord.cpp:117
AirspySettings m_settings
Definition: airspyinput.h:149
static bool match(const Message *message)
Definition: message.cpp:45
DeviceAPI * m_deviceAPI
Definition: airspyinput.h:147
bool applySettings(const AirspySettings &settings, bool force)
void webapiReverseSendStartStop(bool start)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

void AirspyInput::init ( )
virtual

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

Implements DeviceSampleSource.

Definition at line 164 of file airspyinput.cpp.

References applySettings(), and m_settings.

Referenced by AirspyInput::MsgStartStop::MsgStartStop().

165 {
166  applySettings(m_settings, true);
167 }
AirspySettings m_settings
Definition: airspyinput.h:149
bool applySettings(const AirspySettings &settings, bool force)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ networkManagerFinished

void AirspyInput::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 900 of file airspyinput.cpp.

Referenced by AirspyInput(), and ~AirspyInput().

901 {
902  QNetworkReply::NetworkError replyError = reply->error();
903 
904  if (replyError)
905  {
906  qWarning() << "AirspyInput::networkManagerFinished:"
907  << " error(" << (int) replyError
908  << "): " << replyError
909  << ": " << reply->errorString();
910  return;
911  }
912 
913  QString answer = reply->readAll();
914  answer.chop(1); // remove last \n
915  qDebug("AirspyInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
916 }
+ Here is the caller graph for this function:

◆ open_airspy_from_sequence()

struct airspy_device * AirspyInput::open_airspy_from_sequence ( int  sequence)
private

Definition at line 586 of file airspyinput.cpp.

References i, and AirspyPlugin::m_maxDevices.

Referenced by openDevice().

587 {
588  struct airspy_device *devinfo;
589  airspy_error rc = AIRSPY_ERROR_OTHER;
590 
591  for (int i = 0; i < AirspyPlugin::m_maxDevices; i++)
592  {
593  rc = (airspy_error) airspy_open(&devinfo);
594 
595  if (rc == AIRSPY_SUCCESS)
596  {
597  if (i == sequence) {
598  return devinfo;
599  } else {
600  airspy_close(devinfo);
601  }
602  }
603  else
604  {
605  break;
606  }
607  }
608 
609  return 0;
610 }
static const int m_maxDevices
Definition: airspyplugin.h:48
int32_t i
Definition: decimators.h:244
+ Here is the caller graph for this function:

◆ openDevice()

bool AirspyInput::openDevice ( )
private

Definition at line 84 of file airspyinput.cpp.

References closeDevice(), DeviceAPI::getSamplingDeviceSequence(), i, m_dev, m_deviceAPI, DeviceSampleSource::m_sampleFifo, m_sampleRates, open_airspy_from_sequence(), and SampleSinkFifo::setSize().

Referenced by AirspyInput().

85 {
86  if (m_dev != 0)
87  {
88  closeDevice();
89  }
90 
91  airspy_error rc;
92 
93  rc = (airspy_error) airspy_init();
94 
95  if (rc != AIRSPY_SUCCESS)
96  {
97  qCritical("AirspyInput::start: failed to initiate Airspy library %s", airspy_error_name(rc));
98  }
99 
100  if (!m_sampleFifo.setSize(1<<19))
101  {
102  qCritical("AirspyInput::start: could not allocate SampleFifo");
103  return false;
104  }
105 
106  int device = m_deviceAPI->getSamplingDeviceSequence();
107 
108  if ((m_dev = open_airspy_from_sequence(device)) == 0)
109  {
110  qCritical("AirspyInput::start: could not open Airspy #%d", device);
111  return false;
112  }
113 
114 #ifdef LIBAIRSPY_DEFAULT_RATES
115  qDebug("AirspyInput::start: detault rates");
116  m_sampleRates.clear();
117  m_sampleRates.push_back(10000000);
118  m_sampleRates.push_back(2500000);
119 #else
120  uint32_t nbSampleRates;
121  uint32_t *sampleRates;
122 
123  airspy_get_samplerates(m_dev, &nbSampleRates, 0);
124 
125  sampleRates = new uint32_t[nbSampleRates];
126 
127  airspy_get_samplerates(m_dev, sampleRates, nbSampleRates);
128 
129  if (nbSampleRates == 0)
130  {
131  qCritical("AirspyInput::start: could not obtain Airspy sample rates");
132  return false;
133  }
134  else
135  {
136  qDebug("AirspyInput::start: %d sample rates", nbSampleRates);
137  }
138 
139  m_sampleRates.clear();
140 
141  for (unsigned int i=0; i<nbSampleRates; i++)
142  {
143  m_sampleRates.push_back(sampleRates[i]);
144  qDebug("AirspyInput::start: sampleRates[%d] = %u Hz", i, sampleRates[i]);
145  }
146 
147  delete[] sampleRates;
148 #endif
149 
150 // MsgReportAirspy *message = MsgReportAirspy::create(m_sampleRates);
151 // getOutputMessageQueueToGUI()->push(message);
152 
153  rc = (airspy_error) airspy_set_sample_type(m_dev, AIRSPY_SAMPLE_INT16_IQ);
154 
155  if (rc != AIRSPY_SUCCESS)
156  {
157  qCritical("AirspyInput::start: could not set sample type to INT16_IQ");
158  return false;
159  }
160 
161  return true;
162 }
SampleSinkFifo m_sampleFifo
bool setSize(int size)
unsigned int uint32_t
Definition: rtptypes_win.h:46
std::vector< uint32_t > m_sampleRates
Definition: airspyinput.h:153
int32_t i
Definition: decimators.h:244
struct airspy_device * open_airspy_from_sequence(int sequence)
DeviceAPI * m_deviceAPI
Definition: airspyinput.h:147
struct airspy_device * m_dev
Definition: airspyinput.h:150
void closeDevice()
uint32_t getSamplingDeviceSequence() const
Definition: deviceapi.h:123
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

QByteArray AirspyInput::serialize ( ) const
virtual

Implements DeviceSampleSource.

Definition at line 224 of file airspyinput.cpp.

References m_settings, and AirspySettings::serialize().

Referenced by AirspyInput::MsgStartStop::MsgStartStop().

225 {
226  return m_settings.serialize();
227 }
AirspySettings m_settings
Definition: airspyinput.h:149
QByteArray serialize() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCenterFrequency()

void AirspyInput::setCenterFrequency ( qint64  centerFrequency)
virtual

Implements DeviceSampleSource.

Definition at line 267 of file airspyinput.cpp.

References AirspyInput::MsgConfigureAirspy::create(), AirspySettings::m_centerFrequency, DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, m_settings, and MessageQueue::push().

Referenced by setSampleRate().

268 {
269  AirspySettings settings = m_settings;
270  settings.m_centerFrequency = centerFrequency;
271 
272  MsgConfigureAirspy* message = MsgConfigureAirspy::create(settings, false);
273  m_inputMessageQueue.push(message);
274 
275  if (m_guiMessageQueue)
276  {
277  MsgConfigureAirspy* messageToGUI = MsgConfigureAirspy::create(settings, false);
278  m_guiMessageQueue->push(messageToGUI);
279  }
280 }
quint64 m_centerFrequency
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
AirspySettings m_settings
Definition: airspyinput.h:149
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
static MsgConfigureAirspy * create(const AirspySettings &settings, bool force)
Definition: airspyinput.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDeviceCenterFrequency()

void AirspyInput::setDeviceCenterFrequency ( quint64  freq)
private

Definition at line 349 of file airspyinput.cpp.

References m_dev, AirspySettings::m_LOppmTenths, and m_settings.

Referenced by applySettings().

350 {
351  qint64 df = ((qint64)freq_hz * m_settings.m_LOppmTenths) / 10000000LL;
352  freq_hz += df;
353 
354  airspy_error rc = (airspy_error) airspy_set_freq(m_dev, static_cast<uint32_t>(freq_hz));
355 
356  if (rc != AIRSPY_SUCCESS)
357  {
358  qWarning("AirspyInput::setDeviceCenterFrequency: could not frequency to %llu Hz", freq_hz);
359  }
360  else
361  {
362  qDebug("AirspyInput::setDeviceCenterFrequency: frequency set to %llu Hz", freq_hz);
363  }
364 }
AirspySettings m_settings
Definition: airspyinput.h:149
struct airspy_device * m_dev
Definition: airspyinput.h:150
qint32 m_LOppmTenths
+ Here is the caller graph for this function:

◆ setMessageQueueToGUI()

virtual void AirspyInput::setMessageQueueToGUI ( MessageQueue queue)
inlinevirtual

Implements DeviceSampleSource.

Definition at line 110 of file airspyinput.h.

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

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

◆ setSampleRate()

virtual void AirspyInput::setSampleRate ( int  sampleRate)
inlinevirtual

For when the source sample rate is set externally.

Implements DeviceSampleSource.

Definition at line 113 of file airspyinput.h.

References getCenterFrequency(), and setCenterFrequency().

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

◆ start()

bool AirspyInput::start ( )
virtual

Implements DeviceSampleSource.

Definition at line 169 of file airspyinput.cpp.

References applySettings(), m_airspyThread, m_dev, AirspySettings::m_devSampleRateIndex, AirspySettings::m_fcPos, AirspySettings::m_log2Decim, m_mutex, m_running, DeviceSampleSource::m_sampleFifo, m_sampleRates, m_settings, AirspyThread::setFcPos(), AirspyThread::setLog2Decimation(), AirspyThread::setSamplerate(), AirspyThread::startWork(), and stop().

Referenced by AirspyInput::MsgStartStop::MsgStartStop().

170 {
171  QMutexLocker mutexLocker(&m_mutex);
172 
173  if (!m_dev) {
174  return false;
175  }
176 
177  if (m_running) { stop(); }
178 
183 
185 
186  mutexLocker.unlock();
187 
188  applySettings(m_settings, true);
189 
190  qDebug("AirspyInput::startInput: started");
191  m_running = true;
192 
193  return true;
194 }
bool m_running
Definition: airspyinput.h:154
quint32 m_devSampleRateIndex
quint32 m_log2Decim
SampleSinkFifo m_sampleFifo
std::vector< uint32_t > m_sampleRates
Definition: airspyinput.h:153
void setLog2Decimation(unsigned int log2_decim)
AirspySettings m_settings
Definition: airspyinput.h:149
QMutex m_mutex
Definition: airspyinput.h:148
AirspyThread * m_airspyThread
Definition: airspyinput.h:151
void setSamplerate(uint32_t samplerate)
void setFcPos(int fcPos)
bool applySettings(const AirspySettings &settings, bool force)
struct airspy_device * m_dev
Definition: airspyinput.h:150
void startWork()
virtual void stop()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void AirspyInput::stop ( )
virtual

Implements DeviceSampleSource.

Definition at line 209 of file airspyinput.cpp.

References m_airspyThread, m_mutex, m_running, and AirspyThread::stopWork().

Referenced by AirspyInput::MsgStartStop::MsgStartStop(), start(), and ~AirspyInput().

210 {
211  qDebug("AirspyInput::stop");
212  QMutexLocker mutexLocker(&m_mutex);
213 
214  if (m_airspyThread != 0)
215  {
217  delete m_airspyThread;
218  m_airspyThread = 0;
219  }
220 
221  m_running = false;
222 }
bool m_running
Definition: airspyinput.h:154
QMutex m_mutex
Definition: airspyinput.h:148
AirspyThread * m_airspyThread
Definition: airspyinput.h:151
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatDeviceReport()

void AirspyInput::webapiFormatDeviceReport ( SWGSDRangel::SWGDeviceReport response)
private

Definition at line 783 of file airspyinput.cpp.

References SWGSDRangel::SWGDeviceReport::getAirspyReport(), SWGSDRangel::SWGAirspyReport::getSampleRates(), getSampleRates(), and SWGSDRangel::SWGAirspyReport::setSampleRates().

Referenced by webapiReportGet().

784 {
785  response.getAirspyReport()->setSampleRates(new QList<SWGSDRangel::SWGSampleRate*>);
786 
787  for (std::vector<uint32_t>::const_iterator it = getSampleRates().begin(); it != getSampleRates().end(); ++it)
788  {
789  response.getAirspyReport()->getSampleRates()->append(new SWGSDRangel::SWGSampleRate);
790  response.getAirspyReport()->getSampleRates()->back()->setRate(*it);
791  }
792 }
SWGAirspyReport * getAirspyReport()
const std::vector< uint32_t > & getSampleRates() const
Definition: airspyinput.h:116
void setSampleRates(QList< SWGSampleRate *> *sample_rates)
QList< SWGSampleRate * > * getSampleRates()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatDeviceSettings()

void AirspyInput::webapiFormatDeviceSettings ( SWGSDRangel::SWGDeviceSettings response,
const AirspySettings settings 
)
private

Definition at line 747 of file airspyinput.cpp.

References SWGSDRangel::SWGDeviceSettings::getAirspySettings(), SWGSDRangel::SWGAirspySettings::getFileRecordName(), SWGSDRangel::SWGAirspySettings::getReverseApiAddress(), AirspySettings::m_biasT, AirspySettings::m_centerFrequency, AirspySettings::m_dcBlock, AirspySettings::m_devSampleRateIndex, AirspySettings::m_fcPos, AirspySettings::m_fileRecordName, AirspySettings::m_iqCorrection, AirspySettings::m_lnaAGC, AirspySettings::m_lnaGain, AirspySettings::m_log2Decim, AirspySettings::m_LOppmTenths, AirspySettings::m_mixerAGC, AirspySettings::m_mixerGain, AirspySettings::m_reverseAPIAddress, AirspySettings::m_reverseAPIDeviceIndex, AirspySettings::m_reverseAPIPort, AirspySettings::m_transverterDeltaFrequency, AirspySettings::m_transverterMode, AirspySettings::m_useReverseAPI, AirspySettings::m_vgaGain, SWGSDRangel::SWGAirspySettings::setBiasT(), SWGSDRangel::SWGAirspySettings::setCenterFrequency(), SWGSDRangel::SWGAirspySettings::setDcBlock(), SWGSDRangel::SWGAirspySettings::setDevSampleRateIndex(), SWGSDRangel::SWGAirspySettings::setFcPos(), SWGSDRangel::SWGAirspySettings::setFileRecordName(), SWGSDRangel::SWGAirspySettings::setIqCorrection(), SWGSDRangel::SWGAirspySettings::setLnaAgc(), SWGSDRangel::SWGAirspySettings::setLnaGain(), SWGSDRangel::SWGAirspySettings::setLog2Decim(), SWGSDRangel::SWGAirspySettings::setLOppmTenths(), SWGSDRangel::SWGAirspySettings::setMixerAgc(), SWGSDRangel::SWGAirspySettings::setMixerGain(), SWGSDRangel::SWGAirspySettings::setReverseApiAddress(), SWGSDRangel::SWGAirspySettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGAirspySettings::setReverseApiPort(), SWGSDRangel::SWGAirspySettings::setTransverterDeltaFrequency(), SWGSDRangel::SWGAirspySettings::setTransverterMode(), SWGSDRangel::SWGAirspySettings::setUseReverseApi(), and SWGSDRangel::SWGAirspySettings::setVgaGain().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

748 {
750  response.getAirspySettings()->setLOppmTenths(settings.m_LOppmTenths);
752  response.getAirspySettings()->setLnaGain(settings.m_lnaGain);
753  response.getAirspySettings()->setMixerGain(settings.m_mixerGain);
754  response.getAirspySettings()->setVgaGain(settings.m_vgaGain);
755  response.getAirspySettings()->setLnaAgc(settings.m_lnaAGC ? 1 : 0);
756  response.getAirspySettings()->setMixerAgc(settings.m_mixerAGC ? 1 : 0);
757  response.getAirspySettings()->setLog2Decim(settings.m_log2Decim);
758  response.getAirspySettings()->setFcPos((int) settings.m_fcPos);
759  response.getAirspySettings()->setBiasT(settings.m_biasT ? 1 : 0);
760  response.getAirspySettings()->setDcBlock(settings.m_dcBlock ? 1 : 0);
761  response.getAirspySettings()->setIqCorrection(settings.m_iqCorrection ? 1 : 0);
763  response.getAirspySettings()->setTransverterMode(settings.m_transverterMode ? 1 : 0);
764 
765  if (response.getAirspySettings()->getFileRecordName()) {
766  *response.getAirspySettings()->getFileRecordName() = settings.m_fileRecordName;
767  } else {
768  response.getAirspySettings()->setFileRecordName(new QString(settings.m_fileRecordName));
769  }
770 
771  response.getAirspySettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
772 
773  if (response.getAirspySettings()->getReverseApiAddress()) {
775  } else {
776  response.getAirspySettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
777  }
778 
781 }
quint32 m_devSampleRateIndex
quint64 m_centerFrequency
void setLOppmTenths(qint32 l_oppm_tenths)
SWGAirspySettings * getAirspySettings()
QString m_fileRecordName
quint32 m_log2Decim
quint32 m_mixerGain
void setMixerAgc(qint32 mixer_agc)
void setTransverterDeltaFrequency(qint64 transverter_delta_frequency)
void setLog2Decim(qint32 log2_decim)
void setCenterFrequency(qint64 center_frequency)
void setTransverterMode(qint32 transverter_mode)
void setIqCorrection(qint32 iq_correction)
void setReverseApiAddress(QString *reverse_api_address)
qint64 m_transverterDeltaFrequency
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setDevSampleRateIndex(qint32 dev_sample_rate_index)
uint16_t m_reverseAPIPort
void setFileRecordName(QString *file_record_name)
QString m_reverseAPIAddress
uint16_t m_reverseAPIDeviceIndex
void setUseReverseApi(qint32 use_reverse_api)
void setMixerGain(qint32 mixer_gain)
qint32 m_LOppmTenths
void setReverseApiPort(qint32 reverse_api_port)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReportGet()

int AirspyInput::webapiReportGet ( SWGSDRangel::SWGDeviceReport response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 736 of file airspyinput.cpp.

References SWGSDRangel::SWGDeviceReport::getAirspyReport(), SWGSDRangel::SWGAirspyReport::init(), SWGSDRangel::SWGDeviceReport::setAirspyReport(), and webapiFormatDeviceReport().

Referenced by getSampleRates().

739 {
740  (void) errorMessage;
742  response.getAirspyReport()->init();
743  webapiFormatDeviceReport(response);
744  return 200;
745 }
SWGAirspyReport * getAirspyReport()
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
void setAirspyReport(SWGAirspyReport *airspy_report)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

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

Definition at line 794 of file airspyinput.cpp.

References SWGSDRangel::SWGDeviceSettings::asJson(), SWGSDRangel::SWGDeviceSettings::getAirspySettings(), DeviceAPI::getDeviceSetIndex(), AirspySettings::m_biasT, AirspySettings::m_centerFrequency, AirspySettings::m_dcBlock, m_deviceAPI, AirspySettings::m_devSampleRateIndex, AirspySettings::m_fcPos, AirspySettings::m_fileRecordName, AirspySettings::m_iqCorrection, AirspySettings::m_lnaAGC, AirspySettings::m_lnaGain, AirspySettings::m_log2Decim, AirspySettings::m_LOppmTenths, AirspySettings::m_mixerAGC, AirspySettings::m_mixerGain, m_networkManager, m_networkRequest, AirspySettings::m_reverseAPIAddress, AirspySettings::m_reverseAPIDeviceIndex, AirspySettings::m_reverseAPIPort, AirspySettings::m_transverterDeltaFrequency, AirspySettings::m_transverterMode, AirspySettings::m_vgaGain, SWGSDRangel::SWGDeviceSettings::setAirspySettings(), SWGSDRangel::SWGAirspySettings::setBiasT(), SWGSDRangel::SWGAirspySettings::setCenterFrequency(), SWGSDRangel::SWGAirspySettings::setDcBlock(), SWGSDRangel::SWGDeviceSettings::setDeviceHwType(), SWGSDRangel::SWGAirspySettings::setDevSampleRateIndex(), SWGSDRangel::SWGDeviceSettings::setDirection(), SWGSDRangel::SWGAirspySettings::setFcPos(), SWGSDRangel::SWGAirspySettings::setFileRecordName(), SWGSDRangel::SWGAirspySettings::setIqCorrection(), SWGSDRangel::SWGAirspySettings::setLnaAgc(), SWGSDRangel::SWGAirspySettings::setLnaGain(), SWGSDRangel::SWGAirspySettings::setLog2Decim(), SWGSDRangel::SWGAirspySettings::setLOppmTenths(), SWGSDRangel::SWGAirspySettings::setMixerAgc(), SWGSDRangel::SWGAirspySettings::setMixerGain(), SWGSDRangel::SWGDeviceSettings::setOriginatorIndex(), SWGSDRangel::SWGAirspySettings::setTransverterDeltaFrequency(), SWGSDRangel::SWGAirspySettings::setTransverterMode(), and SWGSDRangel::SWGAirspySettings::setVgaGain().

Referenced by applySettings().

795 {
797  swgDeviceSettings->setDirection(0); // single Rx
798  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
799  swgDeviceSettings->setDeviceHwType(new QString("Airspy"));
800  swgDeviceSettings->setAirspySettings(new SWGSDRangel::SWGAirspySettings());
801  SWGSDRangel::SWGAirspySettings *swgAirspySettings = swgDeviceSettings->getAirspySettings();
802 
803  // transfer data that has been modified. When force is on transfer all data except reverse API data
804 
805  if (deviceSettingsKeys.contains("centerFrequency") || force) {
806  swgAirspySettings->setCenterFrequency(settings.m_centerFrequency);
807  }
808  if (deviceSettingsKeys.contains("LOppmTenths") || force) {
809  swgAirspySettings->setLOppmTenths(settings.m_LOppmTenths);
810  }
811  if (deviceSettingsKeys.contains("devSampleRateIndex") || force) {
812  swgAirspySettings->setDevSampleRateIndex(settings.m_devSampleRateIndex);
813  }
814  if (deviceSettingsKeys.contains("lnaGain") || force) {
815  swgAirspySettings->setLnaGain(settings.m_lnaGain);
816  }
817  if (deviceSettingsKeys.contains("mixerGain") || force) {
818  swgAirspySettings->setMixerGain(settings.m_mixerGain);
819  }
820  if (deviceSettingsKeys.contains("vgaGain") || force) {
821  swgAirspySettings->setVgaGain(settings.m_vgaGain);
822  }
823  if (deviceSettingsKeys.contains("lnaAGC") || force) {
824  swgAirspySettings->setLnaAgc(settings.m_lnaAGC ? 1 : 0);
825  }
826  if (deviceSettingsKeys.contains("mixerAGC") || force) {
827  swgAirspySettings->setMixerAgc(settings.m_mixerAGC ? 1 : 0);
828  }
829  if (deviceSettingsKeys.contains("log2Decim") || force) {
830  swgAirspySettings->setLog2Decim(settings.m_log2Decim);
831  }
832  if (deviceSettingsKeys.contains("fcPos") || force) {
833  swgAirspySettings->setFcPos((int) settings.m_fcPos);
834  }
835  if (deviceSettingsKeys.contains("biasT") || force) {
836  swgAirspySettings->setBiasT(settings.m_biasT ? 1 : 0);
837  }
838  if (deviceSettingsKeys.contains("dcBlock") || force) {
839  swgAirspySettings->setDcBlock(settings.m_dcBlock ? 1 : 0);
840  }
841  if (deviceSettingsKeys.contains("iqCorrection") || force) {
842  swgAirspySettings->setIqCorrection(settings.m_iqCorrection ? 1 : 0);
843  }
844  if (deviceSettingsKeys.contains("transverterDeltaFrequency") || force) {
845  swgAirspySettings->setTransverterDeltaFrequency(settings.m_transverterDeltaFrequency);
846  }
847  if (deviceSettingsKeys.contains("transverterMode") || force) {
848  swgAirspySettings->setTransverterMode(settings.m_transverterMode ? 1 : 0);
849  }
850  if (deviceSettingsKeys.contains("fileRecordName") || force) {
851  swgAirspySettings->setFileRecordName(new QString(settings.m_fileRecordName));
852  }
853 
854  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
855  .arg(settings.m_reverseAPIAddress)
856  .arg(settings.m_reverseAPIPort)
857  .arg(settings.m_reverseAPIDeviceIndex);
858  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
859  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
860 
861  QBuffer *buffer=new QBuffer();
862  buffer->open((QBuffer::ReadWrite));
863  buffer->write(swgDeviceSettings->asJson().toUtf8());
864  buffer->seek(0);
865 
866  // Always use PATCH to avoid passing reverse API settings
867  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
868 
869  delete swgDeviceSettings;
870 }
quint32 m_devSampleRateIndex
quint64 m_centerFrequency
QNetworkRequest m_networkRequest
Definition: airspyinput.h:157
void setLOppmTenths(qint32 l_oppm_tenths)
virtual QString asJson() override
SWGAirspySettings * getAirspySettings()
QString m_fileRecordName
quint32 m_log2Decim
quint32 m_mixerGain
void setOriginatorIndex(qint32 originator_index)
void setMixerAgc(qint32 mixer_agc)
void setAirspySettings(SWGAirspySettings *airspy_settings)
void setTransverterDeltaFrequency(qint64 transverter_delta_frequency)
void setLog2Decim(qint32 log2_decim)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
void setCenterFrequency(qint64 center_frequency)
void setTransverterMode(qint32 transverter_mode)
void setIqCorrection(qint32 iq_correction)
qint64 m_transverterDeltaFrequency
DeviceAPI * m_deviceAPI
Definition: airspyinput.h:147
void setDevSampleRateIndex(qint32 dev_sample_rate_index)
uint16_t m_reverseAPIPort
void setFileRecordName(QString *file_record_name)
QNetworkAccessManager * m_networkManager
Definition: airspyinput.h:156
QString m_reverseAPIAddress
uint16_t m_reverseAPIDeviceIndex
void setMixerGain(qint32 mixer_gain)
qint32 m_LOppmTenths
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 AirspyInput::webapiReverseSendStartStop ( bool  start)
private

Definition at line 872 of file airspyinput.cpp.

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

Referenced by handleMessage().

873 {
875  swgDeviceSettings->setDirection(0); // single Rx
876  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
877  swgDeviceSettings->setDeviceHwType(new QString("Airspy"));
878 
879  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
883  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
884  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
885 
886  QBuffer *buffer=new QBuffer();
887  buffer->open((QBuffer::ReadWrite));
888  buffer->write(swgDeviceSettings->asJson().toUtf8());
889  buffer->seek(0);
890 
891  if (start) {
892  m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
893  } else {
894  m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
895  }
896 
897  delete swgDeviceSettings;
898 }
QNetworkRequest m_networkRequest
Definition: airspyinput.h:157
virtual bool start()
virtual QString asJson() override
void setOriginatorIndex(qint32 originator_index)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
AirspySettings m_settings
Definition: airspyinput.h:149
DeviceAPI * m_deviceAPI
Definition: airspyinput.h:147
uint16_t m_reverseAPIPort
QNetworkAccessManager * m_networkManager
Definition: airspyinput.h:156
QString m_reverseAPIAddress
uint16_t m_reverseAPIDeviceIndex
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 AirspyInput::webapiRun ( bool  run,
SWGSDRangel::SWGDeviceState response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 621 of file airspyinput.cpp.

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

Referenced by getSampleRates().

625 {
626  (void) errorMessage;
628  MsgStartStop *message = MsgStartStop::create(run);
629  m_inputMessageQueue.push(message);
630 
631  if (m_guiMessageQueue) // forward to GUI if any
632  {
633  MsgStartStop *msgToGUI = MsgStartStop::create(run);
634  m_guiMessageQueue->push(msgToGUI);
635  }
636 
637  return 200;
638 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
static MsgStartStop * create(bool startStop)
Definition: airspyinput.h:86
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
DeviceAPI * m_deviceAPI
Definition: airspyinput.h:147
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiRunGet()

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

Reimplemented from DeviceSampleSource.

Definition at line 612 of file airspyinput.cpp.

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

Referenced by getSampleRates().

615 {
616  (void) errorMessage;
618  return 200;
619 }
DeviceAPI * m_deviceAPI
Definition: airspyinput.h:147
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 AirspyInput::webapiSettingsGet ( SWGSDRangel::SWGDeviceSettings response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 640 of file airspyinput.cpp.

References SWGSDRangel::SWGDeviceSettings::getAirspySettings(), SWGSDRangel::SWGAirspySettings::init(), m_settings, SWGSDRangel::SWGDeviceSettings::setAirspySettings(), and webapiFormatDeviceSettings().

Referenced by getSampleRates().

643 {
644  (void) errorMessage;
646  response.getAirspySettings()->init();
648  return 200;
649 }
SWGAirspySettings * getAirspySettings()
void setAirspySettings(SWGAirspySettings *airspy_settings)
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const AirspySettings &settings)
AirspySettings m_settings
Definition: airspyinput.h:149
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

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

Reimplemented from DeviceSampleSource.

Definition at line 651 of file airspyinput.cpp.

References AirspyInput::MsgConfigureAirspy::create(), SWGSDRangel::SWGDeviceSettings::getAirspySettings(), SWGSDRangel::SWGAirspySettings::getBiasT(), SWGSDRangel::SWGAirspySettings::getCenterFrequency(), SWGSDRangel::SWGAirspySettings::getDcBlock(), SWGSDRangel::SWGAirspySettings::getDevSampleRateIndex(), SWGSDRangel::SWGAirspySettings::getFcPos(), SWGSDRangel::SWGAirspySettings::getFileRecordName(), SWGSDRangel::SWGAirspySettings::getIqCorrection(), SWGSDRangel::SWGAirspySettings::getLnaAgc(), SWGSDRangel::SWGAirspySettings::getLnaGain(), SWGSDRangel::SWGAirspySettings::getLog2Decim(), SWGSDRangel::SWGAirspySettings::getLOppmTenths(), SWGSDRangel::SWGAirspySettings::getMixerAgc(), SWGSDRangel::SWGAirspySettings::getMixerGain(), SWGSDRangel::SWGAirspySettings::getReverseApiAddress(), SWGSDRangel::SWGAirspySettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGAirspySettings::getReverseApiPort(), SWGSDRangel::SWGAirspySettings::getTransverterDeltaFrequency(), SWGSDRangel::SWGAirspySettings::getTransverterMode(), SWGSDRangel::SWGAirspySettings::getUseReverseApi(), SWGSDRangel::SWGAirspySettings::getVgaGain(), AirspySettings::m_biasT, AirspySettings::m_centerFrequency, AirspySettings::m_dcBlock, AirspySettings::m_devSampleRateIndex, AirspySettings::m_fcPos, AirspySettings::m_fileRecordName, DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, AirspySettings::m_iqCorrection, AirspySettings::m_lnaAGC, AirspySettings::m_lnaGain, AirspySettings::m_log2Decim, AirspySettings::m_LOppmTenths, AirspySettings::m_mixerAGC, AirspySettings::m_mixerGain, AirspySettings::m_reverseAPIAddress, AirspySettings::m_reverseAPIDeviceIndex, AirspySettings::m_reverseAPIPort, m_settings, AirspySettings::m_transverterDeltaFrequency, AirspySettings::m_transverterMode, AirspySettings::m_useReverseAPI, AirspySettings::m_vgaGain, MessageQueue::push(), and webapiFormatDeviceSettings().

Referenced by getSampleRates().

656 {
657  (void) errorMessage;
658  AirspySettings settings = m_settings;
659 
660  if (deviceSettingsKeys.contains("centerFrequency")) {
661  settings.m_centerFrequency = response.getAirspySettings()->getCenterFrequency();
662  }
663  if (deviceSettingsKeys.contains("LOppmTenths")) {
664  settings.m_LOppmTenths = response.getAirspySettings()->getLOppmTenths();
665  }
666  if (deviceSettingsKeys.contains("devSampleRateIndex")) {
668  }
669  if (deviceSettingsKeys.contains("lnaGain")) {
670  settings.m_lnaGain = response.getAirspySettings()->getLnaGain();
671  }
672  if (deviceSettingsKeys.contains("mixerGain")) {
673  settings.m_mixerGain = response.getAirspySettings()->getMixerGain();
674  }
675  if (deviceSettingsKeys.contains("vgaGain")) {
676  settings.m_vgaGain = response.getAirspySettings()->getVgaGain();
677  }
678  if (deviceSettingsKeys.contains("lnaAGC")) {
679  settings.m_lnaAGC = response.getAirspySettings()->getLnaAgc() != 0;
680  }
681  if (deviceSettingsKeys.contains("mixerAGC")) {
682  settings.m_mixerAGC = response.getAirspySettings()->getMixerAgc() != 0;
683  }
684  if (deviceSettingsKeys.contains("log2Decim")) {
685  settings.m_log2Decim = response.getAirspySettings()->getLog2Decim();
686  }
687  if (deviceSettingsKeys.contains("fcPos")) {
688  int fcPos = response.getAirspySettings()->getFcPos();
689  fcPos = fcPos < 0 ? 0 : fcPos > 2 ? 2 : fcPos;
690  settings.m_fcPos = (AirspySettings::fcPos_t) fcPos;
691  }
692  if (deviceSettingsKeys.contains("biasT")) {
693  settings.m_biasT = response.getAirspySettings()->getBiasT() != 0;
694  }
695  if (deviceSettingsKeys.contains("dcBlock")) {
696  settings.m_dcBlock = response.getAirspySettings()->getDcBlock() != 0;
697  }
698  if (deviceSettingsKeys.contains("iqCorrection")) {
699  settings.m_iqCorrection = response.getAirspySettings()->getIqCorrection() != 0;
700  }
701  if (deviceSettingsKeys.contains("transverterDeltaFrequency")) {
703  }
704  if (deviceSettingsKeys.contains("transverterMode")) {
705  settings.m_transverterMode = response.getAirspySettings()->getTransverterMode() != 0;
706  }
707  if (deviceSettingsKeys.contains("fileRecordName")) {
708  settings.m_fileRecordName = *response.getAirspySettings()->getFileRecordName();
709  }
710  if (deviceSettingsKeys.contains("useReverseAPI")) {
711  settings.m_useReverseAPI = response.getAirspySettings()->getUseReverseApi() != 0;
712  }
713  if (deviceSettingsKeys.contains("reverseAPIAddress")) {
715  }
716  if (deviceSettingsKeys.contains("reverseAPIPort")) {
717  settings.m_reverseAPIPort = response.getAirspySettings()->getReverseApiPort();
718  }
719  if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
721  }
722 
723  MsgConfigureAirspy *msg = MsgConfigureAirspy::create(settings, force);
725 
726  if (m_guiMessageQueue) // forward to GUI if any
727  {
728  MsgConfigureAirspy *msgToGUI = MsgConfigureAirspy::create(settings, force);
729  m_guiMessageQueue->push(msgToGUI);
730  }
731 
732  webapiFormatDeviceSettings(response, settings);
733  return 200;
734 }
quint32 m_devSampleRateIndex
quint64 m_centerFrequency
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
SWGAirspySettings * getAirspySettings()
QString m_fileRecordName
quint32 m_log2Decim
quint32 m_mixerGain
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const AirspySettings &settings)
AirspySettings m_settings
Definition: airspyinput.h:149
qint64 m_transverterDeltaFrequency
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
uint16_t m_reverseAPIPort
QString m_reverseAPIAddress
uint16_t m_reverseAPIDeviceIndex
qint32 m_LOppmTenths
static MsgConfigureAirspy * create(const AirspySettings &settings, bool force)
Definition: airspyinput.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ loHighLimitFreq

const qint64 AirspyInput::loHighLimitFreq = 1900000000L
static

Definition at line 144 of file airspyinput.h.

Referenced by AirspyGui::updateFrequencyLimits().

◆ loLowLimitFreq

const qint64 AirspyInput::loLowLimitFreq = 24000000L
static

Definition at line 143 of file airspyinput.h.

Referenced by AirspyGui::updateFrequencyLimits().

◆ m_airspyThread

AirspyThread* AirspyInput::m_airspyThread
private

Definition at line 151 of file airspyinput.h.

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

◆ m_dev

struct airspy_device* AirspyInput::m_dev
private

◆ m_deviceAPI

DeviceAPI* AirspyInput::m_deviceAPI
private

◆ m_deviceDescription

QString AirspyInput::m_deviceDescription
private

Definition at line 152 of file airspyinput.h.

Referenced by closeDevice(), and getDeviceDescription().

◆ m_fileSink

FileRecord* AirspyInput::m_fileSink
private

File sink to record device I/Q output.

Definition at line 155 of file airspyinput.h.

Referenced by AirspyInput(), applySettings(), handleMessage(), and ~AirspyInput().

◆ m_mutex

QMutex AirspyInput::m_mutex
private

Definition at line 148 of file airspyinput.h.

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

◆ m_networkManager

QNetworkAccessManager* AirspyInput::m_networkManager
private

◆ m_networkRequest

QNetworkRequest AirspyInput::m_networkRequest
private

Definition at line 157 of file airspyinput.h.

Referenced by webapiReverseSendSettings(), and webapiReverseSendStartStop().

◆ m_running

bool AirspyInput::m_running
private

Definition at line 154 of file airspyinput.h.

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

◆ m_sampleRates

std::vector<uint32_t> AirspyInput::m_sampleRates
private

Definition at line 153 of file airspyinput.h.

Referenced by applySettings(), getSampleRate(), getSampleRates(), openDevice(), and start().

◆ m_settings

AirspySettings AirspyInput::m_settings
private

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