mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-26 12:27:51 +02:00
Backend abstraction + added android support + partial high DPI scaling
This commit is contained in:
@ -24,6 +24,16 @@ if (MSVC)
|
||||
target_include_directories(airspy_source PUBLIC "C:/Program Files/PothosSDR/include/libairspy/")
|
||||
|
||||
target_link_libraries(airspy_source PRIVATE airspy)
|
||||
elseif (ANDROID)
|
||||
target_include_directories(sdrpp_core PUBLIC
|
||||
/mnt/android_sdr/libusb/libusb
|
||||
/mnt/android_sdr/airspyone_host/libairspy/src
|
||||
)
|
||||
|
||||
target_link_libraries(sdrpp_core PUBLIC
|
||||
/mnt/android_sdr/output/libusb/${ANDROID_ABI}/libusb1.0.so
|
||||
/mnt/android_sdr/output/libairspy/${ANDROID_ABI}/libairspy.so
|
||||
)
|
||||
else (MSVC)
|
||||
find_package(PkgConfig)
|
||||
|
||||
|
@ -10,6 +10,10 @@
|
||||
#include <gui/smgui.h>
|
||||
#include <airspy.h>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <android_backend.h>
|
||||
#endif
|
||||
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
SDRPP_MOD_INFO{
|
||||
@ -75,6 +79,7 @@ public:
|
||||
}
|
||||
|
||||
void refresh() {
|
||||
#ifndef __ANDROID__
|
||||
devList.clear();
|
||||
devListTxt = "";
|
||||
|
||||
@ -88,6 +93,18 @@ public:
|
||||
devListTxt += buf;
|
||||
devListTxt += '\0';
|
||||
}
|
||||
#else
|
||||
// Check for device presence
|
||||
int vid, pid;
|
||||
devFd = backend::getDeviceFD(vid, pid, backend::AIRSPY_VIDPIDS);
|
||||
if (devFd < 0) { return; }
|
||||
|
||||
// Get device info
|
||||
std::string fakeName = "Airspy USB";
|
||||
devList.push_back(0xDEADBEEF);
|
||||
devListTxt += fakeName;
|
||||
devListTxt += '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
void selectFirst() {
|
||||
@ -112,7 +129,11 @@ public:
|
||||
void selectBySerial(uint64_t serial) {
|
||||
airspy_device* dev;
|
||||
try {
|
||||
#ifndef __ANDROID__
|
||||
int err = airspy_open_sn(&dev, serial);
|
||||
#else
|
||||
int err = airspy_open_sn(&dev, devFd);
|
||||
#endif
|
||||
if (err != 0) {
|
||||
char buf[1024];
|
||||
sprintf(buf, "%016" PRIX64, serial);
|
||||
@ -245,7 +266,11 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef __ANDROID__
|
||||
int err = airspy_open_sn(&_this->openDev, _this->selectedSerial);
|
||||
#else
|
||||
int err = airspy_open_sn(&_this->openDev, _this->devFd);
|
||||
#endif
|
||||
if (err != 0) {
|
||||
char buf[1024];
|
||||
sprintf(buf, "%016" PRIX64, _this->selectedSerial);
|
||||
@ -571,6 +596,10 @@ private:
|
||||
bool lnaAgc = false;
|
||||
bool mixerAgc = false;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
int devFd = 0;
|
||||
#endif
|
||||
|
||||
std::vector<uint64_t> devList;
|
||||
std::string devListTxt;
|
||||
std::vector<uint32_t> sampleRateList;
|
||||
|
@ -24,6 +24,16 @@ if (MSVC)
|
||||
target_include_directories(airspyhf_source PUBLIC "C:/Program Files/PothosSDR/include/libairspyhf/")
|
||||
|
||||
target_link_libraries(airspyhf_source PRIVATE airspyhf)
|
||||
elseif (ANDROID)
|
||||
target_include_directories(sdrpp_core PUBLIC
|
||||
/mnt/android_sdr/libusb/libusb
|
||||
/mnt/android_sdr/airspyhf/libairspyhf/src
|
||||
)
|
||||
|
||||
target_link_libraries(sdrpp_core PUBLIC
|
||||
/mnt/android_sdr/output/libusb/${ANDROID_ABI}/libusb1.0.so
|
||||
/mnt/android_sdr/output/libairspyhf/${ANDROID_ABI}/libairspyhf.so
|
||||
)
|
||||
else (MSVC)
|
||||
find_package(PkgConfig)
|
||||
|
||||
|
@ -10,6 +10,10 @@
|
||||
#include <airspyhf.h>
|
||||
#include <gui/widgets/stepped_slider.h>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <android_backend.h>
|
||||
#endif
|
||||
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
SDRPP_MOD_INFO{
|
||||
@ -79,6 +83,7 @@ public:
|
||||
devList.clear();
|
||||
devListTxt = "";
|
||||
|
||||
#ifndef __ANDROID__
|
||||
uint64_t serials[256];
|
||||
int n = airspyhf_list_devices(serials, 256);
|
||||
|
||||
@ -89,6 +94,18 @@ public:
|
||||
devListTxt += buf;
|
||||
devListTxt += '\0';
|
||||
}
|
||||
#else
|
||||
// Check for device presence
|
||||
int vid, pid;
|
||||
devFd = backend::getDeviceFD(vid, pid, backend::AIRSPYHF_VIDPIDS);
|
||||
if (devFd < 0) { return; }
|
||||
|
||||
// Get device info
|
||||
std::string fakeName = "Airspy HF+ USB";
|
||||
devList.push_back(0xDEADBEEF);
|
||||
devListTxt += fakeName;
|
||||
devListTxt += '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
void selectFirst() {
|
||||
@ -113,10 +130,14 @@ public:
|
||||
void selectBySerial(uint64_t serial) {
|
||||
airspyhf_device_t* dev;
|
||||
try {
|
||||
int err = airspyhf_open_sn(&dev, selectedSerial);
|
||||
#ifndef __ANDROID__
|
||||
int err = airspyhf_open_sn(&dev, serial);
|
||||
#else
|
||||
int err = airspyhf_open_sn(&dev, devFd);
|
||||
#endif
|
||||
if (err != 0) {
|
||||
char buf[1024];
|
||||
sprintf(buf, "%016" PRIX64, selectedSerial);
|
||||
sprintf(buf, "%016" PRIX64, serial);
|
||||
spdlog::error("Could not open Airspy HF+ {0}", buf);
|
||||
selectedSerial = 0;
|
||||
return;
|
||||
@ -124,7 +145,7 @@ public:
|
||||
}
|
||||
catch (std::exception e) {
|
||||
char buf[1024];
|
||||
sprintf(buf, "%016" PRIX64, selectedSerial);
|
||||
sprintf(buf, "%016" PRIX64, serial);
|
||||
spdlog::error("Could not open Airspy HF+ {0}", buf);
|
||||
}
|
||||
|
||||
@ -221,7 +242,11 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
int err = airspyhf_open_sn(&_this->openDev, _this->selectedSerial);
|
||||
#ifndef __ANDROID__
|
||||
int err = airspyhf_open_sn(&_this->openDev, _this->selectedSerial);
|
||||
#else
|
||||
int err = airspyhf_open_sn(&_this->openDev, _this->devFd);
|
||||
#endif
|
||||
if (err != 0) {
|
||||
char buf[1024];
|
||||
sprintf(buf, "%016" PRIX64, _this->selectedSerial);
|
||||
@ -368,6 +393,10 @@ private:
|
||||
float atten = 0.0f;
|
||||
std::string selectedSerStr = "";
|
||||
|
||||
#ifdef __ANDROID__
|
||||
int devFd = 0;
|
||||
#endif
|
||||
|
||||
std::vector<uint64_t> devList;
|
||||
std::string devListTxt;
|
||||
std::vector<uint32_t> sampleRateList;
|
||||
|
@ -22,6 +22,16 @@ if (MSVC)
|
||||
target_link_directories(hackrf_source PRIVATE "C:/Program Files/PothosSDR/bin/")
|
||||
|
||||
target_link_libraries(hackrf_source PRIVATE hackrf)
|
||||
elseif (ANDROID)
|
||||
target_include_directories(sdrpp_core PUBLIC
|
||||
/mnt/android_sdr/libusb/libusb
|
||||
/mnt/android_sdr/hackrf/host/libhackrf/src
|
||||
)
|
||||
|
||||
target_link_libraries(sdrpp_core PUBLIC
|
||||
/mnt/android_sdr/output/libusb/${ANDROID_ABI}/libusb1.0.so
|
||||
/mnt/android_sdr/output/libhackrf/${ANDROID_ABI}/libhackrf.so
|
||||
)
|
||||
else (MSVC)
|
||||
find_package(PkgConfig)
|
||||
|
||||
|
@ -5,11 +5,18 @@
|
||||
#include <core.h>
|
||||
#include <gui/style.h>
|
||||
#include <config.h>
|
||||
#include <libhackrf/hackrf.h>
|
||||
#include <gui/widgets/stepped_slider.h>
|
||||
#include <options.h>
|
||||
#include <gui/smgui.h>
|
||||
|
||||
#ifndef __ANDROID__
|
||||
#include <libhackrf/hackrf.h>
|
||||
#else
|
||||
#include <android_backend.h>
|
||||
#include <spdlog/sinks/android_sink.h>
|
||||
#include <hackrf.h>
|
||||
#endif
|
||||
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
SDRPP_MOD_INFO{
|
||||
@ -127,6 +134,7 @@ public:
|
||||
devList.clear();
|
||||
devListTxt = "";
|
||||
|
||||
#ifndef __ANDROID__
|
||||
uint64_t serials[256];
|
||||
hackrf_device_list_t* _devList = hackrf_device_list();
|
||||
|
||||
@ -137,6 +145,15 @@ public:
|
||||
}
|
||||
|
||||
hackrf_device_list_free(_devList);
|
||||
#else
|
||||
int vid, pid;
|
||||
devFd = backend::getDeviceFD(vid, pid, backend::HACKRF_VIDPIDS);
|
||||
if (devFd < 0) { return; }
|
||||
std::string fakeName = "HackRF USB";
|
||||
devList.push_back("fake_serial");
|
||||
devListTxt += fakeName;
|
||||
devListTxt += '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
void selectFirst() {
|
||||
@ -229,7 +246,11 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef __ANDROID__
|
||||
hackrf_error err = (hackrf_error)hackrf_open_by_serial(_this->selectedSerial.c_str(), &_this->openDev);
|
||||
#else
|
||||
hackrf_error err = (hackrf_error)hackrf_open_by_fd(&_this->openDev, _this->devFd);
|
||||
#endif
|
||||
if (err != HACKRF_SUCCESS) {
|
||||
spdlog::error("Could not open HackRF {0}: {1}", _this->selectedSerial, hackrf_error_name(err));
|
||||
return;
|
||||
@ -383,6 +404,10 @@ private:
|
||||
float lna = 0;
|
||||
float vga = 0;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
int devFd = -1;
|
||||
#endif
|
||||
|
||||
std::vector<std::string> devList;
|
||||
std::string devListTxt;
|
||||
};
|
||||
|
@ -24,6 +24,17 @@ if (MSVC)
|
||||
|
||||
target_link_libraries(plutosdr_source PRIVATE libiio)
|
||||
target_link_libraries(plutosdr_source PRIVATE libad9361)
|
||||
elseif (ANDROID)
|
||||
target_include_directories(sdrpp_core PUBLIC
|
||||
/mnt/android_sdr/libiio
|
||||
/mnt/android_sdr/libad9361-iio
|
||||
)
|
||||
|
||||
target_link_libraries(sdrpp_core PUBLIC
|
||||
/mnt/android_sdr/output/libxml2/${ANDROID_ABI}/libxml2.so
|
||||
/mnt/android_sdr/output/libiio/${ANDROID_ABI}/libiio.so
|
||||
/mnt/android_sdr/output/libad9361/${ANDROID_ABI}/libad9361.so
|
||||
)
|
||||
else (MSVC)
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
target_include_directories(plutosdr_source PRIVATE "/Library/Frameworks/iio.framework/Headers")
|
||||
|
@ -22,6 +22,16 @@ if (MSVC)
|
||||
target_link_directories(rtl_sdr_source PRIVATE "C:/Program Files/PothosSDR/bin/")
|
||||
|
||||
target_link_libraries(rtl_sdr_source PRIVATE rtlsdr)
|
||||
elseif (ANDROID)
|
||||
target_include_directories(sdrpp_core PUBLIC
|
||||
/mnt/android_sdr/libusb/libusb
|
||||
/mnt/android_sdr/librtlsdr/include
|
||||
)
|
||||
|
||||
target_link_libraries(sdrpp_core PUBLIC
|
||||
/mnt/android_sdr/output/libusb/${ANDROID_ABI}/libusb1.0.so
|
||||
/mnt/android_sdr/output/librtlsdr/${ANDROID_ABI}/librtlsdr.so
|
||||
)
|
||||
else (MSVC)
|
||||
find_package(PkgConfig)
|
||||
|
||||
|
@ -9,6 +9,9 @@
|
||||
#include <gui/smgui.h>
|
||||
#include <rtl-sdr.h>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <android_backend.h>
|
||||
#endif
|
||||
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
@ -114,6 +117,7 @@ public:
|
||||
devNames.clear();
|
||||
devListTxt = "";
|
||||
|
||||
#ifndef __ANDROID__
|
||||
devCount = rtlsdr_get_device_count();
|
||||
char buf[1024];
|
||||
for (int i = 0; i < devCount; i++) {
|
||||
@ -123,6 +127,20 @@ public:
|
||||
devListTxt += buf;
|
||||
devListTxt += '\0';
|
||||
}
|
||||
#else
|
||||
// Check for device connection
|
||||
devCount = 0;
|
||||
int vid, pid;
|
||||
devFd = backend::getDeviceFD(vid, pid, backend::RTL_SDR_VIDPIDS);
|
||||
if (devFd < 0) { return; }
|
||||
|
||||
// Generate fake device info
|
||||
devCount = 1;
|
||||
std::string fakeName = "RTL-SDR Dongle USB";
|
||||
devNames.push_back(fakeName);
|
||||
devListTxt += fakeName;
|
||||
devListTxt += '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
void selectFirst() {
|
||||
@ -144,9 +162,15 @@ public:
|
||||
void selectById(int id) {
|
||||
selectedDevName = devNames[id];
|
||||
|
||||
if (rtlsdr_open(&openDev, id) < 0) {
|
||||
#ifndef __ANDROID__
|
||||
int oret = rtlsdr_open(&openDev, id);
|
||||
#else
|
||||
int oret = rtlsdr_open(&openDev, devFd);
|
||||
#endif
|
||||
|
||||
if (oret < 0) {
|
||||
selectedDevName = "";
|
||||
spdlog::error("Could not open RTL-SDR");
|
||||
spdlog::error("Could not open RTL-SDR: {0}", oret);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -252,7 +276,13 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
if (rtlsdr_open(&_this->openDev, _this->devId) < 0) {
|
||||
#ifndef __ANDROID__
|
||||
int oret = rtlsdr_open(&_this->openDev, _this->devId);
|
||||
#else
|
||||
int oret = rtlsdr_open(&_this->openDev, _this->devFd);
|
||||
#endif
|
||||
|
||||
if (oret < 0) {
|
||||
spdlog::error("Could not open RTL-SDR");
|
||||
return;
|
||||
}
|
||||
@ -510,6 +540,10 @@ private:
|
||||
int devCount = 0;
|
||||
std::thread workerThread;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
int devFd = -1;
|
||||
#endif
|
||||
|
||||
int ppm = 0;
|
||||
|
||||
bool biasT = false;
|
||||
|
Reference in New Issue
Block a user