2023-11-18 04:07:41 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
|
|
|
// written by Christian Daniel //
|
|
|
|
// Copyright (C) 2014 John Greb <hexameron> //
|
|
|
|
// Copyright (C) 2015-2023 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
|
|
|
|
// Copyright (C) 2019 Davide Gerhard <rainbow@irh.it> //
|
|
|
|
// Copyright (C) 2020 Kacper Michajłow <kasper93@gmail.com> //
|
|
|
|
// Copyright (C) 2022 Jon Beniston, M7RCE <jon@beniston.com> //
|
|
|
|
// //
|
|
|
|
// 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 //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// 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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////
|
2014-05-18 11:52:39 -04:00
|
|
|
#include <QtPlugin>
|
|
|
|
#include <rtl-sdr.h>
|
2017-12-28 18:33:37 -05:00
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/simpleserializer.h"
|
2016-10-10 19:17:55 -04:00
|
|
|
|
2017-12-28 18:33:37 -05:00
|
|
|
#ifdef SERVER_MODE
|
|
|
|
#include "rtlsdrinput.h"
|
|
|
|
#else
|
2014-05-18 11:52:39 -04:00
|
|
|
#include "rtlsdrgui.h"
|
2017-12-28 18:33:37 -05:00
|
|
|
#endif
|
|
|
|
#include "rtlsdrplugin.h"
|
2019-08-04 14:24:44 -04:00
|
|
|
#include "rtlsdrwebapiadapter.h"
|
2022-12-22 06:04:12 -05:00
|
|
|
#ifdef ANDROID
|
|
|
|
#include "util/android.h"
|
|
|
|
#endif
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
const PluginDescriptor RTLSDRPlugin::m_pluginDescriptor = {
|
2020-11-21 09:38:04 -05:00
|
|
|
QStringLiteral("RTLSDR"),
|
|
|
|
QStringLiteral("RTL-SDR Input"),
|
2023-12-31 13:16:27 -05:00
|
|
|
QStringLiteral("7.17.3"),
|
2020-11-21 09:38:04 -05:00
|
|
|
QStringLiteral("(c) Edouard Griffiths, F4EXB"),
|
|
|
|
QStringLiteral("https://github.com/f4exb/sdrangel"),
|
2014-05-18 11:52:39 -04:00
|
|
|
true,
|
2020-11-21 09:38:04 -05:00
|
|
|
QStringLiteral("https://github.com/f4exb/sdrangel")
|
2014-05-18 11:52:39 -04:00
|
|
|
};
|
|
|
|
|
2020-11-21 14:24:18 -05:00
|
|
|
static constexpr const char* const m_hardwareID = "RTLSDR";
|
|
|
|
static constexpr const char* const m_deviceTypeID = RTLSDR_DEVICE_TYPE_ID;
|
2015-09-30 23:05:46 -04:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-09-16 18:34:11 -04:00
|
|
|
void RTLSDRPlugin::enumOriginDevices(QStringList& listedHwIds, OriginDevices& originDevices)
|
2014-05-18 11:52:39 -04:00
|
|
|
{
|
2019-09-16 18:34:11 -04:00
|
|
|
if (listedHwIds.contains(m_hardwareID)) { // check if it was done
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-22 06:04:12 -05:00
|
|
|
#ifdef ANDROID
|
|
|
|
typedef struct rtlsdr_dongle {
|
|
|
|
uint16_t vid;
|
|
|
|
uint16_t pid;
|
|
|
|
const char *name;
|
|
|
|
} rtlsdr_dongle_t;
|
|
|
|
|
|
|
|
// This list comes from librtlsdr.c
|
|
|
|
rtlsdr_dongle_t known_devices[] = {
|
|
|
|
{ 0x0bda, 0x2832, "Generic RTL2832U" },
|
|
|
|
{ 0x0bda, 0x2838, "Generic RTL2832U OEM" },
|
|
|
|
{ 0x0413, 0x6680, "DigitalNow Quad DVB-T PCI-E card" },
|
|
|
|
{ 0x0413, 0x6f0f, "Leadtek WinFast DTV Dongle mini D" },
|
|
|
|
{ 0x0458, 0x707f, "Genius TVGo DVB-T03 USB dongle (Ver. B)" },
|
|
|
|
{ 0x0ccd, 0x00a9, "Terratec Cinergy T Stick Black (rev 1)" },
|
|
|
|
{ 0x0ccd, 0x00b3, "Terratec NOXON DAB/DAB+ USB dongle (rev 1)" },
|
|
|
|
{ 0x0ccd, 0x00b4, "Terratec Deutschlandradio DAB Stick" },
|
|
|
|
{ 0x0ccd, 0x00b5, "Terratec NOXON DAB Stick - Radio Energy" },
|
|
|
|
{ 0x0ccd, 0x00b7, "Terratec Media Broadcast DAB Stick" },
|
|
|
|
{ 0x0ccd, 0x00b8, "Terratec BR DAB Stick" },
|
|
|
|
{ 0x0ccd, 0x00b9, "Terratec WDR DAB Stick" },
|
|
|
|
{ 0x0ccd, 0x00c0, "Terratec MuellerVerlag DAB Stick" },
|
|
|
|
{ 0x0ccd, 0x00c6, "Terratec Fraunhofer DAB Stick" },
|
|
|
|
{ 0x0ccd, 0x00d3, "Terratec Cinergy T Stick RC (Rev.3)" },
|
|
|
|
{ 0x0ccd, 0x00d7, "Terratec T Stick PLUS" },
|
|
|
|
{ 0x0ccd, 0x00e0, "Terratec NOXON DAB/DAB+ USB dongle (rev 2)" },
|
|
|
|
{ 0x1554, 0x5020, "PixelView PV-DT235U(RN)" },
|
|
|
|
{ 0x15f4, 0x0131, "Astrometa DVB-T/DVB-T2" },
|
|
|
|
{ 0x15f4, 0x0133, "HanfTek DAB+FM+DVB-T" },
|
|
|
|
{ 0x185b, 0x0620, "Compro Videomate U620F"},
|
|
|
|
{ 0x185b, 0x0650, "Compro Videomate U650F"},
|
|
|
|
{ 0x185b, 0x0680, "Compro Videomate U680F"},
|
|
|
|
{ 0x1b80, 0xd393, "GIGABYTE GT-U7300" },
|
|
|
|
{ 0x1b80, 0xd394, "DIKOM USB-DVBT HD" },
|
|
|
|
{ 0x1b80, 0xd395, "Peak 102569AGPK" },
|
|
|
|
{ 0x1b80, 0xd397, "KWorld KW-UB450-T USB DVB-T Pico TV" },
|
|
|
|
{ 0x1b80, 0xd398, "Zaapa ZT-MINDVBZP" },
|
|
|
|
{ 0x1b80, 0xd39d, "SVEON STV20 DVB-T USB & FM" },
|
|
|
|
{ 0x1b80, 0xd3a4, "Twintech UT-40" },
|
|
|
|
{ 0x1b80, 0xd3a8, "ASUS U3100MINI_PLUS_V2" },
|
|
|
|
{ 0x1b80, 0xd3af, "SVEON STV27 DVB-T USB & FM" },
|
|
|
|
{ 0x1b80, 0xd3b0, "SVEON STV21 DVB-T USB & FM" },
|
|
|
|
{ 0x1d19, 0x1101, "Dexatek DK DVB-T Dongle (Logilink VG0002A)" },
|
|
|
|
{ 0x1d19, 0x1102, "Dexatek DK DVB-T Dongle (MSI DigiVox mini II V3.0)" },
|
|
|
|
{ 0x1d19, 0x1103, "Dexatek Technology Ltd. DK 5217 DVB-T Dongle" },
|
|
|
|
{ 0x1d19, 0x1104, "MSI DigiVox Micro HD" },
|
|
|
|
{ 0x1f4d, 0xa803, "Sweex DVB-T USB" },
|
|
|
|
{ 0x1f4d, 0xb803, "GTek T803" },
|
|
|
|
{ 0x1f4d, 0xc803, "Lifeview LV5TDeluxe" },
|
|
|
|
{ 0x1f4d, 0xd286, "MyGica TD312" },
|
|
|
|
{ 0x1f4d, 0xd803, "PROlectrix DV107669" },
|
|
|
|
};
|
|
|
|
|
|
|
|
int deviceNo = 0;
|
|
|
|
for (int i = 0; i < sizeof(known_devices)/sizeof(rtlsdr_dongle_t); i++)
|
|
|
|
{
|
|
|
|
QStringList serialStrings = Android::listUSBDeviceSerials(known_devices[i].vid, known_devices[i].pid);
|
|
|
|
|
|
|
|
for (const auto serial : serialStrings)
|
|
|
|
{
|
|
|
|
QString displayableName(QString("RTL-SDR[%1] %2").arg(deviceNo).arg(serial));
|
|
|
|
|
|
|
|
originDevices.append(OriginDevice(
|
|
|
|
displayableName,
|
|
|
|
m_hardwareID,
|
|
|
|
serial,
|
|
|
|
deviceNo, // sequence
|
|
|
|
1, // Nb Rx
|
|
|
|
0 // Nb Tx
|
|
|
|
));
|
|
|
|
|
|
|
|
deviceNo++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
listedHwIds.append(m_hardwareID);
|
|
|
|
#else
|
2014-05-18 11:52:39 -04:00
|
|
|
int count = rtlsdr_get_device_count();
|
|
|
|
char vendor[256];
|
|
|
|
char product[256];
|
|
|
|
char serial[256];
|
|
|
|
|
2019-09-16 18:34:11 -04:00
|
|
|
for(int i = 0; i < count; i++)
|
|
|
|
{
|
2014-05-18 11:52:39 -04:00
|
|
|
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;
|
2019-09-16 18:34:11 -04:00
|
|
|
QString displayableName(QString("RTL-SDR[%1] %2").arg(i).arg(serial));
|
|
|
|
|
|
|
|
originDevices.append(OriginDevice(
|
|
|
|
displayableName,
|
|
|
|
m_hardwareID,
|
|
|
|
serial,
|
|
|
|
i, // sequence
|
|
|
|
1, // Nb Rx
|
|
|
|
0 // Nb Tx
|
|
|
|
));
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
2019-09-16 18:34:11 -04:00
|
|
|
|
|
|
|
listedHwIds.append(m_hardwareID);
|
2022-12-22 06:04:12 -05:00
|
|
|
#endif
|
2019-09-16 18:34:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
PluginInterface::SamplingDevices RTLSDRPlugin::enumSampleSources(const OriginDevices& originDevices)
|
|
|
|
{
|
|
|
|
SamplingDevices result;
|
|
|
|
|
|
|
|
for (OriginDevices::const_iterator it = originDevices.begin(); it != originDevices.end(); ++it)
|
|
|
|
{
|
|
|
|
if (it->hardwareId == m_hardwareID)
|
|
|
|
{
|
|
|
|
result.append(SamplingDevice(
|
|
|
|
it->displayableName,
|
|
|
|
it->hardwareId,
|
|
|
|
m_deviceTypeID,
|
|
|
|
it->serial,
|
|
|
|
it->sequence,
|
|
|
|
PluginInterface::SamplingDevice::PhysicalDevice,
|
|
|
|
PluginInterface::SamplingDevice::StreamSingleRx,
|
|
|
|
1,
|
|
|
|
0
|
|
|
|
));
|
|
|
|
qDebug("RTLSDRPlugin::enumSampleSources: enumerated RTL-SDR device #%d", it->sequence);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-12-17 08:52:18 -05:00
|
|
|
#ifdef SERVER_MODE
|
2020-10-05 13:23:13 -04:00
|
|
|
DeviceGUI* RTLSDRPlugin::createSampleSourcePluginInstanceGUI(
|
2019-05-24 03:37:13 -04:00
|
|
|
const QString& sourceId,
|
|
|
|
QWidget **widget,
|
|
|
|
DeviceUISet *deviceUISet)
|
2017-12-17 08:52:18 -05:00
|
|
|
{
|
2019-06-19 12:50:55 -04:00
|
|
|
(void) sourceId;
|
|
|
|
(void) widget;
|
|
|
|
(void) deviceUISet;
|
2017-12-17 08:52:18 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
2020-10-05 13:23:13 -04:00
|
|
|
DeviceGUI* RTLSDRPlugin::createSampleSourcePluginInstanceGUI(
|
2017-10-29 19:02:28 -04:00
|
|
|
const QString& sourceId,
|
|
|
|
QWidget **widget,
|
|
|
|
DeviceUISet *deviceUISet)
|
2014-05-18 11:52:39 -04:00
|
|
|
{
|
2015-09-30 23:05:46 -04:00
|
|
|
if(sourceId == m_deviceTypeID) {
|
2017-10-29 19:45:23 -04:00
|
|
|
RTLSDRGui* gui = new RTLSDRGui(deviceUISet);
|
2016-05-16 21:41:01 -04:00
|
|
|
*widget = gui;
|
2014-05-18 11:52:39 -04:00
|
|
|
return gui;
|
|
|
|
} else {
|
2017-09-14 07:34:32 -04:00
|
|
|
return 0;
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
}
|
2017-12-17 08:52:18 -05:00
|
|
|
#endif
|
2017-09-14 07:34:32 -04:00
|
|
|
|
2019-05-19 04:28:50 -04:00
|
|
|
DeviceSampleSource *RTLSDRPlugin::createSampleSourcePluginInstance(const QString& sourceId, DeviceAPI *deviceAPI)
|
2017-09-14 07:34:32 -04:00
|
|
|
{
|
|
|
|
if (sourceId == m_deviceTypeID)
|
|
|
|
{
|
|
|
|
RTLSDRInput* input = new RTLSDRInput(deviceAPI);
|
|
|
|
return input;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-04 14:24:44 -04:00
|
|
|
DeviceWebAPIAdapter *RTLSDRPlugin::createDeviceWebAPIAdapter() const
|
|
|
|
{
|
|
|
|
return new RTLSDRWebAPIAdapter();
|
|
|
|
}
|