2014-05-18 11:52:39 -04:00
|
|
|
#include <QtPlugin>
|
|
|
|
#include <QAction>
|
|
|
|
#include <rtl-sdr.h>
|
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "rtlsdrplugin.h"
|
2016-10-10 19:17:55 -04:00
|
|
|
|
|
|
|
#include <device/devicesourceapi.h>
|
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
#include "rtlsdrgui.h"
|
|
|
|
|
|
|
|
const PluginDescriptor RTLSDRPlugin::m_pluginDescriptor = {
|
|
|
|
QString("RTL-SDR Input"),
|
2016-10-09 20:19:21 -04:00
|
|
|
QString("2.1.6"),
|
2015-09-01 19:16:40 -04:00
|
|
|
QString("(c) Edouard Griffiths, F4EXB"),
|
|
|
|
QString("https://github.com/f4exb/sdrangel"),
|
2014-05-18 11:52:39 -04:00
|
|
|
true,
|
2015-09-01 19:16:40 -04:00
|
|
|
QString("https://github.com/f4exb/sdrangel")
|
2014-05-18 11:52:39 -04:00
|
|
|
};
|
|
|
|
|
2015-09-30 23:05:46 -04:00
|
|
|
const QString RTLSDRPlugin::m_deviceTypeID = RTLSDR_DEVICE_TYPE_ID;
|
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
RTLSDRPlugin::RTLSDRPlugin(QObject* parent) :
|
|
|
|
QObject(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const PluginDescriptor& RTLSDRPlugin::getPluginDescriptor() const
|
|
|
|
{
|
|
|
|
return m_pluginDescriptor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RTLSDRPlugin::initPlugin(PluginAPI* pluginAPI)
|
|
|
|
{
|
2016-05-17 11:53:22 -04:00
|
|
|
pluginAPI->registerSampleSource(m_deviceTypeID, this);
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
|
2016-10-13 16:23:43 -04:00
|
|
|
PluginInterface::SamplingDevices RTLSDRPlugin::enumSampleSources()
|
2014-05-18 11:52:39 -04:00
|
|
|
{
|
2016-10-13 16:23:43 -04:00
|
|
|
SamplingDevices result;
|
2014-05-18 11:52:39 -04: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 12:11:08 -05:00
|
|
|
if(rtlsdr_get_device_usb_strings((uint32_t)i, vendor, product, serial) != 0)
|
2014-05-18 11:52:39 -04:00
|
|
|
continue;
|
2015-09-30 23:44:33 -04:00
|
|
|
QString displayedName(QString("RTL-SDR[%1] %2").arg(i).arg(serial));
|
2015-09-30 00:57:40 -04:00
|
|
|
|
2016-10-13 16:23:43 -04:00
|
|
|
result.append(SamplingDevice(displayedName,
|
2015-09-30 23:05:46 -04:00
|
|
|
m_deviceTypeID,
|
2015-09-30 00:57:40 -04:00
|
|
|
QString(serial),
|
|
|
|
i));
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-10-10 19:17:55 -04:00
|
|
|
PluginGUI* RTLSDRPlugin::createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceSourceAPI *deviceAPI)
|
2014-05-18 11:52:39 -04:00
|
|
|
{
|
2015-09-30 23:05:46 -04:00
|
|
|
if(sourceId == m_deviceTypeID) {
|
2016-05-17 11:53:22 -04:00
|
|
|
RTLSDRGui* gui = new RTLSDRGui(deviceAPI);
|
2016-05-16 21:41:01 -04:00
|
|
|
*widget = gui;
|
2014-05-18 11:52:39 -04:00
|
|
|
return gui;
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|