blah2
A real-time passive radar
RspDuo.h
Go to the documentation of this file.
1 
19 #ifndef RSPDUO_H
20 #define RSPDUO_H
21 
22 #include "sdrplay_api.h"
23 #include "data/IqData.h"
24 
25 #include <stdint.h>
26 #include <string>
27 
28 #define BUFFER_SIZE_NR 1024
29 
30 class RspDuo
31 {
32 private:
34  uint32_t fc;
58  std::string path;
60  bool capture;
61 
63  static const double MAX_FREQUENCY_NR;
65  static const uint8_t DEF_DECIMATION_NR;
67  static const int DEF_WAIT_TIME_NR;
69  static const int DEF_CHUNK_TIME_NR;
71  static const int MAX_RUN_TIME_NR;
73  static const int DEF_AGC_BANDWIDTH_NR;
75  static const int MIN_AGC_SET_POINT_NR;
77  static const int DEF_AGC_SET_POINT_NR;
79  static const int MIN_GAIN_REDUCTION_NR;
81  static const int DEF_GAIN_REDUCTION_NR;
83  static const int MAX_GAIN_REDUCTION_NR;
85  static const int DEF_LNA_STATE_NR;
87  static const int MAX_LNA_STATE_NR;
89  static const int DEF_SAMPLE_FREQUENCY_NR;
91  static const int DEF_SAMPLE_RATE_NR;
92 
95  void validate();
96 
99  void open_api();
100 
103  void get_device();
104 
107  void set_device_parameters();
108 
117  static void _stream_a_callback(short *xi, short *xq, sdrplay_api_StreamCbParamsT *params, unsigned int numSamples, unsigned int reset, void *cbContext)
118  {
119  static_cast<RspDuo *>(cbContext)->stream_a_callback(xi, xq, params, numSamples, reset, cbContext);
120  };
121 
130  static void _stream_b_callback(short *xi, short *xq, sdrplay_api_StreamCbParamsT *params, unsigned int numSamples, unsigned int reset, void *cbContext)
131  {
132  static_cast<RspDuo *>(cbContext)->stream_b_callback(xi, xq, params, numSamples, reset, cbContext);
133  };
134 
141  static void _event_callback(sdrplay_api_EventT eventId, sdrplay_api_TunerSelectT tuner, sdrplay_api_EventParamsT *params, void *cbContext)
142  {
143  static_cast<RspDuo *>(cbContext)->event_callback(eventId, tuner, params, cbContext);
144  };
145 
154  void stream_a_callback(short *xi, short *xq, sdrplay_api_StreamCbParamsT *params, unsigned int numSamples, unsigned int reset, void *cbContext);
155 
164  void stream_b_callback(short *xi, short *xq, sdrplay_api_StreamCbParamsT *params, unsigned int numSamples, unsigned int reset, void *cbContext);
165 
172  void event_callback(sdrplay_api_EventT eventId, sdrplay_api_TunerSelectT tuner, sdrplay_api_EventParamsT *params, void *cbContext);
173 
176  void initialise_device();
177 
180  void uninitialise_device();
181 
184  void finish();
185 
186 public:
191  RspDuo(uint32_t fc, std::string path);
192 
195  std::string set_file(std::string path);
196 
199  void start();
200 
203  void stop();
204 
210 
217  void replay(IqData *buffer1, IqData *buffer2, std::string file, bool loop);
218 
221  void open_file();
222 
225  void close_file();
226 
230  void set_capture(bool capture);
231 
234  bool get_capture();
235 };
236 
237 #endif
IqData * buffer1
Definition: RspDuo.cpp:55
IqData * buffer2
Definition: RspDuo.cpp:56
std::string file
Definition: RspDuo.cpp:47
A class to store IQ data.
Definition: IqData.h:17
A class to capture data on the SDRplay RspDuo.
Definition: RspDuo.h:31
static const int DEF_SAMPLE_FREQUENCY_NR
Default sample frequency.
Definition: RspDuo.h:89
int lna_state_nr
LNA state.
Definition: RspDuo.h:44
int gain_reduction_nr
Gain reduction (dB).
Definition: RspDuo.h:42
void replay(IqData *buffer1, IqData *buffer2, std::string file, bool loop)
Implement replay function on RSPduo.
Definition: RspDuo.cpp:120
static const int MAX_LNA_STATE_NR
Max LNA state.
Definition: RspDuo.h:87
std::string path
File path.
Definition: RspDuo.h:58
void get_device()
Device selection function.
Definition: RspDuo.cpp:310
bool small_verbose_fg
Debugging.
Definition: RspDuo.h:54
uint32_t fc
Center frequency (Hz)
Definition: RspDuo.h:34
void stop()
Call methods to gracefully stop capture.
Definition: RspDuo.cpp:93
bool capture
True if capture is enabled.
Definition: RspDuo.h:60
void validate()
Check parameters for valid for capture device.
Definition: RspDuo.cpp:190
static void _stream_b_callback(short *xi, short *xq, sdrplay_api_StreamCbParamsT *params, unsigned int numSamples, unsigned int reset, void *cbContext)
Wrapper for C style callback function for stream_b_callback().
Definition: RspDuo.h:130
bool dab_notch_fg
DAB notch filter.
Definition: RspDuo.h:50
bool get_capture()
Getter for capture.
Definition: RspDuo.cpp:699
static void _stream_a_callback(short *xi, short *xq, sdrplay_api_StreamCbParamsT *params, unsigned int numSamples, unsigned int reset, void *cbContext)
Wrapper for C style callback function for stream_a_callback().
Definition: RspDuo.h:117
static const int MAX_RUN_TIME_NR
Maximum run time of recording.
Definition: RspDuo.h:71
int chunk_time_nr
chunk time of recording (s)
Definition: RspDuo.h:36
static const int DEF_LNA_STATE_NR
Default LNA state.
Definition: RspDuo.h:85
bool rf_notch_fg
MW and FM notch filters.
Definition: RspDuo.h:48
static const uint8_t DEF_DECIMATION_NR
Default decimation.
Definition: RspDuo.h:65
static const double MAX_FREQUENCY_NR
Maximum frequency (Hz).
Definition: RspDuo.h:63
void stream_a_callback(short *xi, short *xq, sdrplay_api_StreamCbParamsT *params, unsigned int numSamples, unsigned int reset, void *cbContext)
Tuner a callback as defined in SDRplay API.
Definition: RspDuo.cpp:495
RspDuo(uint32_t fc, std::string path)
Constructor.
Definition: RspDuo.cpp:59
static const int DEF_WAIT_TIME_NR
Default wait time before recording.
Definition: RspDuo.h:67
int agc_bandwidth_nr
AGC bandwidth (Hz)
Definition: RspDuo.h:38
static const int DEF_SAMPLE_RATE_NR
Default sample rate.
Definition: RspDuo.h:91
static const int DEF_GAIN_REDUCTION_NR
Default gain reduction.
Definition: RspDuo.h:81
void uninitialise_device()
Stop running capture callback function.
Definition: RspDuo.cpp:661
static const int DEF_AGC_SET_POINT_NR
Default AGC set point.
Definition: RspDuo.h:77
std::string set_file(std::string path)
Get file name from path.
Definition: RspDuo.cpp:77
int nDecimation
Decimation factor (integer).
Definition: RspDuo.h:46
bool more_verbose_fg
Debugging.
Definition: RspDuo.h:56
void event_callback(sdrplay_api_EventT eventId, sdrplay_api_TunerSelectT tuner, sdrplay_api_EventParamsT *params, void *cbContext)
Event callback function as defined in SDRplay API.
Definition: RspDuo.cpp:622
void stream_b_callback(short *xi, short *xq, sdrplay_api_StreamCbParamsT *params, unsigned int numSamples, unsigned int reset, void *cbContext)
Tuner b callback as defined in SDRplay API.
Definition: RspDuo.cpp:537
static const int MAX_GAIN_REDUCTION_NR
Maximum gain reduction.
Definition: RspDuo.h:83
static const int MIN_AGC_SET_POINT_NR
Minimum AGC set point.
Definition: RspDuo.h:75
void open_api()
Start API functions.
Definition: RspDuo.cpp:274
bool usb_bulk_fg
USB bulk transfer mode.
Definition: RspDuo.h:52
void open_file()
Open a new file to record IQ.
Definition: RspDuo.cpp:152
void process(IqData *buffer1, IqData *buffer2)
Implement capture function on RSPduo.
Definition: RspDuo.cpp:99
void close_file()
Close IQ file gracefully.
Definition: RspDuo.cpp:182
static const int MIN_GAIN_REDUCTION_NR
Minimum gain reduction.
Definition: RspDuo.h:79
void start()
Call methods to start capture.
Definition: RspDuo.cpp:85
int agc_set_point_nr
AGC set point (dBfs)
Definition: RspDuo.h:40
static const int DEF_AGC_BANDWIDTH_NR
Default AGC bandwidth.
Definition: RspDuo.h:73
void finish()
Internal method to gracefully stop capture..
Definition: RspDuo.cpp:675
void set_capture(bool capture)
Setter for capture.
Definition: RspDuo.cpp:693
void initialise_device()
Start running capture callback function.
Definition: RspDuo.cpp:651
void set_device_parameters()
Set device parameters.
Definition: RspDuo.cpp:395
static void _event_callback(sdrplay_api_EventT eventId, sdrplay_api_TunerSelectT tuner, sdrplay_api_EventParamsT *params, void *cbContext)
Wrapper for C style callback function for event_callback().
Definition: RspDuo.h:141
static const int DEF_CHUNK_TIME_NR
Default chunk time of recording.
Definition: RspDuo.h:69