2016-02-16 20:22:05 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2015 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 PLUGINS_SAMPLESOURCE_SDRDAEMON_SDRDAEMONUDPHANDLER_H_
|
|
|
|
#define PLUGINS_SAMPLESOURCE_SDRDAEMON_SDRDAEMONUDPHANDLER_H_
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QUdpSocket>
|
|
|
|
#include <QHostAddress>
|
|
|
|
#include <QMutex>
|
2016-03-15 01:13:52 -04:00
|
|
|
#include <QElapsedTimer>
|
|
|
|
|
2016-02-16 20:22:05 -05:00
|
|
|
#include "sdrdaemonbuffer.h"
|
|
|
|
|
|
|
|
#define SDRDAEMON_THROTTLE_MS 50
|
|
|
|
|
2016-10-06 13:18:02 -04:00
|
|
|
class SampleSinkFifo;
|
2016-02-16 20:22:05 -05:00
|
|
|
class MessageQueue;
|
|
|
|
class QTimer;
|
2016-05-15 20:14:36 -04:00
|
|
|
class DeviceAPI;
|
2016-02-16 20:22:05 -05:00
|
|
|
|
|
|
|
class SDRdaemonUDPHandler : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2016-10-06 13:18:02 -04:00
|
|
|
SDRdaemonUDPHandler(SampleSinkFifo* sampleFifo, MessageQueue *outputMessageQueueToGUI, DeviceAPI *deviceAPI);
|
2016-02-16 20:22:05 -05:00
|
|
|
~SDRdaemonUDPHandler();
|
2016-02-20 17:02:34 -05:00
|
|
|
void connectTimer(const QTimer* timer);
|
2016-02-16 20:22:05 -05:00
|
|
|
void start();
|
|
|
|
void stop();
|
2016-02-20 17:02:34 -05:00
|
|
|
void configureUDPLink(const QString& address, quint16 port);
|
2016-03-26 16:40:54 -04:00
|
|
|
void getRemoteAddress(QString& s) const { s = m_remoteAddress.toString(); }
|
2016-03-10 23:25:25 -05:00
|
|
|
void setAutoFollowRate(bool autoFollowRate) { m_sdrDaemonBuffer.setAutoFollowRate(autoFollowRate); }
|
2016-03-19 01:14:06 -04:00
|
|
|
void setAutoCorrBuffer(bool autoCorrBuffer) { m_autoCorrBuffer = autoCorrBuffer; m_sdrDaemonBuffer.setAutoCorrBuffer(autoCorrBuffer); }
|
2016-03-18 09:03:34 -04:00
|
|
|
void resetIndexes() { m_sdrDaemonBuffer.setResetIndexes(); }
|
2016-02-16 20:22:05 -05:00
|
|
|
public slots:
|
|
|
|
void dataReadyRead();
|
|
|
|
|
|
|
|
private:
|
2016-05-15 20:14:36 -04:00
|
|
|
DeviceAPI *m_deviceAPI;
|
2016-02-16 20:22:05 -05:00
|
|
|
SDRdaemonBuffer m_sdrDaemonBuffer;
|
|
|
|
QUdpSocket *m_dataSocket;
|
|
|
|
QHostAddress m_dataAddress;
|
2016-03-26 16:40:54 -04:00
|
|
|
QHostAddress m_remoteAddress;
|
2016-02-16 20:22:05 -05:00
|
|
|
quint16 m_dataPort;
|
|
|
|
bool m_dataConnected;
|
|
|
|
char *m_udpBuf;
|
|
|
|
qint64 m_udpReadBytes;
|
2016-10-06 13:18:02 -04:00
|
|
|
SampleSinkFifo *m_sampleFifo;
|
2016-02-16 20:22:05 -05:00
|
|
|
uint32_t m_samplerate;
|
|
|
|
uint32_t m_centerFrequency;
|
|
|
|
uint32_t m_tv_sec;
|
|
|
|
uint32_t m_tv_usec;
|
|
|
|
MessageQueue *m_outputMessageQueueToGUI;
|
|
|
|
uint32_t m_tickCount;
|
|
|
|
std::size_t m_samplesCount;
|
2016-03-16 13:46:16 -04:00
|
|
|
QTimer *m_timer;
|
2016-03-15 13:56:15 -04:00
|
|
|
|
2016-03-15 01:13:52 -04:00
|
|
|
QElapsedTimer m_elapsedTimer;
|
|
|
|
int m_throttlems;
|
2016-03-15 13:06:02 -04:00
|
|
|
uint32_t m_readLengthSamples;
|
|
|
|
uint32_t m_readLength;
|
|
|
|
bool m_throttleToggle;
|
2016-03-16 13:46:16 -04:00
|
|
|
int m_rateDivider;
|
2016-03-19 01:14:06 -04:00
|
|
|
bool m_autoCorrBuffer;
|
2016-02-16 20:22:05 -05:00
|
|
|
|
|
|
|
void setSamplerate(uint32_t samplerate);
|
2016-02-18 16:26:47 -05:00
|
|
|
void processData();
|
2016-02-16 20:22:05 -05:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void tick();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* PLUGINS_SAMPLESOURCE_SDRDAEMON_SDRDAEMONUDPHANDLER_H_ */
|