forked from mannkind/rf24node_msgproto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RF24Node.h
57 lines (43 loc) · 1.8 KB
/
RF24Node.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
#pragma once
#include <string>
#include "RF24Network/RF24Network.h"
#include "IMessageProtocol.h"
#include "IRadioNetwork.h"
#include "RF24Node_types.h"
class IMessageProtocol;
class IRadioNetwork;
class RF24Node {
protected:
payload_map queued_payloads;
IMessageProtocol& msg_proto;
IRadioNetwork& network;
bool debug;
std::vector<char> key;
char topic_separator;
bool write(RF24NetworkHeader& header, const void* message, size_t len);
void handle_receive_message(std::string subject, std::string body);
void handle_receive_temp(RF24NetworkHeader& header);
void handle_receive_humidity(RF24NetworkHeader& header);
void handle_receive_power(RF24NetworkHeader& header);
void handle_receive_switch(RF24NetworkHeader& header);
void handle_receive_energy(RF24NetworkHeader& header);
void handle_receive_rgb(RF24NetworkHeader& header);
void handle_receive_moisture(RF24NetworkHeader& header);
void handle_receive_challenge(RF24NetworkHeader& header);
void handle_receive_timesync(RF24NetworkHeader& header);
void handle_send_switch(uint16_t node, std::string payload, time_t challenge);
void handle_send_rgb(uint16_t node, std::string payload, time_t challenge);
std::vector<uint8_t> generate_siphash(uint16_t node, time_t challenge);
std::string generate_msg_proto_subject(RF24NetworkHeader& header);
public:
RF24Node(IRadioNetwork& _network, IMessageProtocol& _msg_proto, std::vector<char>);
void begin(void);
void end(void);
void loop(void);
void set_debug(bool _debug) {
this->debug = _debug;
}
void set_topic_separator(char s) {
this->topic_separator = s;
}
};