forked from danielkucera/esp-arduino-ebus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschedule.hpp
75 lines (53 loc) · 2.14 KB
/
schedule.hpp
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
#pragma once
#include <WiFiClient.h>
#include <deque>
#include <string>
#include <vector>
#include "Datatypes.h"
#include "EbusHandler.h"
#include "store.hpp"
// This class sends time-controlled active commands to the ebus. All valid
// received messages are compared with passively defined commands and evaluated
// if they match. Raw data (including filter function) can also be output.
// Individual commands are transmitted and the results reported back. The scan
// results are also published.
class Schedule {
public:
Schedule();
void setAddress(const uint8_t source);
void setDistance(const uint8_t distance);
void publishRaw(const char *payload);
void handleFilter(const char *payload);
void handleSend(const char *payload);
void nextCommand();
void processData(const uint8_t byte);
void resetCounters();
void publishCounters();
private:
ebus::EbusHandler ebusHandler;
Command *scheduleCommand = nullptr;
uint32_t distanceCommands = 0;
uint32_t lastCommand = 0;
bool raw = false;
std::vector<std::vector<uint8_t>> rawFilters;
bool send = false;
std::deque<std::vector<uint8_t>> sendCommands;
std::vector<uint8_t> sendCommand;
static void writeCallback(const uint8_t byte);
static int readBufferCallback();
static void activeCallback(const std::vector<uint8_t> &master,
const std::vector<uint8_t> &slave);
static void passiveCallback(const std::vector<uint8_t> &master,
const std::vector<uint8_t> &slave);
static void reactiveCallback(const std::vector<uint8_t> &master,
std::vector<uint8_t> *const slave);
static void errorCallback(const std::string &str);
void processActive(const std::vector<uint8_t>(master),
const std::vector<uint8_t> &slave);
void processPassive(const std::vector<uint8_t> &master,
const std::vector<uint8_t> &slave);
static void publishSend(const std::vector<uint8_t> &master,
const std::vector<uint8_t> &slave);
static void publishValue(Command *command, const std::vector<uint8_t> &value);
};
extern Schedule schedule;