-
Notifications
You must be signed in to change notification settings - Fork 1
/
relay.h
50 lines (37 loc) · 933 Bytes
/
relay.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
#ifndef RELAY_H
#define RELAY_H
#include <Arduino.h>
#include "types.h"
#include <PubSubClient.h>
#include "const.h"
struct RelayInfo {
byte pin;
State state; // Состояние - разрешено/запрещено
SignalType signalType; // Тип сигнала - прямой или инвертный
boolean to_flash; // Хранить во флеш
Status status; // Статус - вкл/выкл
#ifdef MEGA
RelayComment comment;
#endif
};
class Relay {
private:
PubSubClient *_mqtt;
char *_device;
public:
byte index;
RelayInfo info;
Relay();
//~Relay(){};
boolean begin();
void setMqttClient(PubSubClient *client, const char *device);
void load_eeprom();
void save_eeprom();
void save_status_eeprom();
void publish();
void turnOFF();
void turnON();
void switch_relay(byte* payload);
void switch_relay(Status status);
};
#endif //RELAY_H