2014-05-18 15:52:39 +00:00
|
|
|
#include <QtPlugin>
|
|
|
|
#include <rtl-sdr.h>
|
2017-12-28 23:33:37 +00:00
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/simpleserializer.h"
|
2016-10-10 23:17:55 +00:00
|
|
|
#include <device/devicesourceapi.h>
|
|
|
|
|
2017-12-28 23:33:37 +00:00
|
|
|
#ifdef SERVER_MODE
|
|
|
|
#include "rtlsdrinput.h"
|
|
|
|
#else
|
2014-05-18 15:52:39 +00:00
|
|
|
#include "rtlsdrgui.h"
|
2017-12-28 23:33:37 +00:00
|
|
|
#endif
|
|
|
|
#include "rtlsdrplugin.h"
|
2014-05-18 15:52:39 +00:00
|
|
|
|
|
|
|
const PluginDescriptor RTLSDRPlugin::m_pluginDescriptor = {
|
|
|
|
QString("RTL-SDR Input"),
|
2018-05-12 05:25:53 +00:00
|
|
|
QString("3.14.7"),
|
2015-09-01 23:16:40 +00:00
|
|
|
QString("(c) Edouard Griffiths, F4EXB"),
|
|
|
|
QString("https://github.com/f4exb/sdrangel"),
|
2014-05-18 15:52:39 +00:00
|
|
|
true,
|
2015-09-01 23:16:40 +00:00
|
|
|
QString("https://github.com/f4exb/sdrangel")
|
2014-05-18 15:52:39 +00:00
|
|
|
};
|
|
|
|
|
2016-12-29 11:41:10 +00:00
|
|
|
const QString RTLSDRPlugin::m_hardwareID = "RTLSDR";
|
2015-10-01 03:05:46 +00:00
|
|
|
const QString RTLSDRPlugin::m_deviceTypeID = RTLSDR_DEVICE_TYPE_ID;
|
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
RTLSDRPlugin::RTLSDRPlugin(QObject* parent) :
|
|
|
|
QObject(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const PluginDescriptor& RTLSDRPlugin::getPluginDescriptor() const
|
|
|
|
{
|
|
|
|
return m_pluginDescriptor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RTLSDRPlugin::initPlugin(PluginAPI* pluginAPI)
|
|
|
|
{
|
2016-05-17 15:53:22 +00:00
|
|
|
pluginAPI->registerSampleSource(m_deviceTypeID, this);
|
2014-05-18 15:52:39 +00:00
|
|
|
}
|
|
|
|
|
2016-10-13 20:23:43 +00:00
|
|
|
PluginInterface::SamplingDevices RTLSDRPlugin::enumSampleSources()
|
2014-05-18 15:52:39 +00:00
|
|
|
{
|
2016-10-13 20:23:43 +00:00
|
|
|
SamplingDevices result;
|
2014-05-18 15:52:39 +00:00
|
|
|
int count = rtlsdr_get_device_count();
|
|
|
|
char vendor[256];
|
|
|
|
char product[256];
|
|
|
|
char serial[256];
|
|
|
|
|
|
|
|
for(int i = 0; i < count; i++) {
|
|
|
|
vendor[0] = '\0';
|
|
|
|
product[0] = '\0';
|
|
|
|
serial[0] = '\0';
|
|
|
|
|
2014-11-03 17:11:08 +00:00
|
|
|
if(rtlsdr_get_device_usb_strings((uint32_t)i, vendor, product, serial) != 0)
|
2014-05-18 15:52:39 +00:00
|
|
|
continue;
|
2015-10-01 03:44:33 +00:00
|
|
|
QString displayedName(QString("RTL-SDR[%1] %2").arg(i).arg(serial));
|
2015-09-30 04:57:40 +00:00
|
|
|
|
2016-10-13 20:23:43 +00:00
|
|
|
result.append(SamplingDevice(displayedName,
|
2016-12-29 11:41:10 +00:00
|
|
|
m_hardwareID,
|
2015-10-01 03:05:46 +00:00
|
|
|
m_deviceTypeID,
|
2015-09-30 04:57:40 +00:00
|
|
|
QString(serial),
|
2017-11-01 09:37:00 +00:00
|
|
|
i,
|
2017-11-01 19:06:33 +00:00
|
|
|
PluginInterface::SamplingDevice::PhysicalDevice,
|
2017-11-01 09:37:00 +00:00
|
|
|
true,
|
2017-11-19 00:05:16 +00:00
|
|
|
1,
|
2017-11-01 09:37:00 +00:00
|
|
|
0));
|
2014-05-18 15:52:39 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-12-17 13:52:18 +00:00
|
|
|
#ifdef SERVER_MODE
|
|
|
|
PluginInstanceGUI* RTLSDRPlugin::createSampleSourcePluginInstanceGUI(
|
|
|
|
const QString& sourceId __attribute((unused)),
|
|
|
|
QWidget **widget __attribute((unused)),
|
|
|
|
DeviceUISet *deviceUISet __attribute((unused)))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
2017-10-29 23:02:28 +00:00
|
|
|
PluginInstanceGUI* RTLSDRPlugin::createSampleSourcePluginInstanceGUI(
|
|
|
|
const QString& sourceId,
|
|
|
|
QWidget **widget,
|
|
|
|
DeviceUISet *deviceUISet)
|
2014-05-18 15:52:39 +00:00
|
|
|
{
|
2015-10-01 03:05:46 +00:00
|
|
|
if(sourceId == m_deviceTypeID) {
|
2017-10-29 23:45:23 +00:00
|
|
|
RTLSDRGui* gui = new RTLSDRGui(deviceUISet);
|
2016-05-17 01:41:01 +00:00
|
|
|
*widget = gui;
|
2014-05-18 15:52:39 +00:00
|
|
|
return gui;
|
|
|
|
} else {
|
2017-09-14 11:34:32 +00:00
|
|
|
return 0;
|
2014-05-18 15:52:39 +00:00
|
|
|
}
|
|
|
|
}
|
2017-12-17 13:52:18 +00:00
|
|
|
#endif
|
2017-09-14 11:34:32 +00:00
|
|
|
|
|
|
|
DeviceSampleSource *RTLSDRPlugin::createSampleSourcePluginInstanceInput(const QString& sourceId, DeviceSourceAPI *deviceAPI)
|
|
|
|
{
|
|
|
|
if (sourceId == m_deviceTypeID)
|
|
|
|
{
|
|
|
|
RTLSDRInput* input = new RTLSDRInput(deviceAPI);
|
|
|
|
return input;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|