Merge pull request from AlexandreRouma/backend_abstraction

Backend abstraction and android support
This commit is contained in:
AlexandreRouma
2022-03-28 22:27:38 +02:00
committed by GitHub
115 changed files with 5747 additions and 1969 deletions
.gitignoreCMakeLists.txt
android
core
decoder_modules
falcon9_decoder
kg_sstv_decoder
m17_decoder
meteor_demodulator
radio
weather_sat_decoder
misc_modules
frequency_manager
recorder
rigctl_server
scheduler
readme.md
root/res/bandplans
sink_modules
android_audio_sink
audio_sink
network_sink
new_portaudio_sink
portaudio_sink
source_modules
airspy_source
airspyhf_source
bladerf_source
file_source
hackrf_source
limesdr_source
plutosdr_source
rfspace_source
rtl_sdr_source
rtl_tcp_source
sddc_source
sdrplay_source
sdrpp_server_source
soapy_source
spyserver_source

@ -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)

@ -6,10 +6,13 @@
#include <core.h>
#include <gui/style.h>
#include <config.h>
#include <options.h>
#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 +78,7 @@ public:
}
void refresh() {
#ifndef __ANDROID__
devList.clear();
devListTxt = "";
@ -88,6 +92,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 +128,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 +265,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 +595,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;
@ -581,7 +609,7 @@ MOD_EXPORT void _INIT_() {
json def = json({});
def["devices"] = json({});
def["device"] = "";
config.setPath(options::opts.root + "/airspy_config.json");
config.setPath(core::args["root"].s() + "/airspy_config.json");
config.load(def);
config.enableAutoSave();
}