forked from baycom/tfrec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdr.h
70 lines (55 loc) · 1.29 KB
/
sdr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
tfrec - Receiver for TFA IT+ (and compatible) sensors
(c) 2017 Georg Acher, Deti Fliegl {acher|fliegl}(at)baycom.de
#include <GPL-v2>
*/
#ifndef _INCLUDE_SDR_H
#define _INCLUDE_SDR_H
#include <string>
#include <vector>
#include <thread>
using std::thread;
using std::string;
using std::vector;
#include <rtl-sdr.h>
#include "utils.h"
class sdr
{
public:
sdr(int serial=0, int dbg=0,int dumpmode=0,char* dumpfile=NULL);
~sdr(void);
void get_properties(string &vend, string &prod,string &ser) {vend=vendor;prod=product;ser=serial;}
int set_buffer_len(int l);
int start(void);
int stop(void);
int set_frequency(uint32_t f);
int set_gain(int mode, float g);
int set_ppm(int p);
int set_samplerate(int s);
// virtual handle_data();
virtual void read_data(unsigned char *buf, uint32_t len);
int wait(int16_t* &d, int &l);
void done(int len);
static int search_device(char *substr);
private:
string vendor,product,serial;
void read_thread(void);
int nearest_gain(int g);
thread *r_thread;
int running;
int16_t *buffer;
int buffer_len;
rtlsdr_dev_t *dev;
int dbg;
int cur_gain;
int cur_gain_mode;
uint32_t cur_frequ;
int cur_ppm;
int cur_sr;
pthread_cond_t ready;
pthread_mutex_t ready_m;
FILE *dump_fd;
public:
volatile int wr_ptr,rd_ptr;
};
#endif