forked from baycom/tfrec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
decoder.h
75 lines (65 loc) · 1.46 KB
/
decoder.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
71
72
73
74
75
#ifndef _INCLUDE_DECODER_H
#define _INCLUDE_DECODER_H
#include <sys/time.h>
#include <string>
#include <map>
using std::string;
using std::map;
enum sensor_e {
TFA_1=0, // IT+ Klimalogg Pro, 30.3180, 30.3181, 30.3199(?)
TFA_2, // IT+ 30.3143, 30.3146(?), 30.3144
TFA_3, // 30.3155
TX22, // LaCrosse TX22
TFA_WHP, // 30.3306 (rain meter), pulse data
TFA_WHB, // TFA WeatherHub
FIREANGEL=0x20 // ST-630+W2
};
typedef struct {
sensor_e type;
uint64_t id;
double temp;
double humidity;
int alarm;
int flags;
int sequence;
time_t ts;
int rssi;
} sensordata_t;
class decoder
{
public:
decoder(sensor_e _type);
void set_params(char *_handler, int _mode, int _dbg);
virtual void store_bit(int bit);
virtual void flush(int rssi, int offset=0);
virtual void store_data(sensordata_t &d);
virtual void execute_handler(sensordata_t &d);
virtual void flush_storage(void);
virtual int has_sync(void) {return synced;};
int count(void) {return data.size();}
sensor_e get_type(void) {return type;}
virtual void store_bytes(uint8_t *d, int len);
protected:
int dbg;
int bad;
int synced;
sensor_e type;
uint8_t rdata[256];
int byte_cnt;
private:
char *handler;
int mode;
map<uint64_t,sensordata_t> data;
};
class demodulator
{
public:
demodulator(decoder *_dec);
virtual void start(int len);
virtual void reset(void){};
virtual int demod(int thresh, int pwr, int index, int16_t *iq);
decoder *dec;
protected:
int last_bit_idx;
};
#endif