575 lines
20 KiB
C++
Raw Normal View History

2021-03-20 21:53:44 +01:00
#include <imgui.h>
#include <spdlog/spdlog.h>
#include <module.h>
#include <gui/gui.h>
#include <signal_path/signal_path.h>
#include <core.h>
#include <gui/style.h>
#include <config.h>
#include <options.h>
#include <gui/widgets/stepped_slider.h>
#include <libbladeRF.h>
#include <dsp/processing.h>
2021-06-26 18:26:58 +02:00
#include <algorithm>
2021-03-20 21:53:44 +01:00
#define CONCAT(a, b) ((std::string(a) + b).c_str())
#define NUM_BUFFERS 128
2021-05-02 02:23:10 +02:00
#define NUM_TRANSFERS 1
2021-03-20 21:53:44 +01:00
SDRPP_MOD_INFO {
/* Name: */ "bladerf_source",
/* Description: */ "BladeRF source module for SDR++",
/* Author: */ "Ryzerth",
/* Version: */ 0, 1, 0,
/* Max instances */ 1
};
ConfigManager config;
class BladeRFSourceModule : public ModuleManager::Instance {
public:
BladeRFSourceModule(std::string name) {
this->name = name;
2021-05-03 04:20:48 +02:00
sampleRate = 1000000.0;
2021-03-20 21:53:44 +01:00
handler.ctx = this;
handler.selectHandler = menuSelected;
handler.deselectHandler = menuDeselected;
handler.menuHandler = menuHandler;
handler.startHandler = start;
handler.stopHandler = stop;
handler.tuneHandler = tune;
handler.stream = &stream;
refresh();
// Select device here
config.acquire();
2021-06-26 18:26:58 +02:00
std::string serial = config.conf["device"];
config.release();
selectBySerial(serial);
2021-03-20 21:53:44 +01:00
sigpath::sourceManager.registerSource("BladeRF", &handler);
}
~BladeRFSourceModule() {
2021-07-26 03:11:51 +02:00
stop(this);
sigpath::sourceManager.unregisterSource("BladeRF");
2021-03-20 21:53:44 +01:00
}
2021-07-26 03:11:51 +02:00
void postInit() {}
2021-03-20 21:53:44 +01:00
void enable() {
enabled = true;
}
void disable() {
enabled = false;
}
bool isEnabled() {
return enabled;
}
void refresh() {
devListTxt = "";
if (devInfoList != NULL) {
bladerf_free_device_list(devInfoList);
}
devCount = bladerf_get_device_list(&devInfoList);
if (devCount < 0) {
spdlog::error("Could not list devices");
return;
}
for (int i = 0; i < devCount; i++) {
2021-05-03 04:20:48 +02:00
// Keep only the first 32 character of the serial number for display
2021-05-03 18:10:52 +02:00
devListTxt += std::string(devInfoList[i].serial).substr(0, 16);
2021-03-20 21:53:44 +01:00
devListTxt += '\0';
}
}
void selectFirst() {
if (devCount > 0) { selectByInfo(&devInfoList[0]); }
2021-06-28 02:22:51 +02:00
else { selectedSerial = ""; }
2021-03-20 21:53:44 +01:00
}
2021-06-26 18:26:58 +02:00
void selectBySerial(std::string serial, bool reloadChannelId = true) {
if (serial == "") {
selectFirst();
return;
}
for (int i = 0; i < devCount; i++) {
bladerf_devinfo info = devInfoList[i];
if (serial == info.serial) {
devId = i;
selectByInfo(&info, reloadChannelId);
return;
}
}
2021-06-30 03:13:14 +02:00
selectFirst();
2021-06-26 18:26:58 +02:00
}
void selectByInfo(bladerf_devinfo* info, bool reloadChannelId = true) {
2021-03-20 21:53:44 +01:00
int ret = bladerf_open_with_devinfo(&openDev, info);
if (ret != 0) {
spdlog::error("Could not open device {0}", info->serial);
2021-06-26 18:26:58 +02:00
selectedSerial = "";
2021-03-20 21:53:44 +01:00
return;
}
2021-06-26 18:26:58 +02:00
selectedSerial = info->serial;
for (int i = 0; i < devCount; i++) {
if (selectedSerial == devInfoList[i].serial) { devId = i; }
}
2021-05-03 04:20:48 +02:00
// Gather info about the BladeRF's ranges
2021-03-20 21:53:44 +01:00
channelCount = bladerf_get_channel_count(openDev, BLADERF_RX);
2021-06-26 18:26:58 +02:00
// Load the channelId if there are more than 1 channel
if (reloadChannelId) {
config.acquire();
2021-06-26 18:26:58 +02:00
if (channelCount > 1 && config.conf["devices"].contains(info->serial)) {
if (config.conf["devices"][info->serial].contains("channelId")) {
chanId = config.conf["devices"][info->serial]["channelId"];
}
else { chanId = 0; }
}
else { chanId = 0; }
config.release();
}
chanId = std::clamp<int>(chanId, 0, channelCount - 1);
bladerf_get_sample_rate_range(openDev, BLADERF_CHANNEL_RX(chanId), &srRange);
bladerf_get_bandwidth_range(openDev, BLADERF_CHANNEL_RX(chanId), &bwRange);
bladerf_get_gain_range(openDev, BLADERF_CHANNEL_RX(chanId), &gainRange);
2021-06-27 02:20:11 +02:00
int gainModeCount = bladerf_get_gain_modes(openDev, BLADERF_CHANNEL_RX(chanId), &gainModes);
2021-05-02 02:23:10 +02:00
2021-05-03 18:10:52 +02:00
// Generate sampleRate and Bandwidth lists
sampleRates.clear();
sampleRatesTxt = "";
sampleRates.push_back(srRange->min);
sampleRatesTxt += getBandwdithScaled(srRange->min);
sampleRatesTxt += '\0';
for (int i = 2000000; i < srRange->max; i += 2000000) {
sampleRates.push_back(i);
sampleRatesTxt += getBandwdithScaled(i);
sampleRatesTxt += '\0';
}
sampleRates.push_back(srRange->max);
sampleRatesTxt += getBandwdithScaled(srRange->max);
sampleRatesTxt += '\0';
// Generate bandwidth list
bandwidths.clear();
bandwidthsTxt = "";
bandwidths.push_back(bwRange->min);
bandwidthsTxt += getBandwdithScaled(bwRange->min);
bandwidthsTxt += '\0';
for (int i = 2000000; i < bwRange->max; i += 2000000) {
bandwidths.push_back(i);
bandwidthsTxt += getBandwdithScaled(i);
bandwidthsTxt += '\0';
}
bandwidths.push_back(bwRange->max);
bandwidthsTxt += getBandwdithScaled(bwRange->max);
bandwidthsTxt += '\0';
bandwidthsTxt += "Auto";
bandwidthsTxt += '\0';
2021-05-03 18:10:52 +02:00
2021-06-26 18:26:58 +02:00
// Generate list of channel names
channelNamesTxt = "";
char buf[32];
for (int i = 0; i < channelCount; i++) {
sprintf(buf, "RX %d", i+1);
channelNamesTxt += buf;
channelNamesTxt += '\0';
}
2021-06-27 02:20:11 +02:00
// Generate gain mode list
gainModeNames.clear();
gainModesTxt = "";
for (int i = 0; i < gainModeCount; i++) {
std::string gm = gainModes[i].name;
gm[0] = gm[0] & (~0x20);
gainModeNames.push_back(gm);
gainModesTxt += gm;
gainModesTxt += '\0';
}
2021-06-26 18:26:58 +02:00
// Load settings here
config.acquire();
2021-06-27 02:20:11 +02:00
if (!config.conf["devices"].contains(selectedSerial)) {
config.conf["devices"][info->serial]["channelId"] = 0;
config.conf["devices"][selectedSerial]["sampleRate"] = sampleRates[0];
config.conf["devices"][selectedSerial]["bandwidth"] = bandwidths.size(); // Auto
config.conf["devices"][selectedSerial]["gainMode"] = "Manual";
config.conf["devices"][selectedSerial]["overallGain"] = gainRange->min;
}
// Load sample rate
if (config.conf["devices"][selectedSerial].contains("sampleRate")) {
bool found = false;
uint64_t sr = config.conf["devices"][selectedSerial]["sampleRate"];
for (int i = 0; i < sampleRates.size(); i++) {
if (sr == sampleRates[i]) {
srId = i;
sampleRate = sampleRates[i];
found = true;
break;
}
}
if (!found) {
srId = 0;
sampleRate = sampleRates[0];
}
}
else {
srId = 0;
sampleRate = sampleRates[0];
}
2021-06-26 18:26:58 +02:00
2021-06-27 02:20:11 +02:00
// Load bandwidth
if (config.conf["devices"][selectedSerial].contains("bandwidth")) {
bwId = config.conf["devices"][selectedSerial]["bandwidth"];
bwId = std::clamp<int>(bwId, 0, bandwidths.size());
}
else {
bwId = 0;
}
config.release(true);
// Load gain mode
if (config.conf["devices"][selectedSerial].contains("gainMode")) {
std::string gm = config.conf["devices"][selectedSerial]["gainMode"];
bool found = false;
for (int i = 0; i < gainModeNames.size(); i++) {
if (gainModeNames[i] == gm) {
gainMode = i;
found = true;
break;
}
}
if (!found) {
for (int i = 0; i < gainModeNames.size(); i++) {
if (gainModeNames[i] == "Manual") {
gainMode = i;
break;
}
}
}
}
else {
for (int i = 0; i < gainModeNames.size(); i++) {
if (gainModeNames[i] == "Manual") {
gainMode = i;
break;
}
}
}
2021-03-20 21:53:44 +01:00
2021-06-27 02:20:11 +02:00
// Load gain
if (config.conf["devices"][selectedSerial].contains("overallGain")) {
overallGain = config.conf["devices"][selectedSerial]["overallGain"];
overallGain = std::clamp<int>(overallGain, gainRange->min, gainRange->max);
}
else {
overallGain = gainRange->min;
}
2021-03-20 21:53:44 +01:00
bladerf_close(openDev);
}
private:
std::string getBandwdithScaled(double bw) {
char buf[1024];
if (bw >= 1000000.0) {
sprintf(buf, "%.1lfMHz", bw / 1000000.0);
}
else if (bw >= 1000.0) {
sprintf(buf, "%.1lfKHz", bw / 1000.0);
}
else {
sprintf(buf, "%.1lfHz", bw);
}
return std::string(buf);
}
static void menuSelected(void* ctx) {
BladeRFSourceModule* _this = (BladeRFSourceModule*)ctx;
core::setInputSampleRate(_this->sampleRate);
spdlog::info("BladeRFSourceModule '{0}': Menu Select!", _this->name);
}
static void menuDeselected(void* ctx) {
BladeRFSourceModule* _this = (BladeRFSourceModule*)ctx;
spdlog::info("BladeRFSourceModule '{0}': Menu Deselect!", _this->name);
}
static void start(void* ctx) {
BladeRFSourceModule* _this = (BladeRFSourceModule*)ctx;
2021-07-26 04:16:00 +02:00
if (_this->running) { return; }
2021-03-20 21:53:44 +01:00
if (_this->devCount == 0) { return; }
// Open device
bladerf_devinfo info = _this->devInfoList[_this->devId];
int ret = bladerf_open_with_devinfo(&_this->openDev, &info);
if (ret != 0) {
spdlog::error("Could not open device {0}", info.serial);
return;
}
2021-05-03 04:20:48 +02:00
// Calculate buffer size, must be a multiple of 1024
2021-05-02 02:23:10 +02:00
_this->bufferSize = _this->sampleRate / 200.0;
_this->bufferSize /= 1024;
_this->bufferSize *= 1024;
if (_this->bufferSize < 1024) { _this->bufferSize = 1024; }
2021-05-02 02:23:10 +02:00
2021-05-03 04:20:48 +02:00
// Setup device parameters
2021-06-26 18:26:58 +02:00
bladerf_set_sample_rate(_this->openDev, BLADERF_CHANNEL_RX(_this->chanId), _this->sampleRate, NULL);
bladerf_set_frequency(_this->openDev, BLADERF_CHANNEL_RX(_this->chanId), _this->freq);
bladerf_set_bandwidth(_this->openDev, BLADERF_CHANNEL_RX(_this->chanId), (_this->bwId == _this->bandwidths.size()) ?
2021-05-04 20:41:23 +02:00
std::clamp<uint64_t>(_this->sampleRate, _this->bwRange->min, _this->bwRange->max) : _this->bandwidths[_this->bwId], NULL);
2021-06-27 02:20:11 +02:00
bladerf_set_gain_mode(_this->openDev, BLADERF_CHANNEL_RX(_this->chanId), _this->gainModes[_this->gainMode].mode);
// If gain mode is manual, set the gain
if (_this->gainModes[_this->gainMode].mode == BLADERF_GAIN_MANUAL) {
bladerf_set_gain(_this->openDev, BLADERF_CHANNEL_RX(_this->chanId), _this->overallGain);
}
_this->streamingEnabled = true;
2021-03-20 21:53:44 +01:00
2021-09-20 19:59:35 +02:00
// Setup synchronous transfer
2021-05-02 02:23:10 +02:00
bladerf_sync_config(_this->openDev, BLADERF_RX_X1, BLADERF_FORMAT_SC16_Q11, 16, _this->bufferSize, 8, 3500);
2021-03-20 21:53:44 +01:00
2021-05-03 04:20:48 +02:00
// Enable streaming
2021-06-26 18:26:58 +02:00
bladerf_enable_module(_this->openDev, BLADERF_CHANNEL_RX(_this->chanId), true);
2021-03-20 21:53:44 +01:00
_this->running = true;
_this->workerThread = std::thread(&BladeRFSourceModule::worker, _this);
spdlog::info("BladeRFSourceModule '{0}': Start!", _this->name);
}
static void stop(void* ctx) {
BladeRFSourceModule* _this = (BladeRFSourceModule*)ctx;
2021-07-26 04:16:00 +02:00
if (!_this->running) { return; }
2021-03-20 21:53:44 +01:00
_this->running = false;
_this->stream.stopWriter();
2021-05-03 04:20:48 +02:00
2021-06-27 02:20:11 +02:00
_this->streamingEnabled = false;
2021-05-03 04:20:48 +02:00
// Wait for read worker to terminate
2021-03-20 21:53:44 +01:00
if (_this->workerThread.joinable()) {
_this->workerThread.join();
}
2021-06-27 02:20:11 +02:00
// Disable streaming
bladerf_enable_module(_this->openDev, BLADERF_CHANNEL_RX(_this->chanId), false);
2021-03-20 21:53:44 +01:00
2021-05-03 04:20:48 +02:00
// Close device
2021-03-20 21:53:44 +01:00
bladerf_close(_this->openDev);
_this->stream.clearWriteStop();
spdlog::info("BladeRFSourceModule '{0}': Stop!", _this->name);
}
static void tune(double freq, void* ctx) {
BladeRFSourceModule* _this = (BladeRFSourceModule*)ctx;
_this->freq = freq;
if (_this->running) {
2021-06-26 18:26:58 +02:00
bladerf_set_frequency(_this->openDev, BLADERF_CHANNEL_RX(_this->chanId), _this->freq);
2021-03-20 21:53:44 +01:00
}
spdlog::info("BladeRFSourceModule '{0}': Tune: {1}!", _this->name, freq);
}
static void menuHandler(void* ctx) {
BladeRFSourceModule* _this = (BladeRFSourceModule*)ctx;
float menuWidth = ImGui::GetContentRegionAvailWidth();
if (_this->running) { style::beginDisabled(); }
ImGui::SetNextItemWidth(menuWidth);
if (ImGui::Combo(CONCAT("##_balderf_dev_sel_", _this->name), &_this->devId, _this->devListTxt.c_str())) {
2021-06-26 18:26:58 +02:00
bladerf_devinfo info = _this->devInfoList[_this->devId];
_this->selectByInfo(&info);
2021-03-20 21:53:44 +01:00
core::setInputSampleRate(_this->sampleRate);
config.acquire();
2021-06-26 18:26:58 +02:00
config.conf["device"] = _this->selectedSerial;
config.release(true);
2021-03-20 21:53:44 +01:00
}
2021-05-03 18:10:52 +02:00
if (ImGui::Combo(CONCAT("##_balderf_sr_sel_", _this->name), &_this->srId, _this->sampleRatesTxt.c_str())) {
_this->sampleRate = _this->sampleRates[_this->srId];
2021-03-20 21:53:44 +01:00
core::setInputSampleRate(_this->sampleRate);
2021-06-27 02:20:11 +02:00
if (_this->selectedSerial != "") {
config.acquire();
2021-06-27 02:20:11 +02:00
config.conf["devices"][_this->selectedSerial]["sampleRate"] = _this->sampleRates[_this->srId];
config.release(true);
}
2021-03-20 21:53:44 +01:00
}
2021-06-26 18:26:58 +02:00
// Refresh button
2021-03-20 21:53:44 +01:00
ImGui::SameLine();
float refreshBtnWdith = menuWidth - ImGui::GetCursorPosX();
if (ImGui::Button(CONCAT("Refresh##_balderf_refr_", _this->name), ImVec2(refreshBtnWdith, 0))) {
2021-03-20 21:53:44 +01:00
_this->refresh();
2021-06-26 18:26:58 +02:00
_this->selectBySerial(_this->selectedSerial, false);
2021-03-20 21:53:44 +01:00
core::setInputSampleRate(_this->sampleRate);
}
2021-06-26 18:26:58 +02:00
// Channel selection (only show if more than one channel)
2021-06-27 02:20:11 +02:00
if (_this->channelCount > 1) {
2021-08-31 18:39:48 +02:00
ImGui::LeftLabel("RX Channel");
2021-06-27 02:20:11 +02:00
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
ImGui::Combo(CONCAT("##_balderf_ch_sel_", _this->name), &_this->chanId, _this->channelNamesTxt.c_str());
if (_this->selectedSerial != "") {
config.acquire();
2021-06-27 02:20:11 +02:00
config.conf["devices"][_this->selectedSerial]["channelId"] = _this->chanId;
config.release(true);
}
}
2021-06-26 18:26:58 +02:00
2021-03-20 21:53:44 +01:00
if (_this->running) { style::endDisabled(); }
2021-08-31 18:39:48 +02:00
ImGui::LeftLabel("Bandwidth");
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
2021-05-03 18:10:52 +02:00
if (ImGui::Combo(CONCAT("##_balderf_bw_sel_", _this->name), &_this->bwId, _this->bandwidthsTxt.c_str())) {
if (_this->running) {
2021-06-26 18:26:58 +02:00
bladerf_set_bandwidth(_this->openDev, BLADERF_CHANNEL_RX(_this->chanId), (_this->bwId == _this->bandwidths.size()) ?
2021-05-04 20:41:23 +02:00
std::clamp<uint64_t>(_this->sampleRate, _this->bwRange->min, _this->bwRange->max) : _this->bandwidths[_this->bwId], NULL);
2021-05-03 18:10:52 +02:00
}
2021-06-27 02:20:11 +02:00
if (_this->selectedSerial != "") {
config.acquire();
2021-06-27 02:20:11 +02:00
config.conf["devices"][_this->selectedSerial]["bandwidth"] = _this->bwId;
config.release(true);
}
2021-05-03 18:10:52 +02:00
}
2021-03-20 21:53:44 +01:00
// General config BS
2021-08-31 18:39:48 +02:00
ImGui::LeftLabel("Gain control mode");
2021-06-27 02:20:11 +02:00
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
2021-06-30 03:13:14 +02:00
if (ImGui::Combo(CONCAT("##_balderf_gm_sel_", _this->name), &_this->gainMode, _this->gainModesTxt.c_str()) && _this->selectedSerial != "") {
2021-05-02 02:23:10 +02:00
if (_this->running) {
2021-06-27 02:20:11 +02:00
bladerf_set_gain_mode(_this->openDev, BLADERF_CHANNEL_RX(_this->chanId), _this->gainModes[_this->gainMode].mode);
}
// if switched to manual, reset gains
if (_this->gainModes[_this->gainMode].mode == BLADERF_GAIN_MANUAL && _this->running) {
bladerf_set_gain(_this->openDev, BLADERF_CHANNEL_RX(_this->chanId), _this->overallGain);
}
if (_this->selectedSerial != "") {
config.acquire();
2021-06-27 02:20:11 +02:00
config.conf["devices"][_this->selectedSerial]["gainMode"] = _this->gainModeNames[_this->gainMode];
config.release(true);
2021-05-02 02:23:10 +02:00
}
}
2021-03-20 21:53:44 +01:00
2021-06-30 03:13:14 +02:00
if (_this->selectedSerial != "") { if (_this->gainModes[_this->gainMode].mode != BLADERF_GAIN_MANUAL) { style::beginDisabled(); } }
2021-08-31 18:39:48 +02:00
ImGui::LeftLabel("Gain");
2021-06-27 02:20:11 +02:00
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
if (ImGui::SliderInt("##_balderf_oag_sel_", &_this->overallGain, (_this->gainRange != NULL) ? _this->gainRange->min : 0, (_this->gainRange != NULL) ? _this->gainRange->max : 60)) {
if (_this->running) {
spdlog::info("Setting gain to {0}", _this->overallGain);
bladerf_set_gain(_this->openDev, BLADERF_CHANNEL_RX(_this->chanId), _this->overallGain);
}
if (_this->selectedSerial != "") {
config.acquire();
2021-06-27 02:20:11 +02:00
config.conf["devices"][_this->selectedSerial]["overallGain"] = _this->overallGain;
config.release(true);
}
}
2021-06-30 03:13:14 +02:00
if (_this->selectedSerial != "") { if (_this->gainModes[_this->gainMode].mode != BLADERF_GAIN_MANUAL) { style::endDisabled(); } }
2021-06-27 02:20:11 +02:00
2021-03-20 21:53:44 +01:00
}
void worker() {
2021-05-02 02:23:10 +02:00
int16_t* buffer = new int16_t[bufferSize * 2];
bladerf_metadata meta;
2021-05-03 04:20:48 +02:00
2021-06-27 02:20:11 +02:00
while (streamingEnabled) {
2021-05-03 04:20:48 +02:00
// Receive from the stream and break on error
2021-05-02 02:23:10 +02:00
int ret = bladerf_sync_rx(openDev, buffer, bufferSize, &meta, 3500);
2021-05-03 04:20:48 +02:00
if (ret != 0) { break; }
// Convert to complex float and swap buffers
volk_16i_s32f_convert_32f((float*)stream.writeBuf, buffer, 32768.0f, bufferSize * 2);
2021-05-02 02:23:10 +02:00
if (!stream.swap(bufferSize)) { break; }
2021-03-20 21:53:44 +01:00
}
2021-05-03 04:20:48 +02:00
2021-05-02 02:23:10 +02:00
delete[] buffer;
2021-03-20 21:53:44 +01:00
}
std::string name;
bladerf* openDev;
bool enabled = true;
dsp::stream<dsp::complex_t> stream;
double sampleRate;
SourceManager::SourceHandler handler;
bool running = false;
double freq;
int devId = 0;
int srId = 0;
2021-05-03 18:10:52 +02:00
int bwId = 0;
2021-05-02 02:23:10 +02:00
int chanId = 0;
2021-06-27 02:20:11 +02:00
int gainMode = 0;
bool streamingEnabled = false;
2021-03-20 21:53:44 +01:00
2021-05-02 02:23:10 +02:00
int channelCount;
const bladerf_range* srRange = NULL;
const bladerf_range* bwRange = NULL;
const bladerf_range* gainRange = NULL;
2021-05-02 02:23:10 +02:00
2021-05-03 18:10:52 +02:00
std::vector<uint64_t> sampleRates;
std::string sampleRatesTxt;
std::vector<uint64_t> bandwidths;
std::string bandwidthsTxt;
2021-06-26 18:26:58 +02:00
std::string channelNamesTxt;
2021-05-02 02:23:10 +02:00
int bufferSize;
2021-03-20 21:53:44 +01:00
struct bladerf_stream* rxStream;
2021-06-27 02:20:11 +02:00
int overallGain = 0;
2021-05-02 02:23:10 +02:00
2021-03-20 21:53:44 +01:00
std::thread workerThread;
int devCount = 0;
bladerf_devinfo* devInfoList = NULL;
std::string devListTxt;
2021-06-26 18:26:58 +02:00
std::string selectedSerial;
2021-06-27 02:20:11 +02:00
bool isBlade1 = false;
const bladerf_gain_modes* gainModes;
std::vector<std::string> gainModeNames;
std::string gainModesTxt;
int gainModeCount;
2021-03-20 21:53:44 +01:00
};
MOD_EXPORT void _INIT_() {
json def = json({});
def["devices"] = json({});
def["device"] = "";
config.setPath(options::opts.root + "/bladerf_config.json");
config.load(def);
config.enableAutoSave();
}
MOD_EXPORT ModuleManager::Instance* _CREATE_INSTANCE_(std::string name) {
return new BladeRFSourceModule(name);
}
MOD_EXPORT void _DELETE_INSTANCE_(ModuleManager::Instance* instance) {
delete (BladeRFSourceModule*)instance;
}
MOD_EXPORT void _END_() {
config.disableAutoSave();
config.save();
}