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.
bladerf1output.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_BLADERFOUTPUT_H
19 #define INCLUDE_BLADERFOUTPUT_H
20 
21 #include <QString>
22 #include <QNetworkRequest>
23 
24 #include "libbladeRF.h"
25 #include "dsp/devicesamplesink.h"
28 #include "bladerf1outputsettings.h"
29 
30 class QNetworkAccessManager;
31 class QNetworkReply;
32 class DeviceAPI;
34 
36  Q_OBJECT
37 public:
38  class MsgConfigureBladerf1 : public Message {
40 
41  public:
42  const BladeRF1OutputSettings& getSettings() const { return m_settings; }
43  bool getForce() const { return m_force; }
44 
45  static MsgConfigureBladerf1* create(const BladeRF1OutputSettings& settings, bool force)
46  {
47  return new MsgConfigureBladerf1(settings, force);
48  }
49 
50  private:
52  bool m_force;
53 
54  MsgConfigureBladerf1(const BladeRF1OutputSettings& settings, bool force) :
55  Message(),
56  m_settings(settings),
57  m_force(force)
58  { }
59  };
60 
61  class MsgStartStop : public Message {
63 
64  public:
65  bool getStartStop() const { return m_startStop; }
66 
67  static MsgStartStop* create(bool startStop) {
68  return new MsgStartStop(startStop);
69  }
70 
71  protected:
73 
74  MsgStartStop(bool startStop) :
75  Message(),
76  m_startStop(startStop)
77  { }
78  };
79 
80  class MsgReportBladerf1 : public Message {
82 
83  public:
84 
86  {
87  return new MsgReportBladerf1();
88  }
89 
90  protected:
91 
93  Message()
94  { }
95  };
96 
97  Bladerf1Output(DeviceAPI *deviceAPI);
98  virtual ~Bladerf1Output();
99  virtual void destroy();
100 
101  virtual void init();
102  virtual bool start();
103  virtual void stop();
104 
105  virtual QByteArray serialize() const;
106  virtual bool deserialize(const QByteArray& data);
107 
108  virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
109  virtual const QString& getDeviceDescription() const;
110  virtual int getSampleRate() const;
111  virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
112  virtual quint64 getCenterFrequency() const;
113  virtual void setCenterFrequency(qint64 centerFrequency);
114 
115  virtual bool handleMessage(const Message& message);
116 
117  virtual int webapiSettingsGet(
119  QString& errorMessage);
120 
121  virtual int webapiSettingsPutPatch(
122  bool force,
123  const QStringList& deviceSettingsKeys,
124  SWGSDRangel::SWGDeviceSettings& response, // query + response
125  QString& errorMessage);
126 
127  virtual int webapiRunGet(
128  SWGSDRangel::SWGDeviceState& response,
129  QString& errorMessage);
130 
131  virtual int webapiRun(
132  bool run,
133  SWGSDRangel::SWGDeviceState& response,
134  QString& errorMessage);
135 
136 private:
138  QMutex m_mutex;
140  struct bladerf* m_dev;
144  bool m_running;
145  QNetworkAccessManager *m_networkManager;
146  QNetworkRequest m_networkRequest;
147 
148  bool openDevice();
149  void closeDevice();
150  bool applySettings(const BladeRF1OutputSettings& settings, bool force);
152  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const BladeRF1OutputSettings& settings, bool force);
153  void webapiReverseSendStartStop(bool start);
154 
155 private slots:
156  void networkManagerFinished(QNetworkReply *reply);
157 };
158 
159 #endif // INCLUDE_BLADERFOUTPUT_H
virtual QByteArray serialize() const
virtual void destroy()
Bladerf1Output(DeviceAPI *deviceAPI)
virtual bool handleMessage(const Message &message)
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
QNetworkRequest m_networkRequest
virtual const QString & getDeviceDescription() const
virtual void setCenterFrequency(qint64 centerFrequency)
virtual void stop()
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const BladeRF1OutputSettings &settings)
static MsgReportBladerf1 * create()
QString m_deviceDescription
virtual bool start()
struct bladerf * m_dev
virtual void setSampleRate(int sampleRate)
For when the sink sample rate is set externally.
virtual bool deserialize(const QByteArray &data)
virtual quint64 getCenterFrequency() const
Center frequency exposed by the sink.
const BladeRF1OutputSettings & getSettings() const
bool applySettings(const BladeRF1OutputSettings &settings, bool force)
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
DeviceAPI * m_deviceAPI
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
QNetworkAccessManager * m_networkManager
void networkManagerFinished(QNetworkReply *reply)
Bladerf1OutputThread * m_bladerfThread
virtual int getSampleRate() const
Sample rate exposed by the sink.
DeviceBladeRF1Params m_sharedParams
BladeRF1OutputSettings m_settings
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const BladeRF1OutputSettings &settings, bool force)
virtual void setMessageQueueToGUI(MessageQueue *queue)
MsgConfigureBladerf1(const BladeRF1OutputSettings &settings, bool force)
BladeRF1OutputSettings m_settings
static MsgConfigureBladerf1 * create(const BladeRF1OutputSettings &settings, bool force)
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
static MsgStartStop * create(bool startStop)
virtual ~Bladerf1Output()
void webapiReverseSendStartStop(bool start)