| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2015-06-07 17:56:19 +02:00
										 |  |  | // Copyright (C) 2015 Edouard Griffiths, F4EXB                                   //
 | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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_BLADERFINPUT_H
 | 
					
						
							|  |  |  | #define INCLUDE_BLADERFINPUT_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-02 23:16:40 +02:00
										 |  |  | #include <dsp/devicesamplesource.h>
 | 
					
						
							| 
									
										
										
										
											2016-12-30 16:13:28 +01:00
										 |  |  | #include "bladerf/devicebladerf.h"
 | 
					
						
							|  |  |  | #include "bladerf/devicebladerfparam.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-02 23:16:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | #include <libbladeRF.h>
 | 
					
						
							|  |  |  | #include <QString>
 | 
					
						
							| 
									
										
										
										
											2016-12-27 03:11:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-02 03:14:46 +01:00
										 |  |  | #include "bladerfinputsettings.h"
 | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 01:17:55 +02:00
										 |  |  | class DeviceSourceAPI; | 
					
						
							| 
									
										
										
										
											2016-12-27 02:14:31 +01:00
										 |  |  | class BladerfInputThread; | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-02 23:16:40 +02:00
										 |  |  | class BladerfInput : public DeviceSampleSource { | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | public: | 
					
						
							|  |  |  | 	class MsgConfigureBladerf : public Message { | 
					
						
							|  |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							| 
									
										
										
										
											2016-12-27 02:14:31 +01:00
										 |  |  | 		const BladeRFInputSettings& getSettings() const { return m_settings; } | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-27 02:14:31 +01:00
										 |  |  | 		static MsgConfigureBladerf* create(const BladeRFInputSettings& settings) | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | 			return new MsgConfigureBladerf(settings); | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	private: | 
					
						
							| 
									
										
										
										
											2016-12-27 02:14:31 +01:00
										 |  |  | 		BladeRFInputSettings m_settings; | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-27 02:14:31 +01:00
										 |  |  | 		MsgConfigureBladerf(const BladeRFInputSettings& settings) : | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | 			Message(), | 
					
						
							|  |  |  | 			m_settings(settings) | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	class MsgReportBladerf : public Message { | 
					
						
							|  |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		static MsgReportBladerf* create() | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			return new MsgReportBladerf(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	protected: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		MsgReportBladerf() : | 
					
						
							|  |  |  | 			Message() | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 01:17:55 +02:00
										 |  |  | 	BladerfInput(DeviceSourceAPI *deviceAPI); | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | 	virtual ~BladerfInput(); | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | 	virtual bool init(const Message& message); | 
					
						
							|  |  |  | 	virtual bool start(int device); | 
					
						
							|  |  |  | 	virtual void stop(); | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | 	virtual const QString& getDeviceDescription() const; | 
					
						
							|  |  |  | 	virtual int getSampleRate() const; | 
					
						
							|  |  |  | 	virtual quint64 getCenterFrequency() const; | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | 	virtual bool handleMessage(const Message& message); | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2016-12-27 02:14:31 +01:00
										 |  |  | 	bool applySettings(const BladeRFInputSettings& settings, bool force); | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | 	bladerf_lna_gain getLnaGain(int lnaGain); | 
					
						
							| 
									
										
										
										
											2016-12-30 16:13:28 +01:00
										 |  |  | //	struct bladerf *open_bladerf_from_serial(const char *serial);
 | 
					
						
							| 
									
										
										
										
											2015-08-17 08:29:34 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 01:17:55 +02:00
										 |  |  | 	DeviceSourceAPI *m_deviceAPI; | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | 	QMutex m_mutex; | 
					
						
							| 
									
										
										
										
											2016-12-27 02:14:31 +01:00
										 |  |  | 	BladeRFInputSettings m_settings; | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | 	struct bladerf* m_dev; | 
					
						
							| 
									
										
										
										
											2016-12-27 02:14:31 +01:00
										 |  |  | 	BladerfInputThread* m_bladerfThread; | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | 	QString m_deviceDescription; | 
					
						
							| 
									
										
										
										
											2016-12-30 16:13:28 +01:00
										 |  |  | 	DeviceBladeRFParams m_sharedParams; | 
					
						
							| 
									
										
										
										
											2015-06-07 03:30:28 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // INCLUDE_BLADERFINPUT_H
 |