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.
airspyhfinput.h
Go to the documentation of this file.
1 // Copyright (C) 2018 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #ifndef INCLUDE_AIRSPYHFINPUT_H
19 #define INCLUDE_AIRSPYHFINPUT_H
20 
21 #include <QString>
22 #include <QByteArray>
23 #include <QNetworkRequest>
24 
25 #include <libairspyhf/airspyhf.h>
26 #include <dsp/devicesamplesource.h>
27 
28 #include "airspyhfsettings.h"
29 
30 class QNetworkAccessManager;
31 class QNetworkReply;
32 class DeviceAPI;
33 class AirspyHFThread;
34 class FileRecord;
35 
37  Q_OBJECT
38 public:
39  class MsgConfigureAirspyHF : public Message {
41 
42  public:
43  const AirspyHFSettings& getSettings() const { return m_settings; }
44  bool getForce() const { return m_force; }
45 
46  static MsgConfigureAirspyHF* create(const AirspyHFSettings& settings, bool force)
47  {
48  return new MsgConfigureAirspyHF(settings, force);
49  }
50 
51  private:
53  bool m_force;
54 
55  MsgConfigureAirspyHF(const AirspyHFSettings& settings, bool force) :
56  Message(),
57  m_settings(settings),
58  m_force(force)
59  { }
60  };
61 
62  class MsgFileRecord : public Message {
64 
65  public:
66  bool getStartStop() const { return m_startStop; }
67 
68  static MsgFileRecord* create(bool startStop) {
69  return new MsgFileRecord(startStop);
70  }
71 
72  protected:
74 
75  MsgFileRecord(bool startStop) :
76  Message(),
77  m_startStop(startStop)
78  { }
79  };
80 
81  class MsgStartStop : public Message {
83 
84  public:
85  bool getStartStop() const { return m_startStop; }
86 
87  static MsgStartStop* create(bool startStop) {
88  return new MsgStartStop(startStop);
89  }
90 
91  protected:
93 
94  MsgStartStop(bool startStop) :
95  Message(),
96  m_startStop(startStop)
97  { }
98  };
99 
100  AirspyHFInput(DeviceAPI *deviceAPI);
101  virtual ~AirspyHFInput();
102  virtual void destroy();
103 
104  virtual void init();
105  virtual bool start();
106  virtual void stop();
107 
108  virtual QByteArray serialize() const;
109  virtual bool deserialize(const QByteArray& data);
110 
111  virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
112  virtual const QString& getDeviceDescription() const;
113  virtual int getSampleRate() const;
114  virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
115  virtual quint64 getCenterFrequency() const;
116  virtual void setCenterFrequency(qint64 centerFrequency);
117  const std::vector<uint32_t>& getSampleRates() const { return m_sampleRates; }
118 
119  virtual bool handleMessage(const Message& message);
120 
121  virtual int webapiSettingsGet(
123  QString& errorMessage);
124 
125  virtual int webapiSettingsPutPatch(
126  bool force,
127  const QStringList& deviceSettingsKeys,
128  SWGSDRangel::SWGDeviceSettings& response, // query + response
129  QString& errorMessage);
130 
131  virtual int webapiReportGet(
133  QString& errorMessage);
134 
135  virtual int webapiRunGet(
136  SWGSDRangel::SWGDeviceState& response,
137  QString& errorMessage);
138 
139  virtual int webapiRun(
140  bool run,
141  SWGSDRangel::SWGDeviceState& response,
142  QString& errorMessage);
143 
144  static const qint64 loLowLimitFreqHF;
145  static const qint64 loHighLimitFreqHF;
146  static const qint64 loLowLimitFreqVHF;
147  static const qint64 loHighLimitFreqVHF;
148 
149 private:
151  QMutex m_mutex;
153  airspyhf_device_t* m_dev;
156  std::vector<uint32_t> m_sampleRates;
157  bool m_running;
159  QNetworkAccessManager *m_networkManager;
160  QNetworkRequest m_networkRequest;
161 
162  bool openDevice();
163  void closeDevice();
164  bool applySettings(const AirspyHFSettings& settings, bool force);
165  airspyhf_device_t *open_airspyhf_from_serial(const QString& serialStr);
166  void setDeviceCenterFrequency(quint64 freq, const AirspyHFSettings& settings);
169  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const AirspyHFSettings& settings, bool force);
170  void webapiReverseSendStartStop(bool start);
171 
172 private slots:
173  void networkManagerFinished(QNetworkReply *reply);
174 };
175 
176 #endif // INCLUDE_AIRSPYHFINPUT_H
static const qint64 loHighLimitFreqVHF
void setDeviceCenterFrequency(quint64 freq, const AirspyHFSettings &settings)
static MsgConfigureAirspyHF * create(const AirspyHFSettings &settings, bool force)
Definition: airspyhfinput.h:46
MsgConfigureAirspyHF(const AirspyHFSettings &settings, bool force)
Definition: airspyhfinput.h:55
static MsgStartStop * create(bool startStop)
Definition: airspyhfinput.h:87
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
virtual const QString & getDeviceDescription() const
static const qint64 loLowLimitFreqVHF
QString m_deviceDescription
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const AirspyHFSettings &settings, bool force)
airspyhf_device_t * m_dev
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const AirspyHFSettings &settings)
airspyhf_device_t * open_airspyhf_from_serial(const QString &serialStr)
AirspyHFInput(DeviceAPI *deviceAPI)
std::vector< uint32_t > m_sampleRates
virtual QByteArray serialize() const
AirspyHFThread * m_airspyHFThread
virtual int webapiReportGet(SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
void networkManagerFinished(QNetworkReply *reply)
virtual ~AirspyHFInput()
virtual void setCenterFrequency(qint64 centerFrequency)
AirspyHFSettings m_settings
DeviceAPI * m_deviceAPI
QNetworkRequest m_networkRequest
virtual bool deserialize(const QByteArray &data)
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
FileRecord * m_fileSink
File sink to record device I/Q output.
static MsgFileRecord * create(bool startStop)
Definition: airspyhfinput.h:68
bool applySettings(const AirspyHFSettings &settings, bool force)
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
void webapiReverseSendStartStop(bool start)
MsgFileRecord(bool startStop)
Definition: airspyhfinput.h:75
virtual int getSampleRate() const
Sample rate exposed by the source.
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
static const qint64 loLowLimitFreqHF
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
const std::vector< uint32_t > & getSampleRates() const
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
virtual bool start()
static const qint64 loHighLimitFreqHF
virtual void setSampleRate(int sampleRate)
For when the source sample rate is set externally.
virtual void setMessageQueueToGUI(MessageQueue *queue)
virtual quint64 getCenterFrequency() const
Center frequency exposed by the source.
QNetworkAccessManager * m_networkManager
virtual void stop()
MsgStartStop(bool startStop)
Definition: airspyhfinput.h:94
const AirspyHFSettings & getSettings() const
Definition: airspyhfinput.h:43
virtual void destroy()
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
virtual bool handleMessage(const Message &message)