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.
bladerf1input.h
Go to the documentation of this file.
1 // Copyright (C) 2015 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_BLADERFINPUT_H
19 #define INCLUDE_BLADERFINPUT_H
20 
21 #include <QString>
22 #include <QByteArray>
23 #include <QNetworkRequest>
24 
25 #include <libbladeRF.h>
26 #include <dsp/devicesamplesource.h>
27 
28 #include "../../../devices/bladerf1/devicebladerf1.h"
29 #include "../../../devices/bladerf1/devicebladerf1param.h"
30 #include "bladerf1inputsettings.h"
31 
32 class QNetworkAccessManager;
33 class QNetworkReply;
34 class DeviceAPI;
36 class FileRecord;
37 
39  Q_OBJECT
40 public:
41  class MsgConfigureBladerf1 : public Message {
43 
44  public:
45  const BladeRF1InputSettings& getSettings() const { return m_settings; }
46  bool getForce() const { return m_force; }
47 
48  static MsgConfigureBladerf1* create(const BladeRF1InputSettings& settings, bool force)
49  {
50  return new MsgConfigureBladerf1(settings, force);
51  }
52 
53  private:
55  bool m_force;
56 
57  MsgConfigureBladerf1(const BladeRF1InputSettings& settings, bool force) :
58  Message(),
59  m_settings(settings),
60  m_force(force)
61  { }
62  };
63 
64  class MsgFileRecord : public Message {
66 
67  public:
68  bool getStartStop() const { return m_startStop; }
69 
70  static MsgFileRecord* create(bool startStop) {
71  return new MsgFileRecord(startStop);
72  }
73 
74  protected:
76 
77  MsgFileRecord(bool startStop) :
78  Message(),
79  m_startStop(startStop)
80  { }
81  };
82 
83  class MsgStartStop : public Message {
85 
86  public:
87  bool getStartStop() const { return m_startStop; }
88 
89  static MsgStartStop* create(bool startStop) {
90  return new MsgStartStop(startStop);
91  }
92 
93  protected:
95 
96  MsgStartStop(bool startStop) :
97  Message(),
98  m_startStop(startStop)
99  { }
100  };
101 
102  Bladerf1Input(DeviceAPI *deviceAPI);
103  virtual ~Bladerf1Input();
104  virtual void destroy();
105 
106  virtual void init();
107  virtual bool start();
108  virtual void stop();
109 
110  virtual QByteArray serialize() const;
111  virtual bool deserialize(const QByteArray& data);
112 
113  virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
114  virtual const QString& getDeviceDescription() const;
115  virtual int getSampleRate() const;
116  virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
117  virtual quint64 getCenterFrequency() const;
118  virtual void setCenterFrequency(qint64 centerFrequency);
119 
120  virtual bool handleMessage(const Message& message);
121 
122  virtual int webapiSettingsGet(
124  QString& errorMessage);
125 
126  virtual int webapiSettingsPutPatch(
127  bool force,
128  const QStringList& deviceSettingsKeys,
129  SWGSDRangel::SWGDeviceSettings& response, // query + response
130  QString& errorMessage);
131 
132  virtual int webapiRunGet(
133  SWGSDRangel::SWGDeviceState& response,
134  QString& errorMessage);
135 
136  virtual int webapiRun(
137  bool run,
138  SWGSDRangel::SWGDeviceState& response,
139  QString& errorMessage);
140 
141 private:
143  QMutex m_mutex;
145  struct bladerf* m_dev;
149  bool m_running;
151  QNetworkAccessManager *m_networkManager;
152  QNetworkRequest m_networkRequest;
153 
154  bool openDevice();
155  void closeDevice();
156  bool applySettings(const BladeRF1InputSettings& settings, bool force);
157  bladerf_lna_gain getLnaGain(int lnaGain);
159  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const BladeRF1InputSettings& settings, bool force);
160  void webapiReverseSendStartStop(bool start);
161 
162 private slots:
163  void networkManagerFinished(QNetworkReply *reply);
164 };
165 
166 #endif // INCLUDE_BLADERFINPUT_H
bladerf_lna_gain getLnaGain(int lnaGain)
const BladeRF1InputSettings & getSettings() const
Definition: bladerf1input.h:45
MsgStartStop(bool startStop)
Definition: bladerf1input.h:96
DeviceAPI * m_deviceAPI
BladeRF1InputSettings m_settings
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
virtual void setMessageQueueToGUI(MessageQueue *queue)
virtual bool start()
virtual bool handleMessage(const Message &message)
virtual void destroy()
virtual bool deserialize(const QByteArray &data)
virtual const QString & getDeviceDescription() const
QString m_deviceDescription
QNetworkRequest m_networkRequest
FileRecord * m_fileSink
File sink to record device I/Q output.
static MsgStartStop * create(bool startStop)
Definition: bladerf1input.h:89
virtual void setCenterFrequency(qint64 centerFrequency)
Bladerf1Input(DeviceAPI *deviceAPI)
BladeRF1InputSettings m_settings
Definition: bladerf1input.h:54
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
virtual int getSampleRate() const
Sample rate exposed by the source.
virtual quint64 getCenterFrequency() const
Center frequency exposed by the source.
virtual QByteArray serialize() const
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
struct bladerf * m_dev
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
virtual void stop()
virtual ~Bladerf1Input()
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const BladeRF1InputSettings &settings, bool force)
static MsgConfigureBladerf1 * create(const BladeRF1InputSettings &settings, bool force)
Definition: bladerf1input.h:48
MsgConfigureBladerf1(const BladeRF1InputSettings &settings, bool force)
Definition: bladerf1input.h:57
void webapiReverseSendStartStop(bool start)
QNetworkAccessManager * m_networkManager
void networkManagerFinished(QNetworkReply *reply)
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const BladeRF1InputSettings &settings)
DeviceBladeRF1Params m_sharedParams
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
MsgFileRecord(bool startStop)
Definition: bladerf1input.h:77
bool applySettings(const BladeRF1InputSettings &settings, bool force)
virtual void setSampleRate(int sampleRate)
For when the source sample rate is set externally.
Bladerf1InputThread * m_bladerfThread
static MsgFileRecord * create(bool startStop)
Definition: bladerf1input.h:70