2017-01-02 04:39:21 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// 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 //
|
|
|
|
// //
|
|
|
|
// 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_BLADERFOUTPUT_H
|
|
|
|
#define INCLUDE_BLADERFOUTPUT_H
|
|
|
|
|
|
|
|
#include <dsp/devicesamplesink.h>
|
|
|
|
#include "bladerf/devicebladerf.h"
|
|
|
|
#include "bladerf/devicebladerfparam.h"
|
|
|
|
|
|
|
|
#include <libbladeRF.h>
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
#include "bladerfoutputsettings.h"
|
|
|
|
|
|
|
|
class DeviceSinkAPI;
|
|
|
|
class BladerfOutputThread;
|
|
|
|
|
|
|
|
class BladerfOutput : public DeviceSampleSink {
|
|
|
|
public:
|
|
|
|
class MsgConfigureBladerf : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
const BladeRFOutputSettings& getSettings() const { return m_settings; }
|
2017-10-14 01:10:42 -04:00
|
|
|
bool getForce() const { return m_force; }
|
2017-01-02 04:39:21 -05:00
|
|
|
|
2017-10-14 01:10:42 -04:00
|
|
|
static MsgConfigureBladerf* create(const BladeRFOutputSettings& settings, bool force)
|
2017-01-02 04:39:21 -05:00
|
|
|
{
|
2017-10-14 01:10:42 -04:00
|
|
|
return new MsgConfigureBladerf(settings, force);
|
2017-01-02 04:39:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
BladeRFOutputSettings m_settings;
|
2017-10-14 01:10:42 -04:00
|
|
|
bool m_force;
|
2017-01-02 04:39:21 -05:00
|
|
|
|
2017-10-14 01:10:42 -04:00
|
|
|
MsgConfigureBladerf(const BladeRFOutputSettings& settings, bool force) :
|
2017-01-02 04:39:21 -05:00
|
|
|
Message(),
|
2017-10-14 01:10:42 -04:00
|
|
|
m_settings(settings),
|
|
|
|
m_force(force)
|
2017-01-02 04:39:21 -05:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-12-13 18:38:22 -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)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-01-02 04:39:21 -05:00
|
|
|
class MsgReportBladerf : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
static MsgReportBladerf* create()
|
|
|
|
{
|
|
|
|
return new MsgReportBladerf();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
MsgReportBladerf() :
|
|
|
|
Message()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
BladerfOutput(DeviceSinkAPI *deviceAPI);
|
|
|
|
virtual ~BladerfOutput();
|
2017-09-16 05:34:25 -04:00
|
|
|
virtual void destroy();
|
2017-01-02 04:39:21 -05:00
|
|
|
|
2017-12-25 06:59:44 -05:00
|
|
|
virtual void init();
|
2017-04-13 21:44:49 -04:00
|
|
|
virtual bool start();
|
2017-01-02 04:39:21 -05:00
|
|
|
virtual void stop();
|
|
|
|
|
2017-12-24 13:58:26 -05:00
|
|
|
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
|
2017-01-02 04:39:21 -05:00
|
|
|
virtual const QString& getDeviceDescription() const;
|
|
|
|
virtual int getSampleRate() const;
|
|
|
|
virtual quint64 getCenterFrequency() const;
|
|
|
|
|
|
|
|
virtual bool handleMessage(const Message& message);
|
|
|
|
|
2017-12-09 19:57:50 -05:00
|
|
|
virtual int webapiRunGet(
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
|
|
|
virtual int webapiRun(
|
|
|
|
bool run,
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
2017-01-02 04:39:21 -05:00
|
|
|
private:
|
2017-04-13 15:26:36 -04:00
|
|
|
bool openDevice();
|
|
|
|
void closeDevice();
|
2017-01-02 04:39:21 -05:00
|
|
|
bool applySettings(const BladeRFOutputSettings& settings, bool force);
|
|
|
|
|
|
|
|
DeviceSinkAPI *m_deviceAPI;
|
|
|
|
QMutex m_mutex;
|
|
|
|
BladeRFOutputSettings m_settings;
|
|
|
|
struct bladerf* m_dev;
|
|
|
|
BladerfOutputThread* m_bladerfThread;
|
|
|
|
QString m_deviceDescription;
|
|
|
|
DeviceBladeRFParams m_sharedParams;
|
2017-04-13 15:26:36 -04:00
|
|
|
bool m_running;
|
2017-01-02 04:39:21 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_BLADERFOUTPUT_H
|