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.
rtlsdrinput.h
Go to the documentation of this file.
1 // Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
3 // written by Christian Daniel //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #ifndef INCLUDE_RTLSDRINPUT_H
20 #define INCLUDE_RTLSDRINPUT_H
21 
22 #include <QString>
23 #include <QByteArray>
24 #include <QNetworkRequest>
25 
26 #include <dsp/devicesamplesource.h>
27 #include "rtlsdrsettings.h"
28 #include <rtl-sdr.h>
29 
30 class DeviceAPI;
31 class RTLSDRThread;
32 class FileRecord;
33 class QNetworkAccessManager;
34 class QNetworkReply;
35 
37  Q_OBJECT
38 public:
39  class MsgConfigureRTLSDR : public Message {
41 
42  public:
43  const RTLSDRSettings& getSettings() const { return m_settings; }
44  bool getForce() const { return m_force; }
45 
46  static MsgConfigureRTLSDR* create(const RTLSDRSettings& settings, bool force)
47  {
48  return new MsgConfigureRTLSDR(settings, force);
49  }
50 
51  private:
53  bool m_force;
54 
55  MsgConfigureRTLSDR(const RTLSDRSettings& 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  RTLSDRInput(DeviceAPI *deviceAPI);
101  virtual ~RTLSDRInput();
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 
118  virtual bool handleMessage(const Message& message);
119 
120  virtual int webapiSettingsGet(
122  QString& errorMessage);
123 
124  virtual int webapiSettingsPutPatch(
125  bool force,
126  const QStringList& deviceSettingsKeys,
127  SWGSDRangel::SWGDeviceSettings& response, // query + response
128  QString& errorMessage);
129 
130  virtual int webapiReportGet(
132  QString& errorMessage);
133 
134  virtual int webapiRunGet(
135  SWGSDRangel::SWGDeviceState& response,
136  QString& errorMessage);
137 
138  virtual int webapiRun(
139  bool run,
140  SWGSDRangel::SWGDeviceState& response,
141  QString& errorMessage);
142 
143  const std::vector<int>& getGains() const { return m_gains; }
144  void set_ds_mode(int on);
145 
146  static const quint64 frequencyLowRangeMin;
147  static const quint64 frequencyLowRangeMax;
148  static const quint64 frequencyHighRangeMin;
149  static const quint64 frequencyHighRangeMax;
150  static const int sampleRateLowRangeMin;
151  static const int sampleRateLowRangeMax;
152  static const int sampleRateHighRangeMin;
153  static const int sampleRateHighRangeMax;
154 
155 private:
158  QMutex m_mutex;
160  rtlsdr_dev_t* m_dev;
163  std::vector<int> m_gains;
164  bool m_running;
165  QNetworkAccessManager *m_networkManager;
166  QNetworkRequest m_networkRequest;
167 
168  bool openDevice();
169  void closeDevice();
170  bool applySettings(const RTLSDRSettings& settings, bool force);
173  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const RTLSDRSettings& settings, bool force);
174  void webapiReverseSendStartStop(bool start);
175 
176 private slots:
177  void networkManagerFinished(QNetworkReply *reply);
178 };
179 
180 #endif // INCLUDE_RTLSDRINPUT_H
QNetworkAccessManager * m_networkManager
Definition: rtlsdrinput.h:165
void closeDevice()
bool openDevice()
Definition: rtlsdrinput.cpp:90
QNetworkRequest m_networkRequest
Definition: rtlsdrinput.h:166
virtual quint64 getCenterFrequency() const
Center frequency exposed by the source.
static const quint64 frequencyLowRangeMin
Definition: rtlsdrinput.h:146
static const int sampleRateHighRangeMax
Definition: rtlsdrinput.h:153
virtual void setSampleRate(int sampleRate)
For when the source sample rate is set externally.
Definition: rtlsdrinput.h:114
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: rtlsdrinput.h:157
RTLSDRInput(DeviceAPI *deviceAPI)
Definition: rtlsdrinput.cpp:52
static MsgConfigureRTLSDR * create(const RTLSDRSettings &settings, bool force)
Definition: rtlsdrinput.h:46
bool applySettings(const RTLSDRSettings &settings, bool force)
virtual bool deserialize(const QByteArray &data)
MsgConfigureRTLSDR(const RTLSDRSettings &settings, bool force)
Definition: rtlsdrinput.h:55
virtual int getSampleRate() const
Sample rate exposed by the source.
bool getStartStop() const
Definition: rtlsdrinput.h:85
static const int sampleRateHighRangeMin
Definition: rtlsdrinput.h:152
virtual void setMessageQueueToGUI(MessageQueue *queue)
Definition: rtlsdrinput.h:111
virtual bool start()
void webapiReverseSendStartStop(bool start)
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
virtual bool handleMessage(const Message &message)
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
MsgStartStop(bool startStop)
Definition: rtlsdrinput.h:94
MsgFileRecord(bool startStop)
Definition: rtlsdrinput.h:75
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
static MsgStartStop * create(bool startStop)
Definition: rtlsdrinput.h:87
RTLSDRSettings m_settings
Definition: rtlsdrinput.h:159
virtual int webapiReportGet(SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
RTLSDRThread * m_rtlSDRThread
Definition: rtlsdrinput.h:161
static const quint64 frequencyHighRangeMax
Definition: rtlsdrinput.h:149
virtual ~RTLSDRInput()
Definition: rtlsdrinput.cpp:70
virtual const QString & getDeviceDescription() const
std::vector< int > m_gains
Definition: rtlsdrinput.h:163
DeviceAPI * m_deviceAPI
Definition: rtlsdrinput.h:156
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
virtual void setCenterFrequency(qint64 centerFrequency)
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
QMutex m_mutex
Definition: rtlsdrinput.h:158
void set_ds_mode(int on)
bool m_running
Definition: rtlsdrinput.h:164
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const RTLSDRSettings &settings)
static const int sampleRateLowRangeMax
Definition: rtlsdrinput.h:151
virtual void stop()
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const RTLSDRSettings &settings, bool force)
const std::vector< int > & getGains() const
Definition: rtlsdrinput.h:143
virtual QByteArray serialize() const
void networkManagerFinished(QNetworkReply *reply)
const RTLSDRSettings & getSettings() const
Definition: rtlsdrinput.h:43
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
static const int sampleRateLowRangeMin
Definition: rtlsdrinput.h:150
QString m_deviceDescription
Definition: rtlsdrinput.h:162
virtual void destroy()
Definition: rtlsdrinput.cpp:85
rtlsdr_dev_t * m_dev
Definition: rtlsdrinput.h:160
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
static const quint64 frequencyHighRangeMin
Definition: rtlsdrinput.h:148
static const quint64 frequencyLowRangeMax
Definition: rtlsdrinput.h:147
static MsgFileRecord * create(bool startStop)
Definition: rtlsdrinput.h:68