-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRF433Module.h
81 lines (55 loc) · 1.26 KB
/
RF433Module.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
76
77
78
79
80
81
/*
* RF433Module.h
*
* Created on: 10 mai 2017
* Author: horfee
*/
#ifndef SOURCES_RF433MODULE_H_
#define SOURCES_RF433MODULE_H_
#include <vector>
#include <chrono>
#include <map>
#include <atomic>
#ifndef WIRINGPI
#ifdef RPI
#include "_433D.h"
#endif
namespace alarmpi {
class RF433MessageListener {
public:
virtual void onSignalReceived(int message) = 0;
virtual ~RF433MessageListener() {} ;
};
class RF433Module {
public:
RF433Module(int receivingPIN, int transmittingPIN);
virtual ~RF433Module();
int getReceivingPIN();
int getTransmittingPIN();
void setReceivingPIN(int pin);
void setTransmittingPIN(int pin);
void start();
void stop();
bool isStarted() const;
void addListener(RF433MessageListener* listener);
void removeListener(RF433MessageListener* listener);
void sendMessage(unsigned long long int toSend);
private:
int receivingPIN;
int transmittingPIN;
bool started;
std::vector<RF433MessageListener*> listeners;
std::atomic<bool> sending;
int sendRepeat = 1;
#ifdef RPI
int pi;
void cbf(_433D_rx_data_t r);
_433D_rx_t *rx;
_433D_tx_t *tx;
std::map<int, std::chrono::milliseconds> receivedTimes;
#endif
// vector<int> messagesToSend;
};
} /* namespace alarmpi */
#endif
#endif /* SOURCES_RF433MODULE_H_ */