SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
hackrfoutput.h
Go to the documentation of this file.
1 // Copyright (C) 2017 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #ifndef INCLUDE_HACKRFOUTPUT_H
19 #define INCLUDE_HACKRFOUTPUT_H
20 
21 #include <QString>
22 #include <QNetworkRequest>
23 
24 #include "dsp/devicesamplesink.h"
25 #include "libhackrf/hackrf.h"
26 #include "hackrf/devicehackrf.h"
28 #include "hackrfoutputsettings.h"
29 
30 class QNetworkAccessManager;
31 class QNetworkReply;
32 class DeviceAPI;
33 class HackRFOutputThread;
34 
36  Q_OBJECT
37 public:
38 
39  class MsgConfigureHackRF : public Message {
41 
42  public:
43  const HackRFOutputSettings& getSettings() const { return m_settings; }
44  bool getForce() const { return m_force; }
45 
46  static MsgConfigureHackRF* create(const HackRFOutputSettings& settings, bool force)
47  {
48  return new MsgConfigureHackRF(settings, force);
49  }
50 
51  private:
53  bool m_force;
54 
55  MsgConfigureHackRF(const HackRFOutputSettings& settings, bool force) :
56  Message(),
57  m_settings(settings),
58  m_force(force)
59  { }
60  };
61 
62  class MsgStartStop : public Message {
64 
65  public:
66  bool getStartStop() const { return m_startStop; }
67 
68  static MsgStartStop* create(bool startStop) {
69  return new MsgStartStop(startStop);
70  }
71 
72  protected:
74 
75  MsgStartStop(bool startStop) :
76  Message(),
77  m_startStop(startStop)
78  { }
79  };
80 
81  class MsgReportHackRF : public Message {
83 
84  public:
85 
87  {
88  return new MsgReportHackRF();
89  }
90 
91  protected:
92 
94  Message()
95  { }
96  };
97 
98  HackRFOutput(DeviceAPI *deviceAPI);
99  virtual ~HackRFOutput();
100  virtual void destroy();
101 
102  virtual void init();
103  virtual bool start();
104  virtual void stop();
105 
106  virtual QByteArray serialize() const;
107  virtual bool deserialize(const QByteArray& data);
108 
109  virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
110  virtual const QString& getDeviceDescription() const;
111  virtual int getSampleRate() const;
112  virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
113  virtual quint64 getCenterFrequency() const;
114  virtual void setCenterFrequency(qint64 centerFrequency);
115 
116  virtual bool handleMessage(const Message& message);
117 
118  virtual int webapiSettingsGet(
120  QString& errorMessage);
121 
122  virtual int webapiSettingsPutPatch(
123  bool force,
124  const QStringList& deviceSettingsKeys,
125  SWGSDRangel::SWGDeviceSettings& response, // query + response
126  QString& errorMessage);
127 
128  virtual int webapiRunGet(
129  SWGSDRangel::SWGDeviceState& response,
130  QString& errorMessage);
131 
132  virtual int webapiRun(
133  bool run,
134  SWGSDRangel::SWGDeviceState& response,
135  QString& errorMessage);
136 
137 private:
139  QMutex m_mutex;
141  struct hackrf_device* m_dev;
145  QNetworkAccessManager *m_networkManager;
146  QNetworkRequest m_networkRequest;
147  bool m_running;
148 
149  bool openDevice();
150  void closeDevice();
151  bool applySettings(const HackRFOutputSettings& settings, bool force);
152 // hackrf_device *open_hackrf_from_sequence(int sequence);
153  void setDeviceCenterFrequency(quint64 freq_hz, qint32 LOppmTenths);
155  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const HackRFOutputSettings& settings, bool force);
156  void webapiReverseSendStartStop(bool start);
157 
158 private slots:
159  void networkManagerFinished(QNetworkReply *reply);
160 };
161 
162 #endif // INCLUDE_HACKRFINPUT_H
struct hackrf_device * m_dev
Definition: hackrfoutput.h:141
virtual int getSampleRate() const
Sample rate exposed by the sink.
QNetworkRequest m_networkRequest
Definition: hackrfoutput.h:146
virtual const QString & getDeviceDescription() const
virtual void stop()
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const HackRFOutputSettings &settings, bool force)
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const HackRFOutputSettings &settings)
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:52
static MsgConfigureHackRF * create(const HackRFOutputSettings &settings, bool force)
Definition: hackrfoutput.h:46
virtual bool deserialize(const QByteArray &data)
void closeDevice()
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
virtual void destroy()
QMutex m_mutex
Definition: hackrfoutput.h:139
HackRFOutput(DeviceAPI *deviceAPI)
virtual QByteArray serialize() const
MsgStartStop(bool startStop)
Definition: hackrfoutput.h:75
virtual quint64 getCenterFrequency() const
Center frequency exposed by the sink.
virtual void setSampleRate(int sampleRate)
For when the sink sample rate is set externally.
Definition: hackrfoutput.h:112
HackRFOutputSettings m_settings
Definition: hackrfoutput.h:140
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
virtual bool handleMessage(const Message &message)
virtual ~HackRFOutput()
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
QString m_deviceDescription
Definition: hackrfoutput.h:143
DeviceAPI * m_deviceAPI
Definition: hackrfoutput.h:138
static MsgReportHackRF * create()
Definition: hackrfoutput.h:86
virtual void setMessageQueueToGUI(MessageQueue *queue)
Definition: hackrfoutput.h:109
MsgConfigureHackRF(const HackRFOutputSettings &settings, bool force)
Definition: hackrfoutput.h:55
virtual void setCenterFrequency(qint64 centerFrequency)
bool openDevice()
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
void webapiReverseSendStartStop(bool start)
HackRFOutputThread * m_hackRFThread
Definition: hackrfoutput.h:142
virtual bool start()
void setDeviceCenterFrequency(quint64 freq_hz, qint32 LOppmTenths)
QNetworkAccessManager * m_networkManager
Definition: hackrfoutput.h:145
DeviceHackRFParams m_sharedParams
Definition: hackrfoutput.h:144
static MsgStartStop * create(bool startStop)
Definition: hackrfoutput.h:68
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
const HackRFOutputSettings & getSettings() const
Definition: hackrfoutput.h:43
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
bool applySettings(const HackRFOutputSettings &settings, bool force)
void networkManagerFinished(QNetworkReply *reply)