33#ifndef _H_RADIOHANDLER
34#define _H_RADIOHANDLER
45#include "radio/RadioHardware.h"
46#include "fft_mt_r2iq/fft_mt_r2iq.h"
47#include "dsp/ringbuffer.h"
59 sddc_err_t
AttachReal(
void (*callback)(
void* context,
const int16_t*, uint32_t),
void* context =
nullptr);
60 sddc_err_t
AttachIQ(
void (*callback)(
void* context,
const sddc_complex_t*, uint32_t),
void* context =
nullptr);
61 sddc_err_t
Start(
bool convert_r2iq);
72 sddc_err_t SetRFMode(sddc_rf_mode_t mode);
76 uint32_t GetADCSampleRate();
77 sddc_err_t SetADCSampleRate(uint32_t samplefreq);
84 std::vector<float> GetRFGainSteps(sddc_rf_mode_t mode = NOMODE);
85 std::array<float, 2> GetRFGainRange(sddc_rf_mode_t mode = NOMODE);
87 sddc_err_t SetRFGain(
float new_att);
89 std::vector<float> GetIFGainSteps(sddc_rf_mode_t mode = NOMODE);
90 std::array<float, 2> GetIFGainRange(sddc_rf_mode_t mode = NOMODE);
92 sddc_err_t SetIFGain(
float new_gain);
96 sddc_err_t SetBiasT_HF (
bool new_state);
98 sddc_err_t SetBiasT_VHF(
bool new_state);
100 sddc_err_t SetDither(
bool new_state);
102 sddc_err_t SetPGA(
bool new_state);
104 sddc_err_t SetRand(
bool new_state);
107 sddc_err_t SetLED (sddc_leds_t led,
bool on);
110 float getRealSamplesPerSecond()
const {
return real_samples_per_second; }
111 float getIQSamplesPerSecond()
const {
return iq_samples_per_second; }
115 const char *getHardwareName() {
return hardware->GetName(); }
116 uint16_t GetHardwareFirmware() {
return devFirmware; }
120 void EnableDebug(
void (*dbgprintFX3)(
const char* fmt, ...),
bool (*getconsolein)(
char* buf,
int maxlen))
122 this->DbgPrintFX3 = dbgprintFX3;
123 this->GetConsoleIn = getconsolein;
126 bool ReadDebugTrace(uint8_t* pdata, uint8_t len) {
return fx3->ReadDebugTrace(pdata, len); }
129 static size_t GetDeviceListLength();
130 static std::vector<SDDC::DeviceItem> GetDeviceList();
136 void CaculateStats();
139 void (*callbackReal)(
void* context,
const int16_t *data, uint32_t length);
140 void *callbackRealContext;
141 void (*callbackIQ)(
void* context,
const sddc_complex_t *data, uint32_t length);
142 void *callbackIQContext;
144 void (*DbgPrintFX3)(
const char* fmt, ...);
145 bool (*GetConsoleIn)(
char* buf,
int maxlen);
147 bool streamRunning =
false;
150 uint16_t devFirmware;
157 std::thread show_stats_thread;
158 std::thread submit_thread;
161 uint32_t count_real_samples = 0;
162 uint32_t count_iq_samples = 0;
163 float real_samples_per_second = 0;
164 float iq_samples_per_second = 0;
171 bool r2iqEnabled =
false;
Definition RadioHandler.h:54
sddc_err_t AttachIQ(void(*callback)(void *context, const sddc_complex_t *, uint32_t), void *context=nullptr)
Define the function to call when an IQ sample is available.
Definition RadioHandler.cpp:227
uint32_t GetCenterFrequency()
Get the frequency currently tuned in the SDR.
Definition RadioHandler.cpp:584
sddc_err_t Init(SDDC::DeviceItem dev_index)
Initialize the RadioHandler instance.
Definition RadioHandler.cpp:115
sddc_rf_mode_t GetBestRFMode(uint64_t freq)
Return the best RF mode to use for the frequency given.
Definition RadioHandler.cpp:734
sddc_err_t Resume()
Resume data transmission from the SDR.
Definition RadioHandler.cpp:353
RadioModel getHardwareModel()
— Hardware infos — //
Definition RadioHandler.h:114
sddc_rf_mode_t GetRFMode()
Return the current RF mode.
Definition RadioHandler.cpp:740
RadioHandler()
Create a new Radio Handler.
Definition RadioHandler.cpp:94
sddc_err_t Stop()
Stop the SDR data stream and processing functions.
Definition RadioHandler.cpp:305
sddc_err_t Start(bool convert_r2iq)
Start the SDR data stream and processing functions.
Definition RadioHandler.cpp:269
sddc_err_t AttachReal(void(*callback)(void *context, const int16_t *, uint32_t), void *context=nullptr)
Define the function to call when a real sample is available.
Definition RadioHandler.cpp:207
sddc_err_t SetCenterFrequency(uint32_t freq)
Set the frequency tuned in the SDR.
Definition RadioHandler.cpp:606
std::array< float, 2 > GetADCSampleRateLimits()
Get the limits of the ADC of your SDR.
Definition RadioHandler.cpp:747
sddc_err_t Pause()
Pause the data transmission from the SDR.
Definition RadioHandler.cpp:338
sddc_err_t SetDecimation(uint8_t decimate)
Set the decimation factor of the FFT.
Definition RadioHandler.cpp:253
Definition RadioHardware.h:40
Definition fft_mt_r2iq.h:58
Definition ringbuffer.h:49
Definition pf_mixer.h:206