| 
									
										
										
										
											2017-01-02 10:39:21 +01: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 07:10:42 +02:00
										 |  |  | 		bool getForce() const { return m_force; } | 
					
						
							| 
									
										
										
										
											2017-01-02 10:39:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-14 07:10:42 +02:00
										 |  |  | 		static MsgConfigureBladerf* create(const BladeRFOutputSettings& settings, bool force) | 
					
						
							| 
									
										
										
										
											2017-01-02 10:39:21 +01:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2017-10-14 07:10:42 +02:00
										 |  |  | 			return new MsgConfigureBladerf(settings, force); | 
					
						
							| 
									
										
										
										
											2017-01-02 10:39:21 +01:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	private: | 
					
						
							|  |  |  | 		BladeRFOutputSettings m_settings; | 
					
						
							| 
									
										
										
										
											2017-10-14 07:10:42 +02:00
										 |  |  | 		bool m_force; | 
					
						
							| 
									
										
										
										
											2017-01-02 10:39:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-14 07:10:42 +02:00
										 |  |  | 		MsgConfigureBladerf(const BladeRFOutputSettings& settings, bool force) : | 
					
						
							| 
									
										
										
										
											2017-01-02 10:39:21 +01:00
										 |  |  | 			Message(), | 
					
						
							| 
									
										
										
										
											2017-10-14 07:10:42 +02:00
										 |  |  | 			m_settings(settings), | 
					
						
							|  |  |  | 			m_force(force) | 
					
						
							| 
									
										
										
										
											2017-01-02 10:39:21 +01:00
										 |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-14 00:38:22 +01: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 10:39:21 +01: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 11:34:25 +02:00
										 |  |  | 	virtual void destroy(); | 
					
						
							| 
									
										
										
										
											2017-01-02 10:39:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 12:59:44 +01:00
										 |  |  |     virtual void init(); | 
					
						
							| 
									
										
										
										
											2017-04-14 03:44:49 +02:00
										 |  |  | 	virtual bool start(); | 
					
						
							| 
									
										
										
										
											2017-01-02 10:39:21 +01:00
										 |  |  | 	virtual void stop(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-28 04:04:50 +01:00
										 |  |  |     virtual QByteArray serialize() const; | 
					
						
							|  |  |  |     virtual bool deserialize(const QByteArray& data); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-24 19:58:26 +01:00
										 |  |  |     virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; } | 
					
						
							| 
									
										
										
										
											2017-01-02 10:39:21 +01:00
										 |  |  | 	virtual const QString& getDeviceDescription() const; | 
					
						
							|  |  |  | 	virtual int getSampleRate() const; | 
					
						
							|  |  |  | 	virtual quint64 getCenterFrequency() const; | 
					
						
							| 
									
										
										
										
											2017-12-28 04:04:50 +01:00
										 |  |  |     virtual void setCenterFrequency(qint64 centerFrequency); | 
					
						
							| 
									
										
										
										
											2017-01-02 10:39:21 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	virtual bool handleMessage(const Message& message); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-10 01:57:50 +01:00
										 |  |  |     virtual int webapiRunGet( | 
					
						
							|  |  |  |             SWGSDRangel::SWGDeviceState& response, | 
					
						
							|  |  |  |             QString& errorMessage); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual int webapiRun( | 
					
						
							|  |  |  |             bool run, | 
					
						
							|  |  |  |             SWGSDRangel::SWGDeviceState& response, | 
					
						
							|  |  |  |             QString& errorMessage); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-02 10:39:21 +01:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2017-04-13 21:26:36 +02:00
										 |  |  |     bool openDevice(); | 
					
						
							|  |  |  |     void closeDevice(); | 
					
						
							| 
									
										
										
										
											2017-01-02 10:39:21 +01: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 21:26:36 +02:00
										 |  |  |     bool m_running; | 
					
						
							| 
									
										
										
										
											2017-01-02 10:39:21 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // INCLUDE_BLADERFOUTPUT_H
 |