2014-05-18 11:52:39 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
|
|
|
// written by Christian Daniel //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
2019-04-11 00:57:41 -04:00
|
|
|
// (at your option) any later version. //
|
2014-05-18 11:52:39 -04:00
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef INCLUDE_RTLSDRINPUT_H
|
|
|
|
#define INCLUDE_RTLSDRINPUT_H
|
|
|
|
|
2017-12-27 21:21:48 -05:00
|
|
|
#include <QString>
|
|
|
|
#include <QByteArray>
|
2018-12-17 02:51:59 -05:00
|
|
|
#include <QNetworkRequest>
|
2016-10-02 17:16:40 -04:00
|
|
|
|
2017-12-27 21:21:48 -05:00
|
|
|
#include <dsp/devicesamplesource.h>
|
2015-09-30 22:39:00 -04:00
|
|
|
#include "rtlsdrsettings.h"
|
2014-05-18 11:52:39 -04:00
|
|
|
#include <rtl-sdr.h>
|
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
class DeviceAPI;
|
2014-05-18 11:52:39 -04:00
|
|
|
class RTLSDRThread;
|
2017-09-04 05:29:27 -04:00
|
|
|
class FileRecord;
|
2018-12-17 02:51:59 -05:00
|
|
|
class QNetworkAccessManager;
|
|
|
|
class QNetworkReply;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2016-10-02 17:16:40 -04:00
|
|
|
class RTLSDRInput : public DeviceSampleSource {
|
2018-12-18 00:14:18 -05:00
|
|
|
Q_OBJECT
|
2014-05-18 11:52:39 -04:00
|
|
|
public:
|
|
|
|
class MsgConfigureRTLSDR : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
2015-09-30 22:39:00 -04:00
|
|
|
const RTLSDRSettings& getSettings() const { return m_settings; }
|
2017-10-14 01:07:32 -04:00
|
|
|
bool getForce() const { return m_force; }
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2017-10-14 01:07:32 -04:00
|
|
|
static MsgConfigureRTLSDR* create(const RTLSDRSettings& settings, bool force)
|
2014-05-18 11:52:39 -04:00
|
|
|
{
|
2017-10-14 01:07:32 -04:00
|
|
|
return new MsgConfigureRTLSDR(settings, force);
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-09-30 22:39:00 -04:00
|
|
|
RTLSDRSettings m_settings;
|
2017-10-14 01:07:32 -04:00
|
|
|
bool m_force;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2017-10-14 01:07:32 -04:00
|
|
|
MsgConfigureRTLSDR(const RTLSDRSettings& settings, bool force) :
|
2014-05-18 11:52:39 -04:00
|
|
|
Message(),
|
2017-10-14 01:07:32 -04:00
|
|
|
m_settings(settings),
|
|
|
|
m_force(force)
|
2014-05-18 11:52:39 -04:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-09-04 05:29:27 -04:00
|
|
|
class MsgFileRecord : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool getStartStop() const { return m_startStop; }
|
|
|
|
|
|
|
|
static MsgFileRecord* create(bool startStop) {
|
|
|
|
return new MsgFileRecord(startStop);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_startStop;
|
|
|
|
|
|
|
|
MsgFileRecord(bool startStop) :
|
|
|
|
Message(),
|
|
|
|
m_startStop(startStop)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-12-14 12:02:49 -05:00
|
|
|
class MsgStartStop : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool getStartStop() const { return m_startStop; }
|
|
|
|
|
|
|
|
static MsgStartStop* create(bool startStop) {
|
|
|
|
return new MsgStartStop(startStop);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_startStop;
|
|
|
|
|
|
|
|
MsgStartStop(bool startStop) :
|
|
|
|
Message(),
|
|
|
|
m_startStop(startStop)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
RTLSDRInput(DeviceAPI *deviceAPI);
|
2015-08-17 02:29:34 -04:00
|
|
|
virtual ~RTLSDRInput();
|
2017-09-14 20:32:30 -04:00
|
|
|
virtual void destroy();
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2017-12-25 03:10:19 -05:00
|
|
|
virtual void init();
|
2017-04-13 21:40:45 -04:00
|
|
|
virtual bool start();
|
2015-08-17 02:29:34 -04:00
|
|
|
virtual void stop();
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2017-12-27 21:21:48 -05:00
|
|
|
virtual QByteArray serialize() const;
|
|
|
|
virtual bool deserialize(const QByteArray& data);
|
|
|
|
|
2017-12-24 13:58:26 -05:00
|
|
|
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
|
2015-08-17 02:29:34 -04:00
|
|
|
virtual const QString& getDeviceDescription() const;
|
|
|
|
virtual int getSampleRate() const;
|
2019-05-01 22:02:40 -04:00
|
|
|
virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
|
2015-08-17 02:29:34 -04:00
|
|
|
virtual quint64 getCenterFrequency() const;
|
2017-12-27 21:21:48 -05:00
|
|
|
virtual void setCenterFrequency(qint64 centerFrequency);
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2015-08-17 02:29:34 -04:00
|
|
|
virtual bool handleMessage(const Message& message);
|
2014-11-07 14:26:02 -05:00
|
|
|
|
2017-12-06 17:49:14 -05:00
|
|
|
virtual int webapiSettingsGet(
|
|
|
|
SWGSDRangel::SWGDeviceSettings& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
2017-12-07 12:50:36 -05:00
|
|
|
virtual int webapiSettingsPutPatch(
|
|
|
|
bool force,
|
2017-12-26 19:46:33 -05:00
|
|
|
const QStringList& deviceSettingsKeys,
|
2017-12-07 12:50:36 -05:00
|
|
|
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
|
|
|
QString& errorMessage);
|
2017-12-09 04:49:20 -05:00
|
|
|
|
2018-05-26 08:28:06 -04:00
|
|
|
virtual int webapiReportGet(
|
|
|
|
SWGSDRangel::SWGDeviceReport& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
2017-12-09 04:49:20 -05:00
|
|
|
virtual int webapiRunGet(
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
|
|
|
QString& errorMessage);
|
2017-12-07 12:50:36 -05:00
|
|
|
|
2017-12-08 11:12:33 -05:00
|
|
|
virtual int webapiRun(
|
|
|
|
bool run,
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
2019-08-04 14:24:44 -04:00
|
|
|
static void webapiFormatDeviceSettings(
|
|
|
|
SWGSDRangel::SWGDeviceSettings& response,
|
|
|
|
const RTLSDRSettings& settings);
|
|
|
|
|
|
|
|
static void webapiUpdateDeviceSettings(
|
|
|
|
RTLSDRSettings& settings,
|
|
|
|
const QStringList& deviceSettingsKeys,
|
|
|
|
SWGSDRangel::SWGDeviceSettings& response);
|
|
|
|
|
2017-04-12 19:21:25 -04:00
|
|
|
const std::vector<int>& getGains() const { return m_gains; }
|
2014-11-07 14:26:02 -05:00
|
|
|
void set_ds_mode(int on);
|
|
|
|
|
2017-09-23 13:15:56 -04:00
|
|
|
static const quint64 frequencyLowRangeMin;
|
|
|
|
static const quint64 frequencyLowRangeMax;
|
|
|
|
static const quint64 frequencyHighRangeMin;
|
|
|
|
static const quint64 frequencyHighRangeMax;
|
|
|
|
static const int sampleRateLowRangeMin;
|
|
|
|
static const int sampleRateLowRangeMax;
|
|
|
|
static const int sampleRateHighRangeMin;
|
|
|
|
static const int sampleRateHighRangeMax;
|
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
private:
|
2019-05-08 16:11:53 -04:00
|
|
|
DeviceAPI *m_deviceAPI;
|
2017-09-04 05:29:27 -04:00
|
|
|
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
2014-05-18 11:52:39 -04:00
|
|
|
QMutex m_mutex;
|
2015-09-30 22:39:00 -04:00
|
|
|
RTLSDRSettings m_settings;
|
2014-05-18 11:52:39 -04:00
|
|
|
rtlsdr_dev_t* m_dev;
|
|
|
|
RTLSDRThread* m_rtlSDRThread;
|
|
|
|
QString m_deviceDescription;
|
|
|
|
std::vector<int> m_gains;
|
2017-04-12 19:21:25 -04:00
|
|
|
bool m_running;
|
2018-12-17 02:51:59 -05:00
|
|
|
QNetworkAccessManager *m_networkManager;
|
|
|
|
QNetworkRequest m_networkRequest;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2017-04-12 19:21:25 -04:00
|
|
|
bool openDevice();
|
|
|
|
void closeDevice();
|
2015-09-30 22:39:00 -04:00
|
|
|
bool applySettings(const RTLSDRSettings& settings, bool force);
|
2018-05-26 08:28:06 -04:00
|
|
|
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);
|
2018-12-17 02:51:59 -05:00
|
|
|
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const RTLSDRSettings& settings, bool force);
|
2018-12-17 09:00:13 -05:00
|
|
|
void webapiReverseSendStartStop(bool start);
|
2018-12-17 02:51:59 -05:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void networkManagerFinished(QNetworkReply *reply);
|
2014-05-18 11:52:39 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_RTLSDRINPUT_H
|