1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-03 06:24:48 -04:00

BladerRF2 input support. Populate gain modes

This commit is contained in:
f4exb
2018-09-25 17:03:34 +02:00
parent fcaf22418d
commit 5ad52a4a1b
19 changed files with 675 additions and 31 deletions
@@ -16,6 +16,8 @@
#include <QDebug>
#include "libbladeRF.h"
#include "SWGDeviceSettings.h"
#include "SWGBladeRF2InputSettings.h"
#include "SWGDeviceState.h"
@@ -507,6 +509,19 @@ void BladeRF2Input::getGlobalGainRange(int& min, int& max, int& step)
}
}
const bladerf_gain_modes *BladeRF2Input::getGainModes(int& nbGains)
{
const bladerf_gain_modes *modes = 0;
if (m_deviceShared.m_dev) {
nbGains = m_deviceShared.m_dev->getGainModesRx(&modes);
} else {
nbGains = 0;
}
return modes;
}
bool BladeRF2Input::handleMessage(const Message& message)
{
if (MsgConfigureBladeRF2::match(message))
@@ -978,7 +993,7 @@ void BladeRF2Input::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& respo
device->getFrequencyRangeRx(f_min, f_max, step);
response.getBladeRf2InputReport()->setFrequencyRange(new SWGSDRangel::SWGRange);
response.getBladeRf2InputReport()->setFrequencyRange(new SWGSDRangel::SWGFrequencyRange);
response.getBladeRf2InputReport()->getFrequencyRange()->setMin(f_min);
response.getBladeRf2InputReport()->getFrequencyRange()->setMax(f_max);
response.getBladeRf2InputReport()->getFrequencyRange()->setStep(step);
@@ -996,6 +1011,21 @@ void BladeRF2Input::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& respo
response.getBladeRf2InputReport()->getSampleRateRange()->setMin(min);
response.getBladeRf2InputReport()->getSampleRateRange()->setMax(max);
response.getBladeRf2InputReport()->getSampleRateRange()->setStep(step);
response.getBladeRf2InputReport()->setGainModes(new QList<SWGSDRangel::SWGNamedEnum*>);
int nbModes;
const bladerf_gain_modes *modes = getGainModes(nbModes);
if (modes)
{
for (int i = 0; i < nbModes; modes++)
{
response.getBladeRf2InputReport()->getGainModes()->append(new SWGSDRangel::SWGNamedEnum);
response.getBladeRf2InputReport()->getGainModes()->back()->setName(new QString(modes[i].name));
response.getBladeRf2InputReport()->getGainModes()->back()->setValue(modes[i].mode);
}
}
}
}
@@ -28,6 +28,7 @@
class DeviceSourceAPI;
class BladeRF2InputThread;
class FileRecord;
struct bladerf_gain_modes;
class BladeRF2Input : public DeviceSampleSource
{
@@ -116,6 +117,7 @@ public:
void getSampleRateRange(int& min, int& max, int& step);
void getBandwidthRange(int& min, int& max, int& step);
void getGlobalGainRange(int& min, int& max, int& step);
const bladerf_gain_modes *getGainModes(int& nbGains);
virtual bool handleMessage(const Message& message);
@@ -151,6 +153,8 @@ private:
DeviceBladeRF2Shared m_deviceShared;
BladeRF2InputThread *m_thread;
FileRecord *m_fileSink; //!< File sink to record device I/Q output
bladerf_gain_modes **m_gainModes;
int m_nbGainModes;
bool openDevice();
void closeDevice();
@@ -58,6 +58,15 @@ BladeRF2InputGui::BladeRF2InputGui(DeviceUISet *deviceUISet, QWidget* parent) :
ui->bandwidth->setColorMapper(ColorMapper(ColorMapper::GrayYellow));
ui->bandwidth->setValueRange(6, min/1000, max/1000);
m_gainModes = m_sampleSource->getGainModes(m_nbGainModes);
if (m_gainModes)
{
for (int i = 0; i < m_nbGainModes; i++) {
ui->gainMode->addItem(tr("%1").arg(m_gainModes[i].name));
}
}
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
m_statusTimer.start(500);
@@ -65,6 +65,8 @@ private:
quint64 m_deviceCenterFrequency; //!< Center frequency in device
int m_lastEngineState;
MessageQueue m_inputMessageQueue;
const struct bladerf_gain_modes *m_gainModes;
int m_nbGainModes;
void displaySettings();
void sendSettings();